blob: 72fc0ff3b95725c1d7c2c29b3f17ce3236885c9d [file] [log] [blame]
Erik Språng96965ae2018-10-23 15:42:37 +02001/*
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ång96965ae2018-10-23 15:42:37 +020016
17namespace webrtc {
18
19FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder,
Niels Möllerb7edf692019-02-08 16:40:53 +010020 FileWrapper file)
Erik Språng96965ae2018-10-23 15:42:37 +020021 : decoder_(std::move(decoder)),
Niels Möllerb7edf692019-02-08 16:40:53 +010022 writer_(IvfFileWriter::Wrap(std::move(file),
Erik Språng96965ae2018-10-23 15:42:37 +020023 /* byte_limit= */ 100000000)) {}
24
25FrameDumpingDecoder::~FrameDumpingDecoder() = default;
26
27int32_t FrameDumpingDecoder::InitDecode(const VideoCodec* codec_settings,
28 int32_t number_of_cores) {
Niels Möller7aacdd92019-03-25 09:11:40 +010029 codec_type_ = codec_settings->codecType;
Erik Språng96965ae2018-10-23 15:42:37 +020030 return decoder_->InitDecode(codec_settings, number_of_cores);
31}
32
Jonas Olssona4d87372019-07-05 19:08:33 +020033int32_t FrameDumpingDecoder::Decode(const EncodedImage& input_image,
34 bool missing_frames,
35 int64_t render_time_ms) {
Niels Möller7aacdd92019-03-25 09:11:40 +010036 int32_t ret = decoder_->Decode(input_image, missing_frames, render_time_ms);
37 writer_->WriteFrame(input_image, codec_type_);
Erik Språng96965ae2018-10-23 15:42:37 +020038
39 return ret;
40}
41
42int32_t FrameDumpingDecoder::RegisterDecodeCompleteCallback(
43 DecodedImageCallback* callback) {
44 return decoder_->RegisterDecodeCompleteCallback(callback);
45}
46
47int32_t FrameDumpingDecoder::Release() {
48 return decoder_->Release();
49}
50
51bool FrameDumpingDecoder::PrefersLateDecoding() const {
52 return decoder_->PrefersLateDecoding();
53}
54
55const char* FrameDumpingDecoder::ImplementationName() const {
56 return decoder_->ImplementationName();
57}
58
59} // namespace webrtc