pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 1 | /* |
| 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 | |
kwiberg | b60d949 | 2016-03-02 11:41:34 | [diff] [blame] | 14 | #include <memory> |
Peter Boström | 8468abc | 2015-12-18 15:01:11 | [diff] [blame] | 15 | #include <string> |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
| 18 | #include "webrtc/common_types.h" |
| 19 | #include "webrtc/typedefs.h" |
| 20 | #include "webrtc/video_frame.h" |
| 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | class RTPFragmentationHeader; |
| 25 | // TODO(pbos): Expose these through a public (root) header or change these APIs. |
| 26 | struct CodecSpecificInfo; |
hta | 078cd6c | 2016-10-25 16:05:06 | [diff] [blame] | 27 | class VideoCodec; |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 28 | |
| 29 | class DecodedImageCallback { |
| 30 | public: |
| 31 | virtual ~DecodedImageCallback() {} |
| 32 | |
Miguel Casas-Sanchez | 3ca60f3 | 2015-05-30 00:21:40 | [diff] [blame] | 33 | virtual int32_t Decoded(VideoFrame& decodedImage) = 0; |
Per | b6b6998 | 2015-11-10 13:00:27 | [diff] [blame] | 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. |
Per | b6b6998 | 2015-11-10 13:00:27 | [diff] [blame] | 38 | virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) { |
| 39 | // The default implementation ignores custom decode time value. |
| 40 | return Decoded(decodedImage); |
| 41 | } |
sakal | bc6405b | 2017-02-09 12:53:45 | [diff] [blame] | 42 | // TODO(sakal): Remove other implementations when upstream projects have been |
| 43 | // updated. |
| 44 | virtual void Decoded(VideoFrame& decodedImage, |
| 45 | rtc::Optional<int32_t> decode_time_ms, |
| 46 | rtc::Optional<uint8_t> qp) { |
| 47 | Decoded(decodedImage, |
| 48 | decode_time_ms ? static_cast<int32_t>(*decode_time_ms) : -1); |
| 49 | } |
Per | b6b6998 | 2015-11-10 13:00:27 | [diff] [blame] | 50 | |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 51 | virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) { |
| 52 | return -1; |
| 53 | } |
| 54 | |
| 55 | virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; } |
| 56 | }; |
| 57 | |
| 58 | class VideoDecoder { |
| 59 | public: |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 60 | virtual ~VideoDecoder() {} |
| 61 | |
Peter Boström | 5691fcf | 2015-05-18 17:42:03 | [diff] [blame] | 62 | virtual int32_t InitDecode(const VideoCodec* codec_settings, |
| 63 | int32_t number_of_cores) = 0; |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 64 | |
Peter Boström | 5691fcf | 2015-05-18 17:42:03 | [diff] [blame] | 65 | virtual int32_t Decode(const EncodedImage& input_image, |
| 66 | bool missing_frames, |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 67 | const RTPFragmentationHeader* fragmentation, |
Peter Boström | 5691fcf | 2015-05-18 17:42:03 | [diff] [blame] | 68 | const CodecSpecificInfo* codec_specific_info = NULL, |
| 69 | int64_t render_time_ms = -1) = 0; |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 70 | |
| 71 | virtual int32_t RegisterDecodeCompleteCallback( |
| 72 | DecodedImageCallback* callback) = 0; |
| 73 | |
| 74 | virtual int32_t Release() = 0; |
perkj | af6687a | 2015-12-10 17:27:38 | [diff] [blame] | 75 | |
| 76 | // Returns true if the decoder prefer to decode frames late. |
| 77 | // That is, it can not decode infinite number of frames before the decoded |
| 78 | // frame is consumed. |
| 79 | virtual bool PrefersLateDecoding() const { return true; } |
Peter Boström | 8468abc | 2015-12-18 15:01:11 | [diff] [blame] | 80 | |
| 81 | virtual const char* ImplementationName() const { return "unknown"; } |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 82 | }; |
| 83 | |
pbos@webrtc.org | 7b5a896 | 2014-10-29 15:28:39 | [diff] [blame] | 84 | } // namespace webrtc |
| 85 | |
| 86 | #endif // WEBRTC_VIDEO_DECODER_H_ |