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

Unified Diff: content/renderer/media/rtc_video_capturer.cc

Issue 23587018: Replace media::VideoCapture::VideoFrameBuffer with media::VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: a1e0098f Reset timestamps on Stop(). 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/rtc_video_capturer.cc
diff --git a/content/renderer/media/rtc_video_capturer.cc b/content/renderer/media/rtc_video_capturer.cc
index b9acc0ebc075fc16beeb0b3ef5fd6ad41eba81f4..a9345c65943d196284c8ff7d9d57fec4e99259c0 100644
--- a/content/renderer/media/rtc_video_capturer.cc
+++ b/content/renderer/media/rtc_video_capturer.cc
@@ -15,7 +15,8 @@ RtcVideoCapturer::RtcVideoCapturer(
bool is_screencast)
: is_screencast_(is_screencast),
delegate_(new RtcVideoCaptureDelegate(id, vc_manager)),
- state_(VIDEO_CAPTURE_STATE_STOPPED) {
+ state_(VIDEO_CAPTURE_STATE_STOPPED),
+ first_frame_timestamp_valid_(false) {
}
RtcVideoCapturer::~RtcVideoCapturer() {
@@ -40,8 +41,8 @@ cricket::CaptureState RtcVideoCapturer::Start(
SetCaptureFormat(&capture_format);
state_ = VIDEO_CAPTURE_STATE_STARTED;
- start_time_ = base::Time::Now();
- delegate_->StartCapture(cap,
+ delegate_->StartCapture(
+ cap,
base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)),
base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this)));
// Update the desired aspect ratio so that later the video frame can be
@@ -60,6 +61,7 @@ void RtcVideoCapturer::Stop() {
SetCaptureFormat(NULL);
state_ = VIDEO_CAPTURE_STATE_STOPPED;
+ first_frame_timestamp_valid_ = false;
delegate_->StopCapture();
SignalStateChange(this, cricket::CS_STOPPED);
}
@@ -95,34 +97,42 @@ bool RtcVideoCapturer::GetBestCaptureFormat(const cricket::VideoFormat& desired,
}
void RtcVideoCapturer::OnFrameCaptured(
- const media::VideoCapture::VideoFrameBuffer& buf) {
+ const scoped_refptr<media::VideoFrame>& frame) {
+ if (!first_frame_timestamp_valid_) {
+ first_frame_timestamp_ = frame->GetTimestamp();
+ first_frame_timestamp_valid_ = true;
+ }
+
// Currently, |fourcc| is always I420.
- cricket::CapturedFrame frame;
- frame.width = buf.width;
- frame.height = buf.height;
- frame.fourcc = cricket::FOURCC_I420;
- frame.data_size = buf.buffer_size;
+ cricket::CapturedFrame cricket_frame;
Ami GONE FROM CHROMIUM 2013/09/12 22:40:41 your attempts at disambiguation are no match for t
+ cricket_frame.width = frame->coded_size().width();
+ cricket_frame.height = frame->coded_size().height();
+ cricket_frame.fourcc = cricket::FOURCC_I420;
// cricket::CapturedFrame time is in nanoseconds.
- frame.elapsed_time = (buf.timestamp - start_time_).InMicroseconds() *
- base::Time::kNanosecondsPerMicrosecond;
- frame.time_stamp =
- (buf.timestamp - base::Time::UnixEpoch()).InMicroseconds() *
+ cricket_frame.elapsed_time =
+ (frame->GetTimestamp() - first_frame_timestamp_).InMicroseconds() *
base::Time::kNanosecondsPerMicrosecond;
- frame.data = buf.memory_pointer;
- frame.pixel_height = 1;
- frame.pixel_width = 1;
-
- TRACE_EVENT_INSTANT2("rtc_video_capturer",
- "OnFrameCaptured",
- TRACE_EVENT_SCOPE_THREAD,
- "elapsed time",
- frame.elapsed_time,
- "timestamp_ms",
- frame.time_stamp / talk_base::kNumNanosecsPerMillisec);
+ cricket_frame.time_stamp = frame->GetTimestamp().InMicroseconds() *
+ base::Time::kNanosecondsPerMicrosecond;
+ // TODO(sheu): we assume contiguous layout of image planes.
Ami GONE FROM CHROMIUM 2013/09/12 22:40:41 then the pepper code can be simplified even more,
sheu 2013/09/13 00:15:19 yes, but I'd like not to make that assumption expl
+ cricket_frame.data = frame->data(0);
+ cricket_frame.data_size =
+ media::VideoFrame::AllocationSize(frame->format(), frame->coded_size());
+ cricket_frame.pixel_height = 1;
+ cricket_frame.pixel_width = 1;
+
+ TRACE_EVENT_INSTANT2(
+ "rtc_video_capturer",
+ "OnFrameCaptured",
+ TRACE_EVENT_SCOPE_THREAD,
+ "elapsed time",
+ cricket_frame.elapsed_time,
+ "timestamp_ms",
+ cricket_frame.time_stamp / talk_base::kNumNanosecsPerMillisec);
// This signals to libJingle that a new VideoFrame is available.
// libJingle have no assumptions on what thread this signal come from.
- SignalFrameCaptured(this, &frame);
+ SignalFrameCaptured(this, &cricket_frame);
}
void RtcVideoCapturer::OnStateChange(

Powered by Google App Engine
This is Rietveld 408576698