From 4d99f9117f23ab74372bb0f86d97287d1442769c Mon Sep 17 00:00:00 2001 From: melpon Date: Thu, 14 Nov 2024 16:06:54 +0900 Subject: [PATCH] WIP --- .vscode/launch.json | 13 +++++++++++++ .vscode/settings.json | 14 +++++++++++++- src/sora_signaling.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index dbdb504..74157fb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,6 +52,19 @@ "externalConsole": false, "MIMode": "lldb" }, + { + "name": "Ubuntu 24.04 デバッグビルドのデバッグ", + "type": "lldb-dap", + "request": "launch", + "program": "${workspaceFolder}/_build/ubuntu-24.04_x86_64/debug/test/hello", + "args": ["${workspaceFolder}/test/.testparam.json"], + "cwd": "${fileDirname}", + "sourceMap": [["../../../../_source/ubuntu-24.04_x86_64/webrtc/src/", "/home/melpon/dev/webrtc-build-simulcast-multicodec/_source/ubuntu-24.04_x86_64/webrtc/src/"]], + "initCommands": [ + "settings append target.debug-file-search-paths /home/melpon/dev/webrtc-build-simulcast-multicodec/_build/ubuntu-24.04_x86_64/debug/webrtc/" + ], + "runInTerminal": true, + }, ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 993e94f..e8884a8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -20,6 +20,7 @@ "allowTrailingCommas": true, } }], + "lldb-dap.executable-path": "/usr/bin/lldb-dap-18", "files.associations": { "*.cs": "csharp", "CMakeLists.txt": "cmake", @@ -145,6 +146,17 @@ "__threading_support": "cpp", "__verbose_abort": "cpp", "string_view": "cpp", - "*.tcc": "cpp" + "*.tcc": "cpp", + "__assertion_handler": "cpp", + "cuchar": "cpp", + "propagate_const": "cpp", + "print": "cpp", + "expected": "cpp", + "netfwd": "cpp", + "rope": "cpp", + "slist": "cpp", + "spanstream": "cpp", + "stacktrace": "cpp", + "stdfloat": "cpp" } } diff --git a/src/sora_signaling.cpp b/src/sora_signaling.cpp index 10452b5..5c85031 100644 --- a/src/sora_signaling.cpp +++ b/src/sora_signaling.cpp @@ -7,6 +7,10 @@ #include #include +// Boost +#include +#include + #include "sora/data_channel.h" #include "sora/rtc_ssl_verifier.h" #include "sora/rtc_stats.h" @@ -394,7 +398,8 @@ void SoraSignaling::DoSendConnect(bool redirect) { m["data_channels"] = ar; } - auto forwarding_filter_to_json = [](const SoraSignalingConfig::ForwardingFilter& f) -> boost::json::value { + auto forwarding_filter_to_json = + [](const SoraSignalingConfig::ForwardingFilter& f) -> boost::json::value { boost::json::object obj; if (f.name) { obj["name"] = *f.name; @@ -430,7 +435,8 @@ void SoraSignaling::DoSendConnect(bool redirect) { }; if (config_.forwarding_filter) { - m["forwarding_filter"] = forwarding_filter_to_json(*config_.forwarding_filter); + m["forwarding_filter"] = + forwarding_filter_to_json(*config_.forwarding_filter); } if (config_.forwarding_filters) { @@ -934,6 +940,7 @@ void SoraSignaling::OnRead(boost::system::error_code ec, SoraSignalingDirection::RECEIVED, text); const std::string sdp = m.at("sdp").as_string().c_str(); + RTC_LOG(LS_ERROR) << "received sdp: " << sdp; std::string video_mid; std::string audio_mid; @@ -1054,6 +1061,32 @@ void SoraSignaling::OnRead(boost::system::error_code ec, params.scalability_mode = p["scalabilityMode"].as_string().c_str(); } + if (p.count("codec") != 0) { + const auto& c = p["codec"].as_object(); + // video/VP8 のような形式で、video は確定なので後ろのコーデック部分だけ見る + std::string mime_type = c.at("mimeType").as_string().c_str(); + auto& codec = params.codec.emplace(); + codec.kind = cricket::MEDIA_TYPE_VIDEO; + codec.name = mime_type.substr(mime_type.find('/') + 1); + if (c.count("clockRate") != 0) { + codec.clock_rate = c.at("clockRate").to_number(); + } + if (c.count("sdpFmtpLine") != 0) { + // sdpFmtpLine は + // level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e02a + // のような文字列になってるはず + std::vector xs; + boost::algorithm::split( + xs, c.at("sdpFmtpLine").as_string().c_str(), + boost::algorithm::is_any_of(";")); + for (const auto& x : xs) { + std::vector kv; + boost::algorithm::split(kv, x, + boost::algorithm::is_any_of("=")); + codec.parameters[kv[0]] = kv[1]; + } + } + } encoding_parameters.push_back(params); } @@ -1073,6 +1106,7 @@ void SoraSignaling::OnRead(boost::system::error_code ec, } boost::json::value m = {{"type", "answer"}, {"sdp", sdp}}; + RTC_LOG(LS_ERROR) << sdp; self->WsWriteSignaling( boost::json::serialize(m), [self](boost::system::error_code, size_t) {});