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

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: rebase Created 7 years, 3 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"
16 #include "media/filters/gpu_video_accelerator_factories.h" 17 #include "media/filters/gpu_video_accelerator_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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 size_t size = 0; 357 size_t size = 0;
356 GetBufferData( 358 GetBufferData(
357 picture.bitstream_buffer_id(), &timestamp, &width, &height, &size); 359 picture.bitstream_buffer_id(), &timestamp, &width, &height, &size);
358 scoped_refptr<media::VideoFrame> frame = 360 scoped_refptr<media::VideoFrame> frame =
359 CreateVideoFrame(picture, pb, timestamp, width, height, size); 361 CreateVideoFrame(picture, pb, timestamp, width, height, size);
360 bool inserted = 362 bool inserted =
361 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second; 363 picture_buffers_at_display_.insert(picture.picture_buffer_id()).second;
362 DCHECK(inserted); 364 DCHECK(inserted);
363 365
364 // Create a WebRTC video frame. 366 // Create a WebRTC video frame.
365 // TODO(wuchengli): make media::VideoFrame an opaque native handle and put it 367 webrtc::RefCountImpl<NativeHandleImpl>* handle =
366 // into WebRTC frame. 368 new webrtc::RefCountImpl<NativeHandleImpl>(frame);
367 webrtc::I420VideoFrame decoded_image; 369 webrtc::TextureVideoFrame decoded_image(handle, width, height, timestamp, 0);
368 decoded_image.CreateEmptyFrame(
369 width, height, width, (width + 1) / 2, (width + 1) / 2);
370 decoded_image.set_timestamp(timestamp);
371 370
372 // Invoke decode callback. WebRTC expects no callback after Reset or Release. 371 // Invoke decode callback. WebRTC expects no callback after Reset or Release.
373 { 372 {
374 base::AutoLock auto_lock(lock_); 373 base::AutoLock auto_lock(lock_);
375 DCHECK(decode_complete_callback_ != NULL); 374 DCHECK(decode_complete_callback_ != NULL);
376 if (IsBufferAfterReset(picture.bitstream_buffer_id(), 375 if (IsBufferAfterReset(picture.bitstream_buffer_id(),
377 reset_bitstream_buffer_id_)) { 376 reset_bitstream_buffer_id_)) {
378 decode_complete_callback_->Decoded(decoded_image); 377 decode_complete_callback_->Decoded(decoded_image);
379 } 378 }
380 } 379 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 continue; 741 continue;
743 *timestamp = it->timestamp; 742 *timestamp = it->timestamp;
744 *width = it->width; 743 *width = it->width;
745 *height = it->height; 744 *height = it->height;
746 return; 745 return;
747 } 746 }
748 NOTREACHED() << "Missing bitstream buffer id: " << bitstream_buffer_id; 747 NOTREACHED() << "Missing bitstream buffer id: " << bitstream_buffer_id;
749 } 748 }
750 749
751 } // namespace content 750 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/native_handle_impl.cc ('k') | content/renderer/media/rtc_video_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698