| 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/modules/video_coding/main/interface/video_coding.h" | 11 #include "webrtc/modules/video_coding/main/interface/video_coding.h" |
| 12 #include "webrtc/modules/video_coding/main/source/generic_decoder.h" | 12 #include "webrtc/modules/video_coding/main/source/generic_decoder.h" |
| 13 #include "webrtc/modules/video_coding/main/source/internal_defines.h" | 13 #include "webrtc/modules/video_coding/main/source/internal_defines.h" |
| 14 #include "webrtc/system_wrappers/interface/clock.h" | 14 #include "webrtc/system_wrappers/interface/clock.h" |
| 15 #include "webrtc/system_wrappers/interface/logging.h" | 15 #include "webrtc/system_wrappers/interface/logging.h" |
| 16 | 16 |
| 17 namespace webrtc { | 17 namespace webrtc { |
| 18 | 18 |
| 19 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, | 19 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, |
| 20 Clock* clock) | 20 Clock* clock) |
| 21 : | 21 : _critSect(CriticalSectionWrapper::CreateCriticalSection()), |
| 22 _critSect(CriticalSectionWrapper::CreateCriticalSection()), | 22 _clock(clock), |
| 23 _clock(clock), | 23 _receiveCallback(NULL), |
| 24 _receiveCallback(NULL), | 24 _timing(timing), |
| 25 _timing(timing), | 25 _timestampMap(kDecoderFrameMemoryLength), |
| 26 _timestampMap(kDecoderFrameMemoryLength), | 26 _lastReceivedPictureID(0) {} |
| 27 _lastReceivedPictureID(0) | |
| 28 { | |
| 29 } | |
| 30 | 27 |
| 31 VCMDecodedFrameCallback::~VCMDecodedFrameCallback() | 28 VCMDecodedFrameCallback::~VCMDecodedFrameCallback() |
| 32 { | 29 { |
| 33 delete _critSect; | 30 delete _critSect; |
| 34 } | 31 } |
| 35 | 32 |
| 36 void VCMDecodedFrameCallback::SetUserReceiveCallback( | 33 void VCMDecodedFrameCallback::SetUserReceiveCallback( |
| 37 VCMReceiveCallback* receiveCallback) | 34 VCMReceiveCallback* receiveCallback) |
| 38 { | 35 { |
| 39 CriticalSectionScoped cs(_critSect); | 36 CriticalSectionScoped cs(_critSect); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 { | 92 { |
| 96 _lastReceivedPictureID = pictureId; | 93 _lastReceivedPictureID = pictureId; |
| 97 return 0; | 94 return 0; |
| 98 } | 95 } |
| 99 | 96 |
| 100 uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const | 97 uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const |
| 101 { | 98 { |
| 102 return _lastReceivedPictureID; | 99 return _lastReceivedPictureID; |
| 103 } | 100 } |
| 104 | 101 |
| 102 void VCMDecodedFrameCallback::OnDecoderImplementationName( |
| 103 const char* implementation_name) { |
| 104 CriticalSectionScoped cs(_critSect); |
| 105 if (_receiveCallback) |
| 106 _receiveCallback->OnDecoderImplementationName(implementation_name); |
| 107 } |
| 108 |
| 105 void VCMDecodedFrameCallback::Map(uint32_t timestamp, | 109 void VCMDecodedFrameCallback::Map(uint32_t timestamp, |
| 106 VCMFrameInformation* frameInfo) { | 110 VCMFrameInformation* frameInfo) { |
| 107 CriticalSectionScoped cs(_critSect); | 111 CriticalSectionScoped cs(_critSect); |
| 108 _timestampMap.Add(timestamp, frameInfo); | 112 _timestampMap.Add(timestamp, frameInfo); |
| 109 } | 113 } |
| 110 | 114 |
| 111 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) | 115 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) |
| 112 { | 116 { |
| 113 CriticalSectionScoped cs(_critSect); | 117 CriticalSectionScoped cs(_critSect); |
| 114 if (_timestampMap.Pop(timestamp) == NULL) | 118 if (_timestampMap.Pop(timestamp) == NULL) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); | 154 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); |
| 151 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); | 155 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); |
| 152 | 156 |
| 153 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; | 157 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; |
| 154 int32_t ret = _decoder.Decode(frame.EncodedImage(), | 158 int32_t ret = _decoder.Decode(frame.EncodedImage(), |
| 155 frame.MissingFrame(), | 159 frame.MissingFrame(), |
| 156 frame.FragmentationHeader(), | 160 frame.FragmentationHeader(), |
| 157 frame.CodecSpecific(), | 161 frame.CodecSpecific(), |
| 158 frame.RenderTimeMs()); | 162 frame.RenderTimeMs()); |
| 159 | 163 |
| 164 _callback->OnDecoderImplementationName(_decoder.ImplementationName()); |
| 160 if (ret < WEBRTC_VIDEO_CODEC_OK) | 165 if (ret < WEBRTC_VIDEO_CODEC_OK) |
| 161 { | 166 { |
| 162 LOG(LS_WARNING) << "Failed to decode frame with timestamp " | 167 LOG(LS_WARNING) << "Failed to decode frame with timestamp " |
| 163 << frame.TimeStamp() << ", error code: " << ret; | 168 << frame.TimeStamp() << ", error code: " << ret; |
| 164 _callback->Pop(frame.TimeStamp()); | 169 _callback->Pop(frame.TimeStamp()); |
| 165 return ret; | 170 return ret; |
| 166 } | 171 } |
| 167 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || | 172 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || |
| 168 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) | 173 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) |
| 169 { | 174 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 189 _callback = callback; | 194 _callback = callback; |
| 190 return _decoder.RegisterDecodeCompleteCallback(callback); | 195 return _decoder.RegisterDecodeCompleteCallback(callback); |
| 191 } | 196 } |
| 192 | 197 |
| 193 bool VCMGenericDecoder::External() const | 198 bool VCMGenericDecoder::External() const |
| 194 { | 199 { |
| 195 return _isExternal; | 200 return _isExternal; |
| 196 } | 201 } |
| 197 | 202 |
| 198 } // namespace | 203 } // namespace |
| OLD | NEW |