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

Side by Side Diff: content/renderer/media/gpu/rtc_video_encoder.cc

Issue 2925313002: Update WebRtcVideoFrameAdapter to new buffer interface (Closed)
Patch Set: Created 3 years, 6 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/gpu/rtc_video_encoder.h" 5 #include "content/renderer/media/gpu/rtc_video_encoder.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <deque> 9 #include <deque>
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
18 #include "base/numerics/safe_conversions.h" 18 #include "base/numerics/safe_conversions.h"
19 #include "base/rand_util.h" 19 #include "base/rand_util.h"
20 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
21 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
22 #include "base/synchronization/waitable_event.h" 22 #include "base/synchronization/waitable_event.h"
23 #include "base/threading/thread_task_runner_handle.h" 23 #include "base/threading/thread_task_runner_handle.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "content/renderer/media/webrtc/webrtc_video_frame_adapter.h"
25 #include "media/base/bind_to_current_loop.h" 26 #include "media/base/bind_to_current_loop.h"
26 #include "media/base/bitstream_buffer.h" 27 #include "media/base/bitstream_buffer.h"
27 #include "media/base/video_frame.h" 28 #include "media/base/video_frame.h"
28 #include "media/base/video_util.h" 29 #include "media/base/video_util.h"
29 #include "media/filters/h264_parser.h" 30 #include "media/filters/h264_parser.h"
30 #include "media/renderers/gpu_video_accelerator_factories.h" 31 #include "media/renderers/gpu_video_accelerator_factories.h"
31 #include "media/video/video_encode_accelerator.h" 32 #include "media/video/video_encode_accelerator.h"
32 #include "third_party/libyuv/include/libyuv.h" 33 #include "third_party/libyuv/include/libyuv.h"
33 #include "third_party/webrtc/base/timeutils.h" 34 #include "third_party/webrtc/base/timeutils.h"
34 35
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 input_next_frame_keyframe_ = false; 599 input_next_frame_keyframe_ = false;
599 600
600 if (!video_encoder_) { 601 if (!video_encoder_) {
601 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_ERROR); 602 SignalAsyncWaiter(WEBRTC_VIDEO_CODEC_ERROR);
602 return; 603 return;
603 } 604 }
604 605
605 const int index = input_buffers_free_.back(); 606 const int index = input_buffers_free_.back();
606 bool requires_copy = false; 607 bool requires_copy = false;
607 scoped_refptr<media::VideoFrame> frame; 608 scoped_refptr<media::VideoFrame> frame;
608 if (next_frame->video_frame_buffer()->native_handle()) { 609 if (next_frame->video_frame_buffer()->type() ==
609 frame = static_cast<media::VideoFrame*>( 610 webrtc::VideoFrameBuffer::Type::kNative) {
610 next_frame->video_frame_buffer()->native_handle()); 611 frame = static_cast<WebRtcVideoFrameAdapter*>(
612 next_frame->video_frame_buffer().get())
613 ->getMediaVideoFrame();
611 requires_copy = RequiresSizeChange(frame) || 614 requires_copy = RequiresSizeChange(frame) ||
612 frame->storage_type() != media::VideoFrame::STORAGE_SHMEM; 615 frame->storage_type() != media::VideoFrame::STORAGE_SHMEM;
613 } else { 616 } else {
614 requires_copy = true; 617 requires_copy = true;
615 } 618 }
616 619
617 if (requires_copy) { 620 if (requires_copy) {
618 const base::TimeDelta timestamp = 621 const base::TimeDelta timestamp =
619 frame ? frame->timestamp() 622 frame ? frame->timestamp()
620 : base::TimeDelta::FromMilliseconds(next_frame->ntp_time_ms()); 623 : base::TimeDelta::FromMilliseconds(next_frame->ntp_time_ms());
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", 938 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess",
936 init_retval == WEBRTC_VIDEO_CODEC_OK); 939 init_retval == WEBRTC_VIDEO_CODEC_OK);
937 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { 940 if (init_retval == WEBRTC_VIDEO_CODEC_OK) {
938 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", 941 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile",
939 profile, 942 profile,
940 media::VIDEO_CODEC_PROFILE_MAX + 1); 943 media::VIDEO_CODEC_PROFILE_MAX + 1);
941 } 944 }
942 } 945 }
943 946
944 } // namespace content 947 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698