diff --git a/Sora/Sora.cs b/Sora/Sora.cs index a5c968a..db6d1e9 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -86,79 +86,9 @@ public class Rule public string? Version; public string? Metadata; } - public class ForwardingFiltersRule - { - public string field = ""; - public string op = ""; - public string[] values = new string[0]; - } - - public class ForwardingFiltersRuleSet - { - public ForwardingFiltersRule[] rules = new ForwardingFiltersRule[0]; - } - - [Serializable] - public class ForwardingFiltersConfig - { - [Header("Filter Settings")] - public bool enableAction = false; - [Tooltip("Action to take (block/allow)")] - public string action = ""; - - public bool enableName = false; - [Tooltip("Filter name")] - public string name = ""; - - public bool enablePriority = false; - [Tooltip("Filter priority")] - public int? priority; - - [Header("Rules")] - public ForwardingFiltersRuleSet[] ruleSets = new ForwardingFiltersRuleSet[0]; - - public bool enableVersion = false; - [Tooltip("Filter version")] - public string version = ""; - - public bool enableMetadata = false; - [Tooltip("Filter metadata")] - public string metadata = ""; - } public class ForwardingFilters { - // 内部のfiltersリスト - public List filters { get; set; } - - // 読み取り専用のFiltersプロパティ - public IReadOnlyList Filters => filters; - - public ForwardingFilters() - { - filters = new List(); - } - - public void Add(ForwardingFilter filter) - { - if (filters == null) - { - filters = new List(); - } - filters.Add(filter); - } - - // ForwardingFiltersインスタンスを追加するメソッド - public void Add(ForwardingFilters otherFilters) - { - if (otherFilters?.filters != null) - { - if (filters == null) - { - filters = new List(); - } - filters.AddRange(otherFilters.filters); - } - } + public List Filters = new List(); } /// /// カメラの設定 @@ -576,12 +506,10 @@ public void Connect(Config config) } if (config.ForwardingFilters != null && config.ForwardingFilters.Filters.Count > 0) { - var forwardingFilters = new SoraConf.Internal.ForwardingFilters(); - + var ffs = new SoraConf.Internal.ForwardingFilters(); foreach (var filter in config.ForwardingFilters.Filters) { var ff = new SoraConf.Internal.ForwardingFilter(); - if (filter.Action != null) { ff.SetAction(filter.Action); @@ -594,11 +522,9 @@ public void Connect(Config config) { 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(); @@ -612,7 +538,6 @@ public void Connect(Config config) } ff.rules.Add(ccrs); } - if (filter.Version != null) { ff.SetVersion(filter.Version); @@ -621,13 +546,9 @@ public void Connect(Config config) { ff.SetMetadata(filter.Metadata); } - - // ForwardingFilters に追加 - forwardingFilters.Add(ff); + ffs.filters.Add(ff); } - - // forwarding_filters に設定 - cc.forwarding_filters = forwardingFilters; + cc.SetForwardingFilters(ffs); } if (config.UseHardwareEncoder.HasValue) { diff --git a/src/sora.cpp b/src/sora.cpp index 669f91d..1a352cc 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -485,9 +485,7 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, } if (cc.has_forwarding_filters()) { std::vector filters; - const auto& ff = cc.forwarding_filters; - // filters プロパティから直接フィルターを取得するように修正 - for (const auto& filter : ff.filters) { + for (const auto& filter : cc.forwarding_filters.filters) { sora::SoraSignalingConfig::ForwardingFilter ff; if (filter.has_action()) { ff.action = filter.action; @@ -516,7 +514,7 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, boost::system::error_code ec; auto ffmd = boost::json::parse(filter.metadata, ec); if (ec) { - RTC_LOG(LS_WARNING) << "Invalid JSON: forwarding_filters metadata=" + RTC_LOG(LS_WARNING) << "Invalid JSON: forwarding_filter metadata=" << filter.metadata; } else { ff.metadata = ffmd;