blob: 5897901346ce93a73d1144a3fb6542ec36b512e1 [file] [log] [blame]
ilnikd60d06a2017-04-05 03:02:20 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef API_VIDEO_CODECS_VIDEO_DECODER_H_
12#define API_VIDEO_CODECS_VIDEO_DECODER_H_
ilnikd60d06a2017-04-05 03:02:20 -070013
14#include <memory>
15#include <string>
16#include <vector>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "api/video/video_frame.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020019#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "common_video/include/video_frame.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020021#include "typedefs.h" // NOLINT(build/include)
ilnikd60d06a2017-04-05 03:02:20 -070022
23namespace webrtc {
24
25class RTPFragmentationHeader;
26// TODO(pbos): Expose these through a public (root) header or change these APIs.
27struct CodecSpecificInfo;
28class VideoCodec;
29
30class DecodedImageCallback {
31 public:
32 virtual ~DecodedImageCallback() {}
33
34 virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
35 // Provides an alternative interface that allows the decoder to specify the
36 // decode time excluding waiting time for any previous pending frame to
37 // return. This is necessary for breaking positive feedback in the delay
38 // estimation when the decoder has a single output buffer.
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 // TODO(sakal): Remove other implementations when upstream projects have been
44 // updated.
45 virtual void Decoded(VideoFrame& decodedImage,
46 rtc::Optional<int32_t> decode_time_ms,
47 rtc::Optional<uint8_t> qp) {
48 Decoded(decodedImage,
49 decode_time_ms ? static_cast<int32_t>(*decode_time_ms) : -1);
50 }
51
52 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
53 return -1;
54 }
55
56 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; }
57};
58
59class VideoDecoder {
60 public:
61 virtual ~VideoDecoder() {}
62
63 virtual int32_t InitDecode(const VideoCodec* codec_settings,
64 int32_t number_of_cores) = 0;
65
66 virtual int32_t Decode(const EncodedImage& input_image,
67 bool missing_frames,
68 const RTPFragmentationHeader* fragmentation,
69 const CodecSpecificInfo* codec_specific_info = NULL,
70 int64_t render_time_ms = -1) = 0;
71
72 virtual int32_t RegisterDecodeCompleteCallback(
73 DecodedImageCallback* callback) = 0;
74
75 virtual int32_t Release() = 0;
76
77 // Returns true if the decoder prefer to decode frames late.
78 // That is, it can not decode infinite number of frames before the decoded
79 // frame is consumed.
80 virtual bool PrefersLateDecoding() const { return true; }
81
82 virtual const char* ImplementationName() const { return "unknown"; }
83};
84
85} // namespace webrtc
86
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020087#endif // API_VIDEO_CODECS_VIDEO_DECODER_H_