Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: webrtc/modules/video_coding/main/source/generic_decoder.cc

Issue 1422963003: Android MediaCodecVideoDecoder: Manage lifetime of texture frames (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 CriticalSectionScoped cs(_critSect); 39 CriticalSectionScoped cs(_critSect);
40 _receiveCallback = receiveCallback; 40 _receiveCallback = receiveCallback;
41 } 41 }
42 42
43 VCMReceiveCallback* VCMDecodedFrameCallback::UserReceiveCallback() 43 VCMReceiveCallback* VCMDecodedFrameCallback::UserReceiveCallback()
44 { 44 {
45 CriticalSectionScoped cs(_critSect); 45 CriticalSectionScoped cs(_critSect);
46 return _receiveCallback; 46 return _receiveCallback;
47 } 47 }
48 48
49 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
50 int decodeTimeInMs) {
51 // TODO(holmer): We should improve this so that we can handle multiple
52 // callbacks from one call to Decode().
53 VCMFrameInformation* frameInfo;
54 VCMReceiveCallback* callback;
55 {
56 CriticalSectionScoped cs(_critSect);
57 frameInfo = _timestampMap.Pop(decodedImage.timestamp());
58 callback = _receiveCallback;
59 }
60
61 if (frameInfo == NULL) {
62 LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping "
63 "this one.";
64 return WEBRTC_VIDEO_CODEC_OK;
65 }
66
67 int64_t stopTime =
68 (decodeTimeInMs != 0) ? frameInfo->decodeStartTimeMs + decodeTimeInMs :
magjed_webrtc 2015/10/28 11:57:16 I think you should make this lessy hacky and land
69 _clock->TimeInMilliseconds();
70 _timing.StopDecodeTimer(
71 decodedImage.timestamp(),
72 frameInfo->decodeStartTimeMs,
73 stopTime,
74 frameInfo->renderTimeMs);
75
76 if (callback != NULL)
77 {
78 decodedImage.set_render_time_ms(frameInfo->renderTimeMs);
79 decodedImage.set_rotation(frameInfo->rotation);
80 callback->FrameToRender(decodedImage);
81 }
82 return WEBRTC_VIDEO_CODEC_OK;
83 }
84
49 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) { 85 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) {
50 // TODO(holmer): We should improve this so that we can handle multiple 86 return Decoded(decodedImage, 0);
51 // callbacks from one call to Decode().
52 VCMFrameInformation* frameInfo;
53 VCMReceiveCallback* callback;
54 {
55 CriticalSectionScoped cs(_critSect);
56 frameInfo = _timestampMap.Pop(decodedImage.timestamp());
57 callback = _receiveCallback;
58 }
59
60 if (frameInfo == NULL) {
61 LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping "
62 "this one.";
63 return WEBRTC_VIDEO_CODEC_OK;
64 }
65
66 _timing.StopDecodeTimer(
67 decodedImage.timestamp(),
68 frameInfo->decodeStartTimeMs,
69 _clock->TimeInMilliseconds(),
70 frameInfo->renderTimeMs);
71
72 if (callback != NULL)
73 {
74 decodedImage.set_render_time_ms(frameInfo->renderTimeMs);
75 decodedImage.set_rotation(frameInfo->rotation);
76 callback->FrameToRender(decodedImage);
77 }
78 return WEBRTC_VIDEO_CODEC_OK;
79 } 87 }
80 88
81 int32_t 89 int32_t
82 VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame( 90 VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
83 const uint64_t pictureId) 91 const uint64_t pictureId)
84 { 92 {
85 CriticalSectionScoped cs(_critSect); 93 CriticalSectionScoped cs(_critSect);
86 if (_receiveCallback != NULL) 94 if (_receiveCallback != NULL)
87 { 95 {
88 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId); 96 return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 _callback = callback; 197 _callback = callback;
190 return _decoder.RegisterDecodeCompleteCallback(callback); 198 return _decoder.RegisterDecodeCompleteCallback(callback);
191 } 199 }
192 200
193 bool VCMGenericDecoder::External() const 201 bool VCMGenericDecoder::External() const
194 { 202 {
195 return _isExternal; 203 return _isExternal;
196 } 204 }
197 205
198 } // namespace 206 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698