diff --git a/.vscode/launch.json b/.vscode/launch.json index dbdb5040..74157fbd 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 993e94f2..e8884a86 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/CHANGES.md b/CHANGES.md index 98de8996..74e7cc80 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -122,6 +122,8 @@ - @melpon - [ADD] WebSocket での接続時に User-Agent ヘッダーを追加する - @melpon +- [ADD] sumomo に --simulcast-multicodec オプションを追加 + - @melpon ## 2024.6.1 @@ -147,9 +149,9 @@ - [CHANGE] 別リポジトリに分かれていた Sora C++ SDK のサンプル集を examples/ 以下のディレクトリに統合する - @melpon -- [UPDATE] libwebrtc を `m122.6261.1.0` にあげる +- [UPDATE] libwebrtc を `m122.6261.1.1` にあげる - Ubuntu のビルドを通すために、 __assertion_handler というファイルをコピーする必要があった - - @miosakuma @enm10k + - @miosakuma @enm10k @melpon - [UPDATE] libvpl を v2.10.1 にあげる - @enm10k - [ADD] OpenH264 エンコーダを追加 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c71d52e..a8f56ac1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -357,6 +357,7 @@ elseif (SORA_TARGET_OS STREQUAL "macos") PUBLIC WEBRTC_POSIX WEBRTC_MAC + RTC_ENABLE_H265 ) target_link_libraries(sora @@ -402,6 +403,7 @@ elseif (SORA_TARGET_OS STREQUAL "ios") WEBRTC_MAC WEBRTC_IOS OPENSSL_IS_BORINGSSL + RTC_ENABLE_H265 ) elseif (SORA_TARGET_OS STREQUAL "android") @@ -422,6 +424,7 @@ elseif (SORA_TARGET_OS STREQUAL "android") WEBRTC_POSIX WEBRTC_LINUX WEBRTC_ANDROID + RTC_ENABLE_H265 _LIBCPP_ABI_NAMESPACE=Cr _LIBCPP_ABI_VERSION=2 _LIBCPP_DISABLE_AVAILABILITY diff --git a/examples/sumomo/src/sumomo.cpp b/examples/sumomo/src/sumomo.cpp index 603fcad0..4602d623 100644 --- a/examples/sumomo/src/sumomo.cpp +++ b/examples/sumomo/src/sumomo.cpp @@ -40,6 +40,7 @@ struct SumomoConfig { std::optional spotlight; int spotlight_number = 0; std::optional simulcast; + std::optional simulcast_multicodec; std::optional data_channel_signaling; std::optional ignore_disconnect_websocket; @@ -151,6 +152,7 @@ class Sumomo : public std::enable_shared_from_this, config.spotlight = config_.spotlight; config.spotlight_number = config_.spotlight_number; config.simulcast = config_.simulcast; + config.simulcast_multicodec = config_.simulcast_multicodec; config.data_channel_signaling = config_.data_channel_signaling; config.ignore_disconnect_websocket = config_.ignore_disconnect_websocket; config.proxy_agent = "Momo Sample for Sora C++ SDK"; @@ -410,6 +412,8 @@ int main(int argc, char* argv[]) { ->check(CLI::Range(0, 8)); add_optional_bool(app, "--simulcast", config.simulcast, "Use simulcast (default: none)"); + add_optional_bool(app, "--simulcast-multicodec", config.simulcast_multicodec, + "Use simulcast multi-codec (default: none)"); add_optional_bool(app, "--data-channel-signaling", config.data_channel_signaling, "Use DataChannel for Sora signaling (default: none)"); diff --git a/include/sora/sora_signaling.h b/include/sora/sora_signaling.h index 06b58d45..7e46a5a4 100644 --- a/include/sora/sora_signaling.h +++ b/include/sora/sora_signaling.h @@ -107,6 +107,7 @@ struct SoraSignalingConfig { std::string spotlight_focus_rid; std::string spotlight_unfocus_rid; std::optional simulcast; + std::optional simulcast_multicodec; std::string simulcast_rid; std::optional data_channel_signaling; int data_channel_signaling_timeout = 180; diff --git a/src/default_video_formats.cpp b/src/default_video_formats.cpp index 5c720bb8..77ed0127 100644 --- a/src/default_video_formats.cpp +++ b/src/default_video_formats.cpp @@ -27,16 +27,17 @@ std::vector GetDefaultVideoFormats( cricket::kAv1CodecName, webrtc::CodecParameterMap(), webrtc::LibaomAv1EncoderSupportedScalabilityModes())); } else if (codec == webrtc::kVideoCodecH264) { - r.push_back(CreateH264Format(webrtc::H264Profile::kProfileBaseline, - webrtc::H264Level::kLevel3_1, "1")); - r.push_back(CreateH264Format(webrtc::H264Profile::kProfileBaseline, - webrtc::H264Level::kLevel3_1, "0")); - r.push_back( - CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, - webrtc::H264Level::kLevel3_1, "1")); - r.push_back( - CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, - webrtc::H264Level::kLevel3_1, "0")); + for (auto profile : { + webrtc::H264Profile::kProfileBaseline, + webrtc::H264Profile::kProfileConstrainedBaseline, + webrtc::H264Profile::kProfileMain, + }) { + for (auto level : {webrtc::H264Level::kLevel3_1}) { + for (auto mode : {0, 1}) { + r.push_back(CreateH264Format(profile, level, std::to_string(mode))); + } + } + } } else if (codec == webrtc::kVideoCodecH265) { r.push_back(webrtc::SdpVideoFormat(cricket::kH265CodecName)); } diff --git a/src/sora_signaling.cpp b/src/sora_signaling.cpp index cdde5282..5c850316 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" @@ -271,6 +275,10 @@ void SoraSignaling::DoSendConnect(bool redirect) { m["simulcast"] = *config_.simulcast; } + if (config_.simulcast_multicodec) { + m["simulcast_multicodec"] = *config_.simulcast_multicodec; + } + if (!config_.simulcast_rid.empty()) { m["simulcast_rid"] = config_.simulcast_rid; } @@ -390,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; @@ -426,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) { @@ -930,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; @@ -1050,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); } @@ -1069,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) {}); diff --git a/test/.testparam.example.json b/test/.testparam.example.json index b10fbda4..981cd97f 100644 --- a/test/.testparam.example.json +++ b/test/.testparam.example.json @@ -25,6 +25,7 @@ "video_bit_rate": 0, "video_codec_type": null, "simulcast": false, + "simulcast_multicodec": false, "use_hardware_encoder": true, "openh264": null, "ignore_disconnect_websocket": null, diff --git a/test/hello.cpp b/test/hello.cpp index 3e69f13c..a3b768df 100644 --- a/test/hello.cpp +++ b/test/hello.cpp @@ -71,6 +71,7 @@ void HelloSora::Run() { config.video_bit_rate = config_.video_bit_rate; config.multistream = true; config.simulcast = config_.simulcast; + config.simulcast_multicodec = config_.simulcast_multicodec; if (config_.ignore_disconnect_websocket) { config.ignore_disconnect_websocket = *config_.ignore_disconnect_websocket; } @@ -259,6 +260,14 @@ int main(int argc, char* argv[]) { if (get(v, "log_level", x)) { rtc::LogMessage::LogToDebug((rtc::LoggingSeverity)x.to_number()); } + if (auto it = v.as_object().find("simulcast_multicodec"); + it != v.as_object().end()) { + config.simulcast_multicodec = it->value().as_bool(); + } + if (auto it = v.as_object().find("log_level"); it != v.as_object().end()) { + rtc::LogMessage::LogToDebug( + (rtc::LoggingSeverity)boost::json::value_to(it->value())); + } sora::SoraClientContextConfig context_config; context_config.get_android_application_context = GetAndroidApplicationContext; diff --git a/test/hello.h b/test/hello.h index 3d4e8f5c..522194e2 100644 --- a/test/hello.h +++ b/test/hello.h @@ -14,6 +14,7 @@ struct HelloSoraConfig { int video_bit_rate = 0; std::string video_codec_type = "H264"; bool simulcast = false; + bool simulcast_multicodec = false; std::optional ignore_disconnect_websocket; std::string client_id; std::vector data_channels;