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" |
Erik Språng | 96965ae | 2018-10-23 15:42:37 +0200 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder, |
Niels Möller | b7edf69 | 2019-02-08 16:40:53 +0100 | [diff] [blame] | 20 | FileWrapper file) |
Erik Språng | 96965ae | 2018-10-23 15:42:37 +0200 | [diff] [blame] | 21 | : decoder_(std::move(decoder)), |
Niels Möller | b7edf69 | 2019-02-08 16:40:53 +0100 | [diff] [blame] | 22 | writer_(IvfFileWriter::Wrap(std::move(file), |
Erik Språng | 96965ae | 2018-10-23 15:42:37 +0200 | [diff] [blame] | 23 | /* byte_limit= */ 100000000)) {} |
| 24 | |
| 25 | FrameDumpingDecoder::~FrameDumpingDecoder() = default; |
| 26 | |
| 27 | int32_t FrameDumpingDecoder::InitDecode(const VideoCodec* codec_settings, |
| 28 | int32_t number_of_cores) { |
Niels Möller | 7aacdd9 | 2019-03-25 09:11:40 +0100 | [diff] [blame] | 29 | codec_type_ = codec_settings->codecType; |
Erik Språng | 96965ae | 2018-10-23 15:42:37 +0200 | [diff] [blame] | 30 | return decoder_->InitDecode(codec_settings, number_of_cores); |
| 31 | } |
| 32 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 33 | int32_t FrameDumpingDecoder::Decode(const EncodedImage& input_image, |
| 34 | bool missing_frames, |
| 35 | int64_t render_time_ms) { |
Niels Möller | 7aacdd9 | 2019-03-25 09:11:40 +0100 | [diff] [blame] | 36 | int32_t ret = decoder_->Decode(input_image, missing_frames, render_time_ms); |
| 37 | writer_->WriteFrame(input_image, codec_type_); |
Erik Språng | 96965ae | 2018-10-23 15:42:37 +0200 | [diff] [blame] | 38 | |
| 39 | return ret; |
| 40 | } |
| 41 | |
| 42 | int32_t FrameDumpingDecoder::RegisterDecodeCompleteCallback( |
| 43 | DecodedImageCallback* callback) { |
| 44 | return decoder_->RegisterDecodeCompleteCallback(callback); |
| 45 | } |
| 46 | |
| 47 | int32_t FrameDumpingDecoder::Release() { |
| 48 | return decoder_->Release(); |
| 49 | } |
| 50 | |
| 51 | bool FrameDumpingDecoder::PrefersLateDecoding() const { |
| 52 | return decoder_->PrefersLateDecoding(); |
| 53 | } |
| 54 | |
| 55 | const char* FrameDumpingDecoder::ImplementationName() const { |
| 56 | return decoder_->ImplementationName(); |
| 57 | } |
| 58 | |
| 59 | } // namespace webrtc |