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); | 36 virtual ~VCMDecodedFrameCallback(); |
39 virtual ~VCMDecodedFrameCallback(); | 37 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); |
40 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); | 38 VCMReceiveCallback* UserReceiveCallback(); |
41 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 |
45 virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId); | 42 int64_t decode_time_ms); |
46 virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId); | 43 virtual int32_t ReceivedDecodedReferenceFrame(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 | 47 |
50 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); | 48 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); |
51 int32_t Pop(uint32_t timestamp); | 49 int32_t Pop(uint32_t timestamp); |
52 | 50 |
53 private: | 51 private: |
54 // Protect |_receiveCallback| and |_timestampMap|. | 52 // Protect |_receiveCallback| and |_timestampMap|. |
55 CriticalSectionWrapper* _critSect; | 53 CriticalSectionWrapper* _critSect; |
56 Clock* _clock; | 54 Clock* _clock; |
57 VCMReceiveCallback* _receiveCallback; // Guarded by |_critSect|. | 55 VCMReceiveCallback* _receiveCallback; // Guarded by |_critSect|. |
58 VCMTiming& _timing; | 56 VCMTiming* _timing; |
59 VCMTimestampMap _timestampMap; // Guarded by |_critSect|. | 57 VCMTimestampMap _timestampMap; // Guarded by |_critSect|. |
60 uint64_t _lastReceivedPictureID; | 58 uint64_t _lastReceivedPictureID; |
61 }; | 59 }; |
62 | 60 |
| 61 class VCMGenericDecoder { |
| 62 friend class VCMCodecDataBase; |
63 | 63 |
64 class VCMGenericDecoder | 64 public: |
65 { | 65 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); |
66 friend class VCMCodecDataBase; | 66 ~VCMGenericDecoder(); |
67 public: | |
68 VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); | |
69 ~VCMGenericDecoder(); | |
70 | 67 |
71 /** | 68 /** |
72 * Initialize the decoder with the information from the VideoCodec | 69 * Initialize the decoder with the information from the VideoCodec |
73 */ | 70 */ |
74 int32_t InitDecode(const VideoCodec* settings, | 71 int32_t InitDecode(const VideoCodec* settings, int32_t numberOfCores); |
75 int32_t numberOfCores); | |
76 | 72 |
77 /** | 73 /** |
78 * Decode to a raw I420 frame, | 74 * Decode to a raw I420 frame, |
79 * | 75 * |
80 * inputVideoBuffer reference to encoded video frame | 76 * inputVideoBuffer reference to encoded video frame |
81 */ | 77 */ |
82 int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs); | 78 int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs); |
83 | 79 |
84 /** | 80 /** |
85 * Free the decoder memory | 81 * Free the decoder memory |
86 */ | 82 */ |
87 int32_t Release(); | 83 int32_t Release(); |
88 | 84 |
89 /** | 85 /** |
90 * Reset the decoder state, prepare for a new call | 86 * Reset the decoder state, prepare for a new call |
91 */ | 87 */ |
92 int32_t Reset(); | 88 int32_t Reset(); |
93 | 89 |
94 /** | 90 /** |
95 * Set decode callback. Deregistering while decoding is illegal. | 91 * Set decode callback. Deregistering while decoding is illegal. |
96 */ | 92 */ |
97 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); | 93 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); |
98 | 94 |
99 bool External() const; | 95 bool External() const; |
100 bool PrefersLateDecoding() const; | 96 bool PrefersLateDecoding() const; |
101 | 97 |
102 private: | 98 private: |
103 VCMDecodedFrameCallback* _callback; | 99 VCMDecodedFrameCallback* _callback; |
104 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength]; | 100 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength]; |
105 uint32_t _nextFrameInfoIdx; | 101 uint32_t _nextFrameInfoIdx; |
106 VideoDecoder* const _decoder; | 102 VideoDecoder* const _decoder; |
107 VideoCodecType _codecType; | 103 VideoCodecType _codecType; |
108 bool _isExternal; | 104 bool _isExternal; |
109 bool _keyFrameDecoded; | 105 bool _keyFrameDecoded; |
110 }; | 106 }; |
111 | 107 |
112 } // namespace webrtc | 108 } // namespace webrtc |
113 | 109 |
114 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ | 110 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ |
OLD | NEW |