| 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/base/criticalsection.h" |
| 15 #include "webrtc/base/thread_checker.h" |
| 14 #include "webrtc/modules/include/module_common_types.h" | 16 #include "webrtc/modules/include/module_common_types.h" |
| 17 #include "webrtc/modules/video_coding/encoded_frame.h" |
| 15 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 18 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 16 #include "webrtc/modules/video_coding/encoded_frame.h" | |
| 17 #include "webrtc/modules/video_coding/timestamp_map.h" | 19 #include "webrtc/modules/video_coding/timestamp_map.h" |
| 18 #include "webrtc/modules/video_coding/timing.h" | 20 #include "webrtc/modules/video_coding/timing.h" |
| 19 | 21 |
| 20 namespace webrtc { | 22 namespace webrtc { |
| 21 | 23 |
| 22 class VCMReceiveCallback; | 24 class VCMReceiveCallback; |
| 23 | 25 |
| 24 enum { kDecoderFrameMemoryLength = 10 }; | 26 enum { kDecoderFrameMemoryLength = 10 }; |
| 25 | 27 |
| 26 struct VCMFrameInformation { | 28 struct VCMFrameInformation { |
| 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; |
| 31 }; | 33 }; |
| 32 | 34 |
| 33 class VCMDecodedFrameCallback : public DecodedImageCallback { | 35 class VCMDecodedFrameCallback : public DecodedImageCallback { |
| 34 public: | 36 public: |
| 35 VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock); | 37 VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock); |
| 36 virtual ~VCMDecodedFrameCallback(); | 38 ~VCMDecodedFrameCallback() override; |
| 37 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); | |
| 38 VCMReceiveCallback* UserReceiveCallback(); | |
| 39 | 39 |
| 40 int32_t Decoded(VideoFrame& decodedImage) override; | 40 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); |
| 41 int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override; | 41 VCMReceiveCallback* UserReceiveCallback(); |
| 42 void Decoded(VideoFrame& decodedImage, | |
| 43 rtc::Optional<int32_t> decode_time_ms, | |
| 44 rtc::Optional<uint8_t> qp) override; | |
| 45 int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override; | |
| 46 int32_t ReceivedDecodedFrame(const uint64_t pictureId) override; | |
| 47 | 42 |
| 48 uint64_t LastReceivedPictureID() const; | 43 int32_t Decoded(VideoFrame& decodedImage) override; |
| 49 void OnDecoderImplementationName(const char* implementation_name); | 44 int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override; |
| 45 void Decoded(VideoFrame& decodedImage, |
| 46 rtc::Optional<int32_t> decode_time_ms, |
| 47 rtc::Optional<uint8_t> qp) override; |
| 48 int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override; |
| 49 int32_t ReceivedDecodedFrame(const uint64_t pictureId) override; |
| 50 | 50 |
| 51 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); | 51 uint64_t LastReceivedPictureID() const; |
| 52 int32_t Pop(uint32_t timestamp); | 52 void OnDecoderImplementationName(const char* implementation_name); |
| 53 |
| 54 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); |
| 55 int32_t Pop(uint32_t timestamp); |
| 53 | 56 |
| 54 private: | 57 private: |
| 55 // Protect |_receiveCallback| and |_timestampMap|. | 58 // Protect |_receiveCallback| and |_timestampMap|. |
| 56 CriticalSectionWrapper* _critSect; | 59 rtc::CriticalSection _critSect; |
| 57 Clock* _clock; | 60 Clock* _clock; |
| 58 VCMReceiveCallback* _receiveCallback GUARDED_BY(_critSect); | 61 VCMReceiveCallback* _receiveCallback GUARDED_BY(_critSect); |
| 59 VCMTiming* _timing; | 62 VCMTiming* _timing; |
| 60 VCMTimestampMap _timestampMap GUARDED_BY(_critSect); | 63 VCMTimestampMap _timestampMap GUARDED_BY(_critSect); |
| 61 uint64_t _lastReceivedPictureID; | 64 uint64_t _lastReceivedPictureID; |
| 65 rtc::ThreadChecker decoder_thread_checker_; |
| 66 rtc::ThreadChecker construction_thread_checker_; |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 class VCMGenericDecoder { | 69 class VCMGenericDecoder { |
| 65 friend class VCMCodecDataBase; | 70 friend class VCMCodecDataBase; |
| 66 | 71 |
| 67 public: | 72 public: |
| 68 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); | 73 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); |
| 69 ~VCMGenericDecoder(); | 74 ~VCMGenericDecoder(); |
| 70 | 75 |
| 71 /** | 76 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 85 */ | 90 */ |
| 86 int32_t Release(); | 91 int32_t Release(); |
| 87 | 92 |
| 88 /** | 93 /** |
| 89 * Set decode callback. Deregistering while decoding is illegal. | 94 * Set decode callback. Deregistering while decoding is illegal. |
| 90 */ | 95 */ |
| 91 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); | 96 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); |
| 92 | 97 |
| 93 bool External() const; | 98 bool External() const; |
| 94 bool PrefersLateDecoding() const; | 99 bool PrefersLateDecoding() const; |
| 100 void PollDecodedFrames(); |
| 95 | 101 |
| 96 private: | 102 private: |
| 97 VCMDecodedFrameCallback* _callback; | 103 VCMDecodedFrameCallback* _callback; |
| 98 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength]; | 104 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength]; |
| 99 uint32_t _nextFrameInfoIdx; | 105 uint32_t _nextFrameInfoIdx; |
| 100 VideoDecoder* const _decoder; | 106 VideoDecoder* const _decoder; |
| 101 VideoCodecType _codecType; | 107 VideoCodecType _codecType; |
| 102 bool _isExternal; | 108 bool _isExternal; |
| 103 bool _keyFrameDecoded; | 109 bool _keyFrameDecoded; |
| 110 rtc::ThreadChecker decoder_thread_checker_; |
| 104 }; | 111 }; |
| 105 | 112 |
| 106 } // namespace webrtc | 113 } // namespace webrtc |
| 107 | 114 |
| 108 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ | 115 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ |
| OLD | NEW |