| 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/logging.h" | 11 #include "webrtc/base/logging.h" |
| 12 #include "webrtc/base/trace_event.h" | 12 #include "webrtc/base/trace_event.h" |
| 13 #include "webrtc/modules/video_coding/include/video_coding.h" | 13 #include "webrtc/modules/video_coding/include/video_coding.h" |
| 14 #include "webrtc/modules/video_coding/generic_decoder.h" | 14 #include "webrtc/modules/video_coding/generic_decoder.h" |
| 15 #include "webrtc/modules/video_coding/internal_defines.h" | 15 #include "webrtc/modules/video_coding/internal_defines.h" |
| 16 #include "webrtc/system_wrappers/include/clock.h" | 16 #include "webrtc/system_wrappers/include/clock.h" |
| 17 | 17 |
| 18 namespace webrtc { | 18 namespace webrtc { |
| 19 | 19 |
| 20 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, | 20 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, |
| 21 Clock* clock) | 21 Clock* clock) |
| 22 : | 22 : _critSect(CriticalSectionWrapper::CreateCriticalSection()), |
| 23 _critSect(CriticalSectionWrapper::CreateCriticalSection()), | 23 _clock(clock), |
| 24 _clock(clock), | 24 _receiveCallback(NULL), |
| 25 _receiveCallback(NULL), | 25 _timing(timing), |
| 26 _timing(timing), | 26 _timestampMap(kDecoderFrameMemoryLength), |
| 27 _timestampMap(kDecoderFrameMemoryLength), | 27 _lastReceivedPictureID(0) {} |
| 28 _lastReceivedPictureID(0) | |
| 29 { | |
| 30 } | |
| 31 | 28 |
| 32 VCMDecodedFrameCallback::~VCMDecodedFrameCallback() | 29 VCMDecodedFrameCallback::~VCMDecodedFrameCallback() |
| 33 { | 30 { |
| 34 delete _critSect; | 31 delete _critSect; |
| 35 } | 32 } |
| 36 | 33 |
| 37 void VCMDecodedFrameCallback::SetUserReceiveCallback( | 34 void VCMDecodedFrameCallback::SetUserReceiveCallback( |
| 38 VCMReceiveCallback* receiveCallback) | 35 VCMReceiveCallback* receiveCallback) |
| 39 { | 36 { |
| 40 CriticalSectionScoped cs(_critSect); | 37 CriticalSectionScoped cs(_critSect); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 { | 105 { |
| 109 _lastReceivedPictureID = pictureId; | 106 _lastReceivedPictureID = pictureId; |
| 110 return 0; | 107 return 0; |
| 111 } | 108 } |
| 112 | 109 |
| 113 uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const | 110 uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const |
| 114 { | 111 { |
| 115 return _lastReceivedPictureID; | 112 return _lastReceivedPictureID; |
| 116 } | 113 } |
| 117 | 114 |
| 115 void VCMDecodedFrameCallback::OnDecoderImplementationName( |
| 116 const char* implementation_name) { |
| 117 CriticalSectionScoped cs(_critSect); |
| 118 if (_receiveCallback) |
| 119 _receiveCallback->OnDecoderImplementationName(implementation_name); |
| 120 } |
| 121 |
| 118 void VCMDecodedFrameCallback::Map(uint32_t timestamp, | 122 void VCMDecodedFrameCallback::Map(uint32_t timestamp, |
| 119 VCMFrameInformation* frameInfo) { | 123 VCMFrameInformation* frameInfo) { |
| 120 CriticalSectionScoped cs(_critSect); | 124 CriticalSectionScoped cs(_critSect); |
| 121 _timestampMap.Add(timestamp, frameInfo); | 125 _timestampMap.Add(timestamp, frameInfo); |
| 122 } | 126 } |
| 123 | 127 |
| 124 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) | 128 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) |
| 125 { | 129 { |
| 126 CriticalSectionScoped cs(_critSect); | 130 CriticalSectionScoped cs(_critSect); |
| 127 if (_timestampMap.Pop(timestamp) == NULL) | 131 if (_timestampMap.Pop(timestamp) == NULL) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); | 168 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); |
| 165 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); | 169 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); |
| 166 | 170 |
| 167 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; | 171 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; |
| 168 int32_t ret = _decoder.Decode(frame.EncodedImage(), | 172 int32_t ret = _decoder.Decode(frame.EncodedImage(), |
| 169 frame.MissingFrame(), | 173 frame.MissingFrame(), |
| 170 frame.FragmentationHeader(), | 174 frame.FragmentationHeader(), |
| 171 frame.CodecSpecific(), | 175 frame.CodecSpecific(), |
| 172 frame.RenderTimeMs()); | 176 frame.RenderTimeMs()); |
| 173 | 177 |
| 178 _callback->OnDecoderImplementationName(_decoder.ImplementationName()); |
| 174 if (ret < WEBRTC_VIDEO_CODEC_OK) | 179 if (ret < WEBRTC_VIDEO_CODEC_OK) |
| 175 { | 180 { |
| 176 LOG(LS_WARNING) << "Failed to decode frame with timestamp " | 181 LOG(LS_WARNING) << "Failed to decode frame with timestamp " |
| 177 << frame.TimeStamp() << ", error code: " << ret; | 182 << frame.TimeStamp() << ", error code: " << ret; |
| 178 _callback->Pop(frame.TimeStamp()); | 183 _callback->Pop(frame.TimeStamp()); |
| 179 return ret; | 184 return ret; |
| 180 } | 185 } |
| 181 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || | 186 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || |
| 182 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) | 187 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) |
| 183 { | 188 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 203 _callback = callback; | 208 _callback = callback; |
| 204 return _decoder.RegisterDecodeCompleteCallback(callback); | 209 return _decoder.RegisterDecodeCompleteCallback(callback); |
| 205 } | 210 } |
| 206 | 211 |
| 207 bool VCMGenericDecoder::External() const | 212 bool VCMGenericDecoder::External() const |
| 208 { | 213 { |
| 209 return _isExternal; | 214 return _isExternal; |
| 210 } | 215 } |
| 211 | 216 |
| 212 } // namespace | 217 } // namespace |
| OLD | NEW |