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/logging.h" | 12 #include "webrtc/base/logging.h" |
12 #include "webrtc/base/trace_event.h" | 13 #include "webrtc/base/trace_event.h" |
| 14 #include "webrtc/modules/video_coding/generic_decoder.h" |
13 #include "webrtc/modules/video_coding/include/video_coding.h" | 15 #include "webrtc/modules/video_coding/include/video_coding.h" |
14 #include "webrtc/modules/video_coding/generic_decoder.h" | |
15 #include "webrtc/modules/video_coding/internal_defines.h" | 16 #include "webrtc/modules/video_coding/internal_defines.h" |
16 #include "webrtc/system_wrappers/include/clock.h" | 17 #include "webrtc/system_wrappers/include/clock.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 | 20 |
20 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, | 21 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, |
21 Clock* clock) | 22 Clock* clock) |
22 : | 23 : |
23 _critSect(CriticalSectionWrapper::CreateCriticalSection()), | 24 _critSect(CriticalSectionWrapper::CreateCriticalSection()), |
24 _clock(clock), | 25 _clock(clock), |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) | 125 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) |
125 { | 126 { |
126 CriticalSectionScoped cs(_critSect); | 127 CriticalSectionScoped cs(_critSect); |
127 if (_timestampMap.Pop(timestamp) == NULL) | 128 if (_timestampMap.Pop(timestamp) == NULL) |
128 { | 129 { |
129 return VCM_GENERAL_ERROR; | 130 return VCM_GENERAL_ERROR; |
130 } | 131 } |
131 return VCM_OK; | 132 return VCM_OK; |
132 } | 133 } |
133 | 134 |
134 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder& decoder, bool isExternal) | 135 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal) |
135 : | 136 : _callback(NULL), |
136 _callback(NULL), | 137 _frameInfos(), |
137 _frameInfos(), | 138 _nextFrameInfoIdx(0), |
138 _nextFrameInfoIdx(0), | 139 _decoder(decoder), |
139 _decoder(decoder), | 140 _codecType(kVideoCodecUnknown), |
140 _codecType(kVideoCodecUnknown), | 141 _isExternal(isExternal), |
141 _isExternal(isExternal), | 142 _keyFrameDecoded(false) { |
142 _keyFrameDecoded(false) | 143 RTC_CHECK(_decoder); |
143 { | |
144 } | 144 } |
145 | 145 |
146 VCMGenericDecoder::~VCMGenericDecoder() | 146 VCMGenericDecoder::~VCMGenericDecoder() |
147 { | 147 { |
148 } | 148 } |
149 | 149 |
150 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, | 150 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, |
151 int32_t numberOfCores) | 151 int32_t numberOfCores) |
152 { | 152 { |
153 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode"); | 153 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode"); |
154 _codecType = settings->codecType; | 154 _codecType = settings->codecType; |
155 | 155 |
156 return _decoder.InitDecode(settings, numberOfCores); | 156 return _decoder->InitDecode(settings, numberOfCores); |
157 } | 157 } |
158 | 158 |
159 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) { | 159 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) { |
160 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp", | 160 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp", |
161 frame.EncodedImage()._timeStamp); | 161 frame.EncodedImage()._timeStamp); |
162 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; | 162 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; |
163 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); | 163 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); |
164 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); | 164 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); |
165 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); | 165 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); |
166 | 166 |
167 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; | 167 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; |
168 int32_t ret = _decoder.Decode(frame.EncodedImage(), | 168 int32_t ret = _decoder->Decode(frame.EncodedImage(), |
169 frame.MissingFrame(), | 169 frame.MissingFrame(), |
170 frame.FragmentationHeader(), | 170 frame.FragmentationHeader(), |
171 frame.CodecSpecific(), | 171 frame.CodecSpecific(), |
172 frame.RenderTimeMs()); | 172 frame.RenderTimeMs()); |
173 | 173 |
174 if (ret < WEBRTC_VIDEO_CODEC_OK) | 174 if (ret < WEBRTC_VIDEO_CODEC_OK) |
175 { | 175 { |
176 LOG(LS_WARNING) << "Failed to decode frame with timestamp " | 176 LOG(LS_WARNING) << "Failed to decode frame with timestamp " |
177 << frame.TimeStamp() << ", error code: " << ret; | 177 << frame.TimeStamp() << ", error code: " << ret; |
178 _callback->Pop(frame.TimeStamp()); | 178 _callback->Pop(frame.TimeStamp()); |
179 return ret; | 179 return ret; |
180 } | 180 } |
181 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || | 181 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || |
182 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) | 182 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) |
183 { | 183 { |
184 // No output | 184 // No output |
185 _callback->Pop(frame.TimeStamp()); | 185 _callback->Pop(frame.TimeStamp()); |
186 } | 186 } |
187 return ret; | 187 return ret; |
188 } | 188 } |
189 | 189 |
190 int32_t | 190 int32_t |
191 VCMGenericDecoder::Release() | 191 VCMGenericDecoder::Release() |
192 { | 192 { |
193 return _decoder.Release(); | 193 return _decoder->Release(); |
194 } | 194 } |
195 | 195 |
196 int32_t VCMGenericDecoder::Reset() | 196 int32_t VCMGenericDecoder::Reset() |
197 { | 197 { |
198 return _decoder.Reset(); | 198 return _decoder->Reset(); |
199 } | 199 } |
200 | 200 |
201 int32_t VCMGenericDecoder::RegisterDecodeCompleteCallback(VCMDecodedFrameCallbac
k* callback) | 201 int32_t VCMGenericDecoder::RegisterDecodeCompleteCallback(VCMDecodedFrameCallbac
k* callback) |
202 { | 202 { |
203 _callback = callback; | 203 _callback = callback; |
204 return _decoder.RegisterDecodeCompleteCallback(callback); | 204 return _decoder->RegisterDecodeCompleteCallback(callback); |
205 } | 205 } |
206 | 206 |
207 bool VCMGenericDecoder::External() const | 207 bool VCMGenericDecoder::External() const |
208 { | 208 { |
209 return _isExternal; | 209 return _isExternal; |
210 } | 210 } |
211 | 211 |
212 } // namespace | 212 } // namespace |
OLD | NEW |