Chromium Code Reviews| Index: webrtc/video/vie_encoder.h |
| diff --git a/webrtc/video/vie_encoder.h b/webrtc/video/vie_encoder.h |
| index 68f043e1c5818e876b5e0166deab1dbc785ab325..47658d09bbfe639ae22b8e341b453082640f4a12 100644 |
| --- a/webrtc/video/vie_encoder.h |
| +++ b/webrtc/video/vie_encoder.h |
| @@ -60,11 +60,13 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
| int min_transmit_bitrate_bps) = 0; |
| }; |
| + // Down grade resolution at most 2 times for CPU reasons. |
| + static const int kMaxCpuDowngrades = 2; |
|
kthelgason
2016/10/19 12:06:45
Why two? Should this be configurable somewhere?
perkj_webrtc
2016/10/26 16:40:17
I don't want to change behaviour in this cl. That
|
| + |
| ViEEncoder(uint32_t number_of_cores, |
| SendStatisticsProxy* stats_proxy, |
| const webrtc::VideoSendStream::Config::EncoderSettings& settings, |
| rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
| - LoadObserver* overuse_callback, |
| EncodedFrameObserver* encoder_timing); |
| ~ViEEncoder(); |
| // RegisterProcessThread register |module_process_thread| with those objects |
| @@ -74,8 +76,16 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
| void RegisterProcessThread(ProcessThread* module_process_thread); |
| void DeRegisterProcessThread(); |
| - void SetSource(rtc::VideoSourceInterface<VideoFrame>* source); |
| - void SetSink(EncoderSink* sink); |
| + // Sets the source that will provide I420 video frames. |
| + // |disable_resolution| means that this encoder will not request |source| to |
|
åsapersson
2016/10/24 07:54:06
|disable_resolution_scaling|
perkj_webrtc
2016/10/26 16:40:17
Change not to preferences.
|
| + // lower the resolution due to CPU adaptation. |
| + void SetSource(rtc::VideoSourceInterface<VideoFrame>* source, |
| + bool disable_resolution_scaling); |
| + |
| + // Sets the |sink| that gets the encoded frames. |rotation_applied| means |
| + // that the source must support rotation. Only set |rotation_applied| if the |
| + // remote side does not support the rotation extension. |
| + void SetSink(EncoderSink* sink, bool rotation_applied); |
| // TODO(perkj): Can we remove VideoCodec.startBitrate ? |
| void SetStartBitrate(int start_bitrate_bps); |
| @@ -98,6 +108,18 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
| uint8_t fraction_lost, |
| int64_t round_trip_time_ms); |
| + protected: |
| + // Used for testing. For example the |CpuOveruseObserver| methods must be |
| + // called on |encoder_queue_|. |
| + rtc::TaskQueue* encoder_queue() { return &encoder_queue_; } |
| + |
| + // webrtc::CpuOveruseObserver implementation. |
| + // These methods are protected for easier testing. |
| + void OveruseDetected() override; |
| + void NormalUsage() override; |
| + |
| + bool OveruseFrameDetectionEnabled() const; |
| + |
| private: |
| class ConfigureEncoderTask; |
| class EncodeTask; |
| @@ -138,10 +160,6 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
| const CodecSpecificInfo* codec_specific_info, |
| const RTPFragmentationHeader* fragmentation) override; |
| - // webrtc::CpuOveruseObserver implementation. |
| - void OveruseDetected() override; |
| - void NormalUsage() override; |
| - |
| bool EncoderPaused() const; |
| void TraceFrameDropStart(); |
| void TraceFrameDropEnd(); |
| @@ -156,12 +174,12 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
| const VideoCodecType codec_type_; |
| vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); |
| - |
| - OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); |
| - LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); |
| + std::unique_ptr<OveruseFrameDetector> overuse_detector_ |
| + ACCESS_ON(&encoder_queue_); |
| SendStatisticsProxy* const stats_proxy_; |
| rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
| + EncodedFrameObserver* const encoder_timing_; |
| ProcessThread* module_process_thread_; |
| rtc::ThreadChecker module_process_thread_checker_; |
| // |thread_checker_| checks that public methods that are related to lifetime |
| @@ -188,6 +206,16 @@ class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
| bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); |
| uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); |
| Clock* const clock_; |
| + // Counter used for deciding if the video resolution is currently |
| + // restricted by CPU usage. It is reset if |source_| is changed. |
|
åsapersson
2016/10/24 07:54:06
Could not see where it is reset.
perkj_webrtc
2016/10/26 16:40:17
Actually it is not. Removed comment.
|
| + int cpu_restricted_counter_; // ACCESS_ON(&encoder_queue_); |
|
åsapersson
2016/10/24 07:54:06
Should access_on be commented out?
perkj_webrtc
2016/10/26 16:40:17
oops
|
| + |
| + int last_frame_width_; // ACCESS_ON(&encoder_queue_); |
| + int last_frame_height_; // ACCESS_ON(&encoder_queue_); |
| + // Resolution has been requested to be less than |max_pixel_count_|. |
| + rtc::Optional<int> max_pixel_count_; // ACCESS_ON(&encoder_queue_); |
| + // Resolution has been requested to higher than |max_pixel_count_step_up_|. |
| + rtc::Optional<int> max_pixel_count_step_up_; // ACCESS_ON(&encoder_queue_); |
| rtc::RaceChecker incoming_frame_race_checker_; |
| Atomic32 posted_frames_waiting_for_encode_; |