blob: 87f608a859cfa073fb3eac1c1ae9edff47b3c05c [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"
ilnikd60d06a2017-04-05 03:02:20 -070021
22namespace webrtc {
23
ilnikd60d06a2017-04-05 03:02:20 -070024// TODO(pbos): Expose these through a public (root) header or change these APIs.
25struct CodecSpecificInfo;
26class VideoCodec;
27
28class DecodedImageCallback {
29 public:
30 virtual ~DecodedImageCallback() {}
31
32 virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
33 // Provides an alternative interface that allows the decoder to specify the
34 // decode time excluding waiting time for any previous pending frame to
35 // return. This is necessary for breaking positive feedback in the delay
36 // estimation when the decoder has a single output buffer.
Niels Möllerbe682d42018-03-27 08:31:45 +020037 virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms);
38
ilnikd60d06a2017-04-05 03:02:20 -070039 // TODO(sakal): Remove other implementations when upstream projects have been
40 // updated.
41 virtual void Decoded(VideoFrame& decodedImage,
42 rtc::Optional<int32_t> decode_time_ms,
Niels Möllerbe682d42018-03-27 08:31:45 +020043 rtc::Optional<uint8_t> qp);
ilnikd60d06a2017-04-05 03:02:20 -070044
Niels Möllerbe682d42018-03-27 08:31:45 +020045 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId);
ilnikd60d06a2017-04-05 03:02:20 -070046
Niels Möllerbe682d42018-03-27 08:31:45 +020047 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId);
ilnikd60d06a2017-04-05 03:02:20 -070048};
49
50class VideoDecoder {
51 public:
52 virtual ~VideoDecoder() {}
53
54 virtual int32_t InitDecode(const VideoCodec* codec_settings,
55 int32_t number_of_cores) = 0;
56
57 virtual int32_t Decode(const EncodedImage& input_image,
58 bool missing_frames,
Niels Möller8df3a382018-05-07 16:10:01 +020059 const CodecSpecificInfo* codec_specific_info,
Niels Möller401d0762018-05-08 11:54:29 +020060 int64_t render_time_ms) = 0;
ilnikd60d06a2017-04-05 03:02:20 -070061
62 virtual int32_t RegisterDecodeCompleteCallback(
63 DecodedImageCallback* callback) = 0;
64
65 virtual int32_t Release() = 0;
66
67 // Returns true if the decoder prefer to decode frames late.
68 // That is, it can not decode infinite number of frames before the decoded
69 // frame is consumed.
Niels Möllerbe682d42018-03-27 08:31:45 +020070 virtual bool PrefersLateDecoding() const;
ilnikd60d06a2017-04-05 03:02:20 -070071
Niels Möllerbe682d42018-03-27 08:31:45 +020072 virtual const char* ImplementationName() const;
ilnikd60d06a2017-04-05 03:02:20 -070073};
74
75} // namespace webrtc
76
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020077#endif // API_VIDEO_CODECS_VIDEO_DECODER_H_