Skip to content

Commit a8eace8

Browse files
Harald AlvestrandWebRTC LUCI CQ
authored andcommitted
Reland "Assign supported codecs per section, not globally."
This reverts commit 374b892. Reason for revert: Racing CLs sorted out Original change's description: > Revert "Assign supported codecs per section, not globally." > > This reverts commit c92fc76. > > Reason for revert: Gerritt submitted patch set #10 not #12 - this broke > > Original change's description: > > Assign supported codecs per section, not globally. > > > > This uses the PayloadTypeSuggester for PT disambiguation, > > ensuring that conficts are managed across the transport. > > > > Bug: webrtc:360058654 > > Change-Id: Ic8f0569d0d96d97c13765169903929ec8a110104 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/383400 > > Commit-Queue: Harald Alvestrand <[email protected]> > > Reviewed-by: Evan Shrubsole <[email protected]> > > Reviewed-by: Henrik Boström <[email protected]> > > Cr-Commit-Position: refs/heads/main@{#44284} > > Bug: webrtc:360058654 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Change-Id: I16d0d92fb9a1ecc65eda060f81d41faefcca1e4c > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/384000 > Commit-Queue: Harald Alvestrand <[email protected]> > Reviewed-by: Danil Chapovalov <[email protected]> > Bot-Commit: [email protected] <[email protected]> > Reviewed-by: Mirko Bonadei <[email protected]> > Cr-Commit-Position: refs/heads/main@{#44285} Bug: webrtc:360058654 Change-Id: I80b59aab396abbc0afa60dab3516f2a22e822a5d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/383981 Reviewed-by: Mirko Bonadei <[email protected]> Commit-Queue: Mirko Bonadei <[email protected]> Commit-Queue: Harald Alvestrand <[email protected]> Reviewed-by: Danil Chapovalov <[email protected]> Cr-Commit-Position: refs/heads/main@{#44288}
1 parent 7501cf7 commit a8eace8

9 files changed

+164
-219
lines changed

pc/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ rtc_library("codec_vendor") {
428428
"../rtc_base:unique_id_generator",
429429
"//third_party/abseil-cpp/absl/algorithm:container",
430430
"//third_party/abseil-cpp/absl/strings",
431+
"//third_party/abseil-cpp/absl/strings:str_format",
431432
"//third_party/abseil-cpp/absl/strings:string_view",
432433
]
433434
}

pc/codec_vendor.cc

Lines changed: 141 additions & 160 deletions
Large diffs are not rendered by default.

pc/codec_vendor.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,11 @@ class CodecVendor {
4747
const webrtc::FieldTrialsView& trials);
4848

4949
public:
50-
webrtc::RTCError GetCodecsForOffer(
51-
const std::vector<const webrtc::ContentInfo*>& current_active_contents,
52-
CodecList& audio_codecs,
53-
CodecList& video_codecs) const;
54-
webrtc::RTCError GetCodecsForAnswer(
55-
const std::vector<const webrtc::ContentInfo*>& current_active_contents,
56-
const webrtc::SessionDescription& remote_offer,
57-
CodecList& audio_codecs,
58-
CodecList& video_codecs) const;
59-
6050
webrtc::RTCErrorOr<std::vector<Codec>> GetNegotiatedCodecsForOffer(
6151
const MediaDescriptionOptions& media_description_options,
6252
const MediaSessionOptions& session_options,
6353
const webrtc::ContentInfo* current_content,
64-
webrtc::PayloadTypeSuggester& pt_suggester,
65-
const CodecList& codecs);
54+
webrtc::PayloadTypeSuggester& pt_suggester);
6655

6756
webrtc::RTCErrorOr<Codecs> GetNegotiatedCodecsForAnswer(
6857
const MediaDescriptionOptions& media_description_options,
@@ -71,8 +60,7 @@ class CodecVendor {
7160
webrtc::RtpTransceiverDirection answer_rtd,
7261
const webrtc::ContentInfo* current_content,
7362
std::vector<Codec> codecs_from_offer,
74-
webrtc::PayloadTypeSuggester& pt_suggester,
75-
const CodecList& codecs);
63+
webrtc::PayloadTypeSuggester& pt_suggester);
7664

