Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/rtc_video_decoder_bridge_tv.h" | 5 #include "content/renderer/media/rtc_video_decoder_bridge_tv.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } | 84 } |
| 85 // |input_image_| may be destroyed after this call, so we make a copy of the | 85 // |input_image_| may be destroyed after this call, so we make a copy of the |
| 86 // buffer so that we can queue the buffer asynchronously. | 86 // buffer so that we can queue the buffer asynchronously. |
| 87 scoped_refptr<media::DecoderBuffer> buffer = | 87 scoped_refptr<media::DecoderBuffer> buffer = |
| 88 media::DecoderBuffer::CopyFrom(input_image._buffer, input_image._length); | 88 media::DecoderBuffer::CopyFrom(input_image._buffer, input_image._length); |
| 89 if (render_time_ms != -1) { | 89 if (render_time_ms != -1) { |
| 90 buffer->set_timestamp(base::TimeDelta::FromMilliseconds( | 90 buffer->set_timestamp(base::TimeDelta::FromMilliseconds( |
| 91 render_time_ms - timestamp_offset_millis_)); | 91 render_time_ms - timestamp_offset_millis_)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 factory_->QueueBuffer( | 94 factory_->QueueBuffer(buffer, new_size); |
| 95 buffer, | 95 |
| 96 base::Bind(&RTCVideoDecoderBridgeTv::RunDecodeCompleteCallback, | 96 // WebRTC measures the decoding time and control the timing of the Decode() |
| 97 decode_complete_callback_, | 97 // calls. In GoogleTV's implementation, we let WebRTC think decoding is done |
| 98 input_image._timeStamp, | 98 // here so that we can get frames constantly. |
| 99 size_), | 99 RunDecodeCompleteCallback(input_image._timeStamp); |
| 100 new_size); | |
| 101 | 100 |
| 102 return WEBRTC_VIDEO_CODEC_OK; | 101 return WEBRTC_VIDEO_CODEC_OK; |
| 103 } | 102 } |
| 104 | 103 |
| 105 int32_t RTCVideoDecoderBridgeTv::RegisterDecodeCompleteCallback( | 104 int32_t RTCVideoDecoderBridgeTv::RegisterDecodeCompleteCallback( |
| 106 webrtc::DecodedImageCallback* callback) { | 105 webrtc::DecodedImageCallback* callback) { |
| 107 decode_complete_callback_ = callback; | 106 decode_complete_callback_ = callback; |
| 108 return WEBRTC_VIDEO_CODEC_OK; | 107 return WEBRTC_VIDEO_CODEC_OK; |
| 109 } | 108 } |
| 110 | 109 |
| 111 int32_t RTCVideoDecoderBridgeTv::Release() { | 110 int32_t RTCVideoDecoderBridgeTv::Release() { |
| 112 is_initialized_ = false; | 111 is_initialized_ = false; |
| 113 return WEBRTC_VIDEO_CODEC_OK; | 112 return WEBRTC_VIDEO_CODEC_OK; |
| 114 } | 113 } |
| 115 | 114 |
| 116 int32_t RTCVideoDecoderBridgeTv::Reset() { | 115 int32_t RTCVideoDecoderBridgeTv::Reset() { |
| 117 first_frame_ = true; | 116 first_frame_ = true; |
| 118 return WEBRTC_VIDEO_CODEC_OK; | 117 return WEBRTC_VIDEO_CODEC_OK; |
| 119 } | 118 } |
| 120 | 119 |
| 121 // static | 120 void RTCVideoDecoderBridgeTv::RunDecodeCompleteCallback(int64_t timestamp) { |
|
wonsik
2013/07/29 02:33:28
Since this is used only in RTCVideoDecoderBridgeTv
dwkang1
2013/07/29 02:55:35
Done.
| |
| 122 void RTCVideoDecoderBridgeTv::RunDecodeCompleteCallback( | |
| 123 webrtc::DecodedImageCallback* callback, | |
| 124 int64_t timestamp, | |
| 125 gfx::Size size) { | |
| 126 // We call the decode complete callback function to notify libjingle that | 121 // We call the decode complete callback function to notify libjingle that |
| 127 // decoding is finished. In addition, this also reports back to libjingle that | 122 // decoding is finished. In addition, this also reports back to libjingle that |
| 128 // the particular video frame with |timestamp| is correctly rendered to | 123 // the particular video frame with |timestamp| is correctly rendered to |
| 129 // libjingle, so that it can generate proper stats. | 124 // libjingle, so that it can generate proper stats. |
| 130 webrtc::I420VideoFrame dummy_video_frame; | 125 webrtc::I420VideoFrame dummy_video_frame; |
| 131 int half_width = (size.width() + 1) / 2; | 126 int half_width = (size_.width() + 1) / 2; |
| 132 dummy_video_frame.CreateEmptyFrame( | 127 dummy_video_frame.CreateEmptyFrame( |
| 133 size.width(), size.height(), size.width(), half_width, half_width); | 128 size_.width(), size_.height(), size_.width(), half_width, half_width); |
| 134 dummy_video_frame.set_timestamp(timestamp); | 129 dummy_video_frame.set_timestamp(timestamp); |
| 135 callback->Decoded(dummy_video_frame); | 130 decode_complete_callback_->Decoded(dummy_video_frame); |
| 136 } | 131 } |
| 137 | 132 |
| 138 } // namespace content | 133 } // namespace content |
| OLD | NEW |