| 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 30 matching lines...) Expand all Loading... |
| 41 CriticalSectionScoped cs(_critSect); | 41 CriticalSectionScoped cs(_critSect); |
| 42 return _receiveCallback; | 42 return _receiveCallback; |
| 43 } | 43 } |
| 44 | 44 |
| 45 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) { | 45 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) { |
| 46 return Decoded(decodedImage, -1); | 46 return Decoded(decodedImage, -1); |
| 47 } | 47 } |
| 48 | 48 |
| 49 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, | 49 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, |
| 50 int64_t decode_time_ms) { | 50 int64_t decode_time_ms) { |
| 51 Decoded(decodedImage, | |
| 52 decode_time_ms >= 0 ? rtc::Optional<int32_t>(decode_time_ms) | |
| 53 : rtc::Optional<int32_t>(), | |
| 54 rtc::Optional<uint8_t>()); | |
| 55 return WEBRTC_VIDEO_CODEC_OK; | |
| 56 } | |
| 57 | |
| 58 void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, | |
| 59 rtc::Optional<int32_t> decode_time_ms, | |
| 60 rtc::Optional<uint8_t> qp) { | |
| 61 TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded", | 51 TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded", |
| 62 "timestamp", decodedImage.timestamp()); | 52 "timestamp", decodedImage.timestamp()); |
| 63 // TODO(holmer): We should improve this so that we can handle multiple | 53 // TODO(holmer): We should improve this so that we can handle multiple |
| 64 // callbacks from one call to Decode(). | 54 // callbacks from one call to Decode(). |
| 65 VCMFrameInformation* frameInfo; | 55 VCMFrameInformation* frameInfo; |
| 66 VCMReceiveCallback* callback; | 56 VCMReceiveCallback* callback; |
| 67 { | 57 { |
| 68 CriticalSectionScoped cs(_critSect); | 58 CriticalSectionScoped cs(_critSect); |
| 69 frameInfo = _timestampMap.Pop(decodedImage.timestamp()); | 59 frameInfo = _timestampMap.Pop(decodedImage.timestamp()); |
| 70 callback = _receiveCallback; | 60 callback = _receiveCallback; |
| 71 } | 61 } |
| 72 | 62 |
| 73 if (frameInfo == NULL) { | 63 if (frameInfo == NULL) { |
| 74 LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping " | 64 LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping " |
| 75 "this one."; | 65 "this one."; |
| 76 return; | 66 return WEBRTC_VIDEO_CODEC_OK; |
| 77 } | 67 } |
| 78 | 68 |
| 79 const int64_t now_ms = _clock->TimeInMilliseconds(); | 69 const int64_t now_ms = _clock->TimeInMilliseconds(); |
| 80 if (!decode_time_ms) { | 70 if (decode_time_ms < 0) { |
| 81 decode_time_ms = | 71 decode_time_ms = |
| 82 rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs); | 72 static_cast<int32_t>(now_ms - frameInfo->decodeStartTimeMs); |
| 83 } | 73 } |
| 84 _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms, | 74 _timing->StopDecodeTimer(decodedImage.timestamp(), decode_time_ms, now_ms, |
| 85 frameInfo->renderTimeMs); | 75 frameInfo->renderTimeMs); |
| 86 | 76 |
| 87 decodedImage.set_timestamp_us( | 77 decodedImage.set_timestamp_us( |
| 88 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); | 78 frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec); |
| 89 decodedImage.set_rotation(frameInfo->rotation); | 79 decodedImage.set_rotation(frameInfo->rotation); |
| 90 // TODO(sakal): Investigate why callback is NULL sometimes and replace if | 80 // TODO(sakal): Investigate why callback is NULL sometimes and replace if |
| 91 // statement with a DCHECK. | 81 // statement with a DCHECK. |
| 92 if (callback) { | 82 if (callback) { |
| 93 callback->FrameToRender(decodedImage, qp); | 83 callback->FrameToRender(decodedImage); |
| 94 } else { | 84 } else { |
| 95 LOG(LS_WARNING) << "No callback, dropping frame."; | 85 LOG(LS_WARNING) << "No callback, dropping frame."; |
| 96 } | 86 } |
| 87 return WEBRTC_VIDEO_CODEC_OK; |
| 97 } | 88 } |
| 98 | 89 |
| 99 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( | 90 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( |
| 100 const uint64_t pictureId) { | 91 const uint64_t pictureId) { |
| 101 CriticalSectionScoped cs(_critSect); | 92 CriticalSectionScoped cs(_critSect); |
| 102 if (_receiveCallback != NULL) { | 93 if (_receiveCallback != NULL) { |
| 103 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId); | 94 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId); |
| 104 } | 95 } |
| 105 return -1; | 96 return -1; |
| 106 } | 97 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 186 |
| 196 bool VCMGenericDecoder::External() const { | 187 bool VCMGenericDecoder::External() const { |
| 197 return _isExternal; | 188 return _isExternal; |
| 198 } | 189 } |
| 199 | 190 |
| 200 bool VCMGenericDecoder::PrefersLateDecoding() const { | 191 bool VCMGenericDecoder::PrefersLateDecoding() const { |
| 201 return _decoder->PrefersLateDecoding(); | 192 return _decoder->PrefersLateDecoding(); |
| 202 } | 193 } |
| 203 | 194 |
| 204 } // namespace webrtc | 195 } // namespace webrtc |
| OLD | NEW |