-
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
data_channels 項目に header 項目を追加 #104
Conversation
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.
対応ありがとうございます。
@@ -419,6 +419,13 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, | |||
if (dc.has_compress()) { | |||
d.compress = dc.compress; | |||
} |
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.
他は項目を追加に関しての設定なので、一番確認していただきたいのはこの下の追加部分になります。
src/sora.cpp
Outdated
@@ -419,6 +419,13 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, | |||
if (dc.has_compress()) { | |||
d.compress = dc.compress; | |||
} | |||
if (dc.has_header()) { | |||
boost::json::value parsed_value = boost::json::parse(dc.header); | |||
if (parsed_value.is_array()) { |
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.
配列しか許可しないなら、最初から header を配列として定義して下さい。
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.
配列として定義し直しました。
Sora/Sora.cs
Outdated
@@ -62,6 +62,7 @@ public class DataChannel | |||
public int? MaxRetransmits; | |||
public string? Protocol; | |||
public bool? Compress; | |||
public string? Header; |
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.
こっちも配列になってないですね
Sora/Sora.cs
Outdated
@@ -453,6 +454,10 @@ public void Connect(Config config) | |||
{ | |||
c.SetCompress(m.Compress.Value); | |||
} | |||
if (m.Header != null) | |||
{ | |||
c.SetHeader(m.Header); |
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.
これコンパイル通ります…?
src/sora.cpp
Outdated
if (dc.has_header()) { | ||
const auto& header_content = dc.header.content; | ||
d.header->insert(d.header->end(), header_content.begin(), | ||
header_content.end()); |
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.
proto の各要素の型は JSON 文字列にシリアライズされた string 型で、SoraSignalingConfig::DataChannel::header の各要素の型は boost::json::value なんだから、絶対に JSON 文字列をデシリアライズする処理が必要なはずです。
Sora/Sora.cs
Outdated
public class Header | ||
{ | ||
public List<string> content { get; set; } = new List<string>(); | ||
} |
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.
C# は proto と違って string 配列が nullable なので、Header クラスを作る必要は無いです。DataChannel クラスで直接 List<string>? Header
すれば良いです。
proto 側で Header クラスを作ってるのは nullable な string 配列(optional repeated string header
)が定義できないからです。
proto/sora_conf_internal.proto
Outdated
@@ -2,6 +2,10 @@ syntax = "proto3"; | |||
|
|||
package sora_conf.internal; | |||
|
|||
message Header { | |||
repeated string content = 1; | |||
} |
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.
DataChannel の下に作らないなら Header という名前は汎用的すぎるので DataChannelHeader にした方が良いです
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.
ForwardingFilter の Rules と同じように DataChannel の下に作るよう修正します。
src/sora.cpp
Outdated
const auto& header_content = dc.header.content; | ||
d.header->reserve(header_content.size()); | ||
for (const auto& json_str : header_content) { | ||
auto parsed = boost::json::parse(json_str); |
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.
これだとパースエラー時に例外投げちゃうので、他の parse と合わせて error_code を渡すようにして下さい。
src/sora.cpp
Outdated
@@ -419,6 +419,19 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, | |||
if (dc.has_compress()) { | |||
d.compress = dc.compress; | |||
} | |||
if (dc.has_header()) { | |||
d.header = std::vector<boost::json::value>(); | |||
d.header->reserve(dc.header.content.size()); |
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.
reserve するような最適化はいらないので削除して下さい
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.
ご指摘のとおり削除します。
src/sora.cpp
Outdated
boost::system::error_code ec; | ||
auto parsed = boost::json::parse(json_str, ec); | ||
if (ec) { | ||
RTC_LOG(LS_WARNING) << "Invalid JSON in header: " << json_str; |
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.
他のやつと書き方のフォーマットが違いますね。
RTC_LOG(LS_WARNING) << "Invalid JSON in header: " << json_str; | |
RTC_LOG(LS_WARNING) << "Invalid JSON: header=" << json_str; |
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.
失礼しました。メッセージを修正します。
Sora/Sora.cs
Outdated
var header = new SoraConf.Internal.DataChannel.Header(); | ||
header.content.AddRange(m.Header); |
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.
初期化と同時に代入の方がいい感じになりそう。
var header = new SoraConf.Internal.DataChannel.Header(); | |
header.content.AddRange(m.Header); | |
var header = new SoraConf.Internal.DataChannel.Header() { | |
content = m.Header, | |
}; |
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.
初期化と同時に代入するように修正します。
c9087e4 で対応しました。
Sora/Sora.cs
Outdated
@@ -454,6 +454,10 @@ public void Connect(Config config) | |||
{ | |||
c.SetCompress(m.Compress.Value); | |||
} | |||
if (m.Header != null) | |||
{ | |||
c.SetHeader(new SoraConf.Internal.DataChannel.Header { content = new List<string>(m.Header) }); |
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.
これ content = m.Header
とは書けないですか?
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.
ここでまた List 作らなくても良いですね。修正します。
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.
良さそう
レビューありがとうございました。こちらマージします。 |
data_channels 項目に header 項目を追加しました。
dc.header は string から json にパースして設定しています。
This pull request introduces a new
Header
property to theDataChannel
class and updates related files to support this addition. The most important changes include updates to theSora.Config
,DataChannel
class, and associated methods in both C# and C++ code, as well as the protocol buffer definition.Enhancements to
DataChannel
:Sora/Sora.cs
: AddedHeader
property to theDataChannel
class.Sora/Sora.cs
: UpdatedConnect
method to set theHeader
property if it is not null.Protocol buffer updates:
proto/sora_conf_internal.proto
: Addedheader
field to theDataChannel
message.C++ code updates:
src/sora.cpp
: UpdatedDoConnect
method to parse and set theHeader
property from JSON.Documentation updates:
CHANGES.md
: Documented the addition of theHeader
property toDataChannels
.