blob: d0341b184be1912eaddd65c421384ad9db1338b5 [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
Niels Möller4dc66c52018-10-05 14:17:58 +020018#include "api/video/encoded_image.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "api/video/video_frame.h"
Niels Möller802506c2018-05-31 10:44:51 +020020#include "api/video_codecs/video_codec.h"
Mirko Bonadei276827c2018-10-16 14:13:50 +020021#include "rtc_base/system/rtc_export.h"
ilnikd60d06a2017-04-05 03:02:20 -070022
23namespace webrtc {
24
Danil Chapovalovd8bf2d42019-04-23 12:52:02 +000025// TODO(pbos): Expose these through a public (root) header or change these APIs.
26struct CodecSpecificInfo;
27class VideoCodec;
28
Mirko Bonadei977b46a2018-10-24 16:22:04 +020029class RTC_EXPORT DecodedImageCallback {
ilnikd60d06a2017-04-05 03:02:20 -070030 public:
31 virtual ~DecodedImageCallback() {}
32
33 virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
34 // 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.
Niels Möllerbe682d42018-03-27 08:31:45 +020038 virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms);
39
ilnikd60d06a2017-04-05 03:02:20 -070040 // TODO(sakal): Remove other implementations when upstream projects have been
41 // updated.
42 virtual void Decoded(VideoFrame& decodedImage,
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020043 absl::optional<int32_t> decode_time_ms,
44 absl::optional<uint8_t> qp);
ilnikd60d06a2017-04-05 03:02:20 -070045
Niels Möllerbe682d42018-03-27 08:31:45 +020046 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId);
ilnikd60d06a2017-04-05 03:02:20 -070047};
48
Mirko Bonadei276827c2018-10-16 14:13:50 +020049class RTC_EXPORT VideoDecoder {
ilnikd60d06a2017-04-05 03:02:20 -070050 public:
51 virtual ~VideoDecoder() {}
52
53 virtual int32_t InitDecode(const VideoCodec* codec_settings,
54 int32_t number_of_cores) = 0;
55
56 virtual int32_t Decode(const EncodedImage& input_image,
57 bool missing_frames,
Danil Chapovalovd8bf2d42019-04-23 12:52:02 +000058 int64_t render_time_ms);
59
60 // TODO(bugs.webrtc.org/10379): Deprecated. Delete, and make above method pure
61 // virtual, as soon as downstream applications are updated.
62 virtual int32_t Decode(const EncodedImage& input_image,
63 bool missing_frames,
64 const CodecSpecificInfo* codec_specific_info,
65 int64_t render_time_ms);
ilnikd60d06a2017-04-05 03:02:20 -070066
67 virtual int32_t RegisterDecodeCompleteCallback(
68 DecodedImageCallback* callback) = 0;
69
70 virtual int32_t Release() = 0;
71
72 // Returns true if the decoder prefer to decode frames late.
73 // That is, it can not decode infinite number of frames before the decoded
74 // frame is consumed.
Niels Möllerbe682d42018-03-27 08:31:45 +020075 virtual bool PrefersLateDecoding() const;
ilnikd60d06a2017-04-05 03:02:20 -070076
Niels Möllerbe682d42018-03-27 08:31:45 +020077 virtual const char* ImplementationName() const;
ilnikd60d06a2017-04-05 03:02:20 -070078};
79
80} // namespace webrtc
81
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020082#endif // API_VIDEO_CODECS_VIDEO_DECODER_H_