blob: 941c0ac197aaeca7cc7acf1381110709e4ff9932 [file] [log] [blame]
pbos@webrtc.org776e6f22014-10-29 15:28:39 +00001/*
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
14#include <vector>
15
16#include "webrtc/common_types.h"
17#include "webrtc/typedefs.h"
18#include "webrtc/video_frame.h"
19
20namespace webrtc {
21
22class RTPFragmentationHeader;
23// TODO(pbos): Expose these through a public (root) header or change these APIs.
24struct CodecSpecificInfo;
25struct VideoCodec;
26
27class DecodedImageCallback {
28 public:
29 virtual ~DecodedImageCallback() {}
30
magjed@webrtc.org2056ee32015-03-16 13:46:52 +000031 virtual int32_t Decoded(I420VideoFrame& decodedImage) = 0;
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000032 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
33 return -1;
34 }
35
36 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; }
37};
38
39class VideoDecoder {
40 public:
41 enum DecoderType {
42 kVp8,
stefan@webrtc.org7c29e8c2014-11-04 19:41:15 +000043 kVp9
pbos@webrtc.org776e6f22014-10-29 15:28:39 +000044 };
45
46 static VideoDecoder* Create(DecoderType codec_type);
47
48 virtual ~VideoDecoder() {}
49
50 virtual int32_t InitDecode(const VideoCodec* codecSettings,
51 int32_t numberOfCores) = 0;
52
53 virtual int32_t Decode(const EncodedImage& inputImage,
54 bool missingFrames,
55 const RTPFragmentationHeader* fragmentation,
56 const CodecSpecificInfo* codecSpecificInfo = NULL,
57 int64_t renderTimeMs = -1) = 0;
58
59 virtual int32_t RegisterDecodeCompleteCallback(
60 DecodedImageCallback* callback) = 0;
61
62 virtual int32_t Release() = 0;
63 virtual int32_t Reset() = 0;
64
65 virtual int32_t SetCodecConfigParameters(const uint8_t* /*buffer*/,
66 int32_t /*size*/) {
67 return -1;
68 }
69
70 virtual VideoDecoder* Copy() { return NULL; }
71};
72
73} // namespace webrtc
74
75#endif // WEBRTC_VIDEO_DECODER_H_