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