Index: webrtc/media/engine/webrtcvideoengine2.cc |
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc |
index bd7774c045446db202d93383ec4fc7cb0313961d..6bd4b056847648cb8fc7ced32604234760e22b02 100644 |
--- a/webrtc/media/engine/webrtcvideoengine2.cc |
+++ b/webrtc/media/engine/webrtcvideoengine2.cc |
@@ -20,8 +20,6 @@ |
#include "webrtc/base/timeutils.h" |
#include "webrtc/base/trace_event.h" |
#include "webrtc/call.h" |
-#include "webrtc/media/base/videocapturer.h" |
-#include "webrtc/media/base/videorenderer.h" |
#include "webrtc/media/engine/constants.h" |
#include "webrtc/media/engine/simulcast.h" |
#include "webrtc/media/engine/webrtcmediaengine.h" |
@@ -1267,22 +1265,22 @@ void WebRtcVideoChannel2::FillBandwidthEstimationStats( |
video_media_info->bw_estimations.push_back(bwe_info); |
} |
-bool WebRtcVideoChannel2::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { |
- LOG(LS_INFO) << "SetCapturer: " << ssrc << " -> " |
- << (capturer != NULL ? "(capturer)" : "NULL"); |
- RTC_DCHECK(ssrc != 0); |
- { |
- rtc::CritScope stream_lock(&stream_crit_); |
- const auto& kv = send_streams_.find(ssrc); |
- if (kv == send_streams_.end()) { |
- LOG(LS_ERROR) << "No sending stream on ssrc " << ssrc; |
- return false; |
- } |
- if (!kv->second->SetCapturer(capturer)) { |
- return false; |
- } |
+void WebRtcVideoChannel2::SetSource( |
+ uint32_t ssrc, |
+ rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
+ LOG(LS_INFO) << "SetSource: " << ssrc << " -> " |
+ << (source ? "(source)" : "NULL"); |
+ RTC_CHECK(ssrc != 0); |
+ |
+ rtc::CritScope stream_lock(&stream_crit_); |
+ const auto& kv = send_streams_.find(ssrc); |
+ if (kv == send_streams_.end()) { |
+ // Allow unknown ssrc only if source is null. |
+ RTC_CHECK(source == nullptr); |
+ } |
+ else { |
+ send_streams_.find(ssrc)->second->SetSource(source); |
pthatcher1
2016/03/05 01:45:41
Why not kv->second->SetSource(source)?
nisse-webrtc
2016/03/15 16:28:00
Done.
|
} |
- return true; |
} |
void WebRtcVideoChannel2::OnPacketReceived( |
@@ -1483,7 +1481,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
call_(call), |
cpu_restricted_counter_(0), |
number_of_cpu_adapt_changes_(0), |
- capturer_(nullptr), |
+ source_(nullptr), |
external_encoder_factory_(external_encoder_factory), |
stream_(nullptr), |
parameters_(config, send_params.options, max_bitrate_bps, codec_settings), |
@@ -1516,7 +1514,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
} |
WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { |
- DisconnectCapturer(); |
+ DisconnectSource(); |
if (stream_ != NULL) { |
call_->DestroyVideoSendStream(stream_); |
} |
@@ -1554,6 +1552,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( |
if (!sending_) |
return; |
+ // TODO(nisse): Keep? |
pthatcher1
2016/03/05 01:45:41
Yes, we need to keep this. It's part of the stand
nisse-webrtc
2016/03/15 16:28:00
A while ago, I added similar logic in the VideoTra
pthatcher1
2016/03/15 16:56:45
Yes, I saw that CL while Per was here. If the Vid
|
if (muted_) { |
// Create a black frame to transmit instead. |
CreateBlackFrame(&video_frame, |
@@ -1577,13 +1576,14 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( |
stream_->Input()->IncomingCapturedFrame(video_frame); |
} |
-bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( |
- VideoCapturer* capturer) { |
- TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetCapturer"); |
+void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( |
+ rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
+ TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetSource"); |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- if (!DisconnectCapturer() && capturer == NULL) { |
- return false; |
- } |
+ |
+ if (!source && !source_) |
+ return; |
+ DisconnectSource(); |
{ |
rtc::CritScope cs(&lock_); |
@@ -1592,7 +1592,7 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( |
// new capturer may have a different timestamp delta than the previous one. |
first_frame_timestamp_ms_ = 0; |
- if (capturer == NULL) { |
+ if (source == NULL) { |
if (stream_ != NULL) { |
LOG(LS_VERBOSE) << "Disabling capturer, sending black frame."; |
webrtc::VideoFrame black_frame; |
@@ -1609,14 +1609,11 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( |
black_frame.set_render_time_ms(last_frame_timestamp_ms_); |
stream_->Input()->IncomingCapturedFrame(black_frame); |
} |
- |
- capturer_ = NULL; |
- return true; |
} |
} |
- capturer_ = capturer; |
- capturer_->AddOrUpdateSink(this, sink_wants_); |
- return true; |
+ source_ = source; |
+ if (source_) |
+ source_->AddOrUpdateSink(this, sink_wants_); |
pthatcher1
2016/03/05 01:45:41
{} please
nisse-webrtc
2016/03/15 16:28:00
Done.
|
} |
void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { |
@@ -1624,20 +1621,19 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::MuteStream(bool mute) { |
muted_ = mute; |
} |
-bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { |
+void WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectSource() { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- if (capturer_ == NULL) { |
- return false; |
+ if (source_ == NULL) { |
+ return; |
} |
- capturer_->RemoveSink(this); |
- capturer_ = NULL; |
+ source_->RemoveSink(this); |
+ source_ = NULL; |
// Reset |cpu_restricted_counter_| if the capturer is changed. It is not |
// possible to know if the video resolution is restricted by CPU usage after |
// the capturer is changed since the next capturer might be screen capture |
// with another resolution and frame rate. |
cpu_restricted_counter_ = 0; |
- return true; |
} |
const std::vector<uint32_t>& |
@@ -1766,8 +1762,8 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( |
parameters_.config.rtp.extensions = *params.rtp_header_extensions; |
sink_wants_.rotation_applied = !ContainsHeaderExtension( |
*params.rtp_header_extensions, kRtpVideoRotationHeaderExtension); |
- if (capturer_) { |
- capturer_->AddOrUpdateSink(this, sink_wants_); |
+ if (source_) { |
+ source_->AddOrUpdateSink(this, sink_wants_); |
} |
recreate_stream = true; |
} |
@@ -1913,7 +1909,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) { |
return; |
} |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
- if (!capturer_) { |
+ if (!source_) { |
return; |
} |
{ |
@@ -1960,7 +1956,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) { |
sink_wants_.max_pixel_count = max_pixel_count; |
sink_wants_.max_pixel_count_step_up = max_pixel_count_step_up; |
} |
- capturer_->AddOrUpdateSink(this, sink_wants_); |
+ source_->AddOrUpdateSink(this, sink_wants_); |
} |
VideoSenderInfo |
@@ -1995,11 +1991,14 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { |
? CoordinatedVideoAdapter::ADAPTREASON_NONE |
: CoordinatedVideoAdapter::ADAPTREASON_CPU; |
- if (capturer_) { |
+ if (source_) { |
VideoFormat last_captured_frame_format; |
+ // TODO(nisse): Move stats logic elsewhere? |
+#if 0 |
capturer_->GetStats(&info.adapt_frame_drops, &info.effects_frame_drops, |
&info.capturer_frame_time, |
&last_captured_frame_format); |
+#endif |
pthatcher1
2016/03/05 01:45:41
What?
nisse-webrtc
2016/03/15 16:28:00
To get the cl in a landable state, we have to figu
pthatcher1
2016/03/15 16:56:45
adapt_frame_drops, effects_frame_drops, and captur
|
info.input_frame_width = last_captured_frame_format.width; |
info.input_frame_height = last_captured_frame_format.height; |
} |