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 #include "webrtc/base/checks.h" | 11 #include "webrtc/base/checks.h" |
12 #include "webrtc/base/logging.h" | 12 #include "webrtc/base/logging.h" |
13 #include "webrtc/base/trace_event.h" | 13 #include "webrtc/base/trace_event.h" |
14 #include "webrtc/modules/video_coding/include/video_coding.h" | 14 #include "webrtc/modules/video_coding/include/video_coding.h" |
15 #include "webrtc/modules/video_coding/generic_decoder.h" | 15 #include "webrtc/modules/video_coding/generic_decoder.h" |
16 #include "webrtc/modules/video_coding/internal_defines.h" | 16 #include "webrtc/modules/video_coding/internal_defines.h" |
17 #include "webrtc/system_wrappers/include/clock.h" | 17 #include "webrtc/system_wrappers/include/clock.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming* timing, | 21 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming* timing, |
22 Clock* clock) | 22 Clock* clock) |
23 : _critSect(CriticalSectionWrapper::CreateCriticalSection()), | 23 : _critSect(CriticalSectionWrapper::CreateCriticalSection()), |
24 _clock(clock), | 24 _clock(clock), |
25 _receiveCallback(NULL), | 25 _receiveCallback(nullptr), |
26 _timing(timing), | 26 _timing(timing), |
27 _timestampMap(kDecoderFrameMemoryLength), | 27 _timestampMap(kDecoderFrameMemoryLength), |
28 _lastReceivedPictureID(0) {} | 28 _lastReceivedPictureID(0) {} |
29 | 29 |
30 VCMDecodedFrameCallback::~VCMDecodedFrameCallback() { | 30 VCMDecodedFrameCallback::~VCMDecodedFrameCallback() { |
31 delete _critSect; | 31 delete _critSect; |
32 } | 32 } |
33 | 33 |
34 void VCMDecodedFrameCallback::SetUserReceiveCallback( | 34 void VCMDecodedFrameCallback::SetUserReceiveCallback( |
35 VCMReceiveCallback* receiveCallback) { | 35 VCMReceiveCallback* receiveCallback) { |
(...skipping 27 matching lines...) Expand all Loading... |
63 // TODO(holmer): We should improve this so that we can handle multiple | 63 // TODO(holmer): We should improve this so that we can handle multiple |
64 // callbacks from one call to Decode(). | 64 // callbacks from one call to Decode(). |
65 VCMFrameInformation* frameInfo; | 65 VCMFrameInformation* frameInfo; |
66 VCMReceiveCallback* callback; | 66 VCMReceiveCallback* callback; |
67 { | 67 { |
68 CriticalSectionScoped cs(_critSect); | 68 CriticalSectionScoped cs(_critSect); |
69 frameInfo = _timestampMap.Pop(decodedImage.timestamp()); | 69 frameInfo = _timestampMap.Pop(decodedImage.timestamp()); |
70 callback = _receiveCallback; | 70 callback = _receiveCallback; |
71 } | 71 } |
72 | 72 |
73 if (frameInfo == NULL) { | 73 if (frameInfo == nullptr) { |
74 LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping " | 74 LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping " |
75 "this one."; | 75 "this one."; |
76 return; | 76 return; |
77 } | 77 } |
78 | 78 |
79 const int64_t now_ms = _clock->TimeInMilliseconds(); | 79 const int64_t now_ms = _clock->TimeInMilliseconds(); |
80 if (!decode_time_ms) { | 80 if (!decode_time_ms) { |
81 decode_time_ms = | 81 decode_time_ms = |
82 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs); | 82 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs); |
83 } | 83 } |
84 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms, | 84 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms, |
85 frameInfo->renderTimeMs); | 85 frameInfo->renderTimeMs); |
86 | 86 |
87 decodedImage.set_timestamp_us( | 87 decodedImage.set_timestamp_us( |
88 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); | 88 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); |
89 decodedImage.set_rotation(frameInfo->rotation); | 89 decodedImage.set_rotation(frameInfo->rotation); |
90 // TODO(sakal): Investigate why callback is NULL sometimes and replace if | 90 // TODO(sakal): Investigate why callback is null sometimes and replace if |
91 // statement with a DCHECK. | 91 // statement with a DCHECK. |
92 if (callback) { | 92 if (callback) { |
93 callback->FrameToRender(decodedImage, qp); | 93 callback->FrameToRender(decodedImage, qp); |
94 } else { | 94 } else { |
95 LOG(LS_WARNING) << "No callback, dropping frame."; | 95 LOG(LS_WARNING) << "No callback, dropping frame."; |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( | 99 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( |
100 const uint64_t pictureId) { | 100 const uint64_t pictureId) { |
101 CriticalSectionScoped cs(_critSect); | 101 CriticalSectionScoped cs(_critSect); |
102 if (_receiveCallback != NULL) { | 102 if (_receiveCallback != nullptr) { |
103 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId); | 103 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId); |
104 } | 104 } |
105 return -1; | 105 return -1; |
106 } | 106 } |
107 | 107 |
108 int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame( | 108 int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame( |
109 const uint64_t pictureId) { | 109 const uint64_t pictureId) { |
110 _lastReceivedPictureID = pictureId; | 110 _lastReceivedPictureID = pictureId; |
111 return 0; | 111 return 0; |
112 } | 112 } |
(...skipping 10 matching lines...) Expand all Loading... |
123 } | 123 } |
124 | 124 |
125 void VCMDecodedFrameCallback::Map(uint32_t timestamp, | 125 void VCMDecodedFrameCallback::Map(uint32_t timestamp, |
126 VCMFrameInformation* frameInfo) { | 126 VCMFrameInformation* frameInfo) { |
127 CriticalSectionScoped cs(_critSect); | 127 CriticalSectionScoped cs(_critSect); |
128 _timestampMap.Add(timestamp, frameInfo); | 128 _timestampMap.Add(timestamp, frameInfo); |
129 } | 129 } |
130 | 130 |
131 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) { | 131 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) { |
132 CriticalSectionScoped cs(_critSect); | 132 CriticalSectionScoped cs(_critSect); |
133 if (_timestampMap.Pop(timestamp) == NULL) { | 133 if (_timestampMap.Pop(timestamp) == nullptr) { |
134 return VCM_GENERAL_ERROR; | 134 return VCM_GENERAL_ERROR; |
135 } | 135 } |
136 return VCM_OK; | 136 return VCM_OK; |
137 } | 137 } |
138 | 138 |
139 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal) | 139 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal) |
140 : _callback(NULL), | 140 : _callback(nullptr), |
141 _frameInfos(), | 141 _frameInfos(), |
142 _nextFrameInfoIdx(0), | 142 _nextFrameInfoIdx(0), |
143 _decoder(decoder), | 143 _decoder(decoder), |
144 _codecType(kVideoCodecUnknown), | 144 _codecType(kVideoCodecUnknown), |
145 _isExternal(isExternal), | 145 _isExternal(isExternal), |
146 _keyFrameDecoded(false) {} | 146 _keyFrameDecoded(false) {} |
147 | 147 |
148 VCMGenericDecoder::~VCMGenericDecoder() {} | 148 VCMGenericDecoder::~VCMGenericDecoder() {} |
149 | 149 |
150 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, | 150 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 bool VCMGenericDecoder::External() const { | 196 bool VCMGenericDecoder::External() const { |
197 return _isExternal; | 197 return _isExternal; |
198 } | 198 } |
199 | 199 |
200 bool VCMGenericDecoder::PrefersLateDecoding() const { | 200 bool VCMGenericDecoder::PrefersLateDecoding() const { |
201 return _decoder->PrefersLateDecoding(); | 201 return _decoder->PrefersLateDecoding(); |
202 } | 202 } |
203 | 203 |
204 } // namespace webrtc | 204 } // namespace webrtc |
OLD | NEW |