7765
// Functions exposed for testing
7866
void set_audio_codecs(const CodecList& send_codecs,

pc/jsep_transport_controller_unittest.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <utility>
1919
#include <vector>
2020

21+
#include "api/candidate.h"
2122
#include "api/crypto/crypto_options.h"
2223
#include "api/dtls_transport_interface.h"
2324
#include "api/environment/environment.h"

pc/media_session.cc

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "api/rtp_transceiver_direction.h"
3030
#include "api/sctp_transport_interface.h"
3131
#include "media/base/codec.h"
32-
#include "media/base/codec_list.h"
3332
#include "media/base/media_constants.h"
3433
#include "media/base/media_engine.h"
3534
#include "media/base/rid_description.h"
@@ -734,16 +733,6 @@ MediaSessionDescriptionFactory::CreateOfferOrError(
734733
cricket::StreamParamsVec current_streams =
735734
GetCurrentStreamParams(current_active_contents);
736735

737-
cricket::CodecList offer_audio_codecs;
738-
cricket::CodecList offer_video_codecs;
739-
740-
// TODO: issues.webrtc.org/360058654 - Get codecs when we know the right mid.
741-
RTCError error = codec_lookup_helper_->CodecVendor("")->GetCodecsForOffer(
742-
current_active_contents, offer_audio_codecs, offer_video_codecs);
743-
if (!error.ok()) {
744-
return error;
745-
}
746-
747736
AudioVideoRtpHeaderExtensions extensions_with_ids =
748737
GetOfferedRtpHeaderExtensionsWithIds(
749738
current_active_contents, session_options.offer_extmap_allow_mixed,
@@ -762,6 +751,7 @@ MediaSessionDescriptionFactory::CreateOfferOrError(
762751
current_content = &current_description->contents()[msection_index];
763752
// Media type must match unless this media section is being recycled.
764753
}
754+
RTCError error;
765755
switch (media_description_options.type) {
766756
case webrtc::MediaType::AUDIO:
767757
case webrtc::MediaType::VIDEO:
@@ -771,9 +761,6 @@ MediaSessionDescriptionFactory::CreateOfferOrError(
771761
media_description_options.type == webrtc::MediaType::AUDIO
772762
? extensions_with_ids.audio
773763
: extensions_with_ids.video,
774-
media_description_options.type == webrtc::MediaType::AUDIO
775-
? offer_audio_codecs
776-
: offer_video_codecs,
777764
&current_streams, offer.get(), &ice_credentials);
778765
break;
779766
case webrtc::MediaType::DATA:
@@ -882,22 +869,6 @@ MediaSessionDescriptionFactory::CreateAnswerOrError(
882869
}
883870
}
884871

885-
// Get list of all possible codecs that respects existing payload type
886-
// mappings and uses a single payload type space.
887-
//
888-
// Note that these lists may be further filtered for each m= section; this
889-
// step is done just to establish the payload type mappings shared by all
890-
// sections.
891-
cricket::CodecList answer_audio_codecs;
892-
cricket::CodecList answer_video_codecs;
893-
// TODO: issues.webrtc.org/360058654 - do this when we have the MID.
894-
RTCError error = codec_lookup_helper_->CodecVendor("")->GetCodecsForAnswer(
895-
current_active_contents, *offer, answer_audio_codecs,
896-
answer_video_codecs);
897-
if (!error.ok()) {
898-
return error;
899-
}
900-
901872
auto answer = std::make_unique<SessionDescription>();
902873

903874
// If the offer supports BUNDLE, and we want to use it too, create a BUNDLE
@@ -958,15 +929,13 @@ MediaSessionDescriptionFactory::CreateAnswerOrError(
958929
cricket::RtpHeaderExtensions header_extensions =
959930
RtpHeaderExtensionsFromCapabilities(
960931
UnstoppedRtpHeaderExtensionCapabilities(header_extensions_in));
932+
RTCError error;
961933
switch (media_description_options.type) {
962934
case webrtc::MediaType::AUDIO:
963935
case webrtc::MediaType::VIDEO:
964936
error = AddRtpContentForAnswer(
965937
media_description_options, session_options, offer_content, offer,
966938
current_content, current_description, bundle_transport,
967-
media_description_options.type == webrtc::MediaType::AUDIO
968-
? answer_audio_codecs
969-
: answer_video_codecs,
970939
header_extensions, &current_streams, answer.get(),
971940
&ice_credentials);
972941
break;
@@ -1195,7 +1164,6 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForOffer(
11951164
const ContentInfo* current_content,
11961165
const SessionDescription* current_description,
11971166
const cricket::RtpHeaderExtensions& header_extensions,
1198-
const cricket::CodecList& codecs,
11991167
cricket::StreamParamsVec* current_streams,
12001168
SessionDescription* session_description,
12011169
cricket::IceCredentialsIterator* ice_credentials) const {
@@ -1207,7 +1175,7 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForOffer(
12071175
RTCErrorOr<std::vector<cricket::Codec>> error_or_filtered_codecs =
12081176
codec_lookup_helper_->CodecVendor(mid)->GetNegotiatedCodecsForOffer(
12091177
media_description_options, session_options, current_content,
1210-
*codec_lookup_helper_->PayloadTypeSuggester(), codecs);
1178+
*codec_lookup_helper_->PayloadTypeSuggester());
12111179
if (!error_or_filtered_codecs.ok()) {
12121180
return error_or_filtered_codecs.MoveError();
12131181
}
@@ -1327,7 +1295,6 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForAnswer(
13271295
const ContentInfo* current_content,
13281296
const SessionDescription* current_description,
13291297
const cricket::TransportInfo* bundle_transport,
1330-
const cricket::CodecList& codecs,
13311298
const cricket::RtpHeaderExtensions& header_extensions,
13321299
cricket::StreamParamsVec* current_streams,
13331300
SessionDescription* answer,
@@ -1371,7 +1338,7 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForAnswer(
13711338
->GetNegotiatedCodecsForAnswer(
13721339
media_description_options, session_options, offer_rtd, answer_rtd,
13731340
current_content, offer_content_description->codecs(),
1374-
*codec_lookup_helper_->PayloadTypeSuggester(), codecs);
1341+
*codec_lookup_helper_->PayloadTypeSuggester());
13751342
if (!error_or_filtered_codecs.ok()) {
13761343
return error_or_filtered_codecs.MoveError();
13771344
}

pc/media_session.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "api/media_types.h"
2121
#include "api/rtc_error.h"
22-
#include "media/base/codec_list.h"
2322
#include "media/base/stream_params.h"
2423
#include "p2p/base/ice_credentials_iterator.h"
2524
#include "p2p/base/transport_description.h"
@@ -118,7 +117,6 @@ class MediaSessionDescriptionFactory {
118117
const ContentInfo* current_content,
119118
const SessionDescription* current_description,
120119
const cricket::RtpHeaderExtensions& header_extensions,
121-
const cricket::CodecList& codecs,
122120
cricket::StreamParamsVec* current_streams,
123121
SessionDescription* desc,
124122
cricket::IceCredentialsIterator* ice_credentials) const;
@@ -148,7 +146,6 @@ class MediaSessionDescriptionFactory {
148146
const ContentInfo* current_content,
149147
const SessionDescription* current_description,
150148
const cricket::TransportInfo* bundle_transport,
151-
const cricket::CodecList& codecs,
152149
const cricket::RtpHeaderExtensions& header_extensions,
153150
cricket::StreamParamsVec* current_streams,
154151
SessionDescription* answer,

pc/media_session_unittest.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ using ::testing::ElementsAre;
7474
using ::testing::ElementsAreArray;
7575
using ::testing::Eq;
7676
using ::testing::Field;
77+
using ::testing::Gt;
7778
using ::testing::IsEmpty;
7879
using ::testing::Not;
7980
using ::testing::Pointwise;
@@ -111,7 +112,7 @@ cricket::Codec CreateRedAudioCodec(absl::string_view encoding_id) {
111112
const cricket::Codec kAudioCodecs1[] = {
112113
cricket::CreateAudioCodec(111, "opus", 48000, 2),
113114
CreateRedAudioCodec("111"),
114-
cricket::CreateAudioCodec(102, "G722", 16000, 1),
115+
cricket::CreateAudioCodec(103, "G722", 16000, 1),
115116
cricket::CreateAudioCodec(0, "PCMU", 8000, 1),
116117
cricket::CreateAudioCodec(8, "PCMA", 8000, 1),
117118
cricket::CreateAudioCodec(107, "CN", 48000, 1)};
@@ -123,7 +124,7 @@ const cricket::Codec kAudioCodecs2[] = {
123124
};
124125

125126
const cricket::Codec kAudioCodecsAnswer[] = {
126-
cricket::CreateAudioCodec(102, "G722", 16000, 1),
127+
cricket::CreateAudioCodec(103, "G722", 16000, 1),
127128
cricket::CreateAudioCodec(0, "PCMU", 8000, 1),
128129
};
129130

@@ -3410,6 +3411,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
34103411
AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts);
34113412

34123413
std::vector<cricket::Codec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
3414+
ASSERT_THAT(acd->codecs().size(), Gt(0));
34133415
int used_pl_type = acd->codecs()[0].id;
34143416
f2_codecs[0].id = used_pl_type; // Set the payload type for H264.
34153417
AddRtxCodec(cricket::CreateVideoRtxCodec(125, used_pl_type), &f2_codecs);
@@ -4703,6 +4705,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerWithLocalCodecParams) {
47034705
auto answer_acd = answer->contents()[0].media_description();
47044706
auto answer_vcd = answer->contents()[1].media_description();
47054707
// Use the parameters from the local codecs.
4708+
ASSERT_TRUE(answer_acd);
4709+
ASSERT_THAT(answer_acd->codecs().size(), Gt(0));
47064710
EXPECT_TRUE(answer_acd->codecs()[0].GetParam(audio_param_name, &value));
47074711
EXPECT_EQ(audio_value2, value);
47084712
EXPECT_TRUE(answer_vcd->codecs()[0].GetParam(video_param_name, &value));

pc/sdp_offer_answer_unittest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <vector>
1919

2020
#include "absl/strings/match.h"
21+
#include "absl/strings/str_cat.h"
2122
#include "absl/strings/str_replace.h"
2223
#include "api/audio_codecs/audio_format.h"
2324
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
@@ -56,7 +57,6 @@
5657
#include "pc/test/fake_rtc_certificate_generator.h"
5758
#include "pc/test/integration_test_helpers.h"
5859
#include "pc/test/mock_peer_connection_observers.h"
59-
#include "rtc_base/string_encode.h"
6060
#include "rtc_base/thread.h"
6161
#include "system_wrappers/include/metrics.h"
6262
#include "test/gmock.h"
@@ -1726,7 +1726,7 @@ TEST_F(SdpOfferAnswerTest, PayloadTypeMatchingWithSubsequentOfferAnswer) {
17261726
codecs = media_description2->codecs();
17271727
ASSERT_EQ(codecs.size(), 2u);
17281728
EXPECT_EQ(codecs[1].name, av1.name);
1729-
EXPECT_NE(codecs[1].id, av1.id);
1729+
// At this point, the value 127 may or may not have been chosen.
17301730

17311731
// 4. O/A triggered by remote. This "locks in" the payload type.
17321732
auto offer3 = callee->CreateOfferAndSetAsLocal();

rtc_base/net_test_helpers.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@
1111
#ifndef RTC_BASE_NET_TEST_HELPERS_H_
1212
#define RTC_BASE_NET_TEST_HELPERS_H_
1313

14+
#include "rtc_base/system/rtc_export.h"
15+
1416
namespace webrtc {
1517

1618
bool HasIPv4Enabled();
17-
bool HasIPv6Enabled();
19+
RTC_EXPORT bool HasIPv6Enabled();
1820

1921
} // namespace webrtc
2022

23+
namespace rtc {
24+
using webrtc::HasIPv6Enabled;
25+
}
26+
2127
#endif // RTC_BASE_NET_TEST_HELPERS_H_

0 commit comments

Comments
 (0)