Skip to content

Commit

Permalink
Merge pull request #104 from shiguredo/feature/add-datachannels-header
Browse files Browse the repository at this point in the history
data_channels 項目に header 項目を追加
  • Loading branch information
torikizi authored Jan 6, 2025
2 parents f45226a + d900cd2 commit 1778cbe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
- @torikizi
- [ADD] `Sora.Config``ClientCert`, `ClientKey`, `CACert` を追加
- @melpon
- [ADD] DataChannels に `Header` を追加
- @torikizi
- [ADD] ForwardingFilter に name と priority を追加
- @torikizi
- [ADD] ForwardingFilters 機能を使えるようにする
Expand Down
6 changes: 5 additions & 1 deletion Sora/Sora.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public enum SpotlightFocusRidType
R1,
R2,
}

public class DataChannel
{
// 以下は設定必須
Expand All @@ -62,6 +61,7 @@ public class DataChannel
public int? MaxRetransmits;
public string? Protocol;
public bool? Compress;
public List<string>? Header;
}

public const string ActionBlock = "block";
Expand Down Expand Up @@ -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 = m.Header });
}
cc.data_channels.Add(c);
}
cc.proxy_url = config.ProxyUrl;
Expand Down
4 changes: 4 additions & 0 deletions proto/sora_conf_internal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ message DataChannel {
optional int32 max_retransmits = 8;
optional string protocol = 10;
optional bool compress = 12;
message Header {
repeated string content = 1;
}
optional Header header = 14;
}

message ForwardingFilter {
Expand Down
12 changes: 12 additions & 0 deletions src/sora.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,18 @@ 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>();
for (const auto& json_str : dc.header.content) {
boost::system::error_code ec;
auto parsed = boost::json::parse(json_str, ec);
if (ec) {
RTC_LOG(LS_WARNING) << "Invalid JSON: header=" << json_str;
} else {
d.header->push_back(std::move(parsed));
}
}
}
config.data_channels.push_back(std::move(d));
}
if (!cc.metadata.empty()) {
Expand Down

0 comments on commit 1778cbe

Please sign in to comment.