From 484cbb5a78a66547dece06e98b3995e788195347 Mon Sep 17 00:00:00 2001 From: torikizi Date: Mon, 28 Oct 2024 17:43:24 +0900 Subject: [PATCH 01/12] =?UTF-8?q?data=5Fchannels=20=E3=81=AB=20header=20?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/Sora.cs | 5 +++++ proto/sora_conf_internal.proto | 1 + src/sora.cpp | 3 +++ 3 files changed, 9 insertions(+) diff --git a/Sora/Sora.cs b/Sora/Sora.cs index 09fd638..49cf625 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -62,6 +62,7 @@ public class DataChannel public int? MaxRetransmits; public string? Protocol; public bool? Compress; + public string? Header; } public const string ActionBlock = "block"; @@ -453,6 +454,10 @@ public void Connect(Config config) { c.SetCompress(m.Compress.Value); } + if (m.Header != null) + { + c.SetHeader(m.Header); + } cc.data_channels.Add(c); } cc.proxy_url = config.ProxyUrl; diff --git a/proto/sora_conf_internal.proto b/proto/sora_conf_internal.proto index 1789086..3d249bc 100644 --- a/proto/sora_conf_internal.proto +++ b/proto/sora_conf_internal.proto @@ -10,6 +10,7 @@ message DataChannel { optional int32 max_retransmits = 8; optional string protocol = 10; optional bool compress = 12; + optional string header = 14; } message ForwardingFilter { diff --git a/src/sora.cpp b/src/sora.cpp index 36f1d25..cfb13d3 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -419,6 +419,9 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, if (dc.has_compress()) { d.compress = dc.compress; } + if (dc.has_header()) { + d.header = dc.header; + } config.data_channels.push_back(std::move(d)); } if (!cc.metadata.empty()) { From 7a3a41ecb65bda59072d6f379a8c9747b43da485 Mon Sep 17 00:00:00 2001 From: torikizi Date: Mon, 28 Oct 2024 17:46:23 +0900 Subject: [PATCH 02/12] =?UTF-8?q?CHANGES=20=E3=81=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index d75a688..26a105b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,8 @@ - @torikizi - [ADD] `Sora.Config` に `ClientCert`, `ClientKey`, `CACert` を追加 - @melpon +- [ADD] DataChannels に `Header` を追加 + - @torikizi ### misc From 8bca1040dcbc9b3cd8ce8869a72c9ddb3d7668be Mon Sep 17 00:00:00 2001 From: torikizi Date: Mon, 28 Oct 2024 18:47:11 +0900 Subject: [PATCH 03/12] =?UTF-8?q?parse=20=E3=82=92=E5=85=A5=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=83=98=E3=83=83=E3=83=80=E3=83=BC=E3=82=92=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sora.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sora.cpp b/src/sora.cpp index cfb13d3..51c53af 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -420,7 +420,11 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, d.compress = dc.compress; } if (dc.has_header()) { - d.header = dc.header; + boost::json::value parsed_value = boost::json::parse(dc.header); + if (parsed_value.is_array()) { + const auto& ar = parsed_value.as_array(); + d.header.emplace(ar.begin(), ar.end()); + } } config.data_channels.push_back(std::move(d)); } From fda29041280308e793eb9098f3f9f08e68a8d514 Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Fri, 27 Dec 2024 19:03:29 +0900 Subject: [PATCH 04/12] =?UTF-8?q?header=20=E3=82=92=E9=85=8D=E5=88=97?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E5=AE=9A=E7=BE=A9=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proto/sora_conf_internal.proto | 6 +++++- src/sora.cpp | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/proto/sora_conf_internal.proto b/proto/sora_conf_internal.proto index 3d249bc..713ef98 100644 --- a/proto/sora_conf_internal.proto +++ b/proto/sora_conf_internal.proto @@ -2,6 +2,10 @@ syntax = "proto3"; package sora_conf.internal; +message Header { + repeated string content = 1; +} + message DataChannel { string label = 1; string direction = 2; @@ -10,7 +14,7 @@ message DataChannel { optional int32 max_retransmits = 8; optional string protocol = 10; optional bool compress = 12; - optional string header = 14; + optional Header header = 14; } message ForwardingFilter { diff --git a/src/sora.cpp b/src/sora.cpp index 51c53af..00f7015 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -420,11 +420,9 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, d.compress = dc.compress; } if (dc.has_header()) { - boost::json::value parsed_value = boost::json::parse(dc.header); - if (parsed_value.is_array()) { - const auto& ar = parsed_value.as_array(); - d.header.emplace(ar.begin(), ar.end()); - } + const auto& header_content = dc.header.content; + d.header->insert(d.header->end(), header_content.begin(), + header_content.end()); } config.data_channels.push_back(std::move(d)); } From 4db3bc5bb23b06e668a3474b11d58d12bd01c116 Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Sun, 29 Dec 2024 00:40:00 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E3=82=92=E8=A6=8B=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/Sora.cs | 10 +++++++--- src/sora.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Sora/Sora.cs b/Sora/Sora.cs index c7309b2..3ff3197 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -50,7 +50,10 @@ public enum SpotlightFocusRidType R1, R2, } - + public class Header + { + public List content { get; set; } = new List(); + } public class DataChannel { // 以下は設定必須 @@ -62,7 +65,8 @@ public class DataChannel public int? MaxRetransmits; public string? Protocol; public bool? Compress; - public string? Header; + public Header? Header; + } public const string ActionBlock = "block"; @@ -457,7 +461,7 @@ public void Connect(Config config) } if (m.Header != null) { - c.SetHeader(m.Header); + c.SetHeader(new SoraConf.Internal.Header { content = new List(m.Header.content) }); } cc.data_channels.Add(c); } diff --git a/src/sora.cpp b/src/sora.cpp index 1b20c9a..28d495e 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -421,8 +421,11 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, } if (dc.has_header()) { const auto& header_content = dc.header.content; - d.header->insert(d.header->end(), header_content.begin(), - header_content.end()); + d.header->reserve(header_content.size()); + for (const auto& json_str : header_content) { + auto parsed = boost::json::parse(json_str); + d.header->push_back(std::move(parsed)); + } } config.data_channels.push_back(std::move(d)); } From 1a328cf5aba79a61b23b87a8eaf2ee8e43fe0da9 Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:05:07 +0900 Subject: [PATCH 06/12] =?UTF-8?q?Header=20=E3=81=AE=E5=AE=9A=E7=BE=A9?= =?UTF-8?q?=E3=81=AF=20DataChannel=20=E3=81=AE=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proto/sora_conf_internal.proto | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/proto/sora_conf_internal.proto b/proto/sora_conf_internal.proto index e2a07a4..9e9d87e 100644 --- a/proto/sora_conf_internal.proto +++ b/proto/sora_conf_internal.proto @@ -2,10 +2,6 @@ syntax = "proto3"; package sora_conf.internal; -message Header { - repeated string content = 1; -} - message DataChannel { string label = 1; string direction = 2; @@ -14,6 +10,9 @@ 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; } From 4951e6fc6cff3f866b331cc5ed81680c8eeb7573 Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:59:40 +0900 Subject: [PATCH 07/12] =?UTF-8?q?=E4=BB=96=E3=81=A8=E5=90=8C=E6=A7=98?= =?UTF-8?q?=E3=83=91=E3=83=BC=E3=82=B9=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E6=99=82=E3=81=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E5=87=BA?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sora.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sora.cpp b/src/sora.cpp index 28d495e..0e2c791 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -423,8 +423,13 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, 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); - d.header->push_back(std::move(parsed)); + 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; + } else { + d.header->push_back(std::move(parsed)); + } } } config.data_channels.push_back(std::move(d)); From eb88c0d15c276e934ef589702737d6cceee4da1d Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Sun, 29 Dec 2024 22:36:56 +0900 Subject: [PATCH 08/12] =?UTF-8?q?Header=20=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E3=81=AF=E4=B8=8D=E8=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/Sora.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Sora/Sora.cs b/Sora/Sora.cs index 3ff3197..a1223c4 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -50,10 +50,6 @@ public enum SpotlightFocusRidType R1, R2, } - public class Header - { - public List content { get; set; } = new List(); - } public class DataChannel { // 以下は設定必須 @@ -65,8 +61,7 @@ public class DataChannel public int? MaxRetransmits; public string? Protocol; public bool? Compress; - public Header? Header; - + public List? Header; } public const string ActionBlock = "block"; @@ -461,7 +456,7 @@ public void Connect(Config config) } if (m.Header != null) { - c.SetHeader(new SoraConf.Internal.Header { content = new List(m.Header.content) }); + c.SetHeader(new SoraConf.Internal.DataChannel.Header { content = m.Header }); } cc.data_channels.Add(c); } From 36bbab59ddf86bda7824307360bf66f114971020 Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:08:08 +0900 Subject: [PATCH 09/12] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=82=92=E8=A6=8B?= =?UTF-8?q?=E7=9B=B4=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/Sora.cs | 4 +++- src/sora.cpp | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Sora/Sora.cs b/Sora/Sora.cs index a1223c4..e78e1f0 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -456,7 +456,9 @@ public void Connect(Config config) } if (m.Header != null) { - c.SetHeader(new SoraConf.Internal.DataChannel.Header { content = m.Header }); + var header = new SoraConf.Internal.DataChannel.Header(); + header.content.AddRange(m.Header); + c.SetHeader(header); } cc.data_channels.Add(c); } diff --git a/src/sora.cpp b/src/sora.cpp index 0e2c791..59188ea 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -420,9 +420,8 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, d.compress = dc.compress; } if (dc.has_header()) { - const auto& header_content = dc.header.content; - d.header->reserve(header_content.size()); - for (const auto& json_str : header_content) { + d.header->reserve(dc.header.content.size()); + for (const auto& json_str : dc.header.content) { boost::system::error_code ec; auto parsed = boost::json::parse(json_str, ec); if (ec) { From b9e59d774b27f1fea5487f1aff7e920470ee1a50 Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:31:18 +0900 Subject: [PATCH 10/12] =?UTF-8?q?=E3=81=A1=E3=82=83=E3=82=93=E3=81=A8?= =?UTF-8?q?=E5=88=9D=E6=9C=9F=E5=8C=96=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sora.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sora.cpp b/src/sora.cpp index 59188ea..b2bccc3 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -420,6 +420,7 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, d.compress = dc.compress; } if (dc.has_header()) { + d.header = std::vector(); d.header->reserve(dc.header.content.size()); for (const auto& json_str : dc.header.content) { boost::system::error_code ec; From c9087e40fc5f089690a85ad86e966445ea56544b Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Tue, 31 Dec 2024 00:50:43 +0900 Subject: [PATCH 11/12] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E3=81=AE=E8=A6=8B=E7=9B=B4=E3=81=97=E3=81=A8=E3=80=81=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E3=81=AA=E5=87=A6=E7=90=86=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/Sora.cs | 4 +--- src/sora.cpp | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Sora/Sora.cs b/Sora/Sora.cs index e78e1f0..9ccefa8 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -456,9 +456,7 @@ public void Connect(Config config) } if (m.Header != null) { - var header = new SoraConf.Internal.DataChannel.Header(); - header.content.AddRange(m.Header); - c.SetHeader(header); + c.SetHeader(new SoraConf.Internal.DataChannel.Header { content = new List(m.Header) }); } cc.data_channels.Add(c); } diff --git a/src/sora.cpp b/src/sora.cpp index b2bccc3..80ca6fe 100644 --- a/src/sora.cpp +++ b/src/sora.cpp @@ -421,12 +421,11 @@ void Sora::DoConnect(const sora_conf::internal::ConnectConfig& cc, } if (dc.has_header()) { d.header = std::vector(); - d.header->reserve(dc.header.content.size()); 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 in header: " << json_str; + RTC_LOG(LS_WARNING) << "Invalid JSON: header=" << json_str; } else { d.header->push_back(std::move(parsed)); } From d900cd28bee56d12b1f112b0c017c3844494ee31 Mon Sep 17 00:00:00 2001 From: torikizi <51085972+torikizi@users.noreply.github.com> Date: Tue, 31 Dec 2024 02:06:06 +0900 Subject: [PATCH 12/12] =?UTF-8?q?List=20=E4=BD=9C=E3=82=89=E3=81=AA?= =?UTF-8?q?=E3=81=8F=E3=81=A6=E8=89=AF=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/Sora.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sora/Sora.cs b/Sora/Sora.cs index 9ccefa8..a1223c4 100644 --- a/Sora/Sora.cs +++ b/Sora/Sora.cs @@ -456,7 +456,7 @@ public void Connect(Config config) } if (m.Header != null) { - c.SetHeader(new SoraConf.Internal.DataChannel.Header { content = new List(m.Header) }); + c.SetHeader(new SoraConf.Internal.DataChannel.Header { content = m.Header }); } cc.data_channels.Add(c); }