blob: 097bd01f5167f268f3cf10fbfc1e3ee84a8b747e [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"
Yves Gerey3e707812018-11-28 16:47:49 +010016#include "rtc_base/file.h"
Erik Språng96965ae2018-10-23 15:42:37 +020017
18namespace webrtc {
19
20FrameDumpingDecoder::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
26FrameDumpingDecoder::~FrameDumpingDecoder() = default;
27
28int32_t FrameDumpingDecoder::InitDecode(const VideoCodec* codec_settings,
29 int32_t number_of_cores) {
30 return decoder_->InitDecode(codec_settings, number_of_cores);
31}
32
33int32_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
45int32_t FrameDumpingDecoder::RegisterDecodeCompleteCallback(
46 DecodedImageCallback* callback) {
47 return decoder_->RegisterDecodeCompleteCallback(callback);
48}
49
50int32_t FrameDumpingDecoder::Release() {
51 return decoder_->Release();
52}
53
54bool FrameDumpingDecoder::PrefersLateDecoding() const {
55 return decoder_->PrefersLateDecoding();
56}
57
58const char* FrameDumpingDecoder::ImplementationName() const {
59 return decoder_->ImplementationName();
60}
61
62} // namespace webrtc