blob: b8d2c96b1be8da1cb27138f0550302ebe7b378c1 [file] [log] [blame]
pbos@webrtc.org776e6f22014-10-29 15:28:391/*
2 * Copyright (c) 2014 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#ifndef WEBRTC_VIDEO_DECODER_H_
12#define WEBRTC_VIDEO_DECODER_H_
13
kwibergc891eb42016-03-02 11:41:3414#include <memory>
Peter Boströmb7d9a972015-12-18 15:01:1115#include <string>
pbos@webrtc.org776e6f22014-10-29 15:28:3916#include <vector>
17
18#include "webrtc/common_types.h"
19#include "webrtc/typedefs.h"
20#include "webrtc/video_frame.h"
21
22namespace webrtc {
23
24class RTPFragmentationHeader;
25// TODO(pbos): Expose these through a public (root) header or change these APIs.
26struct CodecSpecificInfo;
hta257dc392016-10-25 16:05:0627class VideoCodec;
pbos@webrtc.org776e6f22014-10-29 15:28:3928
29class DecodedImageCallback {
30 public:
31 virtual ~DecodedImageCallback() {}
32
Miguel Casas-Sanchez47650702015-05-30 00:21:4033 virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
Per327d8ba2015-11-10 13:00:2734 // Provides an alternative interface that allows the decoder to specify the
35 // decode time excluding waiting time for any previous pending frame to
36 // return. This is necessary for breaking positive feedback in the delay
37 // estimation when the decoder has a single output buffer.
38 // TODO(perkj): Remove default implementation when chromium has been updated.
39 virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) {
40 // The default implementation ignores custom decode time value.
41 return Decoded(decodedImage);
42 }
43
pbos@webrtc.org776e6f22014-10-29 15:28:3944 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
45 return -1;
46 }
47
48 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; }
49};
50
51class VideoDecoder {
52 public:
pbos@webrtc.org776e6f22014-10-29 15:28:3953 virtual ~VideoDecoder() {}
54
Peter Boström7252a2b2015-05-18 17:42:0355 virtual int32_t InitDecode(const VideoCodec* codec_settings,
56 int32_t number_of_cores) = 0;
pbos@webrtc.org776e6f22014-10-29 15:28:3957
Peter Boström7252a2b2015-05-18 17:42:0358 virtual int32_t Decode(const EncodedImage& input_image,
59 bool missing_frames,
pbos@webrtc.org776e6f22014-10-29 15:28:3960 const RTPFragmentationHeader* fragmentation,
Peter Boström7252a2b2015-05-18 17:42:0361 const CodecSpecificInfo* codec_specific_info = NULL,
62 int64_t render_time_ms = -1) = 0;
pbos@webrtc.org776e6f22014-10-29 15:28:3963
64 virtual int32_t RegisterDecodeCompleteCallback(
65 DecodedImageCallback* callback) = 0;
66
67 virtual int32_t Release() = 0;
perkj796cfaf2015-12-10 17:27:3868
69 // Returns true if the decoder prefer to decode frames late.
70 // That is, it can not decode infinite number of frames before the decoded
71 // frame is consumed.
72 virtual bool PrefersLateDecoding() const { return true; }
Peter Boströmb7d9a972015-12-18 15:01:1173
74 virtual const char* ImplementationName() const { return "unknown"; }
pbos@webrtc.org776e6f22014-10-29 15:28:3975};
76
pbos@webrtc.org776e6f22014-10-29 15:28:3977} // namespace webrtc
78
79#endif // WEBRTC_VIDEO_DECODER_H_