-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
マルチ転送フィルターの追加 #108
base: develop
Are you sure you want to change the base?
マルチ転送フィルターの追加 #108
Changes from 12 commits
0a6b657
874c8fe
8292815
a515d82
dbeea61
0d3cb34
6aa7560
219a3df
5cf82fe
16a605c
3c9e699
c55e160
d88a3cd
0e8f309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,10 +71,11 @@ public class DataChannel | |
public const string FieldKind = "kind"; | ||
public const string OperatorIsIn = "is_in"; | ||
public const string OperatorIsNotIn = "is_not_in"; | ||
|
||
public class ForwardingFilter | ||
{ | ||
public string? Action; | ||
public string? Name; | ||
public int? Priority; | ||
public class Rule | ||
{ | ||
public string Field; | ||
|
@@ -85,7 +86,10 @@ public class Rule | |
public string? Version; | ||
public string? Metadata; | ||
} | ||
|
||
public class ForwardingFilters | ||
{ | ||
public List<ForwardingFilter> Filters = new List<ForwardingFilter>(); | ||
} | ||
/// <summary> | ||
/// カメラの設定 | ||
/// </summary> | ||
|
@@ -234,8 +238,8 @@ public class Config | |
public string ProxyPassword = ""; | ||
// Proxy サーバーに接続するときの User-Agent。未設定ならデフォルト値が使われる | ||
public string ProxyAgent = ""; | ||
|
||
public ForwardingFilter ForwardingFilter; | ||
public List<ForwardingFilter> ForwardingFilters; | ||
|
||
// ハードウェアエンコーダー/デコーダーを利用するかどうか。null の場合は実装依存となる | ||
public bool? UseHardwareEncoder; | ||
|
@@ -461,36 +465,17 @@ public void Connect(Config config) | |
cc.proxy_agent = config.ProxyAgent; | ||
if (config.ForwardingFilter != null) | ||
{ | ||
var ff = new SoraConf.Internal.ForwardingFilter(); | ||
if (config.ForwardingFilter.Action != null) | ||
{ | ||
ff.SetAction(config.ForwardingFilter.Action); | ||
} | ||
foreach (var rs in config.ForwardingFilter.Rules) | ||
{ | ||
var ccrs = new SoraConf.Internal.ForwardingFilter.Rules(); | ||
foreach (var r in rs) | ||
{ | ||
var ccr = new SoraConf.Internal.ForwardingFilter.Rule(); | ||
ccr.field = r.Field; | ||
ccr.op = r.Operator; | ||
foreach (var v in r.Values) | ||
{ | ||
ccr.values.Add(v); | ||
} | ||
ccrs.rules.Add(ccr); | ||
} | ||
ff.rules.Add(ccrs); | ||
} | ||
if (config.ForwardingFilter.Version != null) | ||
{ | ||
ff.SetVersion(config.ForwardingFilter.Version); | ||
} | ||
if (config.ForwardingFilter.Metadata != null) | ||
cc.SetForwardingFilter(ConvertToInternalFilter(config.ForwardingFilter)); | ||
} | ||
|
||
if (config.ForwardingFilters != null && config.ForwardingFilters.Count > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ご指摘の通りに修正しました。 |
||
{ | ||
var ffs = new SoraConf.Internal.ForwardingFilters(); | ||
foreach (var filter in config.ForwardingFilters) | ||
{ | ||
ff.SetMetadata(config.ForwardingFilter.Metadata); | ||
ffs.filters.Add(ConvertToInternalFilter(filter)); | ||
} | ||
cc.SetForwardingFilter(ff); | ||
cc.SetForwardingFilters(ffs); | ||
} | ||
if (config.UseHardwareEncoder.HasValue) | ||
{ | ||
|
@@ -522,6 +507,48 @@ public void Disconnect() | |
sora_disconnect(p); | ||
} | ||
|
||
private SoraConf.Internal.ForwardingFilter ConvertToInternalFilter(ForwardingFilter filter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forwarding filter で1個の機能なので、 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. あとこの関数は static で良いはず There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 名前の変更と static へ変更しました |
||
{ | ||
var ff = new SoraConf.Internal.ForwardingFilter(); | ||
if (filter.Action != null) | ||
{ | ||
ff.SetAction(filter.Action); | ||
} | ||
if (filter.Name != null) | ||
{ | ||
ff.SetName(filter.Name); | ||
} | ||
if (filter.Priority.HasValue) | ||
{ | ||
ff.SetPriority(filter.Priority.Value); | ||
} | ||
foreach (var rs in filter.Rules) | ||
{ | ||
var ccrs = new SoraConf.Internal.ForwardingFilter.Rules(); | ||
foreach (var r in rs) | ||
{ | ||
var ccr = new SoraConf.Internal.ForwardingFilter.Rule(); | ||
ccr.field = r.Field; | ||
ccr.op = r.Operator; | ||
foreach (var v in r.Values) | ||
{ | ||
ccr.values.Add(v); | ||
} | ||
ccrs.rules.Add(ccr); | ||
} | ||
ff.rules.Add(ccrs); | ||
} | ||
if (filter.Version != null) | ||
{ | ||
ff.SetVersion(filter.Version); | ||
} | ||
if (filter.Metadata != null) | ||
{ | ||
ff.SetMetadata(filter.Metadata); | ||
} | ||
return ff; | ||
} | ||
|
||
/// <summary> | ||
/// カメラを切り替えます。 | ||
/// </summary> | ||
|
@@ -1248,4 +1275,4 @@ public static IAudioOutputHelper Create(Action onChangeRoute) | |
#endif | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ message DataChannel { | |
|
||
message ForwardingFilter { | ||
optional string action = 2; | ||
optional string name = 4; | ||
optional int32 priority = 6; | ||
message Rule { | ||
string field = 1; | ||
string op = 2; | ||
|
@@ -27,6 +29,10 @@ message ForwardingFilter { | |
optional string metadata = 7; | ||
} | ||
|
||
message ForwardingFilters { | ||
repeated ForwardingFilter filters = 1; | ||
} | ||
|
||
message CameraConfig { | ||
int32 capturer_type = 17; | ||
int64 unity_camera_texture = 18; | ||
|
@@ -80,6 +86,7 @@ message ConnectConfig { | |
string audio_streaming_language_code = 48; | ||
string signaling_notify_metadata = 49; | ||
optional ForwardingFilter forwarding_filter = 51; | ||
optional ForwardingFilters forwarding_filters = 52; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 書けないようです。ビルドエラーとなりました。 |
||
optional bool use_hardware_encoder = 53; | ||
optional string client_cert = 54; | ||
optional string client_key = 55; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -447,35 +447,14 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, | |
config.proxy_agent = cc.proxy_agent; | ||
config.audio_streaming_language_code = cc.audio_streaming_language_code; | ||
if (cc.has_forwarding_filter()) { | ||
sora::SoraSignalingConfig::ForwardingFilter ff; | ||
if (cc.forwarding_filter.has_action()) { | ||
ff.action = cc.forwarding_filter.action; | ||
} | ||
for (const auto& rs : cc.forwarding_filter.rules) { | ||
std::vector<sora::SoraSignalingConfig::ForwardingFilter::Rule> ffrs; | ||
for (const auto& r : rs.rules) { | ||
sora::SoraSignalingConfig::ForwardingFilter::Rule ffr; | ||
ffr.field = r.field; | ||
ffr.op = r.op; | ||
ffr.values = r.values; | ||
ffrs.push_back(ffr); | ||
} | ||
ff.rules.push_back(ffrs); | ||
} | ||
if (cc.forwarding_filter.has_version()) { | ||
ff.version = cc.forwarding_filter.version; | ||
} | ||
if (cc.forwarding_filter.has_metadata()) { | ||
boost::system::error_code ec; | ||
auto ffmd = boost::json::parse(cc.forwarding_filter.metadata, ec); | ||
if (ec) { | ||
RTC_LOG(LS_WARNING) << "Invalid JSON: forwarding_filter metadata=" | ||
<< cc.forwarding_filter.metadata; | ||
} else { | ||
ff.metadata = ffmd; | ||
} | ||
config.forwarding_filter = convertForwardingFilter(cc.forwarding_filter); | ||
} | ||
if (cc.has_forwarding_filters()) { | ||
std::vector<sora::SoraSignalingConfig::ForwardingFilter> filters; | ||
for (const auto& filter : cc.forwarding_filters.filters) { | ||
filters.push_back(convertForwardingFilter(filter)); | ||
} | ||
config.forwarding_filter = ff; | ||
config.forwarding_filters = filters; | ||
} | ||
if (cc.has_client_cert()) { | ||
config.client_cert = cc.client_cert; | ||
|
@@ -761,6 +740,48 @@ bool Sora::InitADM(rtc::scoped_refptr<webrtc::AudioDeviceModule> adm, | |
return true; | ||
} | ||
|
||
sora::SoraSignalingConfig::ForwardingFilter Sora::convertForwardingFilter( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ConvertToForwardingFilter に修正しました |
||
const sora_conf::internal::ForwardingFilter& filter) { | ||
sora::SoraSignalingConfig::ForwardingFilter ff; | ||
|
||
if (filter.has_action()) { | ||
ff.action = filter.action; | ||
} | ||
if (filter.has_name()) { | ||
ff.name = filter.name; | ||
} | ||
if (filter.has_priority()) { | ||
ff.priority = filter.priority; | ||
} | ||
for (const auto& rs : filter.rules) { | ||
std::vector<sora::SoraSignalingConfig::ForwardingFilter::Rule> ffrs; | ||
for (const auto& r : rs.rules) { | ||
sora::SoraSignalingConfig::ForwardingFilter::Rule ffr; | ||
ffr.field = r.field; | ||
ffr.op = r.op; | ||
ffr.values = r.values; | ||
ffrs.push_back(ffr); | ||
} | ||
ff.rules.push_back(ffrs); | ||
} | ||
|
||
if (filter.has_version()) { | ||
ff.version = filter.version; | ||
} | ||
if (filter.has_metadata()) { | ||
boost::system::error_code ec; | ||
auto ffmd = boost::json::parse(filter.metadata, ec); | ||
if (ec) { | ||
RTC_LOG(LS_WARNING) << "Invalid JSON: forwarding_filter metadata=" | ||
<< filter.metadata; | ||
} else { | ||
ff.metadata = ffmd; | ||
} | ||
} | ||
|
||
return ff; | ||
} | ||
|
||
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> Sora::CreateVideoCapturer( | ||
int capturer_type, | ||
void* unity_camera_texture, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,10 @@ class Sora : public std::enable_shared_from_this<Sora>, | |
void* GetAndroidApplicationContext(void* env); | ||
static sora_conf::ErrorCode ToErrorCode(sora::SoraSignalingErrorCode ec); | ||
|
||
private: | ||
sora::SoraSignalingConfig::ForwardingFilter convertForwardingFilter( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この関数は static にできるはず There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cpp の修正と合わせて static に変更しました。 |
||
const sora_conf::internal::ForwardingFilter& filter); | ||
|
||
// SoraSignalingObserver の実装 | ||
void OnSetOffer(std::string offer) override; | ||
void OnDisconnect(sora::SoraSignalingErrorCode ec, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これはもう不要なはず
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正しました。