-
Notifications
You must be signed in to change notification settings - Fork 5
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
マルチ転送フィルターを設定可能にする #62
Changes from 13 commits
da028f5
e2c73d8
3bd9be8
c593ce5
8521ea0
1c5cdd8
91b1e92
45b09ef
53e1d6e
f12b9e0
b98f63f
8d09916
a181a49
ffd5c58
c0ac41c
a670136
d0394af
7ebc714
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 |
---|---|---|
|
@@ -123,15 +123,78 @@ public class RuleList | |
{ | ||
public Rule[] data; | ||
} | ||
[System.Serializable] | ||
public class ForwardingFilter | ||
{ | ||
public bool enableAction = false; | ||
public string action; | ||
public bool enableName = false; | ||
public string name; | ||
public bool enablePriority = false; | ||
public int priority; | ||
public RuleList[] rules; | ||
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. RuleList の配列だから ruleLists の方が名前的に良さそう。rules だと Rule の配列だと思ってしまいそうなので。 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. ruleLists に名前を変えます。 |
||
public bool enableVersion = false; | ||
public string version = ""; | ||
public bool enableMetadata = false; | ||
public string metadata = ""; | ||
} | ||
|
||
[Serializable] | ||
private class ForwardingFilterMetadata | ||
{ | ||
public string metadata; | ||
} | ||
public static Sora.ForwardingFilter ConvertForwardingFilter(ForwardingFilter forwardingFilter) | ||
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. sora-unity-sdk でやったのと同じように ConvertTo の方が分かりやすいかも。あと SoraSample の ForwardingFilter と Sora.ForwardingFilter が同じ名前なので、違いを出すために ConvertToSoraForwardingFilter とかにすると良さそう。 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. ConvertToSoraForwardingFilter にします。 |
||
{ | ||
var filter = new Sora.ForwardingFilter(); | ||
|
||
if (forwardingFilter.enableAction) filter.Action = forwardingFilter.action; | ||
if (forwardingFilter.enableName) filter.Name = forwardingFilter.name; | ||
if (forwardingFilter.enablePriority) filter.Priority = forwardingFilter.priority; | ||
|
||
if (forwardingFilter.rules != null) | ||
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. インスペクタで設定される値だから forwardingFilter.rules が null になることは無いはず 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. ご指摘のとおりです。こちらもチェックを外します。 |
||
{ | ||
foreach (var ruleListData in forwardingFilter.rules) | ||
{ | ||
var ruleList = new List<Sora.ForwardingFilter.Rule>(); | ||
foreach (var rule in ruleListData.data) | ||
{ | ||
var newRule = new Sora.ForwardingFilter.Rule | ||
{ | ||
Field = rule.field, | ||
Operator = rule.op | ||
}; | ||
newRule.Values.AddRange(rule.values); | ||
ruleList.Add(newRule); | ||
} | ||
|
||
if (ruleList.Any()) | ||
{ | ||
filter.Rules.Add(ruleList); | ||
} | ||
} | ||
} | ||
|
||
if (forwardingFilter.enableVersion) filter.Version = forwardingFilter.version; | ||
if (forwardingFilter.enableMetadata) | ||
{ | ||
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. ToJson 1個で済むようになったので、他の if 文と同じ書き方にしておいて下さい 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. ご指摘のとおりです。他とあわせて一行になるようにします。 |
||
filter.Metadata = JsonUtility.ToJson(new ForwardingFilterMetadata() | ||
{ | ||
metadata = forwardingFilter.metadata | ||
}); | ||
} | ||
|
||
return filter; | ||
} | ||
|
||
[Header("ForwardingFilter の設定")] | ||
public bool enableForwardingFilterAction = false; | ||
public string forwardingFilterAction; | ||
public RuleList[] forwardingFilter; | ||
public bool enableForwardingFilterVersion = false; | ||
public string forwardingFilterVersion = ""; | ||
public bool enableForwardingFilterMetadata = false; | ||
public string forwardingFilterMetadataMessage = ""; | ||
[System.Obsolete("forwardingFilter は非推奨です。代わりに forwardingFilters を使用してください。")] | ||
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. これはもう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. |
||
public bool enableForwardingFilter = false; | ||
public ForwardingFilter forwardingFilter; | ||
|
||
[Header("ForwardingFilters の設定")] | ||
public bool enableForwardingFilters = false; | ||
public ForwardingFilter[] forwardingFilters; | ||
|
||
[Header("DataChannel シグナリングの設定")] | ||
public bool dataChannelSignaling = false; | ||
|
@@ -597,12 +660,6 @@ class VideoH264Params | |
public string profile_level_id; | ||
} | ||
|
||
[Serializable] | ||
class ForwardingFilterMetadata | ||
{ | ||
public string forwarding_filter_metadata; | ||
} | ||
|
||
public void OnClickStart() | ||
{ | ||
|
||
|
@@ -677,16 +734,6 @@ public void OnClickStart() | |
}; | ||
videoH264ParamsJson = JsonUtility.ToJson(h264Params); | ||
} | ||
// enableForwardingFilterMetadata が true の場合はメタデータを設定する | ||
string forwardingFilterMetadataJson = ""; | ||
if (enableForwardingFilterMetadata) | ||
{ | ||
var ffm = new ForwardingFilterMetadata() | ||
{ | ||
forwarding_filter_metadata = forwardingFilterMetadataMessage | ||
}; | ||
forwardingFilterMetadataJson = JsonUtility.ToJson(ffm); | ||
} | ||
|
||
InitSora(); | ||
|
||
|
@@ -777,30 +824,23 @@ public void OnClickStart() | |
} | ||
fixedDataChannelLabels = config.DataChannels.Select(x => x.Label).ToArray(); | ||
} | ||
if (forwardingFilter.Length != 0) | ||
if (enableForwardingFilter) | ||
{ | ||
config.ForwardingFilter = ConvertForwardingFilter(forwardingFilter); | ||
} | ||
if (enableForwardingFilters) | ||
{ | ||
config.ForwardingFilter = new Sora.ForwardingFilter(); | ||
if (enableForwardingFilterAction) config.ForwardingFilter.Action = forwardingFilterAction; | ||
foreach (var rs in forwardingFilter) | ||
config.ForwardingFilters = new List<Sora.ForwardingFilter>(); | ||
|
||
foreach (var filter in forwardingFilters) | ||
{ | ||
var ccrs = new List<Sora.ForwardingFilter.Rule>(); | ||
foreach (var r in rs.data) | ||
var newFilter = ConvertForwardingFilter(filter); | ||
if (newFilter != null) | ||
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. ここが null になることは無いはず 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 ccr = new Sora.ForwardingFilter.Rule(); | ||
ccr.Field = r.field; | ||
ccr.Operator = r.op; | ||
foreach (var v in r.values) | ||
{ | ||
ccr.Values.Add(v); | ||
} | ||
ccrs.Add(ccr); | ||
config.ForwardingFilters.Add(newFilter); | ||
} | ||
config.ForwardingFilter.Rules.Add(ccrs); | ||
} | ||
if (enableForwardingFilterVersion) config.ForwardingFilter.Version = forwardingFilterVersion; | ||
if (enableForwardingFilterMetadata) config.ForwardingFilter.Metadata = forwardingFilterMetadataJson; | ||
} | ||
|
||
sora.Connect(config); | ||
SetState(State.Started); | ||
Debug.LogFormat("Sora is Created: signalingUrl={0}, channelId={1}", signalingUrl, channelId); | ||
|
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.
ここ [ADD] のところと同じ内容だから削って良さそう
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.
確かに同じことが書いてあるだけでした。消します。