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 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 virtual void OnReceivedIntraFrameRequest(size_t stream_index); | 92 virtual void OnReceivedIntraFrameRequest(size_t stream_index); |
93 virtual void OnReceivedSLI(uint8_t picture_id); | 93 virtual void OnReceivedSLI(uint8_t picture_id); |
94 virtual void OnReceivedRPSI(uint64_t picture_id); | 94 virtual void OnReceivedRPSI(uint64_t picture_id); |
95 | 95 |
96 void OnBitrateUpdated(uint32_t bitrate_bps, | 96 void OnBitrateUpdated(uint32_t bitrate_bps, |
97 uint8_t fraction_lost, | 97 uint8_t fraction_lost, |
98 int64_t round_trip_time_ms); | 98 int64_t round_trip_time_ms); |
99 | 99 |
100 private: | 100 private: |
101 class EncodeTask; | 101 class EncodeTask; |
| 102 class ConfigureEncoderTask; |
102 class VideoSourceProxy; | 103 class VideoSourceProxy; |
103 class ConfigureEncoderTask; | 104 |
| 105 struct VideoFrameInfo { |
| 106 VideoFrameInfo(int width, |
| 107 int height, |
| 108 VideoRotation rotation, |
| 109 bool is_texture) |
| 110 : width(width), |
| 111 height(height), |
| 112 rotation(rotation), |
| 113 is_texture(is_texture) {} |
| 114 int width; |
| 115 int height; |
| 116 webrtc::VideoRotation rotation; |
| 117 bool is_texture; |
| 118 }; |
104 | 119 |
105 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config, | 120 void ConfigureEncoderOnTaskQueue(VideoEncoderConfig config, |
106 size_t max_data_payload_length); | 121 size_t max_data_payload_length); |
| 122 void ReconfigureEncoder(); |
107 | 123 |
108 // Implements VideoSinkInterface. | 124 // Implements VideoSinkInterface. |
109 void OnFrame(const VideoFrame& video_frame) override; | 125 void OnFrame(const VideoFrame& video_frame) override; |
110 | 126 |
111 // Implements VideoSendStatisticsCallback. | 127 // Implements VideoSendStatisticsCallback. |
112 void SendStatistics(uint32_t bit_rate, | 128 void SendStatistics(uint32_t bit_rate, |
113 uint32_t frame_rate) override; | 129 uint32_t frame_rate) override; |
114 | 130 |
115 void EncodeVideoFrame(const VideoFrame& frame, | 131 void EncodeVideoFrame(const VideoFrame& frame, |
116 int64_t time_when_posted_in_ms); | 132 int64_t time_when_posted_in_ms); |
(...skipping 14 matching lines...) Expand all Loading... |
131 | 147 |
132 rtc::Event shutdown_event_; | 148 rtc::Event shutdown_event_; |
133 | 149 |
134 const uint32_t number_of_cores_; | 150 const uint32_t number_of_cores_; |
135 | 151 |
136 const std::unique_ptr<VideoSourceProxy> source_proxy_; | 152 const std::unique_ptr<VideoSourceProxy> source_proxy_; |
137 EncoderSink* sink_; | 153 EncoderSink* sink_; |
138 const VideoSendStream::Config::EncoderSettings settings_; | 154 const VideoSendStream::Config::EncoderSettings settings_; |
139 const VideoCodecType codec_type_; | 155 const VideoCodecType codec_type_; |
140 | 156 |
141 const std::unique_ptr<VideoProcessing> vp_; | |
142 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); | 157 vcm::VideoSender video_sender_ ACCESS_ON(&encoder_queue_); |
143 | 158 |
144 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); | 159 OveruseFrameDetector overuse_detector_ ACCESS_ON(&encoder_queue_); |
145 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); | 160 LoadObserver* const load_observer_ ACCESS_ON(&encoder_queue_); |
146 | 161 |
147 SendStatisticsProxy* const stats_proxy_; | 162 SendStatisticsProxy* const stats_proxy_; |
148 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; | 163 rtc::VideoSinkInterface<VideoFrame>* const pre_encode_callback_; |
149 ProcessThread* module_process_thread_; | 164 ProcessThread* module_process_thread_; |
150 rtc::ThreadChecker module_process_thread_checker_; | 165 rtc::ThreadChecker module_process_thread_checker_; |
151 // |thread_checker_| checks that public methods that are related to lifetime | 166 // |thread_checker_| checks that public methods that are related to lifetime |
152 // of ViEEncoder are called on the same thread. | 167 // of ViEEncoder are called on the same thread. |
153 rtc::ThreadChecker thread_checker_; | 168 rtc::ThreadChecker thread_checker_; |
154 | 169 |
155 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_); | 170 VideoEncoderConfig encoder_config_ ACCESS_ON(&encoder_queue_); |
156 // TODO(sprang): Change |rate_allocator_| to be a codec type | 171 // TODO(sprang): Change |rate_allocator_| to be a codec type |
157 // agnostic interface. It is currently VP8 simulcast specific if more than | 172 // agnostic interface. It is currently VP8 simulcast specific if more than |
158 // one layer is specified. | 173 // one layer is specified. |
159 std::unique_ptr<SimulcastRateAllocator> rate_allocator_ | 174 std::unique_ptr<SimulcastRateAllocator> rate_allocator_ |
160 ACCESS_ON(&encoder_queue_); | 175 ACCESS_ON(&encoder_queue_); |
161 | 176 |
162 uint32_t encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); | 177 // Set when ConfigureEncoder has been called in order to lazy reconfigure the |
| 178 // encoder on the next frame. |
| 179 bool pending_encoder_reconfiguration_ ACCESS_ON(&encoder_queue_); |
| 180 rtc::Optional<VideoFrameInfo> last_frame_info_ ACCESS_ON(&encoder_queue_); |
| 181 |
| 182 unsigned int encoder_start_bitrate_bps_ ACCESS_ON(&encoder_queue_); |
163 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); | 183 size_t max_data_payload_length_ ACCESS_ON(&encoder_queue_); |
164 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); | 184 uint32_t last_observed_bitrate_bps_ ACCESS_ON(&encoder_queue_); |
165 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); | 185 bool encoder_paused_and_dropped_frame_ ACCESS_ON(&encoder_queue_); |
166 bool has_received_sli_ ACCESS_ON(&encoder_queue_); | 186 bool has_received_sli_ ACCESS_ON(&encoder_queue_); |
167 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); | 187 uint8_t picture_id_sli_ ACCESS_ON(&encoder_queue_); |
168 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); | 188 bool has_received_rpsi_ ACCESS_ON(&encoder_queue_); |
169 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); | 189 uint64_t picture_id_rpsi_ ACCESS_ON(&encoder_queue_); |
170 Clock* const clock_; | 190 Clock* const clock_; |
171 | 191 |
172 rtc::RaceChecker incoming_frame_race_checker_; | 192 rtc::RaceChecker incoming_frame_race_checker_; |
(...skipping 10 matching lines...) Expand all Loading... |
183 // All public methods are proxied to |encoder_queue_|. It must must be | 203 // All public methods are proxied to |encoder_queue_|. It must must be |
184 // destroyed first to make sure no tasks are run that use other members. | 204 // destroyed first to make sure no tasks are run that use other members. |
185 rtc::TaskQueue encoder_queue_; | 205 rtc::TaskQueue encoder_queue_; |
186 | 206 |
187 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); | 207 RTC_DISALLOW_COPY_AND_ASSIGN(ViEEncoder); |
188 }; | 208 }; |
189 | 209 |
190 } // namespace webrtc | 210 } // namespace webrtc |
191 | 211 |
192 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ | 212 #endif // WEBRTC_VIDEO_VIE_ENCODER_H_ |
OLD | NEW |