Erik Språng | 96965ae | 2018-10-23 15:42:37 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "video/frame_dumping_decoder.h" |
| 12 | |
| 13 | #include <utility> |
| 14 | |
| 15 | #include "modules/video_coding/include/video_codec_interface.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 16 | #include "rtc_base/file.h" |
Erik Språng | 96965ae | 2018-10-23 15:42:37 +0200 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder, |
| 21 | rtc::PlatformFile file) |
| 22 | : decoder_(std::move(decoder)), |
| 23 | writer_(IvfFileWriter::Wrap(rtc::File(file), |
| 24 | /* byte_limit= */ 100000000)) {} |
| 25 | |
| 26 | FrameDumpingDecoder::~FrameDumpingDecoder() = default; |
| 27 | |
| 28 | int32_t FrameDumpingDecoder::InitDecode(const VideoCodec* codec_settings, |
| 29 | int32_t number_of_cores) { |
| 30 | return decoder_->InitDecode(codec_settings, number_of_cores); |
| 31 | } |
| 32 | |
| 33 | int32_t FrameDumpingDecoder::Decode( |
| 34 | const EncodedImage& input_image, |
| 35 | bool missing_frames, |
| 36 | const CodecSpecificInfo* codec_specific_info, |
| 37 | int64_t render_time_ms) { |
| 38 | int32_t ret = decoder_->Decode(input_image, missing_frames, |
| 39 | codec_specific_info, render_time_ms); |
| 40 | writer_->WriteFrame(input_image, codec_specific_info->codecType); |
| 41 | |
| 42 | return ret; |
| 43 | } |
| 44 | |
| 45 | int32_t FrameDumpingDecoder::RegisterDecodeCompleteCallback( |
| 46 | DecodedImageCallback* callback) { |
| 47 | return decoder_->RegisterDecodeCompleteCallback(callback); |
| 48 | } |
| 49 | |
| 50 | int32_t FrameDumpingDecoder::Release() { |
| 51 | return decoder_->Release(); |
| 52 | } |
| 53 | |
| 54 | bool FrameDumpingDecoder::PrefersLateDecoding() const { |
| 55 | return decoder_->PrefersLateDecoding(); |
| 56 | } |
| 57 | |
| 58 | const char* FrameDumpingDecoder::ImplementationName() const { |
| 59 | return decoder_->ImplementationName(); |
| 60 | } |
| 61 | |
| 62 | } // namespace webrtc |