| 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.h" | 5 #include "content/renderer/media/rtc_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 11 #include "base/safe_numerics.h" | 11 #include "base/safe_numerics.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
| 14 #include "content/child/child_thread.h" | 14 #include "content/child/child_thread.h" |
| 15 #include "content/renderer/media/native_handle_impl.h" |
| 15 #include "media/base/bind_to_loop.h" | 16 #include "media/base/bind_to_loop.h" |
| 16 #include "media/filters/gpu_video_decoder_factories.h" | 17 #include "media/filters/gpu_video_decoder_factories.h" |
| 18 #include "third_party/webrtc/common_video/interface/texture_video_frame.h" |
| 17 #include "third_party/webrtc/system_wrappers/interface/ref_count.h" | 19 #include "third_party/webrtc/system_wrappers/interface/ref_count.h" |
| 18 | 20 |
| 19 namespace content { | 21 namespace content { |
| 20 | 22 |
| 21 const int32 RTCVideoDecoder::ID_LAST = 0x3FFFFFFF; | 23 const int32 RTCVideoDecoder::ID_LAST = 0x3FFFFFFF; |
| 22 const int32 RTCVideoDecoder::ID_HALF = 0x20000000; | 24 const int32 RTCVideoDecoder::ID_HALF = 0x20000000; |
| 23 const int32 RTCVideoDecoder::ID_INVALID = -1; | 25 const int32 RTCVideoDecoder::ID_INVALID = -1; |
| 24 | 26 |
| 25 // Maximum number of concurrent VDA::Decode() operations RVD will maintain. | 27 // Maximum number of concurrent VDA::Decode() operations RVD will maintain. |
| 26 // Higher values allow better pipelining in the GPU, but also require more | 28 // Higher values allow better pipelining in the GPU, but also require more |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 size_t size = 0; | 355 size_t size = 0; |
| 354 GetBufferData( | 356 GetBufferData( |
| 355 picture.bitstream_buffer_id(), ×tamp, &width, &height, &size); | 357 picture.bitstream_buffer_id(), ×tamp, &width, &height, &size); |
| 356 scoped_refptr<media::VideoFrame> frame = | 358 scoped_refptr<media::VideoFrame> frame = |
| 357 CreateVideoFrame(picture, pb, timestamp, width, height, size); | 359 CreateVideoFrame(picture, pb, timestamp, width, height, size); |
| 358 bool inserted = | 360 bool inserted = |
| 359 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second; | 361 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second; |
| 360 DCHECK(inserted); | 362 DCHECK(inserted); |
| 361 | 363 |
| 362 // Create a WebRTC video frame. | 364 // Create a WebRTC video frame. |
| 363 // TODO(wuchengli): make media::VideoFrame an opaque native handle and put it | 365 webrtc::RefCountImpl<NativeHandleImpl>* handle = |
| 364 // into WebRTC frame. | 366 new webrtc::RefCountImpl<NativeHandleImpl>(frame); |
| 365 webrtc::I420VideoFrame decoded_image; | 367 webrtc::TextureVideoFrame decoded_image(handle, width, height, timestamp, 0); |
| 366 decoded_image.CreateEmptyFrame( | |
| 367 width, height, width, (width + 1) / 2, (width + 1) / 2); | |
| 368 decoded_image.set_timestamp(timestamp); | |
| 369 | 368 |
| 370 // Invoke decode callback. WebRTC expects no frame callback after Release. | 369 // Invoke decode callback. WebRTC expects no frame callback after Release. |
| 371 { | 370 { |
| 372 base::AutoLock auto_lock(lock_); | 371 base::AutoLock auto_lock(lock_); |
| 373 DCHECK(decode_complete_callback_ != NULL); | 372 DCHECK(decode_complete_callback_ != NULL); |
| 374 if (IsBufferAfterReset(picture.bitstream_buffer_id(), | 373 if (IsBufferAfterReset(picture.bitstream_buffer_id(), |
| 375 reset_bitstream_buffer_id_)) { | 374 reset_bitstream_buffer_id_)) { |
| 376 decode_complete_callback_->Decoded(decoded_image); | 375 decode_complete_callback_->Decoded(decoded_image); |
| 377 } | 376 } |
| 378 } | 377 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 continue; | 731 continue; |
| 733 *timestamp = it->timestamp; | 732 *timestamp = it->timestamp; |
| 734 *width = it->width; | 733 *width = it->width; |
| 735 *height = it->height; | 734 *height = it->height; |
| 736 return; | 735 return; |
| 737 } | 736 } |
| 738 NOTREACHED() << "Missing bitstream buffer id: " << bitstream_buffer_id; | 737 NOTREACHED() << "Missing bitstream buffer id: " << bitstream_buffer_id; |
| 739 } | 738 } |
| 740 | 739 |
| 741 } // namespace content | 740 } // namespace content |
| OLD | NEW |