From d797cb6ca737b682306d591b63e2654fcd3ab19b Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Tue, 27 Jun 2023 20:07:09 +0000 Subject: [PATCH] Remove all split channels related code Bug: webrtc:13931 Change-Id: I93b8ca0ba1ec15bf260236bbc914b41fbb30aa58 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/310680 Commit-Queue: Florent Castelli Reviewed-by: Jeremy Leconte Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#40376} --- BUILD.gn | 1 - infra/specs/client.webrtc.json | 409 ------------- infra/specs/gn_isolate_map.pyl | 4 - infra/specs/test_suites.pyl | 2 - infra/specs/tryserver.webrtc.json | 486 --------------- media/BUILD.gn | 42 -- media/base/delayable.h | 38 -- media/base/fake_media_engine.h | 47 -- media/base/media_channel.h | 14 +- media/base/media_channel_impl.cc | 15 - media/base/media_channel_impl.h | 212 +------ media/base/media_channel_shim.cc | 57 -- media/base/media_channel_shim.h | 575 ------------------ media/base/media_engine.h | 90 --- media/base/media_engine_unittest.cc | 64 -- media/engine/null_webrtc_video_engine.h | 13 - media/engine/webrtc_video_engine.cc | 23 - media/engine/webrtc_video_engine.h | 10 - media/engine/webrtc_voice_engine.cc | 23 - media/engine/webrtc_voice_engine.h | 9 - media/engine/webrtc_voice_engine_unittest.cc | 1 - pc/BUILD.gn | 24 +- pc/audio_rtp_receiver_unittest.cc | 40 +- pc/channel.cc | 75 +-- pc/channel.h | 57 +- pc/channel_interface.h | 1 - ..._connection_mediachannel_split_unittest.cc | 209 ------- pc/rtp_sender_receiver_unittest.cc | 8 +- pc/rtp_transceiver.cc | 140 ++--- pc/rtp_transceiver_unittest.cc | 4 +- pc/test/mock_channel_interface.h | 28 +- ...k_voice_media_receive_channel_interface.h} | 190 ++---- 32 files changed, 187 insertions(+), 2724 deletions(-) delete mode 100644 media/base/delayable.h delete mode 100644 media/base/media_channel_shim.cc delete mode 100644 media/base/media_channel_shim.h delete mode 100644 pc/peer_connection_mediachannel_split_unittest.cc rename pc/test/{mock_voice_media_channel.h => mock_voice_media_receive_channel_interface.h} (51%) diff --git a/BUILD.gn b/BUILD.gn index 47476e4525..c3e253a4e8 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -64,7 +64,6 @@ if (!build_with_chromium) { "modules/video_capture:video_capture_internal_impl", "modules/video_coding:video_codec_perf_tests", "net/dcsctp:dcsctp_unittests", - "pc:peer_connection_mediachannel_split_unittests", "pc:peerconnection_unittests", "pc:rtc_pc_unittests", "pc:slow_peer_connection_unittests", diff --git a/infra/specs/client.webrtc.json b/infra/specs/client.webrtc.json index 0a40d6216d..7494e53cf4 100644 --- a/infra/specs/client.webrtc.json +++ b/infra/specs/client.webrtc.json @@ -173,27 +173,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -665,27 +644,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -1186,27 +1144,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -1678,27 +1615,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -2435,25 +2351,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -2844,25 +2741,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-20.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -3234,25 +3112,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -3624,25 +3483,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -4033,25 +3873,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -4442,25 +4263,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -4833,25 +4635,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -5225,25 +5008,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -5635,25 +5399,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -6072,26 +5817,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cores": "12", - "cpu": "x86-64", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -6483,26 +6208,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cores": "12", - "cpu": "x86-64", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -6887,25 +6592,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -7297,25 +6983,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "arm64-64-Apple_M1", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -7714,25 +7381,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -8104,25 +7752,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -8494,25 +8123,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -8884,25 +8494,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { diff --git a/infra/specs/gn_isolate_map.pyl b/infra/specs/gn_isolate_map.pyl index 508d80dab7..7e31965b4e 100644 --- a/infra/specs/gn_isolate_map.pyl +++ b/infra/specs/gn_isolate_map.pyl @@ -71,10 +71,6 @@ "label": "//modules:modules_unittests", "type": "windowed_test_launcher", }, - "peer_connection_mediachannel_split_unittests": { - "label": "//pc:peer_connection_mediachannel_split_unittests", - "type": "console_test_launcher", - }, "peerconnection_unittests": { "label": "//pc:peerconnection_unittests", "type": "console_test_launcher", diff --git a/infra/specs/test_suites.pyl b/infra/specs/test_suites.pyl index 2e440a67d9..bf4be30feb 100644 --- a/infra/specs/test_suites.pyl +++ b/infra/specs/test_suites.pyl @@ -25,7 +25,6 @@ 'modules_unittests': { 'mixins': ['shards-6'], }, - 'peer_connection_mediachannel_split_unittests': {}, 'peerconnection_unittests': { 'mixins': ['shards-4'], }, @@ -64,7 +63,6 @@ 'modules_unittests': { 'mixins': ['shards-6'], }, - 'peer_connection_mediachannel_split_unittests': {}, 'peerconnection_unittests': { 'mixins': ['shards-4'], }, diff --git a/infra/specs/tryserver.webrtc.json b/infra/specs/tryserver.webrtc.json index c68347d715..7b92f19316 100644 --- a/infra/specs/tryserver.webrtc.json +++ b/infra/specs/tryserver.webrtc.json @@ -173,27 +173,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -690,27 +669,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -1207,27 +1165,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -1750,27 +1687,6 @@ "test": "modules_unittests", "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "merge": { - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "resultdb": { - "enable": true, - "has_native_resultdb_integration": true - }, - "swarming": { - "dimension_sets": [ - { - "android_devices": "1", - "device_type": "walleye", - "os": "Android" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "peer_connection_mediachannel_split_unittests", - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "merge": { "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5699,25 +5615,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -6120,26 +6017,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "isolate_profile_data": true, - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "isolate_profile_data": true, @@ -6617,25 +6494,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -7027,25 +6885,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -7460,25 +7299,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-20.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -7850,25 +7670,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -8329,25 +8130,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -8719,25 +8501,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -9128,25 +8891,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -9537,25 +9281,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -9927,25 +9652,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Ubuntu-18.04" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -10323,26 +10029,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cores": "12", - "cpu": "x86-64", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -10735,26 +10421,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cores": "12", - "cpu": "x86-64", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -11139,25 +10805,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "arm64-64-Apple_M1", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -11529,25 +11176,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -11989,25 +11617,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "arm64-64-Apple_M1", - "os": "Mac-12" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -12379,25 +11988,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -12773,25 +12363,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -13163,25 +12734,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -13553,25 +13105,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { @@ -13943,25 +13476,6 @@ }, "test_id_prefix": "ninja://modules:modules_unittests/" }, - { - "isolate_name": "peer_connection_mediachannel_split_unittests", - "merge": { - "script": "//testing/merge_scripts/standard_isolated_script_merge.py" - }, - "name": "peer_connection_mediachannel_split_unittests", - "resultdb": { - "result_format": "json" - }, - "swarming": { - "dimension_sets": [ - { - "cpu": "x86-64", - "os": "Windows-10-19045" - } - ] - }, - "test_id_prefix": "ninja://pc:peer_connection_mediachannel_split_unittests/" - }, { "isolate_name": "peerconnection_unittests", "merge": { diff --git a/media/BUILD.gn b/media/BUILD.gn index 3ecc881f31..22eb02ab4f 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -141,40 +141,6 @@ rtc_library("rtc_media_base") { ] } -rtc_library("media_channel_shim") { - sources = [ - "base/media_channel_shim.cc", - "base/media_channel_shim.h", - ] - deps = [ - ":codec", - ":media_channel", - ":media_channel_impl", - ":stream_params", - "../api:frame_transformer_interface", - "../api:rtc_error", - "../api:rtp_headers", - "../api:rtp_parameters", - "../api:rtp_sender_interface", - "../api:scoped_refptr", - "../api/crypto:frame_decryptor_interface", - "../api/crypto:frame_encryptor_interface", - "../api/transport/rtp:rtp_source", - "../api/video:recordable_encoded_frame", - "../api/video:video_frame", - "../api/video_codecs:video_codecs_api", - "../modules/rtp_rtcp:rtp_rtcp_format", - "../rtc_base:checks", - "../rtc_base:network_route", - "../rtc_base/network:sent_packet", - ] - absl_deps = [ - "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/strings", - "//third_party/abseil-cpp/absl/types:optional", - ] -} - rtc_library("media_channel_impl") { sources = [ "base/media_channel_impl.cc", @@ -230,7 +196,6 @@ rtc_source_set("media_channel") { sources = [ "base/media_channel.h" ] deps = [ ":codec", - ":delayable", ":media_constants", ":rtp_utils", ":stream_params", @@ -279,11 +244,6 @@ rtc_source_set("media_channel") { ] } -rtc_source_set("delayable") { - sources = [ "base/delayable.h" ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] -} - rtc_library("codec") { sources = [ "base/codec.cc", @@ -474,7 +434,6 @@ rtc_library("rtc_audio_video") { ":codec", ":media_channel", ":media_channel_impl", - ":media_channel_shim", ":media_constants", ":rid_description", ":rtc_media_base", @@ -841,7 +800,6 @@ if (rtc_include_tests) { deps = [ ":codec", ":media_channel", - ":media_channel_shim", ":media_constants", ":rtc_audio_video", ":rtc_internal_video_codecs", diff --git a/media/base/delayable.h b/media/base/delayable.h deleted file mode 100644 index f0344c5dec..0000000000 --- a/media/base/delayable.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MEDIA_BASE_DELAYABLE_H_ -#define MEDIA_BASE_DELAYABLE_H_ - -#include - -#include "absl/types/optional.h" - -namespace cricket { - -// Delayable is used by user code through ApplyConstraints algorithm. Its -// methods must take precendence over similar functional in `syncable.h`. -class Delayable { - public: - virtual ~Delayable() {} - // Set base minimum delay of the receive stream with specified ssrc. - // Base minimum delay sets lower bound on minimum delay value which - // determines minimum delay until audio playout. - // Returns false if there is no stream with given ssrc. - virtual bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) = 0; - - // Returns current value of base minimum delay in milliseconds. - virtual absl::optional GetBaseMinimumPlayoutDelayMs( - uint32_t ssrc) const = 0; -}; - -} // namespace cricket - -#endif // MEDIA_BASE_DELAYABLE_H_ diff --git a/media/base/fake_media_engine.h b/media/base/fake_media_engine.h index 34c91cf08f..1fd95c9001 100644 --- a/media/base/fake_media_engine.h +++ b/media/base/fake_media_engine.h @@ -778,29 +778,6 @@ class FakeVoiceEngine : public VoiceEngineInterface { const AudioOptions& options, const webrtc::CryptoOptions& crypto_options, webrtc::AudioCodecPairId codec_pair_id) override; - VoiceMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::AudioCodecPairId codec_pair_id) override { - RTC_DCHECK_RUN_ON(call->worker_thread()); - std::unique_ptr send_channel; - std::unique_ptr receive_channel; - if (role == MediaChannel::Role::kSend || - role == MediaChannel::Role::kBoth) { - send_channel = CreateSendChannel(call, config, options, crypto_options, - codec_pair_id); - } - if (role == MediaChannel::Role::kReceive || - role == MediaChannel::Role::kBoth) { - receive_channel = CreateReceiveChannel(call, config, options, - crypto_options, codec_pair_id); - } - return new VoiceMediaShimChannel(std::move(send_channel), - std::move(receive_channel)); - } // TODO(ossu): For proper testing, These should either individually settable // or the voice engine should reference mockable factories. @@ -844,30 +821,6 @@ class FakeVideoEngine : public VideoEngineInterface { const MediaConfig& config, const VideoOptions& options, const webrtc::CryptoOptions& crypto_options) override; - VideoMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) - override { - RTC_LOG(LS_INFO) << "CreateMediaChannel. Options: " << options.ToString(); - std::unique_ptr send_channel; - std::unique_ptr receive_channel; - if (role == MediaChannel::Role::kSend || - role == MediaChannel::Role::kBoth) { - send_channel = CreateSendChannel(call, config, options, crypto_options, - video_bitrate_allocator_factory); - } - if (role == MediaChannel::Role::kReceive || - role == MediaChannel::Role::kBoth) { - receive_channel = - CreateReceiveChannel(call, config, options, crypto_options); - } - return new VideoMediaShimChannel(std::move(send_channel), - std::move(receive_channel)); - } FakeVideoMediaSendChannel* GetSendChannel(size_t index); FakeVideoMediaReceiveChannel* GetReceiveChannel(size_t index); diff --git a/media/base/media_channel.h b/media/base/media_channel.h index 3fd37b34aa..9657f1fbe5 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -43,7 +43,6 @@ #include "call/video_receive_stream.h" #include "common_video/include/quality_limitation_reason.h" #include "media/base/codec.h" -#include "media/base/delayable.h" #include "media/base/media_constants.h" #include "media/base/stream_params.h" #include "modules/audio_processing/include/audio_processing_statistics.h" @@ -75,7 +74,6 @@ webrtc::RTCError InvokeSetParametersCallback(SetParametersCallback& callback, namespace cricket { class AudioSource; -class MediaChannel; // TODO(bugs.webrtc.org/13931): Delete when irrelevant class VideoCapturer; struct RtpHeader; struct VideoFormat; @@ -260,7 +258,7 @@ class MediaSendChannelInterface { absl::AnyInvocable callback) = 0; }; -class MediaReceiveChannelInterface : public Delayable { +class MediaReceiveChannelInterface { public: virtual ~MediaReceiveChannelInterface() = default; @@ -312,6 +310,16 @@ class MediaReceiveChannelInterface : public Delayable { uint32_t ssrc, rtc::scoped_refptr frame_transformer) = 0; + + // Set base minimum delay of the receive stream with specified ssrc. + // Base minimum delay sets lower bound on minimum delay value which + // determines minimum delay until audio playout. + // Returns false if there is no stream with given ssrc. + virtual bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) = 0; + + // Returns current value of base minimum delay in milliseconds. + virtual absl::optional GetBaseMinimumPlayoutDelayMs( + uint32_t ssrc) const = 0; }; // The stats information is structured as follows: diff --git a/media/base/media_channel_impl.cc b/media/base/media_channel_impl.cc index 12f2179712..9bfb0f037b 100644 --- a/media/base/media_channel_impl.cc +++ b/media/base/media_channel_impl.cc @@ -61,11 +61,6 @@ MediaChannelUtil::MediaChannelUtil(TaskQueueBase* network_thread, bool enable_dscp) : transport_(network_thread, enable_dscp) {} -MediaChannel::MediaChannel(Role role, - TaskQueueBase* network_thread, - bool enable_dscp) - : MediaChannelUtil(network_thread, enable_dscp), role_(role) {} - MediaChannelUtil::~MediaChannelUtil() {} void MediaChannelUtil::SetInterface(MediaChannelNetworkInterface* iface) { @@ -181,10 +176,6 @@ std::map AudioSendParameters::ToStringMap() const { return params; } -cricket::MediaType VoiceMediaChannel::media_type() const { - return cricket::MediaType::MEDIA_TYPE_AUDIO; -} - VideoSendParameters::VideoSendParameters() = default; VideoSendParameters::~VideoSendParameters() = default; @@ -194,12 +185,6 @@ std::map VideoSendParameters::ToStringMap() const { return params; } -cricket::MediaType VideoMediaChannel::media_type() const { - return cricket::MediaType::MEDIA_TYPE_VIDEO; -} - -void VideoMediaChannel::SetVideoCodecSwitchingEnabled(bool enabled) {} - // --------------------- MediaChannelUtil::TransportForMediaChannels ----- MediaChannelUtil::TransportForMediaChannels::TransportForMediaChannels( diff --git a/media/base/media_channel_impl.h b/media/base/media_channel_impl.h index 1a037f77fa..1583e346d6 100644 --- a/media/base/media_channel_impl.h +++ b/media/base/media_channel_impl.h @@ -59,16 +59,12 @@ #include "rtc_base/socket.h" #include "rtc_base/thread_annotations.h" // This file contains the base classes for classes that implement -// the MediaChannel interfaces. +// the channel interfaces. // These implementation classes used to be the exposed interface names, // but this is in the process of being changed. -// TODO(bugs.webrtc.org/13931): Remove the MediaChannel class. namespace cricket { -class VoiceMediaChannel; -class VideoMediaChannel; - // The `MediaChannelUtil` class provides functionality that is used by // multiple MediaChannel-like objects, of both sending and receiving // types. @@ -195,212 +191,6 @@ class MediaChannelUtil { TransportForMediaChannels transport_; }; -// The `MediaChannel` class implements both the SendChannel and -// ReceiveChannel interface. It is used in legacy code that does not -// use the split interfaces. -class MediaChannel : public MediaChannelUtil, - public MediaSendChannelInterface, - public MediaReceiveChannelInterface { - public: - // Role of the channel. Used to describe which interface it supports. - // This is temporary until we stop using the same implementation for both - // interfaces. - enum class Role { - kSend, - kReceive, - kBoth // Temporary value for non-converted test and downstream code - // TODO(bugs.webrtc.org/13931): Remove kBoth when usage is removed. - }; - - MediaChannel(Role role, - webrtc::TaskQueueBase* network_thread, - bool enable_dscp = false); - virtual ~MediaChannel() = default; - - Role role() const { return role_; } - - // Downcasting to the subclasses. - virtual VideoMediaChannel* AsVideoChannel() { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - - virtual VoiceMediaChannel* AsVoiceChannel() { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - // Must declare the methods inherited from the base interface template, - // even when abstract, to tell the compiler that all instances of the name - // referred to by subclasses of this share the same implementation. - cricket::MediaType media_type() const override = 0; - void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override = 0; - void OnPacketSent(const rtc::SentPacket& sent_packet) override = 0; - void OnReadyToSend(bool ready) override = 0; - void OnNetworkRouteChanged(absl::string_view transport_name, - const rtc::NetworkRoute& network_route) override = - 0; - void SetSendCodecChangedCallback( - absl::AnyInvocable callback) override = 0; - - // Methods from the APIs that are implemented in MediaChannelUtil - using MediaChannelUtil::ExtmapAllowMixed; - using MediaChannelUtil::HasNetworkInterface; - using MediaChannelUtil::SetExtmapAllowMixed; - using MediaChannelUtil::SetInterface; - - private: - const Role role_; -}; - -// Base class for implementation classes - -class VideoMediaChannel : public MediaChannel, - public VideoMediaSendChannelInterface, - public VideoMediaReceiveChannelInterface { - public: - explicit VideoMediaChannel(MediaChannel::Role role, - webrtc::TaskQueueBase* network_thread, - bool enable_dscp = false) - : MediaChannel(role, network_thread, enable_dscp) {} - ~VideoMediaChannel() override {} - - // Downcasting to the implemented interfaces. - VideoMediaSendChannelInterface* AsVideoSendChannel() override { return this; } - VoiceMediaSendChannelInterface* AsVoiceSendChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - - VideoMediaReceiveChannelInterface* AsVideoReceiveChannel() override { - return this; - } - VoiceMediaReceiveChannelInterface* AsVoiceReceiveChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - cricket::MediaType media_type() const override; - - // Downcasting to the subclasses. - VideoMediaChannel* AsVideoChannel() override { return this; } - - void SetExtmapAllowMixed(bool mixed) override { - MediaChannel::SetExtmapAllowMixed(mixed); - } - bool ExtmapAllowMixed() const override { - return MediaChannel::ExtmapAllowMixed(); - } - void SetInterface(MediaChannelNetworkInterface* iface) override { - return MediaChannel::SetInterface(iface); - } - // Declared here in order to avoid "found by multiple paths" compile error - bool AddSendStream(const StreamParams& sp) override = 0; - void ChooseReceiverReportSsrc(const std::set& choices) override = 0; - void SetSsrcListChangedCallback( - absl::AnyInvocable&)> callback) override = - 0; - bool AddRecvStream(const StreamParams& sp) override = 0; - void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override = 0; - void SetEncoderSelector(uint32_t ssrc, - webrtc::VideoEncoderFactory::EncoderSelectorInterface* - encoder_selector) override {} - - // Gets quality stats for the channel. - virtual bool GetSendStats(VideoMediaSendInfo* info) = 0; - virtual bool GetReceiveStats(VideoMediaReceiveInfo* info) = 0; - bool GetStats(VideoMediaSendInfo* info) override { - return GetSendStats(info); - } - bool GetStats(VideoMediaReceiveInfo* info) override { - return GetReceiveStats(info); - } - - // TODO(bugs.webrtc.org/13931): Remove when configuration is more sensible - void SetSendCodecChangedCallback( - absl::AnyInvocable callback) override = 0; - // Enable network condition based codec switching. - // Note: should have been pure virtual. - void SetVideoCodecSwitchingEnabled(bool enabled) override; - - private: - // Functions not implemented on this interface - bool HasNetworkInterface() const override { - return MediaChannel::HasNetworkInterface(); - } -}; - -// Base class for implementation classes -class VoiceMediaChannel : public MediaChannel, - public VoiceMediaSendChannelInterface, - public VoiceMediaReceiveChannelInterface { - public: - MediaType media_type() const override; - VoiceMediaChannel(MediaChannel::Role role, - webrtc::TaskQueueBase* network_thread, - bool enable_dscp = false) - : MediaChannel(role, network_thread, enable_dscp) {} - ~VoiceMediaChannel() override {} - - // Downcasting to the implemented interfaces. - VoiceMediaSendChannelInterface* AsVoiceSendChannel() override { return this; } - - VoiceMediaReceiveChannelInterface* AsVoiceReceiveChannel() override { - return this; - } - - VoiceMediaChannel* AsVoiceChannel() override { return this; } - - VideoMediaSendChannelInterface* AsVideoSendChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - VideoMediaReceiveChannelInterface* AsVideoReceiveChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - - // Declared here in order to avoid "found by multiple paths" compile error - bool AddSendStream(const StreamParams& sp) override = 0; - bool AddRecvStream(const StreamParams& sp) override = 0; - void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override = 0; - void SetEncoderSelector(uint32_t ssrc, - webrtc::VideoEncoderFactory::EncoderSelectorInterface* - encoder_selector) override {} - void ChooseReceiverReportSsrc(const std::set& choices) override = 0; - void SetSsrcListChangedCallback( - absl::AnyInvocable&)> callback) override = - 0; - webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override = 0; - webrtc::RTCError SetRtpSendParameters( - uint32_t ssrc, - const webrtc::RtpParameters& parameters, - webrtc::SetParametersCallback callback = nullptr) override = 0; - - void SetExtmapAllowMixed(bool mixed) override { - MediaChannel::SetExtmapAllowMixed(mixed); - } - bool ExtmapAllowMixed() const override { - return MediaChannel::ExtmapAllowMixed(); - } - void SetInterface(MediaChannelNetworkInterface* iface) override { - return MediaChannel::SetInterface(iface); - } - bool HasNetworkInterface() const override { - return MediaChannel::HasNetworkInterface(); - } - - // Gets quality stats for the channel. - virtual bool GetSendStats(VoiceMediaSendInfo* info) = 0; - virtual bool GetReceiveStats(VoiceMediaReceiveInfo* info, - bool get_and_clear_legacy_stats) = 0; - bool GetStats(VoiceMediaSendInfo* info) override { - return GetSendStats(info); - } - bool GetStats(VoiceMediaReceiveInfo* info, - bool get_and_clear_legacy_stats) override { - return GetReceiveStats(info, get_and_clear_legacy_stats); - } -}; - } // namespace cricket #endif // MEDIA_BASE_MEDIA_CHANNEL_IMPL_H_ diff --git a/media/base/media_channel_shim.cc b/media/base/media_channel_shim.cc deleted file mode 100644 index adc749ff9d..0000000000 --- a/media/base/media_channel_shim.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2023 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "media/base/media_channel_shim.h" - -namespace cricket { - -// Note: The VideoMediaChannel default implementations are not used here, and -// should be removed from that interface. -// TODO(bugs.webrtc.org/13931): Remove them. -VoiceMediaShimChannel::VoiceMediaShimChannel( - std::unique_ptr send_impl, - std::unique_ptr receive_impl) - : VoiceMediaChannel(MediaChannel::Role::kBoth, nullptr, false), - send_impl_(std::move(send_impl)), - receive_impl_(std::move(receive_impl)) { - if (send_impl_ && receive_impl_) { - send_impl_->SetSsrcListChangedCallback( - [this](const std::set& choices) { - receive_impl_->ChooseReceiverReportSsrc(choices); - }); - send_impl_->SetSendCodecChangedCallback([this]() { - receive_impl_->SetReceiveNackEnabled(send_impl_->SendCodecHasNack()); - receive_impl_->SetReceiveNonSenderRttEnabled( - send_impl_->SenderNonSenderRttEnabled()); - }); - } -} - -VideoMediaShimChannel::VideoMediaShimChannel( - std::unique_ptr send_impl, - std::unique_ptr receive_impl) - : VideoMediaChannel(MediaChannel::Role::kBoth, nullptr, false), - send_impl_(std::move(send_impl)), - receive_impl_(std::move(receive_impl)) { - if (send_impl_ && receive_impl_) { - send_impl_->SetSendCodecChangedCallback([this]() { - // Adjust receive streams based on send codec. - receive_impl_->SetReceiverFeedbackParameters( - send_impl_->SendCodecHasLntf(), send_impl_->SendCodecHasNack(), - send_impl_->SendCodecRtcpMode(), send_impl_->SendCodecRtxTime()); - }); - send_impl_->SetSsrcListChangedCallback( - [this](const std::set& choices) { - receive_impl_->ChooseReceiverReportSsrc(choices); - }); - } -} - -} // namespace cricket diff --git a/media/base/media_channel_shim.h b/media/base/media_channel_shim.h deleted file mode 100644 index f051d1a11a..0000000000 --- a/media/base/media_channel_shim.h +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright 2023 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MEDIA_BASE_MEDIA_CHANNEL_SHIM_H_ -#define MEDIA_BASE_MEDIA_CHANNEL_SHIM_H_ - -#include - -#include -#include -#include -#include -#include -#include - -#include "absl/functional/any_invocable.h" -#include "absl/strings/string_view.h" -#include "absl/types/optional.h" -#include "api/crypto/frame_decryptor_interface.h" -#include "api/crypto/frame_encryptor_interface.h" -#include "api/frame_transformer_interface.h" -#include "api/media_types.h" -#include "api/rtc_error.h" -#include "api/rtp_headers.h" -#include "api/rtp_parameters.h" -#include "api/rtp_sender_interface.h" -#include "api/scoped_refptr.h" -#include "api/transport/rtp/rtp_source.h" -#include "api/video/recordable_encoded_frame.h" -#include "api/video/video_frame.h" -#include "api/video/video_sink_interface.h" -#include "api/video/video_source_interface.h" -#include "api/video_codecs/video_encoder_factory.h" -#include "media/base/codec.h" -#include "media/base/media_channel.h" -#include "media/base/media_channel_impl.h" -#include "media/base/stream_params.h" -#include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "rtc_base/checks.h" -#include "rtc_base/network/sent_packet.h" -#include "rtc_base/network_route.h" - -namespace cricket { - -// The VideoMediaShimChannel is replacing the VideoMediaChannel -// interface. -// If called with both send_impl and receive_impl, it operates in kBoth -// mode; if called with only one, it will shim that one and DCHECK if one -// tries to do functions belonging to the other. -class VoiceMediaShimChannel : public VoiceMediaChannel { - public: - VoiceMediaShimChannel( - std::unique_ptr send_impl, - std::unique_ptr receive_impl); - - VoiceMediaSendChannelInterface* AsVoiceSendChannel() override { return this; } - VoiceMediaReceiveChannelInterface* AsVoiceReceiveChannel() override { - return this; - } - VideoMediaSendChannelInterface* AsVideoSendChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - VideoMediaReceiveChannelInterface* AsVideoReceiveChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - - // SetInterface needs to run on both send and receive channels. - void SetInterface(MediaChannelNetworkInterface* iface) override { - if (send_impl_) { - send_impl()->SetInterface(iface); - } - if (receive_impl_) { - receive_impl()->SetInterface(iface); - } - } - - // Implementation of MediaBaseChannelInterface - cricket::MediaType media_type() const override { return MEDIA_TYPE_AUDIO; } - - // Implementation of MediaSendChannelInterface - absl::optional GetSendCodec() const override { - return send_impl()->GetSendCodec(); - } - void OnPacketSent(const rtc::SentPacket& sent_packet) override { - send_impl()->OnPacketSent(sent_packet); - } - void OnReadyToSend(bool ready) override { send_impl()->OnReadyToSend(ready); } - void OnNetworkRouteChanged(absl::string_view transport_name, - const rtc::NetworkRoute& network_route) override { - send_impl()->OnNetworkRouteChanged(transport_name, network_route); - } - void SetExtmapAllowMixed(bool extmap_allow_mixed) override { - send_impl()->SetExtmapAllowMixed(extmap_allow_mixed); - } - bool HasNetworkInterface() const override { - return send_impl()->HasNetworkInterface(); - } - bool ExtmapAllowMixed() const override { - return send_impl()->ExtmapAllowMixed(); - } - - bool AddSendStream(const StreamParams& sp) override { - return send_impl()->AddSendStream(sp); - } - bool RemoveSendStream(uint32_t ssrc) override { - return send_impl()->RemoveSendStream(ssrc); - } - void SetFrameEncryptor(uint32_t ssrc, - rtc::scoped_refptr - frame_encryptor) override { - send_impl()->SetFrameEncryptor(ssrc, frame_encryptor); - } - webrtc::RTCError SetRtpSendParameters( - uint32_t ssrc, - const webrtc::RtpParameters& parameters, - webrtc::SetParametersCallback callback = nullptr) override { - return send_impl()->SetRtpSendParameters(ssrc, parameters, - std::move(callback)); - } - - void SetEncoderToPacketizerFrameTransformer( - uint32_t ssrc, - rtc::scoped_refptr frame_transformer) - override { - return send_impl()->SetEncoderToPacketizerFrameTransformer( - ssrc, frame_transformer); - } - webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override { - return send_impl()->GetRtpSendParameters(ssrc); - } - // Implementation of MediaReceiveChannelInterface - void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override { - receive_impl()->OnPacketReceived(packet); - } - bool AddRecvStream(const StreamParams& sp) override { - return receive_impl()->AddRecvStream(sp); - } - bool RemoveRecvStream(uint32_t ssrc) override { - return receive_impl()->RemoveRecvStream(ssrc); - } - void ResetUnsignaledRecvStream() override { - return receive_impl()->ResetUnsignaledRecvStream(); - } - absl::optional GetUnsignaledSsrc() const override { - return receive_impl()->GetUnsignaledSsrc(); - } - void ChooseReceiverReportSsrc(const std::set& choices) override { - return receive_impl()->ChooseReceiverReportSsrc(choices); - } - void OnDemuxerCriteriaUpdatePending() override { - receive_impl()->OnDemuxerCriteriaUpdatePending(); - } - void OnDemuxerCriteriaUpdateComplete() override { - receive_impl()->OnDemuxerCriteriaUpdateComplete(); - } - void SetFrameDecryptor(uint32_t ssrc, - rtc::scoped_refptr - frame_decryptor) override { - receive_impl()->SetFrameDecryptor(ssrc, frame_decryptor); - } - void SetDepacketizerToDecoderFrameTransformer( - uint32_t ssrc, - rtc::scoped_refptr frame_transformer) - override { - receive_impl()->SetDepacketizerToDecoderFrameTransformer(ssrc, - frame_transformer); - } - bool SendCodecHasNack() const override { - return send_impl()->SendCodecHasNack(); - } - void SetSendCodecChangedCallback( - absl::AnyInvocable callback) override { - send_impl()->SetSendCodecChangedCallback(std::move(callback)); - } - // Implementation of VoiceMediaSendChannel - bool SetSendParameters(const AudioSendParameters& params) override { - return send_impl()->SetSendParameters(params); - } - void SetSend(bool send) override { return send_impl()->SetSend(send); } - bool SetAudioSend(uint32_t ssrc, - bool enable, - const AudioOptions* options, - AudioSource* source) override { - return send_impl()->SetAudioSend(ssrc, enable, options, source); - } - bool CanInsertDtmf() override { return send_impl()->CanInsertDtmf(); } - bool InsertDtmf(uint32_t ssrc, int event, int duration) override { - return send_impl()->InsertDtmf(ssrc, event, duration); - } - bool GetStats(VoiceMediaSendInfo* info) override { - return send_impl()->GetStats(info); - } - bool SenderNackEnabled() const override { - return send_impl()->SenderNackEnabled(); - } - bool SenderNonSenderRttEnabled() const override { - return send_impl()->SenderNonSenderRttEnabled(); - } - // Implementation of VoiceMediaReceiveChannelInterface - bool SetRecvParameters(const AudioRecvParameters& params) override { - return receive_impl()->SetRecvParameters(params); - } - webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const override { - return receive_impl()->GetRtpReceiveParameters(ssrc); - } - std::vector GetSources(uint32_t ssrc) const override { - return receive_impl()->GetSources(ssrc); - } - webrtc::RtpParameters GetDefaultRtpReceiveParameters() const override { - return receive_impl()->GetDefaultRtpReceiveParameters(); - } - void SetPlayout(bool playout) override { - return receive_impl()->SetPlayout(playout); - } - bool SetOutputVolume(uint32_t ssrc, double volume) override { - return receive_impl()->SetOutputVolume(ssrc, volume); - } - bool SetDefaultOutputVolume(double volume) override { - return receive_impl()->SetDefaultOutputVolume(volume); - } - void SetRawAudioSink( - uint32_t ssrc, - std::unique_ptr sink) override { - return receive_impl()->SetRawAudioSink(ssrc, std::move(sink)); - } - void SetDefaultRawAudioSink( - std::unique_ptr sink) override { - return receive_impl()->SetDefaultRawAudioSink(std::move(sink)); - } - bool GetStats(VoiceMediaReceiveInfo* info, bool reset_legacy) override { - return receive_impl_->GetStats(info, reset_legacy); - } - void SetReceiveNackEnabled(bool enabled) override { - receive_impl_->SetReceiveNackEnabled(enabled); - } - void SetReceiveNonSenderRttEnabled(bool enabled) override { - receive_impl_->SetReceiveNonSenderRttEnabled(enabled); - } - void SetSsrcListChangedCallback( - absl::AnyInvocable&)> callback) override { - send_impl()->SetSsrcListChangedCallback(std::move(callback)); - } - // Implementation of Delayable - bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override { - return receive_impl()->SetBaseMinimumPlayoutDelayMs(ssrc, delay_ms); - } - absl::optional GetBaseMinimumPlayoutDelayMs( - uint32_t ssrc) const override { - return receive_impl()->GetBaseMinimumPlayoutDelayMs(ssrc); - } - bool GetSendStats(VoiceMediaSendInfo* info) override { - return send_impl()->GetStats(info); - } - bool GetReceiveStats(VoiceMediaReceiveInfo* info, - bool reset_legacy) override { - return receive_impl()->GetStats(info, reset_legacy); - } - - // Only for testing of implementations - these will be used to static_cast the - // pointers to the implementations, so can only be safely used in conjunction - // with the corresponding create functions. - VoiceMediaSendChannelInterface* SendImplForTesting() { - return send_impl_.get(); - } - VoiceMediaReceiveChannelInterface* ReceiveImplForTesting() { - return receive_impl_.get(); - } - - private: - VoiceMediaSendChannelInterface* send_impl() { return send_impl_.get(); } - VoiceMediaReceiveChannelInterface* receive_impl() { - RTC_DCHECK(receive_impl_); - return receive_impl_.get(); - } - const VoiceMediaSendChannelInterface* send_impl() const { - RTC_DCHECK(send_impl_); - return send_impl_.get(); - } - const VoiceMediaReceiveChannelInterface* receive_impl() const { - return receive_impl_.get(); - } - - std::unique_ptr send_impl_; - std::unique_ptr receive_impl_; -}; - -// The VideoMediaShimChannel is replacing the VideoMediaChannel -// interface. -// If called with both send_impl and receive_impl, it operates in kBoth -// mode; if called with only one, it will shim that one and DCHECK if one -// tries to do functions belonging to the other. - -class VideoMediaShimChannel : public VideoMediaChannel { - public: - VideoMediaShimChannel( - std::unique_ptr send_impl, - std::unique_ptr receive_impl); - - VideoMediaSendChannelInterface* AsVideoSendChannel() override { return this; } - VideoMediaReceiveChannelInterface* AsVideoReceiveChannel() override { - return this; - } - VoiceMediaSendChannelInterface* AsVoiceSendChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - VoiceMediaReceiveChannelInterface* AsVoiceReceiveChannel() override { - RTC_CHECK_NOTREACHED(); - return nullptr; - } - - // SetInterface needs to run on both send and receive channels. - void SetInterface(MediaChannelNetworkInterface* iface) override { - if (send_impl_) { - send_impl()->SetInterface(iface); - } - if (receive_impl_) { - receive_impl()->SetInterface(iface); - } - } - - // Implementation of MediaBaseChannelInterface - cricket::MediaType media_type() const override { return MEDIA_TYPE_VIDEO; } - - // Implementation of MediaSendChannelInterface - void OnPacketSent(const rtc::SentPacket& sent_packet) override { - send_impl()->OnPacketSent(sent_packet); - } - void OnReadyToSend(bool ready) override { send_impl()->OnReadyToSend(ready); } - void OnNetworkRouteChanged(absl::string_view transport_name, - const rtc::NetworkRoute& network_route) override { - send_impl()->OnNetworkRouteChanged(transport_name, network_route); - } - void SetExtmapAllowMixed(bool extmap_allow_mixed) override { - send_impl()->SetExtmapAllowMixed(extmap_allow_mixed); - } - bool HasNetworkInterface() const override { - return send_impl()->HasNetworkInterface(); - } - bool ExtmapAllowMixed() const override { - return send_impl()->ExtmapAllowMixed(); - } - - bool AddSendStream(const StreamParams& sp) override { - return send_impl()->AddSendStream(sp); - } - bool RemoveSendStream(uint32_t ssrc) override { - return send_impl()->RemoveSendStream(ssrc); - } - void SetFrameEncryptor(uint32_t ssrc, - rtc::scoped_refptr - frame_encryptor) override { - send_impl()->SetFrameEncryptor(ssrc, frame_encryptor); - } - webrtc::RTCError SetRtpSendParameters( - uint32_t ssrc, - const webrtc::RtpParameters& parameters, - webrtc::SetParametersCallback callback = nullptr) override { - return send_impl()->SetRtpSendParameters(ssrc, parameters, - std::move(callback)); - } - - void SetEncoderToPacketizerFrameTransformer( - uint32_t ssrc, - rtc::scoped_refptr frame_transformer) - override { - return send_impl()->SetEncoderToPacketizerFrameTransformer( - ssrc, frame_transformer); - } - void SetEncoderSelector(uint32_t ssrc, - webrtc::VideoEncoderFactory::EncoderSelectorInterface* - encoder_selector) override { - send_impl()->SetEncoderSelector(ssrc, encoder_selector); - } - webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override { - return send_impl()->GetRtpSendParameters(ssrc); - } - // Send_Implementation of VideoMediaSendChannelInterface - bool SetSendParameters(const VideoSendParameters& params) override { - return send_impl()->SetSendParameters(params); - } - absl::optional GetSendCodec() const override { - return send_impl()->GetSendCodec(); - } - bool SetSend(bool send) override { return send_impl()->SetSend(send); } - bool SetVideoSend( - uint32_t ssrc, - const VideoOptions* options, - rtc::VideoSourceInterface* source) override { - return send_impl()->SetVideoSend(ssrc, options, source); - } - void GenerateSendKeyFrame(uint32_t ssrc, - const std::vector& rids) override { - return send_impl()->GenerateSendKeyFrame(ssrc, rids); - } - void SetVideoCodecSwitchingEnabled(bool enabled) override { - return send_impl()->SetVideoCodecSwitchingEnabled(enabled); - } - bool GetStats(VideoMediaSendInfo* info) override { - return send_impl_->GetStats(info); - } - bool GetSendStats(VideoMediaSendInfo* info) override { - return send_impl_->GetStats(info); - } - void FillBitrateInfo(BandwidthEstimationInfo* bwe_info) override { - return send_impl_->FillBitrateInfo(bwe_info); - } - // Information queries to support SetReceiverFeedbackParameters - webrtc::RtcpMode SendCodecRtcpMode() const override { - return send_impl()->SendCodecRtcpMode(); - } - bool SendCodecHasLntf() const override { - return send_impl()->SendCodecHasLntf(); - } - bool SendCodecHasNack() const override { - return send_impl()->SendCodecHasNack(); - } - absl::optional SendCodecRtxTime() const override { - return send_impl()->SendCodecRtxTime(); - } - void SetSsrcListChangedCallback( - absl::AnyInvocable&)> callback) override { - send_impl()->SetSsrcListChangedCallback(std::move(callback)); - } - void SetSendCodecChangedCallback( - absl::AnyInvocable callback) override { - // This callback is used internally by the shim, so should not be called by - // users for the "both" case. - if (send_impl_ && receive_impl_) { - RTC_CHECK_NOTREACHED(); - } - send_impl()->SetSendCodecChangedCallback(std::move(callback)); - } - - // Implementation of Delayable - bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override { - return receive_impl()->SetBaseMinimumPlayoutDelayMs(ssrc, delay_ms); - } - absl::optional GetBaseMinimumPlayoutDelayMs( - uint32_t ssrc) const override { - return receive_impl()->GetBaseMinimumPlayoutDelayMs(ssrc); - } - // Implementation of MediaReceiveChannelInterface - void OnPacketReceived(const webrtc::RtpPacketReceived& packet) override { - receive_impl()->OnPacketReceived(packet); - } - bool AddRecvStream(const StreamParams& sp) override { - return receive_impl()->AddRecvStream(sp); - } - bool RemoveRecvStream(uint32_t ssrc) override { - return receive_impl()->RemoveRecvStream(ssrc); - } - void ResetUnsignaledRecvStream() override { - return receive_impl()->ResetUnsignaledRecvStream(); - } - absl::optional GetUnsignaledSsrc() const override { - return receive_impl()->GetUnsignaledSsrc(); - } - void ChooseReceiverReportSsrc(const std::set& choices) override { - return receive_impl()->ChooseReceiverReportSsrc(choices); - } - void OnDemuxerCriteriaUpdatePending() override { - receive_impl()->OnDemuxerCriteriaUpdatePending(); - } - void OnDemuxerCriteriaUpdateComplete() override { - receive_impl()->OnDemuxerCriteriaUpdateComplete(); - } - void SetFrameDecryptor(uint32_t ssrc, - rtc::scoped_refptr - frame_decryptor) override { - receive_impl()->SetFrameDecryptor(ssrc, frame_decryptor); - } - void SetDepacketizerToDecoderFrameTransformer( - uint32_t ssrc, - rtc::scoped_refptr frame_transformer) - override { - receive_impl()->SetDepacketizerToDecoderFrameTransformer(ssrc, - frame_transformer); - } - // Implementation of VideoMediaReceiveChannelInterface - bool SetRecvParameters(const VideoRecvParameters& params) override { - return receive_impl()->SetRecvParameters(params); - } - webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const override { - return receive_impl()->GetRtpReceiveParameters(ssrc); - } - webrtc::RtpParameters GetDefaultRtpReceiveParameters() const override { - return receive_impl()->GetDefaultRtpReceiveParameters(); - } - bool SetSink(uint32_t ssrc, - rtc::VideoSinkInterface* sink) override { - return receive_impl()->SetSink(ssrc, sink); - } - void SetDefaultSink( - rtc::VideoSinkInterface* sink) override { - return receive_impl()->SetDefaultSink(sink); - } - void RequestRecvKeyFrame(uint32_t ssrc) override { - return receive_impl()->RequestRecvKeyFrame(ssrc); - } - std::vector GetSources(uint32_t ssrc) const override { - return receive_impl()->GetSources(ssrc); - } - // Set recordable encoded frame callback for `ssrc` - void SetRecordableEncodedFrameCallback( - uint32_t ssrc, - std::function callback) - override { - return receive_impl()->SetRecordableEncodedFrameCallback( - ssrc, std::move(callback)); - } - // Clear recordable encoded frame callback for `ssrc` - void ClearRecordableEncodedFrameCallback(uint32_t ssrc) override { - receive_impl()->ClearRecordableEncodedFrameCallback(ssrc); - } - bool GetStats(VideoMediaReceiveInfo* info) override { - return receive_impl()->GetStats(info); - } - bool GetReceiveStats(VideoMediaReceiveInfo* info) override { - return receive_impl()->GetStats(info); - } - void SetReceiverFeedbackParameters(bool lntf_enabled, - bool nack_enabled, - webrtc::RtcpMode rtcp_mode, - absl::optional rtx_time) override { - receive_impl()->SetReceiverFeedbackParameters(lntf_enabled, nack_enabled, - rtcp_mode, rtx_time); - } - void SetReceive(bool receive) override { - receive_impl()->SetReceive(receive); - } - bool AddDefaultRecvStreamForTesting(const StreamParams& sp) override { - return receive_impl()->AddDefaultRecvStreamForTesting(sp); - } - - // Only for testing of implementations - these will be used to static_cast the - // pointers to the implementations, so can only be safely used in conjunction - // with the corresponding create functions. - VideoMediaSendChannelInterface* SendImplForTesting() { - return send_impl_.get(); - } - VideoMediaReceiveChannelInterface* ReceiveImplForTesting() { - return receive_impl_.get(); - } - - private: - VideoMediaSendChannelInterface* send_impl() { return send_impl_.get(); } - VideoMediaReceiveChannelInterface* receive_impl() { - RTC_DCHECK(receive_impl_); - return receive_impl_.get(); - } - const VideoMediaSendChannelInterface* send_impl() const { - RTC_DCHECK(send_impl_); - return send_impl_.get(); - } - const VideoMediaReceiveChannelInterface* receive_impl() const { - return receive_impl_.get(); - } - - std::unique_ptr send_impl_; - std::unique_ptr receive_impl_; -}; - -} // namespace cricket - -#endif // MEDIA_BASE_MEDIA_CHANNEL_SHIM_H_ diff --git a/media/base/media_engine.h b/media/base/media_engine.h index 0d10248ed0..b3d7491165 100644 --- a/media/base/media_engine.h +++ b/media/base/media_engine.h @@ -38,9 +38,6 @@ class Call; namespace cricket { -class VideoMediaChannel; -class VoiceMediaChannel; - // Checks that the scalability_mode value of each encoding is supported by at // least one video codec of the list. If the list is empty, no check is done. webrtc::RTCError CheckScalabilityModeValues( @@ -120,42 +117,6 @@ class VoiceEngineInterface : public RtpHeaderExtensionQueryInterface { return nullptr; } - // MediaChannel creation - // Creates a voice media channel. Returns NULL on failure. - virtual VoiceMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::AudioCodecPairId codec_pair_id) { - // For the case where a subclass overrides the deprecated method - // but not the replacement method, call the deprecated method. - // TODO(bugs.webrtc.org/13931): Remove default implementation - // when downstream has migrated to new API. - RTC_CHECK(!recursion_guard_); -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - RTC_LOG(LS_ERROR) - << "Override of deprecated declaration detected - please update!"; - return CreateMediaChannel(call, config, options, crypto_options); -#pragma clang diagnostic pop - } - - // Backwards compatible version - [[deprecated("Use version with role parameter")]] virtual VoiceMediaChannel* - CreateMediaChannel(webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options) { - recursion_guard_ = true; - auto new_channel = - CreateMediaChannel(MediaChannel::Role::kBoth, call, config, options, - crypto_options, webrtc::AudioCodecPairId::Create()); - recursion_guard_ = false; - return new_channel; - } - virtual const std::vector& send_codecs() const = 0; virtual const std::vector& recv_codecs() const = 0; @@ -170,11 +131,6 @@ class VoiceEngineInterface : public RtpHeaderExtensionQueryInterface { virtual absl::optional GetAudioDeviceStats() = 0; - - private: - // Workaround variable for avoiding recursion between old and new APIs. - // TODO(bugs.webrtc.org/13931): Remove when old interface is gone. - bool recursion_guard_ = false; }; class VideoEngineInterface : public RtpHeaderExtensionQueryInterface { @@ -206,47 +162,6 @@ class VideoEngineInterface : public RtpHeaderExtensionQueryInterface { return nullptr; } - // Creates a video media channel. - // Returns NULL on failure. - virtual VideoMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { - // For the case where a subclass overrides the deprecated method - // but not the replacement method, call the deprecated method. - // TODO(bugs.webrtc.org/13931): Remove default implementation - // when downstream has migrated to new API. - RTC_CHECK(!recursion_guard_); -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - RTC_LOG(LS_ERROR) - << "Override of deprecated declaration detected - please update!"; - return CreateMediaChannel(call, config, options, crypto_options, - video_bitrate_allocator_factory); -#pragma clang diagnostic pop - } - - // Creates a video media channel. - // Returns NULL on failure. - // TODO(bugs.webrtc.org/13931): Stop downstream usage of this function. - [[deprecated("Please specify the role")]] virtual VideoMediaChannel* - CreateMediaChannel( - webrtc::Call* call, - const MediaConfig& config, - const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { - recursion_guard_ = true; - auto new_channel = - CreateMediaChannel(MediaChannel::Role::kBoth, call, config, options, - crypto_options, video_bitrate_allocator_factory); - recursion_guard_ = false; - return new_channel; - } - // Retrieve list of supported codecs. virtual std::vector send_codecs() const = 0; virtual std::vector recv_codecs() const = 0; @@ -261,11 +176,6 @@ class VideoEngineInterface : public RtpHeaderExtensionQueryInterface { RTC_DCHECK(include_rtx); return recv_codecs(); } - - private: - // Workaround variable for avoiding recursion between old and new APIs. - // TODO(bugs.webrtc.org/13931): Remove when old interface is gone. - bool recursion_guard_ = false; }; // MediaEngineInterface is an abstraction of a media engine which can be diff --git a/media/base/media_engine_unittest.cc b/media/base/media_engine_unittest.cc index 23203d110e..b8db32a2d5 100644 --- a/media/base/media_engine_unittest.cc +++ b/media/base/media_engine_unittest.cc @@ -83,68 +83,4 @@ class MostlyMockVoiceEngineInterface : public VoiceEngineInterface { (override)); }; -class OldStyleVoiceEngineInterface : public MostlyMockVoiceEngineInterface { - public: - using MostlyMockVoiceEngineInterface::CreateMediaChannel; - // Old style overrides the deprecated API only. - VoiceMediaChannel* CreateMediaChannel( - webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options) override { - ++call_count; - return nullptr; - } - int call_count = 0; -}; - -class NewStyleVoiceEngineInterface : public MostlyMockVoiceEngineInterface { - // New style overrides the non-deprecated API. - VoiceMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::AudioCodecPairId codec_pair_id) override { - return nullptr; - } -}; - -TEST(MediaEngineTest, NewStyleApiCallsOldIfOverridden) { - OldStyleVoiceEngineInterface implementation_under_test; - MediaConfig config; - AudioOptions options; - webrtc::CryptoOptions crypto_options; - // Calling the old-style interface. - implementation_under_test.CreateMediaChannel(nullptr, config, options, - crypto_options); - EXPECT_EQ(implementation_under_test.call_count, 1); - // Calling the new-style interface redirects to the old-style interface. - implementation_under_test.CreateMediaChannel( - MediaChannel::Role::kBoth, nullptr, config, options, crypto_options, - webrtc::AudioCodecPairId::Create()); - EXPECT_EQ(implementation_under_test.call_count, 2); -} - -#if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -TEST(MediaEngineTest, NoOverrideOfCreateCausesCrash) { - MostlyMockVoiceEngineInterface implementation_under_test; - MediaConfig config; - AudioOptions options; - webrtc::CryptoOptions crypto_options; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - - EXPECT_DEATH(implementation_under_test.CreateMediaChannel( - nullptr, config, options, crypto_options), - "Check failed: !recursion_guard_"); -#pragma clang diagnostic pop - EXPECT_DEATH(implementation_under_test.CreateMediaChannel( - MediaChannel::Role::kBoth, nullptr, config, options, - crypto_options, webrtc::AudioCodecPairId::Create()), - "Check failed: !recursion_guard_"); -} -#endif - } // namespace cricket diff --git a/media/engine/null_webrtc_video_engine.h b/media/engine/null_webrtc_video_engine.h index 5efefd498f..f94cb43e75 100644 --- a/media/engine/null_webrtc_video_engine.h +++ b/media/engine/null_webrtc_video_engine.h @@ -24,8 +24,6 @@ class Call; namespace cricket { -class VideoMediaChannel; - // Video engine implementation that does nothing and can be used in // CompositeMediaEngine. class NullWebRtcVideoEngine : public VideoEngineInterface { @@ -49,17 +47,6 @@ class NullWebRtcVideoEngine : public VideoEngineInterface { const override { return {}; } - - VideoMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) - override { - return nullptr; - } }; } // namespace cricket diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 83bb39d446..bf086e66cf 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -762,29 +762,6 @@ WebRtcVideoEngine::CreateReceiveChannel( call, config, options, crypto_options, decoder_factory_.get()); } -VideoMediaChannel* WebRtcVideoEngine::CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { - RTC_LOG(LS_INFO) << "CreateMediaChannel. Options: " << options.ToString(); - std::unique_ptr send_channel; - std::unique_ptr receive_channel; - if (role == MediaChannel::Role::kSend || role == MediaChannel::Role::kBoth) { - send_channel = CreateSendChannel(call, config, options, crypto_options, - video_bitrate_allocator_factory); - } - if (role == MediaChannel::Role::kReceive || - role == MediaChannel::Role::kBoth) { - receive_channel = - CreateReceiveChannel(call, config, options, crypto_options); - } - return new VideoMediaShimChannel(std::move(send_channel), - std::move(receive_channel)); -} - std::vector WebRtcVideoEngine::send_codecs(bool include_rtx) const { return GetPayloadTypesAndDefaultCodecs(encoder_factory_.get(), /*is_decoder_factory=*/false, diff --git a/media/engine/webrtc_video_engine.h b/media/engine/webrtc_video_engine.h index 67df781589..db2519c480 100644 --- a/media/engine/webrtc_video_engine.h +++ b/media/engine/webrtc_video_engine.h @@ -59,7 +59,6 @@ #include "media/base/codec.h" #include "media/base/media_channel.h" #include "media/base/media_channel_impl.h" -#include "media/base/media_channel_shim.h" #include "media/base/media_config.h" #include "media/base/media_engine.h" #include "media/base/stream_params.h" @@ -117,15 +116,6 @@ class WebRtcVideoEngine : public VideoEngineInterface { const VideoOptions& options, const webrtc::CryptoOptions& crypto_options) override; - VideoMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const VideoOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) - override; - std::vector send_codecs() const override { return send_codecs(true); } diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index 38193d7610..ba664a5752 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -486,29 +486,6 @@ WebRtcVoiceEngine::CreateReceiveChannel( this, config, options, crypto_options, call, codec_pair_id); } -VoiceMediaChannel* WebRtcVoiceEngine::CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::AudioCodecPairId codec_pair_id) { - RTC_DCHECK_RUN_ON(call->worker_thread()); - std::unique_ptr send_channel; - std::unique_ptr receive_channel; - if (role == MediaChannel::Role::kSend || role == MediaChannel::Role::kBoth) { - send_channel = - CreateSendChannel(call, config, options, crypto_options, codec_pair_id); - } - if (role == MediaChannel::Role::kReceive || - role == MediaChannel::Role::kBoth) { - receive_channel = CreateReceiveChannel(call, config, options, - crypto_options, codec_pair_id); - } - return new VoiceMediaShimChannel(std::move(send_channel), - std::move(receive_channel)); -} - void WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::ApplyOptions: " diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h index 2c89376925..a0b1b703c9 100644 --- a/media/engine/webrtc_voice_engine.h +++ b/media/engine/webrtc_voice_engine.h @@ -53,7 +53,6 @@ #include "media/base/codec.h" #include "media/base/media_channel.h" #include "media/base/media_channel_impl.h" -#include "media/base/media_channel_shim.h" #include "media/base/media_config.h" #include "media/base/media_engine.h" #include "media/base/rtp_utils.h" @@ -121,14 +120,6 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { const webrtc::CryptoOptions& crypto_options, webrtc::AudioCodecPairId codec_pair_id) override; - VoiceMediaChannel* CreateMediaChannel( - MediaChannel::Role role, - webrtc::Call* call, - const MediaConfig& config, - const AudioOptions& options, - const webrtc::CryptoOptions& crypto_options, - webrtc::AudioCodecPairId codec_pair_id) override; - const std::vector& send_codecs() const override; const std::vector& recv_codecs() const override; std::vector GetRtpHeaderExtensions() diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 74021af8e3..65c187bbda 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -28,7 +28,6 @@ #include "media/base/fake_network_interface.h" #include "media/base/fake_rtp.h" #include "media/base/media_channel.h" -#include "media/base/media_channel_shim.h" #include "media/base/media_constants.h" #include "media/engine/fake_webrtc_call.h" #include "modules/audio_device/include/mock_audio_device.h" diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 2f671d2694..8b2e1282f8 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -2450,7 +2450,6 @@ if (rtc_include_tests && !build_with_chromium) { "../common_video", "../logging:fake_rtc_event_log", "../media:codec", - "../media:delayable", "../media:media_channel", "../media:media_constants", "../media:rid_description", @@ -2559,27 +2558,6 @@ if (rtc_include_tests && !build_with_chromium) { ] } - rtc_test("peer_connection_mediachannel_split_unittests") { - testonly = true - sources = [ "peer_connection_mediachannel_split_unittest.cc" ] - deps = [ - ":integration_test_helpers", - ":session_description", - "../api:libjingle_peerconnection_api", - "../api:media_stream_interface", - "../api:rtc_error", - "../api:rtc_stats_api", - "../api:scoped_refptr", - "../media:codec", - "../media:media_constants", - "../rtc_base:gunit_helpers", - "../rtc_base:rtc_base_tests_utils", - "../test:test_main", - "../test:test_support", - ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] - } - rtc_library("data_channel_controller_unittest") { testonly = true sources = [ "data_channel_controller_unittest.cc" ] @@ -2758,7 +2736,7 @@ if (rtc_include_tests && !build_with_chromium) { "test/mock_peer_connection_observers.h", "test/mock_rtp_receiver_internal.h", "test/mock_rtp_sender_internal.h", - "test/mock_voice_media_channel.h", + "test/mock_voice_media_receive_channel_interface.h", "test/peer_connection_test_wrapper.cc", "test/peer_connection_test_wrapper.h", "test/rtc_stats_obtainer.h", diff --git a/pc/audio_rtp_receiver_unittest.cc b/pc/audio_rtp_receiver_unittest.cc index 5a3383f94c..9eb20c982f 100644 --- a/pc/audio_rtp_receiver_unittest.cc +++ b/pc/audio_rtp_receiver_unittest.cc @@ -12,7 +12,7 @@ #include -#include "pc/test/mock_voice_media_channel.h" +#include "pc/test/mock_voice_media_receive_channel_interface.h" #include "rtc_base/gunit.h" #include "rtc_base/thread.h" #include "test/gmock.h" @@ -38,28 +38,26 @@ class AudioRtpReceiverTest : public ::testing::Test { rtc::make_ref_counted(worker_, std::string(), std::vector(), - false)), - media_channel_(cricket::MediaChannel::Role::kReceive, - rtc::Thread::Current()) { - EXPECT_CALL(media_channel_, SetRawAudioSink(kSsrc, _)); - EXPECT_CALL(media_channel_, SetBaseMinimumPlayoutDelayMs(kSsrc, _)); + false)) { + EXPECT_CALL(receive_channel_, SetRawAudioSink(kSsrc, _)); + EXPECT_CALL(receive_channel_, SetBaseMinimumPlayoutDelayMs(kSsrc, _)); } ~AudioRtpReceiverTest() { - EXPECT_CALL(media_channel_, SetOutputVolume(kSsrc, kVolumeMuted)); + EXPECT_CALL(receive_channel_, SetOutputVolume(kSsrc, kVolumeMuted)); receiver_->SetMediaChannel(nullptr); } rtc::AutoThread main_thread_; rtc::Thread* worker_; rtc::scoped_refptr receiver_; - cricket::MockVoiceMediaChannel media_channel_; + cricket::MockVoiceMediaReceiveChannelInterface receive_channel_; }; TEST_F(AudioRtpReceiverTest, SetOutputVolumeIsCalled) { std::atomic_int set_volume_calls(0); - EXPECT_CALL(media_channel_, SetOutputVolume(kSsrc, kDefaultVolume)) + EXPECT_CALL(receive_channel_, SetOutputVolume(kSsrc, kDefaultVolume)) .WillOnce(InvokeWithoutArgs([&] { set_volume_calls++; return true; @@ -67,11 +65,11 @@ TEST_F(AudioRtpReceiverTest, SetOutputVolumeIsCalled) { receiver_->track(); receiver_->track()->set_enabled(true); - receiver_->SetMediaChannel(media_channel_.AsVoiceReceiveChannel()); - EXPECT_CALL(media_channel_, SetDefaultRawAudioSink(_)).Times(0); + receiver_->SetMediaChannel(&receive_channel_); + EXPECT_CALL(receive_channel_, SetDefaultRawAudioSink(_)).Times(0); receiver_->SetupMediaChannel(kSsrc); - EXPECT_CALL(media_channel_, SetOutputVolume(kSsrc, kVolume)) + EXPECT_CALL(receive_channel_, SetOutputVolume(kSsrc, kVolume)) .WillOnce(InvokeWithoutArgs([&] { set_volume_calls++; return true; @@ -87,11 +85,11 @@ TEST_F(AudioRtpReceiverTest, VolumesSetBeforeStartingAreRespected) { receiver_->OnSetVolume(kVolume); receiver_->track()->set_enabled(true); - receiver_->SetMediaChannel(media_channel_.AsVoiceReceiveChannel()); + receiver_->SetMediaChannel(&receive_channel_); // The previosly set initial volume should be propagated to the provided // media_channel_ as soon as SetupMediaChannel is called. - EXPECT_CALL(media_channel_, SetOutputVolume(kSsrc, kVolume)); + EXPECT_CALL(receive_channel_, SetOutputVolume(kSsrc, kVolume)); receiver_->SetupMediaChannel(kSsrc); } @@ -102,13 +100,13 @@ TEST_F(AudioRtpReceiverTest, VolumesSetBeforeStartingAreRespected) { TEST(AudioRtpReceiver, OnChangedNotificationsAfterConstruction) { webrtc::test::RunLoop loop; auto* thread = rtc::Thread::Current(); // Points to loop's thread. - cricket::MockVoiceMediaChannel media_channel( - cricket::MediaChannel::Role::kReceive, thread); + cricket::MockVoiceMediaReceiveChannelInterface receive_channel; auto receiver = rtc::make_ref_counted( - thread, std::string(), std::vector(), true, &media_channel); + thread, std::string(), std::vector(), true, + &receive_channel); - EXPECT_CALL(media_channel, SetDefaultRawAudioSink(_)).Times(1); - EXPECT_CALL(media_channel, SetDefaultOutputVolume(kDefaultVolume)).Times(1); + EXPECT_CALL(receive_channel, SetDefaultRawAudioSink(_)).Times(1); + EXPECT_CALL(receive_channel, SetDefaultOutputVolume(kDefaultVolume)).Times(1); receiver->SetupUnsignaledMediaChannel(); loop.Flush(); @@ -119,10 +117,10 @@ TEST(AudioRtpReceiver, OnChangedNotificationsAfterConstruction) { // for the worker thread. This notification should trigger the volume // of the media channel to be set to kVolumeMuted. // Flush the worker thread, but set the expectation first for the call. - EXPECT_CALL(media_channel, SetDefaultOutputVolume(kVolumeMuted)).Times(1); + EXPECT_CALL(receive_channel, SetDefaultOutputVolume(kVolumeMuted)).Times(1); loop.Flush(); - EXPECT_CALL(media_channel, SetDefaultOutputVolume(kVolumeMuted)).Times(1); + EXPECT_CALL(receive_channel, SetDefaultOutputVolume(kVolumeMuted)).Times(1); receiver->SetMediaChannel(nullptr); } diff --git a/pc/channel.cc b/pc/channel.cc index ba1f17527b..05c41748ff 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -140,32 +140,6 @@ BaseChannel::BaseChannel( RTC_DLOG(LS_INFO) << "Created channel: " << ToString(); } -BaseChannel::BaseChannel(rtc::Thread* worker_thread, - rtc::Thread* network_thread, - rtc::Thread* signaling_thread, - std::unique_ptr media_channel, - absl::string_view mid, - bool srtp_required, - webrtc::CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator) - : media_channel_(std::move(media_channel)), - worker_thread_(worker_thread), - network_thread_(network_thread), - signaling_thread_(signaling_thread), - alive_(PendingTaskSafetyFlag::Create()), - srtp_required_(srtp_required), - extensions_filter_( - crypto_options.srtp.enable_encrypted_rtp_header_extensions - ? webrtc::RtpExtension::kPreferEncryptedExtension - : webrtc::RtpExtension::kDiscardEncryptedExtension), - demuxer_criteria_(mid), - ssrc_generator_(ssrc_generator) { - RTC_DCHECK_RUN_ON(worker_thread_); - RTC_DCHECK(media_channel_); - RTC_DCHECK(ssrc_generator_); - RTC_DLOG(LS_INFO) << "Created channel: " << ToString(); -} - BaseChannel::~BaseChannel() { TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); RTC_DCHECK_RUN_ON(worker_thread_); @@ -178,15 +152,9 @@ BaseChannel::~BaseChannel() { } std::string BaseChannel::ToString() const { - if (media_send_channel_) { - return StringFormat( - "{mid: %s, media_type: %s}", mid().c_str(), - MediaTypeToString(media_send_channel_->media_type()).c_str()); - } else { - return StringFormat( - "{mid: %s, media_type: %s}", mid().c_str(), - MediaTypeToString(media_channel_->media_type()).c_str()); - } + return StringFormat( + "{mid: %s, media_type: %s}", mid().c_str(), + MediaTypeToString(media_send_channel_->media_type()).c_str()); } bool BaseChannel::ConnectToRtpTransport_n() { @@ -866,26 +834,6 @@ VoiceChannel::VoiceChannel( crypto_options, ssrc_generator) {} -VoiceChannel::VoiceChannel( - rtc::Thread* worker_thread, - rtc::Thread* network_thread, - rtc::Thread* signaling_thread, - std::unique_ptr media_channel_impl, - absl::string_view mid, - bool srtp_required, - webrtc::CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator) - : BaseChannel(worker_thread, - network_thread, - signaling_thread, - std::move(media_channel_impl), - mid, - srtp_required, - crypto_options, - ssrc_generator) { - InitCallback(); -} - VoiceChannel::~VoiceChannel() { TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); // this can't be done in the base class, since it calls a virtual @@ -1041,23 +989,6 @@ VideoChannel::VideoChannel( send_channel()->SendCodecRtxTime()); }); } -VideoChannel::VideoChannel( - rtc::Thread* worker_thread, - rtc::Thread* network_thread, - rtc::Thread* signaling_thread, - std::unique_ptr media_channel_impl, - absl::string_view mid, - bool srtp_required, - webrtc::CryptoOptions crypto_options, - UniqueRandomIdGenerator* ssrc_generator) - : BaseChannel(worker_thread, - network_thread, - signaling_thread, - std::move(media_channel_impl), - mid, - srtp_required, - crypto_options, - ssrc_generator) {} VideoChannel::~VideoChannel() { TRACE_EVENT0("webrtc", "VideoChannel::~VideoChannel"); diff --git a/pc/channel.h b/pc/channel.h index e082c2d506..1e158879b6 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -94,16 +94,6 @@ class BaseChannel : public ChannelInterface, bool srtp_required, webrtc::CryptoOptions crypto_options, rtc::UniqueRandomIdGenerator* ssrc_generator); - // Constructor for use when the MediaChannel is not split - // TODO(bugs.webrtc.org/13931): Delete when split channel project is complete. - BaseChannel(rtc::Thread* worker_thread, - rtc::Thread* network_thread, - rtc::Thread* signaling_thread, - std::unique_ptr media_channel_impl, - absl::string_view mid, - bool srtp_required, - webrtc::CryptoOptions crypto_options, - rtc::UniqueRandomIdGenerator* ssrc_generator); virtual ~BaseChannel(); rtc::Thread* worker_thread() const { return worker_thread_; } @@ -316,13 +306,6 @@ class BaseChannel : public ChannelInterface, // Return description of media channel to facilitate logging std::string ToString() const; - // MediaChannel implementation pointers. - // Either the `media_channel_` is set, or the `media_send_channel_` - // and the `media_receive_channel_` is set. - // TODO(bugs.webrtc.org/13931): Delete `media_channel_` when split channel - // project is complete. - const std::unique_ptr media_channel_; - const std::unique_ptr media_send_channel_; const std::unique_ptr media_receive_channel_; @@ -396,16 +379,6 @@ class VoiceChannel : public BaseChannel { bool srtp_required, webrtc::CryptoOptions crypto_options, rtc::UniqueRandomIdGenerator* ssrc_generator); - // Constructor for use when the MediaChannel is not split - // TODO(bugs.webrtc.org/13931): Delete when split channel project is complete. - VoiceChannel(rtc::Thread* worker_thread, - rtc::Thread* network_thread, - rtc::Thread* signaling_thread, - std::unique_ptr media_channel_impl, - absl::string_view mid, - bool srtp_required, - webrtc::CryptoOptions crypto_options, - rtc::UniqueRandomIdGenerator* ssrc_generator); ~VoiceChannel(); @@ -416,17 +389,11 @@ class VoiceChannel : public BaseChannel { VoiceChannel* AsVoiceChannel() override { return this; } VoiceMediaSendChannelInterface* send_channel() { - if (media_send_channel_) { - return media_send_channel_->AsVoiceSendChannel(); - } - return media_channel_->AsVoiceSendChannel(); + return media_send_channel_->AsVoiceSendChannel(); } VoiceMediaReceiveChannelInterface* receive_channel() { - if (media_receive_channel_) { - return media_receive_channel_->AsVoiceReceiveChannel(); - } - return media_channel_->AsVoiceReceiveChannel(); + return media_receive_channel_->AsVoiceReceiveChannel(); } VoiceMediaSendChannelInterface* media_send_channel() override { @@ -483,16 +450,6 @@ class VideoChannel : public BaseChannel { bool srtp_required, webrtc::CryptoOptions crypto_options, rtc::UniqueRandomIdGenerator* ssrc_generator); - // Constructor for use when the MediaChannel is not split - // TODO(bugs.webrtc.org/13931): Delete when split channel project is complete. - VideoChannel(rtc::Thread* worker_thread, - rtc::Thread* network_thread, - rtc::Thread* signaling_thread, - std::unique_ptr media_channel_impl, - absl::string_view mid, - bool srtp_required, - webrtc::CryptoOptions crypto_options, - rtc::UniqueRandomIdGenerator* ssrc_generator); ~VideoChannel(); VideoChannel* AsVideoChannel() override { return this; } @@ -502,17 +459,11 @@ class VideoChannel : public BaseChannel { } VideoMediaSendChannelInterface* send_channel() { - if (media_send_channel_) { - return media_send_channel_->AsVideoSendChannel(); - } - return media_channel_->AsVideoSendChannel(); + return media_send_channel_->AsVideoSendChannel(); } VideoMediaReceiveChannelInterface* receive_channel() { - if (media_receive_channel_) { - return media_receive_channel_->AsVideoReceiveChannel(); - } - return media_channel_->AsVideoReceiveChannel(); + return media_receive_channel_->AsVideoReceiveChannel(); } VideoMediaSendChannelInterface* media_send_channel() override { diff --git a/pc/channel_interface.h b/pc/channel_interface.h index 7495ad8931..8d6a9fe745 100644 --- a/pc/channel_interface.h +++ b/pc/channel_interface.h @@ -28,7 +28,6 @@ class VideoBitrateAllocatorFactory; namespace cricket { -class MediaChannel; class VoiceChannel; class VideoChannel; class MediaContentDescription; diff --git a/pc/peer_connection_mediachannel_split_unittest.cc b/pc/peer_connection_mediachannel_split_unittest.cc deleted file mode 100644 index 97e5ecdc40..0000000000 --- a/pc/peer_connection_mediachannel_split_unittest.cc +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// Integration tests for PeerConnection to exercise the options of -// either splitting or not splitting the MediaChannel object. -// These tests exercise a full stack over a simulated network. - -// TODO(bugs.webrtc.org/13931): Delete these tests when split is landed. - -#include -#include - -#include "absl/types/optional.h" -#include "api/media_stream_interface.h" -#include "api/peer_connection_interface.h" -#include "api/rtc_error.h" -#include "api/scoped_refptr.h" -#include "api/stats/rtc_stats.h" -#include "api/stats/rtc_stats_report.h" -#include "api/stats/rtcstats_objects.h" -#include "media/base/codec.h" -#include "media/base/media_constants.h" -#include "pc/session_description.h" -#include "pc/test/integration_test_helpers.h" -#include "rtc_base/gunit.h" -#include "rtc_base/virtual_socket_server.h" -#include "test/gtest.h" - -namespace webrtc { - -namespace { - -class PeerConnectionMediaChannelSplitTest - : public PeerConnectionIntegrationBaseTest, - public ::testing::WithParamInterface { - protected: - PeerConnectionMediaChannelSplitTest() - : PeerConnectionIntegrationBaseTest(SdpSemantics::kUnifiedPlan, - /* field_trials = */ GetParam()) {} -}; - -int NacksReceivedCount(PeerConnectionIntegrationWrapper& pc) { - rtc::scoped_refptr report = pc.NewGetStats(); - auto sender_stats = report->GetStatsOfType(); - if (sender_stats.size() != 1) { - ADD_FAILURE(); - return 0; - } - if (!sender_stats[0]->nack_count.is_defined()) { - return 0; - } - return *sender_stats[0]->nack_count; -} - -int NacksSentCount(PeerConnectionIntegrationWrapper& pc) { - rtc::scoped_refptr report = pc.NewGetStats(); - auto receiver_stats = report->GetStatsOfType(); - if (receiver_stats.size() != 1) { - ADD_FAILURE(); - return 0; - } - if (!receiver_stats[0]->nack_count.is_defined()) { - return 0; - } - return *receiver_stats[0]->nack_count; -} - -// Test disabled because it is flaky. -TEST_P(PeerConnectionMediaChannelSplitTest, - DISABLED_AudioPacketLossCausesNack) { - RTCConfiguration config; - ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config)); - ConnectFakeSignaling(); - auto audio_transceiver_or_error = - caller()->pc()->AddTransceiver(caller()->CreateLocalAudioTrack()); - ASSERT_TRUE(audio_transceiver_or_error.ok()); - auto send_transceiver = audio_transceiver_or_error.MoveValue(); - // Munge the SDP to include NACK and RRTR on Opus, and remove all other - // codecs. - caller()->SetGeneratedSdpMunger([](cricket::SessionDescription* desc) { - for (ContentInfo& content : desc->contents()) { - cricket::AudioContentDescription* media = - content.media_description()->as_audio(); - std::vector codecs = media->codecs(); - std::vector codecs_out; - for (cricket::AudioCodec codec : codecs) { - if (codec.name == "opus") { - codec.AddFeedbackParam(cricket::FeedbackParam( - cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)); - codec.AddFeedbackParam(cricket::FeedbackParam( - cricket::kRtcpFbParamRrtr, cricket::kParamValueEmpty)); - codecs_out.push_back(codec); - } - } - EXPECT_FALSE(codecs_out.empty()); - media->set_codecs(codecs_out); - } - }); - - caller()->CreateAndSetAndSignalOffer(); - // Check for failure in helpers - ASSERT_FALSE(HasFailure()); - MediaExpectations media_expectations; - media_expectations.CalleeExpectsSomeAudio(1); - ExpectNewFrames(media_expectations); - ASSERT_FALSE(HasFailure()); - - virtual_socket_server()->set_drop_probability(0.2); - - // Wait until callee has sent at least one NACK. - // Note that due to stats caching, this might only be visible 50 ms - // after the nack was in fact sent. - EXPECT_TRUE_WAIT(NacksSentCount(*callee()) > 0, kDefaultTimeout); - ASSERT_FALSE(HasFailure()); - - virtual_socket_server()->set_drop_probability(0.0); - // Wait until caller has received at least one NACK - EXPECT_TRUE_WAIT(NacksReceivedCount(*caller()) > 0, kDefaultTimeout); -} - -TEST_P(PeerConnectionMediaChannelSplitTest, VideoPacketLossCausesNack) { - RTCConfiguration config; - ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(config, config)); - ConnectFakeSignaling(); - auto video_transceiver_or_error = - caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack()); - ASSERT_TRUE(video_transceiver_or_error.ok()); - auto send_transceiver = video_transceiver_or_error.MoveValue(); - // Munge the SDP to include NACK and RRTR on VP8, and remove all other - // codecs. - caller()->SetGeneratedSdpMunger([](cricket::SessionDescription* desc) { - for (ContentInfo& content : desc->contents()) { - cricket::VideoContentDescription* media = - content.media_description()->as_video(); - std::vector codecs = media->codecs(); - std::vector codecs_out; - for (cricket::VideoCodec codec : codecs) { - if (codec.name == "VP8") { - ASSERT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( - cricket::kRtcpFbParamNack, cricket::kParamValueEmpty))); - codecs_out.push_back(codec); - } - } - EXPECT_FALSE(codecs_out.empty()); - media->set_codecs(codecs_out); - } - }); - - caller()->CreateAndSetAndSignalOffer(); - // Check for failure in helpers - ASSERT_FALSE(HasFailure()); - MediaExpectations media_expectations; - media_expectations.CalleeExpectsSomeVideo(1); - ExpectNewFrames(media_expectations); - ASSERT_FALSE(HasFailure()); - - virtual_socket_server()->set_drop_probability(0.2); - - // Wait until callee has sent at least one NACK. - // Note that due to stats caching, this might only be visible 50 ms - // after the nack was in fact sent. - EXPECT_TRUE_WAIT(NacksSentCount(*callee()) > 0, kDefaultTimeout); - ASSERT_FALSE(HasFailure()); - - // Wait until caller has received at least one NACK - EXPECT_TRUE_WAIT(NacksReceivedCount(*caller()) > 0, kDefaultTimeout); -} - -// Test that we can get capture start ntp time. -TEST_P(PeerConnectionMediaChannelSplitTest, - GetCaptureStartNtpTimeWithOldStatsApi) { - ASSERT_TRUE(CreatePeerConnectionWrappers()); - ConnectFakeSignaling(); - caller()->AddAudioTrack(); - - callee()->AddAudioTrack(); - - // Do offer/answer, wait for the callee to receive some frames. - caller()->CreateAndSetAndSignalOffer(); - ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); - - // Get the remote audio track created on the receiver, so they can be used as - // GetStats filters. - auto receivers = callee()->pc()->GetReceivers(); - ASSERT_EQ(1u, receivers.size()); - auto remote_audio_track = receivers[0]->track(); - - // Get the audio output level stats. Note that the level is not available - // until an RTCP packet has been received. - EXPECT_TRUE_WAIT(callee()->OldGetStatsForTrack(remote_audio_track.get()) - ->CaptureStartNtpTime() > 0, - 2 * kMaxWaitForFramesMs); -} - -INSTANTIATE_TEST_SUITE_P(PeerConnectionMediaChannelSplitTest, - PeerConnectionMediaChannelSplitTest, - Values("WebRTC-SplitMediaChannel/Disabled/", - "WebRTC-SplitMediaChannel/Enabled/")); - -} // namespace - -} // namespace webrtc diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc index f659ecf2ef..09470d657d 100644 --- a/pc/rtp_sender_receiver_unittest.cc +++ b/pc/rtp_sender_receiver_unittest.cc @@ -37,7 +37,6 @@ #include "api/video/video_bitrate_allocator_factory.h" #include "api/video/video_codec_constants.h" #include "media/base/codec.h" -#include "media/base/delayable.h" #include "media/base/fake_media_engine.h" #include "media/base/media_channel.h" #include "media/base/media_config.h" @@ -485,9 +484,10 @@ class RtpSenderReceiverTest // Check that minimum Jitter Buffer delay is propagated to the underlying // `media_channel`. - void VerifyRtpReceiverDelayBehaviour(cricket::Delayable* media_channel, - RtpReceiverInterface* receiver, - uint32_t ssrc) { + void VerifyRtpReceiverDelayBehaviour( + cricket::MediaReceiveChannelInterface* media_channel, + RtpReceiverInterface* receiver, + uint32_t ssrc) { receiver->SetJitterBufferMinimumDelay(/*delay_seconds=*/0.5); absl::optional delay_ms = media_channel->GetBaseMinimumPlayoutDelayMs(ssrc); // In milliseconds. diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index 8948b7c968..f1f7b88759 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc @@ -202,8 +202,6 @@ RTCError RtpTransceiver::CreateChannel( return RTCError(RTCErrorType::INTERNAL_ERROR, "No media engine for mid=" + std::string(mid)); } - bool use_split_media_channel = - !context()->field_trials().IsDisabled("WebRTC-SplitMediaChannel"); std::unique_ptr new_channel; if (media_type() == cricket::MEDIA_TYPE_AUDIO) { // TODO(bugs.webrtc.org/11992): CreateVideoChannel internally switches to @@ -219,50 +217,34 @@ RTCError RtpTransceiver::CreateChannel( AudioCodecPairId codec_pair_id = AudioCodecPairId::Create(); - if (use_split_media_channel) { - std::unique_ptr - media_send_channel = media_engine()->voice().CreateSendChannel( - call_ptr, media_config, audio_options, crypto_options, - codec_pair_id); - if (!media_send_channel) { - // TODO(bugs.webrtc.org/14912): Consider CHECK or reporting failure - return; - } - std::unique_ptr - media_receive_channel = - media_engine()->voice().CreateReceiveChannel( - call_ptr, media_config, audio_options, crypto_options, - codec_pair_id); - if (!media_receive_channel) { - return; - } - // Note that this is safe because both sending and - // receiving channels will be deleted at the same time. - media_send_channel->SetSsrcListChangedCallback( - [receive_channel = media_receive_channel.get()]( - const std::set& choices) { - receive_channel->ChooseReceiverReportSsrc(choices); - }); - - new_channel = std::make_unique( - context()->worker_thread(), context()->network_thread(), - context()->signaling_thread(), std::move(media_send_channel), - std::move(media_receive_channel), mid, srtp_required, - crypto_options, context()->ssrc_generator()); - } else { - cricket::VoiceMediaChannel* media_channel = - media_engine()->voice().CreateMediaChannel( - cricket::MediaChannel::Role::kBoth, call_ptr, media_config, - audio_options, crypto_options, AudioCodecPairId::Create()); - if (!media_channel) { - return; - } - - new_channel = std::make_unique( - context()->worker_thread(), context()->network_thread(), - context()->signaling_thread(), absl::WrapUnique(media_channel), mid, - srtp_required, crypto_options, context()->ssrc_generator()); + std::unique_ptr + media_send_channel = media_engine()->voice().CreateSendChannel( + call_ptr, media_config, audio_options, crypto_options, + codec_pair_id); + if (!media_send_channel) { + // TODO(bugs.webrtc.org/14912): Consider CHECK or reporting failure + return; } + std::unique_ptr + media_receive_channel = media_engine()->voice().CreateReceiveChannel( + call_ptr, media_config, audio_options, crypto_options, + codec_pair_id); + if (!media_receive_channel) { + return; + } + // Note that this is safe because both sending and + // receiving channels will be deleted at the same time. + media_send_channel->SetSsrcListChangedCallback( + [receive_channel = + media_receive_channel.get()](const std::set& choices) { + receive_channel->ChooseReceiverReportSsrc(choices); + }); + + new_channel = std::make_unique( + context()->worker_thread(), context()->network_thread(), + context()->signaling_thread(), std::move(media_send_channel), + std::move(media_receive_channel), mid, srtp_required, crypto_options, + context()->ssrc_generator()); }); } else { RTC_DCHECK_EQ(cricket::MEDIA_TYPE_VIDEO, media_type()); @@ -273,49 +255,33 @@ RTCError RtpTransceiver::CreateChannel( context()->worker_thread()->BlockingCall([&] { RTC_DCHECK_RUN_ON(context()->worker_thread()); - if (use_split_media_channel) { - std::unique_ptr - media_send_channel = media_engine()->video().CreateSendChannel( - call_ptr, media_config, video_options, crypto_options, - video_bitrate_allocator_factory); - if (!media_send_channel) { - return; - } - - std::unique_ptr - media_receive_channel = - media_engine()->video().CreateReceiveChannel( - call_ptr, media_config, video_options, crypto_options); - if (!media_receive_channel) { - return; - } - // Note that this is safe because both sending and - // receiving channels will be deleted at the same time. - media_send_channel->SetSsrcListChangedCallback( - [receive_channel = media_receive_channel.get()]( - const std::set& choices) { - receive_channel->ChooseReceiverReportSsrc(choices); - }); - - new_channel = std::make_unique( - context()->worker_thread(), context()->network_thread(), - context()->signaling_thread(), std::move(media_send_channel), - std::move(media_receive_channel), mid, srtp_required, - crypto_options, context()->ssrc_generator()); - } else { - cricket::VideoMediaChannel* media_channel = - media_engine()->video().CreateMediaChannel( - cricket::MediaChannel::Role::kBoth, call_ptr, media_config, - video_options, crypto_options, video_bitrate_allocator_factory); - if (!media_channel) { - return; - } - - new_channel = std::make_unique( - context()->worker_thread(), context()->network_thread(), - context()->signaling_thread(), absl::WrapUnique(media_channel), mid, - srtp_required, crypto_options, context()->ssrc_generator()); + std::unique_ptr + media_send_channel = media_engine()->video().CreateSendChannel( + call_ptr, media_config, video_options, crypto_options, + video_bitrate_allocator_factory); + if (!media_send_channel) { + return; } + + std::unique_ptr + media_receive_channel = media_engine()->video().CreateReceiveChannel( + call_ptr, media_config, video_options, crypto_options); + if (!media_receive_channel) { + return; + } + // Note that this is safe because both sending and + // receiving channels will be deleted at the same time. + media_send_channel->SetSsrcListChangedCallback( + [receive_channel = + media_receive_channel.get()](const std::set& choices) { + receive_channel->ChooseReceiverReportSsrc(choices); + }); + + new_channel = std::make_unique( + context()->worker_thread(), context()->network_thread(), + context()->signaling_thread(), std::move(media_send_channel), + std::move(media_receive_channel), mid, srtp_required, crypto_options, + context()->ssrc_generator()); }); } if (!new_channel) { diff --git a/pc/rtp_transceiver_unittest.cc b/pc/rtp_transceiver_unittest.cc index 9e47fab80f..8b4a2389ce 100644 --- a/pc/rtp_transceiver_unittest.cc +++ b/pc/rtp_transceiver_unittest.cc @@ -382,7 +382,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, EXPECT_CALL(*mock_channel, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(*mock_channel, media_type()) .WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_AUDIO)); - EXPECT_CALL(*mock_channel, media_send_channel()) + EXPECT_CALL(*mock_channel, voice_media_send_channel()) .WillRepeatedly(Return(nullptr)); EXPECT_CALL(*mock_channel, mid()).WillRepeatedly(ReturnRef(content_name)); EXPECT_CALL(*mock_channel, SetRtpTransport(_)).WillRepeatedly(Return(true)); @@ -415,7 +415,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, ReturnsNegotiatedHdrExts) { EXPECT_CALL(*mock_channel, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(*mock_channel, media_type()) .WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_AUDIO)); - EXPECT_CALL(*mock_channel, media_send_channel()) + EXPECT_CALL(*mock_channel, voice_media_send_channel()) .WillRepeatedly(Return(nullptr)); EXPECT_CALL(*mock_channel, mid()).WillRepeatedly(ReturnRef(content_name)); EXPECT_CALL(*mock_channel, SetRtpTransport(_)).WillRepeatedly(Return(true)); diff --git a/pc/test/mock_channel_interface.h b/pc/test/mock_channel_interface.h index 3d82beb287..6b85ed8d11 100644 --- a/pc/test/mock_channel_interface.h +++ b/pc/test/mock_channel_interface.h @@ -14,6 +14,7 @@ #include #include +#include "media/base/media_channel.h" #include "pc/channel_interface.h" #include "test/gmock.h" @@ -27,12 +28,27 @@ class MockChannelInterface : public cricket::ChannelInterface { MOCK_METHOD(cricket::MediaType, media_type, (), (const, override)); MOCK_METHOD(VideoChannel*, AsVideoChannel, (), (override)); MOCK_METHOD(VoiceChannel*, AsVoiceChannel, (), (override)); - MOCK_METHOD(MediaChannel*, media_send_channel, (), (override)); - MOCK_METHOD(VoiceMediaChannel*, voice_media_send_channel, (), (override)); - MOCK_METHOD(VideoMediaChannel*, video_media_send_channel, (), (override)); - MOCK_METHOD(MediaChannel*, media_receive_channel, (), (override)); - MOCK_METHOD(VoiceMediaChannel*, voice_media_receive_channel, (), (override)); - MOCK_METHOD(VideoMediaChannel*, video_media_receive_channel, (), (override)); + MOCK_METHOD(MediaSendChannelInterface*, media_send_channel, (), (override)); + MOCK_METHOD(VoiceMediaSendChannelInterface*, + voice_media_send_channel, + (), + (override)); + MOCK_METHOD(VideoMediaSendChannelInterface*, + video_media_send_channel, + (), + (override)); + MOCK_METHOD(MediaReceiveChannelInterface*, + media_receive_channel, + (), + (override)); + MOCK_METHOD(VoiceMediaReceiveChannelInterface*, + voice_media_receive_channel, + (), + (override)); + MOCK_METHOD(VideoMediaReceiveChannelInterface*, + video_media_receive_channel, + (), + (override)); MOCK_METHOD(absl::string_view, transport_name, (), (const, override)); MOCK_METHOD(const std::string&, mid, (), (const, override)); MOCK_METHOD(void, Enable, (bool), (override)); diff --git a/pc/test/mock_voice_media_channel.h b/pc/test/mock_voice_media_receive_channel_interface.h similarity index 51% rename from pc/test/mock_voice_media_channel.h rename to pc/test/mock_voice_media_receive_channel_interface.h index 2668032037..b53c204f0d 100644 --- a/pc/test/mock_voice_media_channel.h +++ b/pc/test/mock_voice_media_receive_channel_interface.h @@ -1,5 +1,5 @@ /* - * Copyright 2021 The WebRTC project authors. All Rights Reserved. + * Copyright 2023 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -7,8 +7,8 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -#ifndef PC_TEST_MOCK_VOICE_MEDIA_CHANNEL_H_ -#define PC_TEST_MOCK_VOICE_MEDIA_CHANNEL_H_ +#ifndef PC_TEST_MOCK_VOICE_MEDIA_RECEIVE_CHANNEL_INTERFACE_H_ +#define PC_TEST_MOCK_VOICE_MEDIA_RECEIVE_CHANNEL_INTERFACE_H_ #include #include @@ -23,102 +23,16 @@ #include "test/gmock.h" #include "test/gtest.h" -using ::testing::InvokeWithoutArgs; -using ::testing::Mock; - namespace cricket { -class MockVoiceMediaChannel : public VoiceMediaChannel { + +class MockVoiceMediaReceiveChannelInterface + : public VoiceMediaReceiveChannelInterface { public: - MockVoiceMediaChannel(MediaChannel::Role role, - webrtc::TaskQueueBase* network_thread) - : VoiceMediaChannel(role, network_thread) {} + MockVoiceMediaReceiveChannelInterface() { + ON_CALL(*this, AsVoiceReceiveChannel).WillByDefault(testing::Return(this)); + } - MOCK_METHOD(void, - SetInterface, - (MediaChannelNetworkInterface * iface), - (override)); - MOCK_METHOD(void, - OnPacketReceived, - (const webrtc::RtpPacketReceived& packet), - (override)); - MOCK_METHOD(void, - OnPacketSent, - (const rtc::SentPacket& sent_packet), - (override)); - MOCK_METHOD(void, OnReadyToSend, (bool ready), (override)); - MOCK_METHOD(void, - OnNetworkRouteChanged, - (absl::string_view transport_name, - const rtc::NetworkRoute& network_route), - (override)); - MOCK_METHOD(void, SetExtmapAllowMixed, (bool extmap_allow_mixed), (override)); - MOCK_METHOD(bool, ExtmapAllowMixed, (), (const, override)); - MOCK_METHOD(bool, HasNetworkInterface, (), (const, override)); - MOCK_METHOD(bool, AddSendStream, (const StreamParams& sp), (override)); - MOCK_METHOD(bool, RemoveSendStream, (uint32_t ssrc), (override)); - MOCK_METHOD(bool, AddRecvStream, (const StreamParams& sp), (override)); - MOCK_METHOD(bool, RemoveRecvStream, (uint32_t ssrc), (override)); - MOCK_METHOD(void, ResetUnsignaledRecvStream, (), (override)); - MOCK_METHOD(absl::optional, - GetUnsignaledSsrc, - (), - (const, override)); - MOCK_METHOD(void, - ChooseReceiverReportSsrc, - (const std::set&), - (override)); - MOCK_METHOD(absl::optional, GetSendCodec, (), (const, override)); - MOCK_METHOD(bool, SendCodecHasNack, (), (const, override)); - MOCK_METHOD(void, - SetSsrcListChangedCallback, - (absl::AnyInvocable&)>), - (override)); - MOCK_METHOD(void, - SetSendCodecChangedCallback, - (absl::AnyInvocable), - (override)); - MOCK_METHOD(void, OnDemuxerCriteriaUpdatePending, (), (override)); - MOCK_METHOD(void, OnDemuxerCriteriaUpdateComplete, (), (override)); - MOCK_METHOD(int, GetRtpSendTimeExtnId, (), (const, override)); - MOCK_METHOD( - void, - SetFrameEncryptor, - (uint32_t ssrc, - rtc::scoped_refptr frame_encryptor), - (override)); - MOCK_METHOD( - void, - SetFrameDecryptor, - (uint32_t ssrc, - rtc::scoped_refptr frame_decryptor), - (override)); - MOCK_METHOD(webrtc::RtpParameters, - GetRtpSendParameters, - (uint32_t ssrc), - (const, override)); - MOCK_METHOD(webrtc::RTCError, - SetRtpSendParameters, - (uint32_t ssrc, - const webrtc::RtpParameters& parameters, - webrtc::SetParametersCallback callback), - (override)); - MOCK_METHOD( - void, - SetEncoderToPacketizerFrameTransformer, - (uint32_t ssrc, - rtc::scoped_refptr frame_transformer), - (override)); - MOCK_METHOD( - void, - SetDepacketizerToDecoderFrameTransformer, - (uint32_t ssrc, - rtc::scoped_refptr frame_transformer), - (override)); - - MOCK_METHOD(bool, - SetSendParameters, - (const AudioSendParameters& params), - (override)); + // VoiceMediaReceiveChannelInterface MOCK_METHOD(bool, SetRecvParameters, (const AudioRecvParameters& params), @@ -127,34 +41,20 @@ class MockVoiceMediaChannel : public VoiceMediaChannel { GetRtpReceiveParameters, (uint32_t ssrc), (const, override)); + MOCK_METHOD(std::vector, + GetSources, + (uint32_t ssrc), + (const, override)); MOCK_METHOD(webrtc::RtpParameters, GetDefaultRtpReceiveParameters, (), (const, override)); MOCK_METHOD(void, SetPlayout, (bool playout), (override)); - MOCK_METHOD(void, SetSend, (bool send), (override)); - MOCK_METHOD(bool, - SetAudioSend, - (uint32_t ssrc, - bool enable, - const AudioOptions* options, - AudioSource* source), - (override)); MOCK_METHOD(bool, SetOutputVolume, (uint32_t ssrc, double volume), (override)); MOCK_METHOD(bool, SetDefaultOutputVolume, (double volume), (override)); - MOCK_METHOD(bool, CanInsertDtmf, (), (override)); - MOCK_METHOD(bool, - InsertDtmf, - (uint32_t ssrc, int event, int duration), - (override)); - MOCK_METHOD(bool, GetSendStats, (VoiceMediaSendInfo * info), (override)); - MOCK_METHOD(bool, - GetReceiveStats, - (VoiceMediaReceiveInfo * info, bool get_and_clear_legacy_stats), - (override)); MOCK_METHOD(void, SetRawAudioSink, (uint32_t ssrc, std::unique_ptr sink), @@ -163,11 +63,56 @@ class MockVoiceMediaChannel : public VoiceMediaChannel { SetDefaultRawAudioSink, (std::unique_ptr sink), (override)); - MOCK_METHOD(std::vector, - GetSources, - (uint32_t ssrc), - (const, override)); + MOCK_METHOD(bool, + GetStats, + (VoiceMediaReceiveInfo * stats, bool reset_legacy), + (override)); + MOCK_METHOD(void, SetReceiveNackEnabled, (bool enabled), (override)); + MOCK_METHOD(void, SetReceiveNonSenderRttEnabled, (bool enabled), (override)); + // MediaReceiveChannelInterface + MOCK_METHOD(VideoMediaReceiveChannelInterface*, + AsVideoReceiveChannel, + (), + (override)); + MOCK_METHOD(VoiceMediaReceiveChannelInterface*, + AsVoiceReceiveChannel, + (), + (override)); + MOCK_METHOD(cricket::MediaType, media_type, (), (const, override)); + MOCK_METHOD(bool, AddRecvStream, (const StreamParams& sp), (override)); + MOCK_METHOD(bool, RemoveRecvStream, (uint32_t ssrc), (override)); + MOCK_METHOD(void, ResetUnsignaledRecvStream, (), (override)); + MOCK_METHOD(void, + SetInterface, + (MediaChannelNetworkInterface * iface), + (override)); + MOCK_METHOD(void, + OnPacketReceived, + (const webrtc::RtpPacketReceived& packet), + (override)); + MOCK_METHOD(absl::optional, + GetUnsignaledSsrc, + (), + (const, override)); + MOCK_METHOD(void, + ChooseReceiverReportSsrc, + (const std::set& choices), + (override)); + MOCK_METHOD(void, OnDemuxerCriteriaUpdatePending, (), (override)); + MOCK_METHOD(void, OnDemuxerCriteriaUpdateComplete, (), (override)); + MOCK_METHOD( + void, + SetFrameDecryptor, + (uint32_t ssrc, + rtc::scoped_refptr frame_decryptor), + (override)); + MOCK_METHOD( + void, + SetDepacketizerToDecoderFrameTransformer, + (uint32_t ssrc, + rtc::scoped_refptr frame_transformer), + (override)); MOCK_METHOD(bool, SetBaseMinimumPlayoutDelayMs, (uint32_t ssrc, int delay_ms), @@ -176,11 +121,10 @@ class MockVoiceMediaChannel : public VoiceMediaChannel { GetBaseMinimumPlayoutDelayMs, (uint32_t ssrc), (const, override)); - MOCK_METHOD(bool, SenderNackEnabled, (), (const, override)); - MOCK_METHOD(bool, SenderNonSenderRttEnabled, (), (const, override)); - MOCK_METHOD(void, SetReceiveNackEnabled, (bool enabled), (override)); - MOCK_METHOD(void, SetReceiveNonSenderRttEnabled, (bool enabled), (override)); }; + +static_assert(!std::is_abstract_v, ""); + } // namespace cricket -#endif // PC_TEST_MOCK_VOICE_MEDIA_CHANNEL_H_ +#endif // PC_TEST_MOCK_VOICE_MEDIA_RECEIVE_CHANNEL_INTERFACE_H_