| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ |
| 13 | 13 |
| 14 #include "webrtc/modules/include/module_common_types.h" | 14 #include "webrtc/modules/include/module_common_types.h" |
| 15 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 15 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 16 #include "webrtc/modules/video_coding/encoded_frame.h" | 16 #include "webrtc/modules/video_coding/encoded_frame.h" |
| 17 #include "webrtc/modules/video_coding/timestamp_map.h" | 17 #include "webrtc/modules/video_coding/timestamp_map.h" |
| 18 #include "webrtc/modules/video_coding/timing.h" | 18 #include "webrtc/modules/video_coding/timing.h" |
| 19 | 19 |
| 20 namespace webrtc | 20 namespace webrtc { |
| 21 { | |
| 22 | 21 |
| 23 class VCMReceiveCallback; | 22 class VCMReceiveCallback; |
| 24 | 23 |
| 25 enum { kDecoderFrameMemoryLength = 10 }; | 24 enum { kDecoderFrameMemoryLength = 10 }; |
| 26 | 25 |
| 27 struct VCMFrameInformation | 26 struct VCMFrameInformation { |
| 28 { | 27 int64_t renderTimeMs; |
| 29 int64_t renderTimeMs; | 28 int64_t decodeStartTimeMs; |
| 30 int64_t decodeStartTimeMs; | 29 void* userData; |
| 31 void* userData; | 30 VideoRotation rotation; |
| 32 VideoRotation rotation; | |
| 33 }; | 31 }; |
| 34 | 32 |
| 35 class VCMDecodedFrameCallback : public DecodedImageCallback | 33 class VCMDecodedFrameCallback : public DecodedImageCallback { |
| 36 { | 34 public: |
| 37 public: | 35 VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock); |
| 38 VCMDecodedFrameCallback(VCMTiming& timing, Clock* clock); | |
| 39 virtual ~VCMDecodedFrameCallback(); | 36 virtual ~VCMDecodedFrameCallback(); |
| 40 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); | 37 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); |
| 41 VCMReceiveCallback* UserReceiveCallback(); | 38 VCMReceiveCallback* UserReceiveCallback(); |
| 42 | 39 |
| 43 virtual int32_t Decoded(VideoFrame& decodedImage); | 40 virtual int32_t Decoded(VideoFrame& decodedImage); // NOLINT |
| 44 virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms); | 41 virtual int32_t Decoded(VideoFrame& decodedImage, // NOLINT |
| 42 int64_t decode_time_ms); |
| 45 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId); | 43 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId); |
| 46 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId); | 44 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId); |
| 47 | 45 |
| 48 uint64_t LastReceivedPictureID() const; | 46 uint64_t LastReceivedPictureID() const; |
| 49 void OnDecoderImplementationName(const char* implementation_name); | 47 void OnDecoderImplementationName(const char* implementation_name); |
| 50 | 48 |
| 51 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); | 49 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); |
| 52 int32_t Pop(uint32_t timestamp); | 50 int32_t Pop(uint32_t timestamp); |
| 53 | 51 |
| 54 private: | 52 private: |
| 55 // Protect |_receiveCallback| and |_timestampMap|. | 53 // Protect |_receiveCallback| and |_timestampMap|. |
| 56 CriticalSectionWrapper* _critSect; | 54 CriticalSectionWrapper* _critSect; |
| 57 Clock* _clock; | 55 Clock* _clock; |
| 58 VCMReceiveCallback* _receiveCallback GUARDED_BY(_critSect); | 56 VCMReceiveCallback* _receiveCallback GUARDED_BY(_critSect); |
| 59 VCMTiming& _timing; | 57 VCMTiming* _timing; |
| 60 VCMTimestampMap _timestampMap GUARDED_BY(_critSect); | 58 VCMTimestampMap _timestampMap GUARDED_BY(_critSect); |
| 61 uint64_t _lastReceivedPictureID; | 59 uint64_t _lastReceivedPictureID; |
| 62 }; | 60 }; |
| 63 | 61 |
| 62 class VCMGenericDecoder { |
| 63 friend class VCMCodecDataBase; |
| 64 | 64 |
| 65 class VCMGenericDecoder | 65 public: |
| 66 { | 66 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); |
| 67 friend class VCMCodecDataBase; | 67 ~VCMGenericDecoder(); |
| 68 public: | |
| 69 VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); | |
| 70 ~VCMGenericDecoder(); | |
| 71 | 68 |
| 72 /** | 69 /** |
| 73 * Initialize the decoder with the information from the VideoCodec | 70 * Initialize the decoder with the information from the VideoCodec |
| 74 */ | 71 */ |
| 75 int32_t InitDecode(const VideoCodec* settings, | 72 int32_t InitDecode(const VideoCodec* settings, int32_t numberOfCores); |
| 76 int32_t numberOfCores); | |
| 77 | 73 |
| 78 /** | 74 /** |
| 79 * Decode to a raw I420 frame, | 75 * Decode to a raw I420 frame, |
| 80 * | 76 * |
| 81 * inputVideoBuffer reference to encoded video frame | 77 * inputVideoBuffer reference to encoded video frame |
| 82 */ | 78 */ |
| 83 int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs); | 79 int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs); |
| 84 | 80 |
| 85 /** | 81 /** |
| 86 * Free the decoder memory | 82 * Free the decoder memory |
| 87 */ | 83 */ |
| 88 int32_t Release(); | 84 int32_t Release(); |
| 89 | 85 |
| 90 /** | 86 /** |
| 91 * Reset the decoder state, prepare for a new call | 87 * Reset the decoder state, prepare for a new call |
| 92 */ | 88 */ |
| 93 int32_t Reset(); | 89 int32_t Reset(); |
| 94 | 90 |
| 95 /** | 91 /** |
| 96 * Set decode callback. Deregistering while decoding is illegal. | 92 * Set decode callback. Deregistering while decoding is illegal. |
| 97 */ | 93 */ |
| 98 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); | 94 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); |
| 99 | 95 |
| 100 bool External() const; | 96 bool External() const; |
| 101 bool PrefersLateDecoding() const; | 97 bool PrefersLateDecoding() const; |
| 102 | 98 |
| 103 private: | 99 private: |
| 104 VCMDecodedFrameCallback* _callback; | 100 VCMDecodedFrameCallback* _callback; |
| 105 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength]; | 101 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength]; |
| 106 uint32_t _nextFrameInfoIdx; | 102 uint32_t _nextFrameInfoIdx; |
| 107 VideoDecoder* const _decoder; | 103 VideoDecoder* const _decoder; |
| 108 VideoCodecType _codecType; | 104 VideoCodecType _codecType; |
| 109 bool _isExternal; | 105 bool _isExternal; |
| 110 bool _keyFrameDecoded; | 106 bool _keyFrameDecoded; |
| 111 }; | 107 }; |
| 112 | 108 |
| 113 } // namespace webrtc | 109 } // namespace webrtc |
| 114 | 110 |
| 115 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ | 111 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ |
| OLD | NEW |