pbos@webrtc.org | 776e6f2 | 2014-10-29 15:28:39 +0000 | [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 | |
| 14 | #include <vector> |
| 15 | |
| 16 | #include "webrtc/common_types.h" |
| 17 | #include "webrtc/typedefs.h" |
| 18 | #include "webrtc/video_frame.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class RTPFragmentationHeader; |
| 23 | // TODO(pbos): Expose these through a public (root) header or change these APIs. |
| 24 | struct CodecSpecificInfo; |
| 25 | struct VideoCodec; |
| 26 | |
| 27 | class DecodedImageCallback { |
| 28 | public: |
| 29 | virtual ~DecodedImageCallback() {} |
| 30 | |
| 31 | virtual int32_t Decoded(I420VideoFrame& decodedImage) = 0; |
| 32 | 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 | |
| 39 | class VideoDecoder { |
| 40 | public: |
| 41 | enum DecoderType { |
| 42 | kVp8, |
| 43 | }; |
| 44 | |
| 45 | static VideoDecoder* Create(DecoderType codec_type); |
| 46 | |
| 47 | virtual ~VideoDecoder() {} |
| 48 | |
| 49 | virtual int32_t InitDecode(const VideoCodec* codecSettings, |
| 50 | int32_t numberOfCores) = 0; |
| 51 | |
| 52 | virtual int32_t Decode(const EncodedImage& inputImage, |
| 53 | bool missingFrames, |
| 54 | const RTPFragmentationHeader* fragmentation, |
| 55 | const CodecSpecificInfo* codecSpecificInfo = NULL, |
| 56 | int64_t renderTimeMs = -1) = 0; |
| 57 | |
| 58 | virtual int32_t RegisterDecodeCompleteCallback( |
| 59 | DecodedImageCallback* callback) = 0; |
| 60 | |
| 61 | virtual int32_t Release() = 0; |
| 62 | virtual int32_t Reset() = 0; |
| 63 | |
| 64 | virtual int32_t SetCodecConfigParameters(const uint8_t* /*buffer*/, |
| 65 | int32_t /*size*/) { |
| 66 | return -1; |
| 67 | } |
| 68 | |
| 69 | virtual VideoDecoder* Copy() { return NULL; } |
| 70 | }; |
| 71 | |
| 72 | } // namespace webrtc |
| 73 | |
| 74 | #endif // WEBRTC_VIDEO_DECODER_H_ |