Chromium Code Reviews| Index: webrtc/video/video_quality_test.cc |
| diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc |
| index 51160c91c6a2e15b23f8b4c90d536e58eba8478f..31a30bc05b39ead916b66df8f549b4eb52f56e4b 100644 |
| --- a/webrtc/video/video_quality_test.cc |
| +++ b/webrtc/video/video_quality_test.cc |
| @@ -99,7 +99,6 @@ namespace webrtc { |
| class VideoAnalyzer : public PacketReceiver, |
| public Transport, |
| public rtc::VideoSinkInterface<VideoFrame>, |
| - public VideoCaptureInput, |
| public EncodedFrameObserver { |
| public: |
| VideoAnalyzer(test::LayerFilteringTransport* transport, |
| @@ -110,8 +109,7 @@ class VideoAnalyzer : public PacketReceiver, |
| FILE* graph_data_output_file, |
| const std::string& graph_title, |
| uint32_t ssrc_to_analyze) |
| - : input_(nullptr), |
| - transport_(transport), |
| + : transport_(transport), |
| receiver_(nullptr), |
| send_stream_(nullptr), |
| test_label_(test_label), |
| @@ -119,6 +117,7 @@ class VideoAnalyzer : public PacketReceiver, |
| graph_title_(graph_title), |
| ssrc_to_analyze_(ssrc_to_analyze), |
| pre_encode_proxy_(this), |
| + input_capture_proxy_(this), |
| encode_timing_proxy_(this), |
| frames_to_process_(duration_frames), |
| frames_recorded_(0), |
| @@ -198,15 +197,9 @@ class VideoAnalyzer : public PacketReceiver, |
| samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; |
| } |
| - void IncomingCapturedFrame(const VideoFrame& video_frame) override { |
| - VideoFrame copy = video_frame; |
| - copy.set_timestamp(copy.ntp_time_ms() * 90); |
| - { |
| - rtc::CritScope lock(&crit_); |
| - frames_.push_back(copy); |
| - } |
| - |
| - input_->IncomingCapturedFrame(video_frame); |
| + void OnCapturedFrame(const VideoFrame& video_frame) { |
| + rtc::CritScope lock(&crit_); |
| + frames_.push_back(video_frame); |
|
stefan-webrtc
2016/09/13 07:19:53
Why did we have to use a copy before but not now?
sprang_webrtc
2016/09/13 08:35:26
Because we now call this method after all the time
|
| } |
| void PreEncodeOnFrame(const VideoFrame& video_frame) { |
| @@ -344,6 +337,9 @@ class VideoAnalyzer : public PacketReceiver, |
| rtc::VideoSinkInterface<VideoFrame>* pre_encode_proxy() { |
| return &pre_encode_proxy_; |
| } |
| + rtc::VideoSinkInterface<VideoFrame>* input_capture_proxy() { |
| + return &input_capture_proxy_; |
| + } |
| EncodedFrameObserver* encode_timing_proxy() { return &encode_timing_proxy_; } |
| VideoCaptureInput* input_; |
| @@ -427,7 +423,8 @@ class VideoAnalyzer : public PacketReceiver, |
| VideoAnalyzer* const parent_; |
| }; |
| - // This class receives the send-side OnFrame callback and is provided to not |
| + // This class receives the send-side OnFrame callback triggered on the encoder |
| + // thread just before encoding the thread. It is provided as a proxy to not |
| // conflict with the receiver-side renderer callback. |
| class PreEncodeProxy : public rtc::VideoSinkInterface<VideoFrame> { |
| public: |
| @@ -441,6 +438,21 @@ class VideoAnalyzer : public PacketReceiver, |
| VideoAnalyzer* const parent_; |
| }; |
| + // This class receives the send-side OnFrame callback triggered when the |
| + // capturer receives a new frame. It is provided as a proxy to not conflict |
| + // with the receiver-side renderer callback. |
| + class InputCaptureProxy : public rtc::VideoSinkInterface<VideoFrame> { |
| + public: |
| + explicit InputCaptureProxy(VideoAnalyzer* parent) : parent_(parent) {} |
| + |
| + void OnFrame(const VideoFrame& video_frame) override { |
| + parent_->OnCapturedFrame(video_frame); |
| + } |
| + |
| + private: |
| + VideoAnalyzer* const parent_; |
| + }; |
| + |
| void AddFrameComparison(const VideoFrame& reference, |
| const VideoFrame& render, |
| bool dropped, |
| @@ -702,6 +714,7 @@ class VideoAnalyzer : public PacketReceiver, |
| const std::string graph_title_; |
| const uint32_t ssrc_to_analyze_; |
| PreEncodeProxy pre_encode_proxy_; |
| + InputCaptureProxy input_capture_proxy_; |
| OnEncodeTimingProxy encode_timing_proxy_; |
| std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); |
| std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); |
| @@ -1118,6 +1131,7 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { |
| SetupCommon(&analyzer, &recv_transport); |
| video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; |
| video_send_config_.pre_encode_callback = analyzer.pre_encode_proxy(); |
| + video_send_config_.local_renderer = analyzer.input_capture_proxy(); |
| for (auto& config : video_receive_configs_) |
| config.pre_decode_callback = &analyzer; |
| RTC_DCHECK(!video_send_config_.post_encode_callback); |
| @@ -1127,10 +1141,9 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { |
| SetupScreenshare(); |
| CreateVideoStreams(); |
| - analyzer.input_ = video_send_stream_->Input(); |
| analyzer.send_stream_ = video_send_stream_; |
| - CreateCapturer(&analyzer); |
| + CreateCapturer(video_send_stream_->Input()); |
| video_send_stream_->Start(); |
| for (VideoReceiveStream* receive_stream : video_receive_streams_) |