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

Side by Side 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: Switch to C++11 for loop. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 *codec = send_codec_->codec; 983 *codec = send_codec_->codec;
984 return true; 984 return true;
985 } 985 }
986 986
987 bool WebRtcVideoChannel2::SetSend(bool send) { 987 bool WebRtcVideoChannel2::SetSend(bool send) {
988 LOG(LS_VERBOSE) << "SetSend: " << (send ? "true" : "false"); 988 LOG(LS_VERBOSE) << "SetSend: " << (send ? "true" : "false");
989 if (send && !send_codec_) { 989 if (send && !send_codec_) {
990 LOG(LS_ERROR) << "SetSend(true) called before setting codec."; 990 LOG(LS_ERROR) << "SetSend(true) called before setting codec.";
991 return false; 991 return false;
992 } 992 }
993 if (send) { 993 {
994 StartAllSendStreams(); 994 rtc::CritScope stream_lock(&stream_crit_);
995 } else { 995 for (const auto& kv : send_streams_) {
996 StopAllSendStreams(); 996 kv.second->SetSend(send);
997 }
997 } 998 }
998 sending_ = send; 999 sending_ = send;
999 return true; 1000 return true;
1000 } 1001 }
1001 1002
1002 bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable, 1003 bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable,
1003 const VideoOptions* options) { 1004 const VideoOptions* options) {
1004 TRACE_EVENT0("webrtc", "SetVideoSend"); 1005 TRACE_EVENT0("webrtc", "SetVideoSend");
1005 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable 1006 LOG(LS_INFO) << "SetVideoSend (ssrc= " << ssrc << ", enable = " << enable
1006 << "options: " << (options ? options->ToString() : "nullptr") 1007 << "options: " << (options ? options->ToString() : "nullptr")
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 rtcp_receiver_report_ssrc_ = ssrc; 1070 rtcp_receiver_report_ssrc_ = ssrc;
1070 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added " 1071 LOG(LS_INFO) << "SetLocalSsrc on all the receive streams because we added "
1071 "a send stream."; 1072 "a send stream.";
1072 for (auto& kv : receive_streams_) 1073 for (auto& kv : receive_streams_)
1073 kv.second->SetLocalSsrc(ssrc); 1074 kv.second->SetLocalSsrc(ssrc);
1074 } 1075 }
1075 if (default_send_ssrc_ == 0) { 1076 if (default_send_ssrc_ == 0) {
1076 default_send_ssrc_ = ssrc; 1077 default_send_ssrc_ = ssrc;
1077 } 1078 }
1078 if (sending_) { 1079 if (sending_) {
1079 stream->Start(); 1080 stream->SetSend(true);
1080 } 1081 }
1081 1082
1082 return true; 1083 return true;
1083 } 1084 }
1084 1085
1085 bool WebRtcVideoChannel2::RemoveSendStream(uint32_t ssrc) { 1086 bool WebRtcVideoChannel2::RemoveSendStream(uint32_t ssrc) {
1086 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; 1087 LOG(LS_INFO) << "RemoveSendStream: " << ssrc;
1087 1088
1088 if (ssrc == 0) { 1089 if (ssrc == 0) {
1089 if (default_send_ssrc_ == 0) { 1090 if (default_send_ssrc_ == 0) {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 rtc::PacketOptions rtc_options; 1476 rtc::PacketOptions rtc_options;
1476 rtc_options.packet_id = options.packet_id; 1477 rtc_options.packet_id = options.packet_id;
1477 return MediaChannel::SendPacket(&packet, rtc_options); 1478 return MediaChannel::SendPacket(&packet, rtc_options);
1478 } 1479 }
1479 1480
1480 bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) { 1481 bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) {
1481 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen); 1482 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen);
1482 return MediaChannel::SendRtcp(&packet, rtc::PacketOptions()); 1483 return MediaChannel::SendRtcp(&packet, rtc::PacketOptions());
1483 } 1484 }
1484 1485
1485 void WebRtcVideoChannel2::StartAllSendStreams() {
1486 rtc::CritScope stream_lock(&stream_crit_);
1487 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
1488 send_streams_.begin();
1489 it != send_streams_.end(); ++it) {
1490 it->second->Start();
1491 }
1492 }
1493
1494 void WebRtcVideoChannel2::StopAllSendStreams() {
1495 rtc::CritScope stream_lock(&stream_crit_);
1496 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
1497 send_streams_.begin();
1498 it != send_streams_.end(); ++it) {
1499 it->second->Stop();
1500 }
1501 }
1502
1503 WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters:: 1486 WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters::
1504 VideoSendStreamParameters( 1487 VideoSendStreamParameters(
1505 const webrtc::VideoSendStream::Config& config, 1488 const webrtc::VideoSendStream::Config& config,
1506 const VideoOptions& options, 1489 const VideoOptions& options,
1507 int max_bitrate_bps, 1490 int max_bitrate_bps,
1508 const rtc::Optional<VideoCodecSettings>& codec_settings) 1491 const rtc::Optional<VideoCodecSettings>& codec_settings)
1509 : config(config), 1492 : config(config),
1510 options(options), 1493 options(options),
1511 max_bitrate_bps(max_bitrate_bps), 1494 max_bitrate_bps(max_bitrate_bps),
1512 codec_settings(codec_settings) {} 1495 codec_settings(codec_settings) {}
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 if (!ValidateRtpParameters(new_parameters)) { 1858 if (!ValidateRtpParameters(new_parameters)) {
1876 return false; 1859 return false;
1877 } 1860 }
1878 1861
1879 rtc::CritScope cs(&lock_); 1862 rtc::CritScope cs(&lock_);
1880 if (new_parameters.encodings[0].max_bitrate_bps != 1863 if (new_parameters.encodings[0].max_bitrate_bps !=
1881 rtp_parameters_.encodings[0].max_bitrate_bps) { 1864 rtp_parameters_.encodings[0].max_bitrate_bps) {
1882 pending_encoder_reconfiguration_ = true; 1865 pending_encoder_reconfiguration_ = true;
1883 } 1866 }
1884 rtp_parameters_ = new_parameters; 1867 rtp_parameters_ = new_parameters;
1868 // Encoding may have been activated/deactivated.
1869 UpdateSendState();
1885 return true; 1870 return true;
1886 } 1871 }
1887 1872
1888 bool WebRtcVideoChannel2::WebRtcVideoSendStream::ValidateRtpParameters( 1873 bool WebRtcVideoChannel2::WebRtcVideoSendStream::ValidateRtpParameters(
1889 const webrtc::RtpParameters& rtp_parameters) { 1874 const webrtc::RtpParameters& rtp_parameters) {
1890 if (rtp_parameters.encodings.size() != 1) { 1875 if (rtp_parameters.encodings.size() != 1) {
1891 LOG(LS_ERROR) 1876 LOG(LS_ERROR)
1892 << "Attempted to set RtpParameters without exactly one encoding"; 1877 << "Attempted to set RtpParameters without exactly one encoding";
1893 return false; 1878 return false;
1894 } 1879 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 codec_settings.codec); 1972 codec_settings.codec);
1988 1973
1989 stream_->ReconfigureVideoEncoder(encoder_config); 1974 stream_->ReconfigureVideoEncoder(encoder_config);
1990 1975
1991 encoder_config.encoder_specific_settings = NULL; 1976 encoder_config.encoder_specific_settings = NULL;
1992 pending_encoder_reconfiguration_ = false; 1977 pending_encoder_reconfiguration_ = false;
1993 1978
1994 parameters_.encoder_config = encoder_config; 1979 parameters_.encoder_config = encoder_config;
1995 } 1980 }
1996 1981
1997 void WebRtcVideoChannel2::WebRtcVideoSendStream::Start() { 1982 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSend(bool send) {
1998 rtc::CritScope cs(&lock_); 1983 rtc::CritScope cs(&lock_);
1999 RTC_DCHECK(stream_ != NULL); 1984 RTC_DCHECK(stream_ != nullptr);
2000 stream_->Start(); 1985 sending_ = send;
2001 sending_ = true; 1986 UpdateSendState();
2002 } 1987 }
2003 1988
2004 void WebRtcVideoChannel2::WebRtcVideoSendStream::Stop() { 1989 void WebRtcVideoChannel2::WebRtcVideoSendStream::UpdateSendState() {
2005 rtc::CritScope cs(&lock_); 1990 rtc::CritScope cs(&lock_);
pbos-webrtc 2016/03/22 18:13:43 Don't take the lock here. (see header comment) Al
Taylor Brandstetter 2016/03/22 18:32:43 Done.
2006 if (stream_ != NULL) { 1991 if (sending_ && rtp_parameters_.encodings[0].active) {
2007 stream_->Stop(); 1992 RTC_DCHECK(stream_ != nullptr);
1993 stream_->Start();
1994 } else {
1995 if (stream_ != nullptr) {
1996 stream_->Stop();
1997 }
2008 } 1998 }
2009 sending_ = false;
2010 } 1999 }
2011 2000
2012 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) { 2001 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) {
2013 if (worker_thread_ != rtc::Thread::Current()) { 2002 if (worker_thread_ != rtc::Thread::Current()) {
2014 invoker_.AsyncInvoke<void>( 2003 invoker_.AsyncInvoke<void>(
2015 worker_thread_, 2004 worker_thread_,
2016 rtc::Bind(&WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate, 2005 rtc::Bind(&WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate,
2017 this, load)); 2006 this, load));
2018 return; 2007 return;
2019 } 2008 }
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 rtx_mapping[video_codecs[i].codec.id] != 2602 rtx_mapping[video_codecs[i].codec.id] !=
2614 fec_settings.red_payload_type) { 2603 fec_settings.red_payload_type) {
2615 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2604 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2616 } 2605 }
2617 } 2606 }
2618 2607
2619 return video_codecs; 2608 return video_codecs;
2620 } 2609 }
2621 2610
2622 } // namespace cricket 2611 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698