Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1024)

Unified Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 1822923002: Adding support for RTCRtpEncodingParameters.active flag. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing DCHECKs. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoengine2.cc
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc
index 3cff1e6fbd63778fa4a72721d0d4beac49f4a51e..d46e6c858585aba06a1e76ffb9693c602881796a 100644
--- a/webrtc/media/engine/webrtcvideoengine2.cc
+++ b/webrtc/media/engine/webrtcvideoengine2.cc
@@ -877,7 +877,7 @@ webrtc::RtpParameters WebRtcVideoChannel2::GetRtpParameters(
return webrtc::RtpParameters();
}
- return it->second->rtp_parameters();
+ return it->second->GetRtpParameters();
}
bool WebRtcVideoChannel2::SetRtpParameters(
@@ -990,10 +990,11 @@ bool WebRtcVideoChannel2::SetSend(bool send) {
LOG(LS_ERROR) << "SetSend(true) called before setting codec.";
return false;
}
- if (send) {
- StartAllSendStreams();
- } else {
- StopAllSendStreams();
+ {
+ rtc::CritScope stream_lock(&stream_crit_);
+ for (const auto& kv : send_streams_) {
+ kv.second->SetSend(send);
+ }
}
sending_ = send;
return true;
@@ -1076,7 +1077,7 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) {
default_send_ssrc_ = ssrc;
}
if (sending_) {
- stream->Start();
+ stream->SetSend(true);
}
return true;
@@ -1482,24 +1483,6 @@ bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) {
return MediaChannel::SendRtcp(&packet, rtc::PacketOptions());
}
-void WebRtcVideoChannel2::StartAllSendStreams() {
- rtc::CritScope stream_lock(&stream_crit_);
- for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
- send_streams_.begin();
- it != send_streams_.end(); ++it) {
- it->second->Start();
- }
-}
-
-void WebRtcVideoChannel2::StopAllSendStreams() {
- rtc::CritScope stream_lock(&stream_crit_);
- for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
- send_streams_.begin();
- it != send_streams_.end(); ++it) {
- it->second->Stop();
- }
-}
-
WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters::
VideoSendStreamParameters(
const webrtc::VideoSendStream::Config& config,
@@ -1882,9 +1865,17 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpParameters(
pending_encoder_reconfiguration_ = true;
}
rtp_parameters_ = new_parameters;
+ // Encoding may have been activated/deactivated.
+ UpdateSendState();
return true;
}
+webrtc::RtpParameters
+WebRtcVideoChannel2::WebRtcVideoSendStream::GetRtpParameters() const {
+ rtc::CritScope cs(&lock_);
+ return rtp_parameters_;
+}
+
bool WebRtcVideoChannel2::WebRtcVideoSendStream::ValidateRtpParameters(
const webrtc::RtpParameters& rtp_parameters) {
if (rtp_parameters.encodings.size() != 1) {
@@ -1895,6 +1886,19 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::ValidateRtpParameters(
return true;
}
+void WebRtcVideoChannel2::WebRtcVideoSendStream::UpdateSendState() {
+ // TODO(deadbeef): Need to handle more than one encoding in the future.
+ RTC_DCHECK(rtp_parameters_.encodings.size() == 1u);
+ if (sending_ && rtp_parameters_.encodings[0].active) {
+ RTC_DCHECK(stream_ != nullptr);
+ stream_->Start();
+ } else {
+ if (stream_ != nullptr) {
+ stream_->Stop();
+ }
+ }
+}
+
webrtc::VideoEncoderConfig
WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
const Dimensions& dimensions,
@@ -1994,19 +1998,10 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions(
parameters_.encoder_config = encoder_config;
}
-void WebRtcVideoChannel2::WebRtcVideoSendStream::Start() {
+void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSend(bool send) {
rtc::CritScope cs(&lock_);
- RTC_DCHECK(stream_ != NULL);
- stream_->Start();
- sending_ = true;
-}
-
-void WebRtcVideoChannel2::WebRtcVideoSendStream::Stop() {
- rtc::CritScope cs(&lock_);
- if (stream_ != NULL) {
- stream_->Stop();
- }
- sending_ = false;
+ sending_ = send;
+ UpdateSendState();
}
void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) {
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698