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 29 matching lines...) Expand all Loading... |
157 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; | 161 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; |
158 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); | 162 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); |
159 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); | 163 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); |
160 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); | 164 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); |
161 | 165 |
162 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; | 166 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; |
163 int32_t ret = _decoder->Decode(frame.EncodedImage(), frame.MissingFrame(), | 167 int32_t ret = _decoder->Decode(frame.EncodedImage(), frame.MissingFrame(), |
164 frame.FragmentationHeader(), | 168 frame.FragmentationHeader(), |
165 frame.CodecSpecific(), frame.RenderTimeMs()); | 169 frame.CodecSpecific(), frame.RenderTimeMs()); |
166 | 170 |
| 171 _callback->OnDecoderImplementationName(_decoder->ImplementationName()); |
167 if (ret < WEBRTC_VIDEO_CODEC_OK) | 172 if (ret < WEBRTC_VIDEO_CODEC_OK) |
168 { | 173 { |
169 LOG(LS_WARNING) << "Failed to decode frame with timestamp " | 174 LOG(LS_WARNING) << "Failed to decode frame with timestamp " |
170 << frame.TimeStamp() << ", error code: " << ret; | 175 << frame.TimeStamp() << ", error code: " << ret; |
171 _callback->Pop(frame.TimeStamp()); | 176 _callback->Pop(frame.TimeStamp()); |
172 return ret; | 177 return ret; |
173 } | 178 } |
174 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || | 179 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || |
175 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) | 180 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) |
176 { | 181 { |
(...skipping 19 matching lines...) Expand all Loading... |
196 | 201 |
197 bool VCMGenericDecoder::External() const { | 202 bool VCMGenericDecoder::External() const { |
198 return _isExternal; | 203 return _isExternal; |
199 } | 204 } |
200 | 205 |
201 bool VCMGenericDecoder::PrefersLateDecoding() const { | 206 bool VCMGenericDecoder::PrefersLateDecoding() const { |
202 return _decoder->PrefersLateDecoding(); | 207 return _decoder->PrefersLateDecoding(); |
203 } | 208 } |
204 | 209 |
205 } // namespace | 210 } // namespace |
OLD | NEW |