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_VIE_ENCODER_H_ |
12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ | 12 #define WEBRTC_VIDEO_VIE_ENCODER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/api/video/video_rotation.h" | 18 #include "webrtc/api/video/video_rotation.h" |
| 19 #include "webrtc/api/video/video_content_type.h" |
19 #include "webrtc/base/criticalsection.h" | 20 #include "webrtc/base/criticalsection.h" |
20 #include "webrtc/base/event.h" | 21 #include "webrtc/base/event.h" |
21 #include "webrtc/base/sequenced_task_checker.h" | 22 #include "webrtc/base/sequenced_task_checker.h" |
22 #include "webrtc/base/task_queue.h" | 23 #include "webrtc/base/task_queue.h" |
23 #include "webrtc/call/call.h" | 24 #include "webrtc/call/call.h" |
24 #include "webrtc/common_types.h" | 25 #include "webrtc/common_types.h" |
25 #include "webrtc/common_video/include/video_bitrate_allocator.h" | 26 #include "webrtc/common_video/include/video_bitrate_allocator.h" |
26 #include "webrtc/media/base/videosinkinterface.h" | 27 #include "webrtc/media/base/videosinkinterface.h" |
27 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 28 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
28 #include "webrtc/modules/video_coding/utility/quality_scaler.h" | 29 #include "webrtc/modules/video_coding/utility/quality_scaler.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 int min_transmit_bitrate_bps) = 0; | 62 int min_transmit_bitrate_bps) = 0; |
62 }; | 63 }; |
63 | 64 |
64 // Downscale resolution at most 2 times for CPU reasons. | 65 // Downscale resolution at most 2 times for CPU reasons. |
65 static const int kMaxCpuDowngrades = 2; | 66 static const int kMaxCpuDowngrades = 2; |
66 | 67 |
67 ViEEncoder(uint32_t number_of_cores, | 68 ViEEncoder(uint32_t number_of_cores, |
68 SendStatisticsProxy* stats_proxy, | 69 SendStatisticsProxy* stats_proxy, |
69 const VideoSendStream::Config::EncoderSettings& settings, | 70 const VideoSendStream::Config::EncoderSettings& settings, |
70 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, | 71 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback, |
71 EncodedFrameObserver* encoder_timing); | 72 EncodedFrameObserver* encoder_timing, |
| 73 VideoEncoderConfig::ContentType content_type); |
72 ~ViEEncoder(); | 74 ~ViEEncoder(); |
73 // RegisterProcessThread register |module_process_thread| with those objects | 75 // RegisterProcessThread register |module_process_thread| with those objects |
74 // that use it. Registration has to happen on the thread where | 76 // that use it. Registration has to happen on the thread where |
75 // |module_process_thread| was created (libjingle's worker thread). | 77 // |module_process_thread| was created (libjingle's worker thread). |
76 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. | 78 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue. |
77 void RegisterProcessThread(ProcessThread* module_process_thread); | 79 void RegisterProcessThread(ProcessThread* module_process_thread); |
78 void DeRegisterProcessThread(); | 80 void DeRegisterProcessThread(); |
79 | 81 |
80 // Sets the source that will provide I420 video frames. | 82 // Sets the source that will provide I420 video frames. |
81 // |degradation_preference| control whether or not resolution or frame rate | 83 // |degradation_preference| control whether or not resolution or frame rate |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 private: | 126 private: |
125 class ConfigureEncoderTask; | 127 class ConfigureEncoderTask; |
126 class EncodeTask; | 128 class EncodeTask; |
127 class VideoSourceProxy; | 129 class VideoSourceProxy; |
128 | 130 |
129 class VideoFrameInfo { | 131 class VideoFrameInfo { |
130 public: | 132 public: |
131 VideoFrameInfo(int width, | 133 VideoFrameInfo(int width, |
132 int height, | 134 int height, |
133 VideoRotation rotation, | 135 VideoRotation rotation, |
| 136 VideoContentType content_type, |
134 bool is_texture) | 137 bool is_texture) |
135 : width(width), | 138 : width(width), |
136 height(height), | 139 height(height), |
137 rotation(rotation), | 140 rotation(rotation), |
| 141 content_type_(content_type), |
138 is_texture(is_texture) {} | 142 is_texture(is_texture) {} |
139 int width; | 143 int width; |
140 int height; | 144 int height; |
141 VideoRotation rotation; | 145 VideoRotation rotation; |
| 146 VideoContentType content_type_; |
142 bool is_texture; | 147 bool is_texture; |
143 int pixel_count() const { return width * height; } | 148 int pixel_count() const { return width * height; } |
144 }; | 149 }; |
145 | 150 |
146 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config, | 151 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config, |
147 size_t max_data_payload_length, | 152 size_t max_data_payload_length, |
148 bool nack_enabled); | 153 bool nack_enabled); |
149 void ReconfigureEncoder(); | 154 void ReconfigureEncoder(); |
150 | 155 |
151 void ConfigureQualityScaler(); | 156 void ConfigureQualityScaler(); |
(...skipping 23 matching lines...) Expand all Loading... |
175 rtc::Event shutdown_event_; | 180 rtc::Event shutdown_event_; |
176 | 181 |
177 const uint32_t number_of_cores_; | 182 const uint32_t number_of_cores_; |
178 // Counts how many frames we've dropped in the initial rampup phase. | 183 // Counts how many frames we've dropped in the initial rampup phase. |
179 int initial_rampup_; | 184 int initial_rampup_; |
180 | 185 |
181 const std::unique_ptr<VideoSourceProxy> source_proxy_; | 186 const std::unique_ptr<VideoSourceProxy> source_proxy_; |
182 EncoderSink* sink_; | 187 EncoderSink* sink_; |
183 const VideoSendStream::Config::EncoderSettings settings_; | 188 const VideoSendStream::Config::EncoderSettings settings_; |
184 const VideoCodecType codec_type_; | 189 const VideoCodecType codec_type_; |
| 190 const VideoEncoderConfig::ContentType content_type_; |
185 | 191 |
186 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); | 192 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); |
187 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); | 193 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); |
188 std::unique_ptr<QualityScaler> quality_scaler_ ACCESS_ON(&encoder_queue_); | 194 std::unique_ptr<QualityScaler> quality_scaler_ ACCESS_ON(&encoder_queue_); |
189 | 195 |
190 SendStatisticsProxy* const stats_proxy_; | 196 SendStatisticsProxy* const stats_proxy_; |
191 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 197 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
192 ProcessThread* module_process_thread_; | 198 ProcessThread* module_process_thread_; |
193 rtc::ThreadChecker module_process_thread_checker_; | 199 rtc::ThreadChecker module_process_thread_checker_; |
194 // |thread_checker_| checks that public methods that are related to lifetime | 200 // |thread_checker_| checks that public methods that are related to lifetime |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // All public methods are proxied to |encoder_queue_|. It must must be | 251 // All public methods are proxied to |encoder_queue_|. It must must be |
246 // destroyed first to make sure no tasks are run that use other members. | 252 // destroyed first to make sure no tasks are run that use other members. |
247 rtc::TaskQueue encoder_queue_; | 253 rtc::TaskQueue encoder_queue_; |
248 | 254 |
249 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); | 255 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); |
250 }; | 256 }; |
251 | 257 |
252 } // namespace webrtc | 258 } // namespace webrtc |
253 | 259 |
254 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 260 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |