| 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); | 39 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); |
| 38 VCMReceiveCallback* UserReceiveCallback(); | 40 VCMReceiveCallback* UserReceiveCallback(); |
| 39 | 41 |
| 40 int32_t Decoded(VideoFrame& decodedImage) override; | 42 int32_t Decoded(VideoFrame& decodedImage) override; |
| 41 int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override; | 43 int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override; |
| 42 void Decoded(VideoFrame& decodedImage, | 44 void Decoded(VideoFrame& decodedImage, |
| 43 rtc::Optional<int32_t> decode_time_ms, | 45 rtc::Optional<int32_t> decode_time_ms, |
| 44 rtc::Optional<uint8_t> qp) override; | 46 rtc::Optional<uint8_t> qp) override; |
| 45 int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override; | 47 int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override; |
| 46 int32_t ReceivedDecodedFrame(const uint64_t pictureId) override; | 48 int32_t ReceivedDecodedFrame(const uint64_t pictureId) override; |
| 47 | 49 |
| 48 uint64_t LastReceivedPictureID() const; | 50 uint64_t LastReceivedPictureID() const; |
| 49 void OnDecoderImplementationName(const char* implementation_name); | 51 void OnDecoderImplementationName(const char* implementation_name); |
| 50 | 52 |
| 51 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); | 53 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); |
| 52 int32_t Pop(uint32_t timestamp); | 54 int32_t Pop(uint32_t timestamp); |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 // Protect |_receiveCallback| and |_timestampMap|. | 57 rtc::ThreadChecker construction_thread_; |
| 56 CriticalSectionWrapper* _critSect; | 58 // Protect |_timestampMap|. |
| 57 Clock* _clock; | 59 Clock* const _clock; |
| 58 VCMReceiveCallback* _receiveCallback GUARDED_BY(_critSect); | 60 // This callback must be set before the decoder thread starts running |
| 59 VCMTiming* _timing; | 61 // and must only be unset when external threads (e.g decoder thread) |
| 60 VCMTimestampMap _timestampMap GUARDED_BY(_critSect); | 62 // have been stopped. Due to that, the variable should regarded as const |
| 61 uint64_t _lastReceivedPictureID; | 63 // while there are more than one threads involved, it must be set |
| 64 // from the same thread, and therfore a lock is not required to access it. |
| 65 VCMReceiveCallback* _receiveCallback = nullptr; |
| 66 VCMTiming* _timing; |
| 67 rtc::CriticalSection lock_; |
| 68 VCMTimestampMap _timestampMap GUARDED_BY(lock_); |
| 69 uint64_t _lastReceivedPictureID; |
| 62 }; | 70 }; |
| 63 | 71 |
| 64 class VCMGenericDecoder { | 72 class VCMGenericDecoder { |
| 65 friend class VCMCodecDataBase; | 73 friend class VCMCodecDataBase; |
| 66 | 74 |
| 67 public: | 75 public: |
| 68 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); | 76 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); |
| 69 ~VCMGenericDecoder(); | 77 ~VCMGenericDecoder(); |
| 70 | 78 |
| 71 /** | 79 /** |
| (...skipping 27 matching lines...) Expand all Loading... |
| 99 uint32_t _nextFrameInfoIdx; | 107 uint32_t _nextFrameInfoIdx; |
| 100 VideoDecoder* const _decoder; | 108 VideoDecoder* const _decoder; |
| 101 VideoCodecType _codecType; | 109 VideoCodecType _codecType; |
| 102 bool _isExternal; | 110 bool _isExternal; |
| 103 bool _keyFrameDecoded; | 111 bool _keyFrameDecoded; |
| 104 }; | 112 }; |
| 105 | 113 |
| 106 } // namespace webrtc | 114 } // namespace webrtc |
| 107 | 115 |
| 108 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ | 116 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ |
| OLD | NEW |