Remove public sync_label from StreamParams
This change replaces the use of sync_label from StreamParams with
the new stream_labels() and set_stream_labels() getter and setter.
Bug: webrtc:7932
Change-Id: Ibd6d38f7d4efed37ac07963e6fbe377c93a28fd6
Reviewed-on: https://webrtc-review.googlesource.com/58540
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22257}
diff --git a/media/base/streamparams.cc b/media/base/streamparams.cc
index e59479d..0713909 100644
--- a/media/base/streamparams.cc
+++ b/media/base/streamparams.cc
@@ -215,6 +215,10 @@
sync_label = (stream_labels.empty() ? "" : stream_labels[0]);
}
+std::string StreamParams::first_stream_label() const {
+ return sync_label;
+}
+
bool IsOneSsrcStream(const StreamParams& sp) {
if (sp.ssrcs.size() == 1 && sp.ssrc_groups.empty()) {
return true;
diff --git a/media/base/streamparams.h b/media/base/streamparams.h
index 9060515..818fd94 100644
--- a/media/base/streamparams.h
+++ b/media/base/streamparams.h
@@ -69,14 +69,10 @@
}
bool operator==(const StreamParams& other) const {
- return (groupid == other.groupid &&
- id == other.id &&
- ssrcs == other.ssrcs &&
- ssrc_groups == other.ssrc_groups &&
- type == other.type &&
- display == other.display &&
- cname == other.cname &&
- sync_label == other.sync_label);
+ return (groupid == other.groupid && id == other.id &&
+ ssrcs == other.ssrcs && ssrc_groups == other.ssrc_groups &&
+ type == other.type && display == other.display &&
+ cname == other.cname && sync_label == other.sync_label);
}
bool operator!=(const StreamParams &other) const {
return !(*this == other);
@@ -150,6 +146,10 @@
std::vector<std::string> stream_labels() const;
void set_stream_labels(const std::vector<std::string>& stream_labels);
+ // Returns the first stream label or "" if none exist. This method exists only
+ // as temporary backwards compatibility with the old sync_label.
+ std::string first_stream_label() const;
+
std::string ToString() const;
// Resource of the MUC jid of the participant of with this stream.
diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc
index d822030..eb8cff0 100644
--- a/media/engine/webrtcvideoengine.cc
+++ b/media/engine/webrtcvideoengine.cc
@@ -1224,7 +1224,9 @@
// TODO(nisse): Rename config variable to avoid negation.
config.disable_prerenderer_smoothing =
!video_config_.enable_prerenderer_smoothing;
- config.sync_group = sp.sync_label;
+ if (!sp.stream_labels().empty()) {
+ config.sync_group = sp.stream_labels()[0];
+ }
receive_streams_[ssrc] = new WebRtcVideoReceiveStream(
call_, sp, std::move(config), decoder_factory_, default_stream,
diff --git a/media/engine/webrtcvideoengine_unittest.cc b/media/engine/webrtcvideoengine_unittest.cc
index f33dc6c..46ade39 100644
--- a/media/engine/webrtcvideoengine_unittest.cc
+++ b/media/engine/webrtcvideoengine_unittest.cc
@@ -1485,7 +1485,7 @@
const std::string kSyncLabel = "AvSyncLabel";
cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc);
- sp.sync_label = kSyncLabel;
+ sp.set_stream_labels({kSyncLabel});
EXPECT_TRUE(channel_->AddRecvStream(sp));
EXPECT_EQ(1, fake_call_->GetVideoReceiveStreams().size());
diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc
index 51cbba2..9e0dda6 100644
--- a/media/engine/webrtcvoiceengine.cc
+++ b/media/engine/webrtcvoiceengine.cc
@@ -1113,7 +1113,7 @@
uint32_t local_ssrc,
bool use_transport_cc,
bool use_nack,
- const std::string& sync_group,
+ const std::vector<std::string>& stream_labels,
const std::vector<webrtc::RtpExtension>& extensions,
webrtc::Call* call,
webrtc::Transport* rtcp_send_transport,
@@ -1131,7 +1131,9 @@
config_.rtcp_send_transport = rtcp_send_transport;
config_.jitter_buffer_max_packets = jitter_buffer_max_packets;
config_.jitter_buffer_fast_accelerate = jitter_buffer_fast_accelerate;
- config_.sync_group = sync_group;
+ if (!stream_labels.empty()) {
+ config_.sync_group = stream_labels[0];
+ }
config_.decoder_factory = decoder_factory;
config_.decoder_map = decoder_map;
RecreateAudioReceiveStream();
@@ -1170,8 +1172,13 @@
ReconfigureAudioReceiveStream();
}
- void MaybeRecreateAudioReceiveStream(const std::string& sync_group) {
+ void MaybeRecreateAudioReceiveStream(
+ const std::vector<std::string>& stream_labels) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
+ std::string sync_group;
+ if (!stream_labels.empty()) {
+ sync_group = stream_labels[0];
+ }
if (config_.sync_group != sync_group) {
RTC_LOG(LS_INFO) << "Recreating AudioReceiveStream for SSRC="
<< config_.rtp.remote_ssrc
@@ -1839,9 +1846,9 @@
}
// If this stream was previously received unsignaled, we promote it, possibly
- // recreating the AudioReceiveStream, if sync_label has changed.
+ // recreating the AudioReceiveStream, if stream labels have changed.
if (MaybeDeregisterUnsignaledRecvStream(ssrc)) {
- recv_streams_[ssrc]->MaybeRecreateAudioReceiveStream(sp.sync_label);
+ recv_streams_[ssrc]->MaybeRecreateAudioReceiveStream(sp.stream_labels());
return true;
}
@@ -1852,20 +1859,12 @@
// Create a new channel for receiving audio data.
recv_streams_.insert(std::make_pair(
- ssrc,
- new WebRtcAudioReceiveStream(
- ssrc,
- receiver_reports_ssrc_,
- recv_transport_cc_enabled_,
- recv_nack_enabled_,
- sp.sync_label,
- recv_rtp_extensions_,
- call_,
- this,
- engine()->decoder_factory_,
- decoder_map_,
- engine()->audio_jitter_buffer_max_packets_,
- engine()->audio_jitter_buffer_fast_accelerate_)));
+ ssrc, new WebRtcAudioReceiveStream(
+ ssrc, receiver_reports_ssrc_, recv_transport_cc_enabled_,
+ recv_nack_enabled_, sp.stream_labels(), recv_rtp_extensions_,
+ call_, this, engine()->decoder_factory_, decoder_map_,
+ engine()->audio_jitter_buffer_max_packets_,
+ engine()->audio_jitter_buffer_fast_accelerate_)));
recv_streams_[ssrc]->SetPlayout(playout_);
return true;
diff --git a/media/engine/webrtcvoiceengine_unittest.cc b/media/engine/webrtcvoiceengine_unittest.cc
index d71d77d..02c9178 100644
--- a/media/engine/webrtcvoiceengine_unittest.cc
+++ b/media/engine/webrtcvoiceengine_unittest.cc
@@ -2656,7 +2656,7 @@
int audio_receive_stream_id = streams.front()->id();
cricket::StreamParams stream_params;
stream_params.ssrcs.push_back(1);
- stream_params.sync_label = "sync_label";
+ stream_params.set_stream_labels({"sync_label"});
EXPECT_TRUE(channel_->AddRecvStream(stream_params));
EXPECT_EQ(1, streams.size());
EXPECT_NE(audio_receive_stream_id, streams.front()->id());
@@ -3041,7 +3041,7 @@
EXPECT_TRUE(SetupSendStream());
cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc);
- sp.sync_label = kSyncLabel;
+ sp.set_stream_labels({kSyncLabel});
// Creating two channels to make sure that sync label is set properly for both
// the default voice channel and following ones.
EXPECT_TRUE(channel_->AddRecvStream(sp));
diff --git a/pc/mediasession.cc b/pc/mediasession.cc
index a1bc01f..b224cc8 100644
--- a/pc/mediasession.cc
+++ b/pc/mediasession.cc
@@ -475,7 +475,7 @@
stream_param.cname = rtcp_cname;
// TODO(steveanton): Support any number of stream ids.
RTC_CHECK(sender.stream_ids.size() == 1U);
- stream_param.sync_label = sender.stream_ids[0];
+ stream_param.set_stream_labels(sender.stream_ids);
content_description->AddStream(stream_param);
// Store the new StreamParams in current_streams.
@@ -487,7 +487,7 @@
// MediaStream to another.
// TODO(steveanton): Support any number of stream ids.
RTC_CHECK(sender.stream_ids.size() == 1U);
- param->sync_label = sender.stream_ids[0];
+ param->set_stream_labels(sender.stream_ids);
content_description->AddStream(*param);
}
}
diff --git a/pc/mediasession_unittest.cc b/pc/mediasession_unittest.cc
index af6b695..c21403a 100644
--- a/pc/mediasession_unittest.cc
+++ b/pc/mediasession_unittest.cc
@@ -375,7 +375,7 @@
simulcast_params.ssrcs = MAKE_VECTOR(kSimulcastParamsSsrc);
simulcast_params.ssrc_groups = ssrc_groups;
simulcast_params.cname = "Video_SIM_FEC";
- simulcast_params.sync_label = kMediaStream1;
+ simulcast_params.set_stream_labels({kMediaStream1});
StreamParamsVec video_streams;
video_streams.push_back(simulcast_params);
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index 428530f..ef5294f 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -1954,7 +1954,7 @@
const auto& streams = content->media_description()->streams();
if (!content->rejected && !streams.empty()) {
transceiver->internal()->sender_internal()->set_stream_ids(
- {streams[0].sync_label});
+ streams[0].stream_labels());
transceiver->internal()->sender_internal()->SetSsrc(
streams[0].first_ssrc());
}
@@ -2221,7 +2221,10 @@
// Create a sync label in the case of an unsignalled msid.
std::string sync_label = rtc::CreateRandomUuid();
if (!media_desc->streams().empty()) {
- sync_label = media_desc->streams()[0].sync_label;
+ const cricket::StreamParams& stream_params = media_desc->streams()[0];
+ if (!stream_params.stream_labels().empty()) {
+ sync_label = stream_params.stream_labels()[0];
+ }
}
if (RtpTransceiverDirectionHasRecv(local_direction) &&
(!transceiver->current_direction() ||
@@ -3858,7 +3861,9 @@
for (const cricket::StreamParams& params : streams) {
// The sync_label is the MediaStream label and the |stream.id| is the
// sender id.
- const std::string& stream_label = params.sync_label;
+ // TODO(bugs.webrtc.org/7932): Add support for multiple stream labels.
+ const std::string& stream_label =
+ (!params.stream_labels().empty() ? params.stream_labels()[0] : "");
const std::string& sender_id = params.id;
uint32_t ssrc = params.first_ssrc();
@@ -3981,7 +3986,7 @@
const cricket::StreamParams* params =
cricket::GetStreamBySsrc(streams, info.first_ssrc);
if (!params || params->id != info.sender_id ||
- params->sync_label != info.stream_label) {
+ params->first_stream_label() != info.stream_label) {
OnLocalSenderRemoved(info, media_type);
sender_it = current_senders->erase(sender_it);
} else {
@@ -3993,7 +3998,7 @@
for (const cricket::StreamParams& params : streams) {
// The sync_label is the MediaStream label and the |stream.id| is the
// sender id.
- const std::string& stream_label = params.sync_label;
+ const std::string& stream_label = params.first_stream_label();
const std::string& sender_id = params.id;
uint32_t ssrc = params.first_ssrc();
const RtpSenderInfo* sender_info =
@@ -4057,7 +4062,7 @@
// MediaStreams and Tracks.
// For MediaStreams, the sync_label is the MediaStream label and the
// track label is the same as |streamid|.
- const std::string& channel_label = params.sync_label;
+ const std::string& channel_label = params.first_stream_label();
auto data_channel_it = rtp_data_channels_.find(channel_label);
if (data_channel_it == rtp_data_channels_.end()) {
RTC_LOG(LS_ERROR) << "channel label not found";
@@ -4079,9 +4084,9 @@
for (const cricket::StreamParams& params : streams) {
// The data channel label is either the mslabel or the SSRC if the mslabel
// does not exist. Ex a=ssrc:444330170 mslabel:test1.
- std::string label = params.sync_label.empty()
+ std::string label = params.first_stream_label().empty()
? rtc::ToString(params.first_ssrc())
- : params.sync_label;
+ : params.first_stream_label();
auto data_channel_it = rtp_data_channels_.find(label);
if (data_channel_it == rtp_data_channels_.end()) {
// This is a new data channel.
diff --git a/pc/peerconnectioninterface_unittest.cc b/pc/peerconnectioninterface_unittest.cc
index fa1581e..eb396f5 100644
--- a/pc/peerconnectioninterface_unittest.cc
+++ b/pc/peerconnectioninterface_unittest.cc
@@ -495,7 +495,7 @@
const std::string& stream_label,
const std::string& track_id) {
for (const cricket::StreamParams& params : streams) {
- if (params.sync_label == stream_label && params.id == track_id) {
+ if (params.first_stream_label() == stream_label && params.id == track_id) {
return true;
}
}
@@ -1903,7 +1903,7 @@
cricket::GetFirstVideoContentDescription(offer->description());
ASSERT_TRUE(video_desc != nullptr);
ASSERT_EQ(1u, video_desc->streams().size());
- EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].sync_label);
+ EXPECT_EQ(kStreamLabel1, video_desc->streams()[0].first_stream_label());
}
// Test that we can specify a certain track that we want statistics about.
diff --git a/pc/webrtcsdp.cc b/pc/webrtcsdp.cc
index e796f4c..2a626f8 100644
--- a/pc/webrtcsdp.cc
+++ b/pc/webrtcsdp.cc
@@ -634,7 +634,7 @@
}
track->add_ssrc(ssrc_info->ssrc_id);
track->cname = ssrc_info->cname;
- track->sync_label = stream_id;
+ track->set_stream_labels({stream_id});
track->id = track_id;
}
}
@@ -643,7 +643,9 @@
std::set<std::string>* labels) {
for (const StreamParams& stream_params :
content->media_description()->streams()) {
- labels->insert(stream_params.sync_label);
+ for (const std::string& stream_label : stream_params.stream_labels()) {
+ labels->insert(stream_label);
+ }
}
}
@@ -1476,7 +1478,9 @@
const StreamParamsVec& streams = media_desc->streams();
if (streams.size() == 1u) {
const StreamParams& track = streams[0];
- const std::string& stream_id = track.sync_label;
+ // TODO(bugs.webrtc.org/7932): Support serializing more than one stream
+ // label.
+ const std::string& stream_id = track.first_stream_label();
InitAttrLine(kAttributeMsid, &os);
os << kSdpDelimiterColon << stream_id << kSdpDelimiterSpace << track.id;
AddLine(os.str(), message);
@@ -1528,11 +1532,12 @@
for (StreamParamsVec::const_iterator track = media_desc->streams().begin();
track != media_desc->streams().end(); ++track) {
- // Require that the track belongs to a media stream,
- // ie the sync_label is set. This extra check is necessary since the
- // MediaContentDescription always contains a streamparam with an ssrc even
- // if no track or media stream have been created.
- if (track->sync_label.empty()) continue;
+ // Require that the track belongs to a media stream. This extra check is
+ // necessary since the MediaContentDescription always contains a
+ // StreamParams with an ssrc even if no track or media stream have been
+ // created.
+ if (track->stream_labels().empty())
+ continue;
// Build the ssrc-group lines.
for (size_t i = 0; i < track->ssrc_groups.size(); ++i) {
@@ -1563,7 +1568,9 @@
// a=ssrc:<ssrc-id> msid:identifier [appdata]
// The appdata consists of the "id" attribute of a MediaStreamTrack,
// which corresponds to the "id" attribute of StreamParams.
- const std::string& stream_id = track->sync_label;
+ // TODO(bugs.webrtc.org/7932): Support serializing more than one stream
+ // label.
+ const std::string& stream_id = track->first_stream_label();
InitAttrLine(kAttributeSsrc, &os);
os << kSdpDelimiterColon << ssrc << kSdpDelimiterSpace
<< kSsrcAttributeMsid << kSdpDelimiterColon << stream_id
@@ -1576,7 +1583,8 @@
// a=ssrc:<ssrc-id> mslabel:<value>
// The label isn't yet defined.
// a=ssrc:<ssrc-id> label:<value>
- AddSsrcLine(ssrc, kSsrcAttributeMslabel, track->sync_label, message);
+ AddSsrcLine(ssrc, kSsrcAttributeMslabel, track->first_stream_label(),
+ message);
AddSsrcLine(ssrc, kSSrcAttributeLabel, track->id, message);
}
}
diff --git a/pc/webrtcsdp_unittest.cc b/pc/webrtcsdp_unittest.cc
index c268b04..c0e07e0 100644
--- a/pc/webrtcsdp_unittest.cc
+++ b/pc/webrtcsdp_unittest.cc
@@ -874,7 +874,7 @@
StreamParams audio_stream;
audio_stream.id = kAudioTrackId1;
audio_stream.cname = kStream1Cname;
- audio_stream.sync_label = kStreamLabel1;
+ audio_stream.set_stream_labels({kStreamLabel1});
audio_stream.ssrcs.push_back(kAudioTrack1Ssrc);
audio_desc_->AddStream(audio_stream);
rtc::SocketAddress audio_addr("74.125.127.126", 2345);
@@ -886,7 +886,7 @@
StreamParams video_stream;
video_stream.id = kVideoTrackId1;
video_stream.cname = kStream1Cname;
- video_stream.sync_label = kStreamLabel1;
+ video_stream.set_stream_labels({kStreamLabel1});
video_stream.ssrcs.push_back(kVideoTrack1Ssrc1);
video_stream.ssrcs.push_back(kVideoTrack1Ssrc2);
cricket::SsrcGroup ssrc_group(kFecSsrcGroupSemantics, video_stream.ssrcs);
@@ -1055,21 +1055,21 @@
StreamParams audio_track_2;
audio_track_2.id = kAudioTrackId2;
audio_track_2.cname = kStream2Cname;
- audio_track_2.sync_label = kStreamLabel2;
+ audio_track_2.set_stream_labels({kStreamLabel2});
audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc);
audio_desc_->AddStream(audio_track_2);
StreamParams video_track_2;
video_track_2.id = kVideoTrackId2;
video_track_2.cname = kStream2Cname;
- video_track_2.sync_label = kStreamLabel2;
+ video_track_2.set_stream_labels({kStreamLabel2});
video_track_2.ssrcs.push_back(kVideoTrack2Ssrc);
video_desc_->AddStream(video_track_2);
StreamParams video_track_3;
video_track_3.id = kVideoTrackId3;
video_track_3.cname = kStream2Cname;
- video_track_3.sync_label = kStreamLabel2;
+ video_track_3.set_stream_labels({kStreamLabel2});
video_track_3.ssrcs.push_back(kVideoTrack3Ssrc);
video_desc_->AddStream(video_track_3);
@@ -1090,7 +1090,7 @@
StreamParams audio_track_2;
audio_track_2.id = kAudioTrackId2;
audio_track_2.cname = kStream2Cname;
- audio_track_2.sync_label = kStreamLabel2;
+ audio_track_2.set_stream_labels({kStreamLabel2});
audio_track_2.ssrcs.push_back(kAudioTrack2Ssrc);
audio_desc_2->AddStream(audio_track_2);
desc_.AddContent(kAudioContentName2, MediaProtocolType::kRtp, audio_desc_2);
@@ -1101,7 +1101,7 @@
StreamParams video_track_2;
video_track_2.id = kVideoTrackId2;
video_track_2.cname = kStream2Cname;
- video_track_2.sync_label = kStreamLabel2;
+ video_track_2.set_stream_labels({kStreamLabel2});
video_track_2.ssrcs.push_back(kVideoTrack2Ssrc);
video_desc_2->AddStream(video_track_2);
desc_.AddContent(kVideoContentName2, MediaProtocolType::kRtp, video_desc_2);
@@ -1113,7 +1113,7 @@
StreamParams video_track_3;
video_track_3.id = kVideoTrackId3;
video_track_3.cname = kStream2Cname;
- video_track_3.sync_label = kStreamLabel2;
+ video_track_3.set_stream_labels({kStreamLabel2});
video_track_3.ssrcs.push_back(kVideoTrack3Ssrc);
video_desc_3->AddStream(video_track_3);
desc_.AddContent(kVideoContentName3, MediaProtocolType::kRtp, video_desc_3);
@@ -1518,7 +1518,7 @@
StreamParams data_stream;
data_stream.id = kDataChannelMsid;
data_stream.cname = kDataChannelCname;
- data_stream.sync_label = kDataChannelLabel;
+ data_stream.set_stream_labels({kDataChannelLabel});
data_stream.ssrcs.push_back(kDataChannelSsrc);
data_desc_->AddStream(data_stream);
data_desc_->AddCrypto(CryptoParams(