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

Side by Side Diff: content/renderer/media/rtc_video_decoder.cc

Issue 19041006: Send video frames backed by textures to WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove SetHandle and use ctor instead Created 7 years, 5 months 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 // 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"
17 #include "third_party/webrtc/common_video/interface/texture_video_frame.h"
16 #include "third_party/webrtc/system_wrappers/interface/ref_count.h" 18 #include "third_party/webrtc/system_wrappers/interface/ref_count.h"
17 19
18 namespace content { 20 namespace content {
19 21
20 const int32 RTCVideoDecoder::ID_LAST = 0x3FFFFFFF; 22 const int32 RTCVideoDecoder::ID_LAST = 0x3FFFFFFF;
21 const int32 RTCVideoDecoder::ID_HALF = 0x20000000; 23 const int32 RTCVideoDecoder::ID_HALF = 0x20000000;
22 const int32 RTCVideoDecoder::ID_INVALID = -1; 24 const int32 RTCVideoDecoder::ID_INVALID = -1;
23 25
24 // Maximum number of concurrent VDA::Decode() operations RVD will maintain. 26 // Maximum number of concurrent VDA::Decode() operations RVD will maintain.
25 // Higher values allow better pipelining in the GPU, but also require more 27 // Higher values allow better pipelining in the GPU, but also require more
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 size_t size = 0; 345 size_t size = 0;
344 GetBufferData( 346 GetBufferData(
345 picture.bitstream_buffer_id(), &timestamp, &width, &height, &size); 347 picture.bitstream_buffer_id(), &timestamp, &width, &height, &size);
346 scoped_refptr<media::VideoFrame> frame = 348 scoped_refptr<media::VideoFrame> frame =
347 CreateVideoFrame(picture, pb, timestamp, width, height, size); 349 CreateVideoFrame(picture, pb, timestamp, width, height, size);
348 bool inserted = 350 bool inserted =
349 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second; 351 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second;
350 DCHECK(inserted); 352 DCHECK(inserted);
351 353
352 // Create a WebRTC video frame. 354 // Create a WebRTC video frame.
353 // TODO(wuchengli): make media::VideoFrame an opaque native handle and put it 355 webrtc::RefCountImpl<NativeHandleImpl>* handle =
354 // into WebRTC frame. 356 new webrtc::RefCountImpl<NativeHandleImpl>(frame);
355 webrtc::I420VideoFrame decoded_image; 357 webrtc::TextureVideoFrame decoded_image(handle, width, height, timestamp, 0);
356 decoded_image.CreateEmptyFrame(
357 width, height, width, (width + 1) / 2, (width + 1) / 2);
358 decoded_image.set_timestamp(timestamp);
359 358
360 // Invoke decode callback. WebRTC expects no frame callback after Release. 359 // Invoke decode callback. WebRTC expects no frame callback after Release.
361 { 360 {
362 base::AutoLock auto_lock(lock_); 361 base::AutoLock auto_lock(lock_);
363 DCHECK(decode_complete_callback_ != NULL); 362 DCHECK(decode_complete_callback_ != NULL);
364 if (IsBufferAfterReset(picture.bitstream_buffer_id(), 363 if (IsBufferAfterReset(picture.bitstream_buffer_id(),
365 reset_bitstream_buffer_id_)) { 364 reset_bitstream_buffer_id_)) {
366 decode_complete_callback_->Decoded(decoded_image); 365 decode_complete_callback_->Decoded(decoded_image);
367 } 366 }
368 } 367 }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 continue; 726 continue;
728 *timestamp = it->timestamp; 727 *timestamp = it->timestamp;
729 *width = it->width; 728 *width = it->width;
730 *height = it->height; 729 *height = it->height;
731 return; 730 return;
732 } 731 }
733 NOTREACHED() << "Missing bitstream buffer id: " << bitstream_buffer_id; 732 NOTREACHED() << "Missing bitstream buffer id: " << bitstream_buffer_id;
734 } 733 }
735 734
736 } // namespace content 735 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698