OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #ifndef WEBRTC_VIDEO_VIE_ENCODER_H_ | 11 #ifndef WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_ |
12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ | 12 #define WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/api/video/video_rotation.h" | 19 #include "webrtc/api/video/video_rotation.h" |
20 #include "webrtc/api/video_codecs/video_encoder.h" | 20 #include "webrtc/api/video_codecs/video_encoder.h" |
21 #include "webrtc/call/call.h" | 21 #include "webrtc/call/call.h" |
22 #include "webrtc/common_types.h" | 22 #include "webrtc/common_types.h" |
(...skipping 10 matching lines...) Expand all Loading... |
33 #include "webrtc/typedefs.h" | 33 #include "webrtc/typedefs.h" |
34 #include "webrtc/video/overuse_frame_detector.h" | 34 #include "webrtc/video/overuse_frame_detector.h" |
35 #include "webrtc/video_send_stream.h" | 35 #include "webrtc/video_send_stream.h" |
36 | 36 |
37 namespace webrtc { | 37 namespace webrtc { |
38 | 38 |
39 class ProcessThread; | 39 class ProcessThread; |
40 class SendStatisticsProxy; | 40 class SendStatisticsProxy; |
41 class VideoBitrateAllocationObserver; | 41 class VideoBitrateAllocationObserver; |
42 | 42 |
43 // VieEncoder represent a video encoder that accepts raw video frames as input | 43 // VideoStreamEncoder represent a video encoder that accepts raw video frames as |
44 // and produces an encoded bit stream. | 44 // input and produces an encoded bit stream. |
45 // Usage: | 45 // Usage: |
46 // Instantiate. | 46 // Instantiate. |
47 // Call SetSink. | 47 // Call SetSink. |
48 // Call SetSource. | 48 // Call SetSource. |
49 // Call ConfigureEncoder with the codec settings. | 49 // Call ConfigureEncoder with the codec settings. |
50 // Call Stop() when done. | 50 // Call Stop() when done. |
51 class ViEEncoder : public rtc::VideoSinkInterface<VideoFrame>, | 51 class VideoStreamEncoder : public rtc::VideoSinkInterface<VideoFrame>, |
52 public EncodedImageCallback, | 52 public EncodedImageCallback, |
53 public VCMSendStatisticsCallback, | 53 public VCMSendStatisticsCallback, |
54 public AdaptationObserverInterface { | 54 public AdaptationObserverInterface { |
55 public: | 55 public: |
56 // Interface for receiving encoded video frames and notifications about | 56 // Interface for receiving encoded video frames and notifications about |
57 // configuration changes. | 57 // configuration changes. |
58 class EncoderSink : public EncodedImageCallback { | 58 class EncoderSink : public EncodedImageCallback { |
59 public: | 59 public: |
60 virtual void OnEncoderConfigurationChanged( | 60 virtual void OnEncoderConfigurationChanged( |
61 std::vector<VideoStream> streams, | 61 std::vector<VideoStream> streams, |
62 int min_transmit_bitrate_bps) = 0; | 62 int min_transmit_bitrate_bps) = 0; |
63 }; | 63 }; |
64 | 64 |
65 // Number of resolution and framerate reductions (-1: disabled). | 65 // Number of resolution and framerate reductions (-1: disabled). |
66 struct AdaptCounts { | 66 struct AdaptCounts { |
67 int resolution = 0; | 67 int resolution = 0; |
68 int fps = 0; | 68 int fps = 0; |
69 }; | 69 }; |
70 | 70 |
71 // Downscale resolution at most 2 times for CPU reasons. | 71 // Downscale resolution at most 2 times for CPU reasons. |
72 static const int kMaxCpuResolutionDowngrades = 2; | 72 static const int kMaxCpuResolutionDowngrades = 2; |
73 // Downscale framerate at most 4 times. | 73 // Downscale framerate at most 4 times. |
74 static const int kMaxCpuFramerateDowngrades = 4; | 74 static const int kMaxCpuFramerateDowngrades = 4; |
75 | 75 |
76 ViEEncoder(uint32_t number_of_cores, | 76 VideoStreamEncoder(uint32_t number_of_cores, |
77 SendStatisticsProxy* stats_proxy, | 77 SendStatisticsProxy* stats_proxy, |
78 const VideoSendStream::Config::EncoderSettings& settings, | 78 const VideoSendStream::Config::EncoderSettings& settings, |
79 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 79 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
80 EncodedFrameObserver* encoder_timing, | 80 EncodedFrameObserver* encoder_timing, |
81 std::unique_ptr<OveruseFrameDetector> overuse_detector); | 81 std::unique_ptr<OveruseFrameDetector> overuse_detector); |
82 ~ViEEncoder(); | 82 ~VideoStreamEncoder(); |
83 // RegisterProcessThread register |module_process_thread| with those objects | 83 // RegisterProcessThread register |module_process_thread| with those objects |
84 // that use it. Registration has to happen on the thread where | 84 // that use it. Registration has to happen on the thread where |
85 // |module_process_thread| was created (libjingle's worker thread). | 85 // |module_process_thread| was created (libjingle's worker thread). |
86 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. | 86 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. |
87 void RegisterProcessThread(ProcessThread* module_process_thread); | 87 void RegisterProcessThread(ProcessThread* module_process_thread); |
88 void DeRegisterProcessThread(); | 88 void DeRegisterProcessThread(); |
89 | 89 |
90 // Sets the source that will provide I420 video frames. | 90 // Sets the source that will provide I420 video frames. |
91 // |degradation_preference| control whether or not resolution or frame rate | 91 // |degradation_preference| control whether or not resolution or frame rate |
92 // may be reduced. | 92 // may be reduced. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); | 236 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); |
237 std::unique_ptr<OveruseFrameDetector> overuse_detector_ | 237 std::unique_ptr<OveruseFrameDetector> overuse_detector_ |
238 ACCESS_ON(&encoder_queue_); | 238 ACCESS_ON(&encoder_queue_); |
239 std::unique_ptr<QualityScaler> quality_scaler_ ACCESS_ON(&encoder_queue_); | 239 std::unique_ptr<QualityScaler> quality_scaler_ ACCESS_ON(&encoder_queue_); |
240 | 240 |
241 SendStatisticsProxy* const stats_proxy_; | 241 SendStatisticsProxy* const stats_proxy_; |
242 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 242 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
243 ProcessThread* module_process_thread_; | 243 ProcessThread* module_process_thread_; |
244 rtc::ThreadChecker module_process_thread_checker_; | 244 rtc::ThreadChecker module_process_thread_checker_; |
245 // |thread_checker_| checks that public methods that are related to lifetime | 245 // |thread_checker_| checks that public methods that are related to lifetime |
246 // of ViEEncoder are called on the same thread. | 246 // of VideoStreamEncoder are called on the same thread. |
247 rtc::ThreadChecker thread_checker_; | 247 rtc::ThreadChecker thread_checker_; |
248 | 248 |
249 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_); | 249 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_); |
250 std::unique_ptr<VideoBitrateAllocator> rate_allocator_ | 250 std::unique_ptr<VideoBitrateAllocator> rate_allocator_ |
251 ACCESS_ON(&encoder_queue_); | 251 ACCESS_ON(&encoder_queue_); |
252 // The maximum frame rate of the current codec configuration, as determined | 252 // The maximum frame rate of the current codec configuration, as determined |
253 // at the last ReconfigureEncoder() call. | 253 // at the last ReconfigureEncoder() call. |
254 int max_framerate_ ACCESS_ON(&encoder_queue_); | 254 int max_framerate_ ACCESS_ON(&encoder_queue_); |
255 | 255 |
256 // Set when ConfigureEncoder has been called in order to lazy reconfigure the | 256 // Set when ConfigureEncoder has been called in order to lazy reconfigure the |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 int captured_frame_count_ ACCESS_ON(&encoder_queue_); | 301 int captured_frame_count_ ACCESS_ON(&encoder_queue_); |
302 int dropped_frame_count_ ACCESS_ON(&encoder_queue_); | 302 int dropped_frame_count_ ACCESS_ON(&encoder_queue_); |
303 | 303 |
304 VideoBitrateAllocationObserver* bitrate_observer_ ACCESS_ON(&encoder_queue_); | 304 VideoBitrateAllocationObserver* bitrate_observer_ ACCESS_ON(&encoder_queue_); |
305 rtc::Optional<int64_t> last_parameters_update_ms_ ACCESS_ON(&encoder_queue_); | 305 rtc::Optional<int64_t> last_parameters_update_ms_ ACCESS_ON(&encoder_queue_); |
306 | 306 |
307 // All public methods are proxied to |encoder_queue_|. It must must be | 307 // All public methods are proxied to |encoder_queue_|. It must must be |
308 // destroyed first to make sure no tasks are run that use other members. | 308 // destroyed first to make sure no tasks are run that use other members. |
309 rtc::TaskQueue encoder_queue_; | 309 rtc::TaskQueue encoder_queue_; |
310 | 310 |
311 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); | 311 RTC_DISALLOW_COPY_AND_ASSIGN(VideoStreamEncoder); |
312 }; | 312 }; |
313 | 313 |
314 } // namespace webrtc | 314 } // namespace webrtc |
315 | 315 |
316 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 316 #endif // WEBRTC_VIDEO_VIDEO_STREAM_ENCODER_H_ |
OLD | NEW |