| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 num_spatial_resizes_(0) { | 131 num_spatial_resizes_(0) { |
| 132 RTC_DCHECK(encoder); | 132 RTC_DCHECK(encoder); |
| 133 RTC_DCHECK(decoder); | 133 RTC_DCHECK(decoder); |
| 134 RTC_DCHECK(packet_manipulator); | 134 RTC_DCHECK(packet_manipulator); |
| 135 RTC_DCHECK(analysis_frame_reader); | 135 RTC_DCHECK(analysis_frame_reader); |
| 136 RTC_DCHECK(analysis_frame_writer); | 136 RTC_DCHECK(analysis_frame_writer); |
| 137 RTC_DCHECK(stats); | 137 RTC_DCHECK(stats); |
| 138 frame_infos_.reserve(analysis_frame_reader->NumberOfFrames()); | 138 frame_infos_.reserve(analysis_frame_reader->NumberOfFrames()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 VideoProcessor::~VideoProcessor() { | 141 VideoProcessor::~VideoProcessor() = default; |
| 142 encoder_->RegisterEncodeCompleteCallback(nullptr); | |
| 143 decoder_->RegisterDecodeCompleteCallback(nullptr); | |
| 144 } | |
| 145 | 142 |
| 146 void VideoProcessor::Init() { | 143 void VideoProcessor::Init() { |
| 147 RTC_DCHECK(!initialized_) << "VideoProcessor already initialized."; | 144 RTC_DCHECK(!initialized_) << "VideoProcessor already initialized."; |
| 148 initialized_ = true; | 145 initialized_ = true; |
| 149 | 146 |
| 150 // Setup required callbacks for the encoder and decoder. | 147 // Setup required callbacks for the encoder and decoder. |
| 151 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()), | 148 RTC_CHECK_EQ(encoder_->RegisterEncodeCompleteCallback(encode_callback_.get()), |
| 152 WEBRTC_VIDEO_CODEC_OK) | 149 WEBRTC_VIDEO_CODEC_OK) |
| 153 << "Failed to register encode complete callback"; | 150 << "Failed to register encode complete callback"; |
| 154 RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(decode_callback_.get()), | 151 RTC_CHECK_EQ(decoder_->RegisterDecodeCompleteCallback(decode_callback_.get()), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 182 printf(" Codec implementation name : %s_%s\n", | 179 printf(" Codec implementation name : %s_%s\n", |
| 183 CodecTypeToPayloadName(config_.codec_settings.codecType) | 180 CodecTypeToPayloadName(config_.codec_settings.codecType) |
| 184 .value_or("Unknown"), | 181 .value_or("Unknown"), |
| 185 encoder_->ImplementationName()); | 182 encoder_->ImplementationName()); |
| 186 } | 183 } |
| 187 PrintCodecSettings(config_.codec_settings); | 184 PrintCodecSettings(config_.codec_settings); |
| 188 printf("\n"); | 185 printf("\n"); |
| 189 } | 186 } |
| 190 } | 187 } |
| 191 | 188 |
| 189 void VideoProcessor::Release() { |
| 190 encoder_->RegisterEncodeCompleteCallback(nullptr); |
| 191 decoder_->RegisterDecodeCompleteCallback(nullptr); |
| 192 |
| 193 RTC_CHECK_EQ(encoder_->Release(), WEBRTC_VIDEO_CODEC_OK); |
| 194 RTC_CHECK_EQ(decoder_->Release(), WEBRTC_VIDEO_CODEC_OK); |
| 195 |
| 196 initialized_ = false; |
| 197 } |
| 198 |
| 192 bool VideoProcessor::ProcessFrame(int frame_number) { | 199 bool VideoProcessor::ProcessFrame(int frame_number) { |
| 193 RTC_DCHECK_GE(frame_number, 0); | 200 RTC_DCHECK_GE(frame_number, 0); |
| 194 RTC_DCHECK_LE(frame_number, frame_infos_.size()) | 201 RTC_DCHECK_LE(frame_number, frame_infos_.size()) |
| 195 << "Must process frames without gaps."; | 202 << "Must process frames without gaps."; |
| 196 RTC_DCHECK(initialized_) << "VideoProcessor not initialized."; | 203 RTC_DCHECK(initialized_) << "VideoProcessor not initialized."; |
| 197 | 204 |
| 198 rtc::scoped_refptr<I420BufferInterface> buffer( | 205 rtc::scoped_refptr<I420BufferInterface> buffer( |
| 199 analysis_frame_reader_->ReadFrame()); | 206 analysis_frame_reader_->ReadFrame()); |
| 200 | 207 |
| 201 if (!buffer) { | 208 if (!buffer) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) { | 496 int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) { |
| 490 RTC_DCHECK_GT(timestamp, 0); | 497 RTC_DCHECK_GT(timestamp, 0); |
| 491 const int ticks_per_frame = | 498 const int ticks_per_frame = |
| 492 kRtpClockRateHz / config_.codec_settings.maxFramerate; | 499 kRtpClockRateHz / config_.codec_settings.maxFramerate; |
| 493 RTC_DCHECK_EQ(timestamp % ticks_per_frame, 0); | 500 RTC_DCHECK_EQ(timestamp % ticks_per_frame, 0); |
| 494 return (timestamp / ticks_per_frame) - 1; | 501 return (timestamp / ticks_per_frame) - 1; |
| 495 } | 502 } |
| 496 | 503 |
| 497 } // namespace test | 504 } // namespace test |
| 498 } // namespace webrtc | 505 } // namespace webrtc |
| OLD | NEW |