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 140 matching lines...) Loading... | |
151 RTC_DCHECK(encoder); | 151 RTC_DCHECK(encoder); |
152 RTC_DCHECK(decoder); | 152 RTC_DCHECK(decoder); |
153 RTC_DCHECK(packet_manipulator); | 153 RTC_DCHECK(packet_manipulator); |
154 RTC_DCHECK(analysis_frame_reader); | 154 RTC_DCHECK(analysis_frame_reader); |
155 RTC_DCHECK(analysis_frame_writer); | 155 RTC_DCHECK(analysis_frame_writer); |
156 RTC_DCHECK(stats); | 156 RTC_DCHECK(stats); |
157 | 157 |
158 frame_infos_.reserve(num_frames_); | 158 frame_infos_.reserve(num_frames_); |
159 } | 159 } |
160 | 160 |
161 VideoProcessorImpl::~VideoProcessorImpl() = default; | |
162 | |
161 bool VideoProcessorImpl::Init() { | 163 bool VideoProcessorImpl::Init() { |
162 RTC_DCHECK(!initialized_) | 164 RTC_DCHECK(!initialized_) |
163 << "This VideoProcessor has already been initialized."; | 165 << "This VideoProcessor has already been initialized."; |
164 | 166 |
165 // Calculate a factor used for bit rate calculations. | 167 // Calculate a factor used for bit rate calculations. |
166 bit_rate_factor_ = config_.codec_settings->maxFramerate * 0.001 * 8; // bits | 168 bit_rate_factor_ = config_.codec_settings->maxFramerate * 0.001 * 8; // bits |
167 | 169 |
168 // Setup required callbacks for the encoder/decoder. | 170 // Setup required callbacks for the encoder/decoder. |
169 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()), | 171 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()), |
170 WEBRTC_VIDEO_CODEC_OK) | 172 WEBRTC_VIDEO_CODEC_OK) |
(...skipping 25 matching lines...) Loading... | |
196 printf(" Decoder implementation name: %s\n", | 198 printf(" Decoder implementation name: %s\n", |
197 decoder_->ImplementationName()); | 199 decoder_->ImplementationName()); |
198 PrintCodecSettings(config_.codec_settings); | 200 PrintCodecSettings(config_.codec_settings); |
199 } | 201 } |
200 | 202 |
201 initialized_ = true; | 203 initialized_ = true; |
202 | 204 |
203 return true; | 205 return true; |
204 } | 206 } |
205 | 207 |
206 VideoProcessorImpl::~VideoProcessorImpl() { | 208 void VideoProcessorImpl::DeregisterCallbacks() { |
207 encoder_->RegisterEncodeCompleteCallback(nullptr); | 209 encoder_->RegisterEncodeCompleteCallback(nullptr); |
brandtr
2017/03/10 09:50:54
Must be called on the task queue.
tommi
2017/03/10 09:57:12
as a drive by comment, there aren't any thread or
| |
208 decoder_->RegisterDecodeCompleteCallback(nullptr); | 210 decoder_->RegisterDecodeCompleteCallback(nullptr); |
209 } | 211 } |
210 | 212 |
211 void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) { | 213 void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) { |
212 int set_rates_result = encoder_->SetRateAllocation( | 214 int set_rates_result = encoder_->SetRateAllocation( |
213 bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate), | 215 bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate), |
214 frame_rate); | 216 frame_rate); |
215 RTC_DCHECK_GE(set_rates_result, 0) | 217 RTC_DCHECK_GE(set_rates_result, 0) |
216 << "Failed to update encoder with new rate " << bit_rate; | 218 << "Failed to update encoder with new rate " << bit_rate; |
217 num_dropped_frames_ = 0; | 219 num_dropped_frames_ = 0; |
(...skipping 273 matching lines...) Loading... | |
491 if (decoded_frame_writer_) { | 493 if (decoded_frame_writer_) { |
492 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); | 494 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); |
493 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); | 495 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); |
494 } | 496 } |
495 | 497 |
496 last_decoded_frame_buffer_ = std::move(extracted_buffer); | 498 last_decoded_frame_buffer_ = std::move(extracted_buffer); |
497 } | 499 } |
498 | 500 |
499 } // namespace test | 501 } // namespace test |
500 } // namespace webrtc | 502 } // namespace webrtc |
OLD | NEW |