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

Side by Side Diff: content/renderer/media_capture_from_element/html_video_element_capturer_source.cc

Issue 2727583007: HTMLMediaElement capture: teach the captured MStream to follow up source events (Closed)
Patch Set: haraken@ comments Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/mediacapturefromelement/HTMLMediaElementCapture-capture.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_capture_from_element/html_video_element_capture r_source.h" 5 #include "content/renderer/media_capture_from_element/html_video_element_capture r_source.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 HtmlVideoElementCapturerSource::~HtmlVideoElementCapturerSource() { 55 HtmlVideoElementCapturerSource::~HtmlVideoElementCapturerSource() {
56 DCHECK(thread_checker_.CalledOnValidThread()); 56 DCHECK(thread_checker_.CalledOnValidThread());
57 } 57 }
58 58
59 void HtmlVideoElementCapturerSource::GetCurrentSupportedFormats( 59 void HtmlVideoElementCapturerSource::GetCurrentSupportedFormats(
60 int max_requested_width, 60 int max_requested_width,
61 int max_requested_height, 61 int max_requested_height,
62 double max_requested_frame_rate, 62 double max_requested_frame_rate,
63 const VideoCaptureDeviceFormatsCB& callback) { 63 const VideoCaptureDeviceFormatsCB& callback) {
64 DVLOG(3) << __func__ << "{ max_requested_height = " << max_requested_height 64 DVLOG(2) << __func__ << "{ max_requested_height = " << max_requested_height
65 << "}) { max_requested_width = " << max_requested_width 65 << "}) { max_requested_width = " << max_requested_width
66 << "}) { max_requested_frame_rate = " << max_requested_frame_rate 66 << "}) { max_requested_frame_rate = " << max_requested_frame_rate
67 << "})"; 67 << "})";
68 DCHECK(thread_checker_.CalledOnValidThread()); 68 DCHECK(thread_checker_.CalledOnValidThread());
69 69
70 // WebMediaPlayer has a setRate() but can't be read back. 70 // WebMediaPlayer has a setRate() but can't be read back.
71 // TODO(mcasas): Add getRate() to WMPlayer and/or fix the spec to allow users 71 // TODO(mcasas): Add getRate() to WMPlayer and/or fix the spec to allow users
72 // to specify it. 72 // to specify it.
73 const media::VideoCaptureFormat format( 73 const media::VideoCaptureFormat format(
74 web_media_player_->naturalSize(), 74 web_media_player_->naturalSize(),
75 MediaStreamVideoSource::kDefaultFrameRate, 75 MediaStreamVideoSource::kDefaultFrameRate,
76 media::PIXEL_FORMAT_I420); 76 media::PIXEL_FORMAT_I420);
77 media::VideoCaptureFormats formats; 77 media::VideoCaptureFormats formats;
78 formats.push_back(format); 78 formats.push_back(format);
79 callback.Run(formats); 79 callback.Run(formats);
80 } 80 }
81 81
82 void HtmlVideoElementCapturerSource::StartCapture( 82 void HtmlVideoElementCapturerSource::StartCapture(
83 const media::VideoCaptureParams& params, 83 const media::VideoCaptureParams& params,
84 const VideoCaptureDeliverFrameCB& new_frame_callback, 84 const VideoCaptureDeliverFrameCB& new_frame_callback,
85 const RunningCallback& running_callback) { 85 const RunningCallback& running_callback) {
86 DVLOG(3) << __func__ << " requested " 86 DVLOG(2) << __func__ << " requested "
87 << media::VideoCaptureFormat::ToString(params.requested_format); 87 << media::VideoCaptureFormat::ToString(params.requested_format);
88 DCHECK(params.requested_format.IsValid()); 88 DCHECK(params.requested_format.IsValid());
89 DCHECK(thread_checker_.CalledOnValidThread()); 89 DCHECK(thread_checker_.CalledOnValidThread());
90 90
91 running_callback_ = running_callback; 91 running_callback_ = running_callback;
92 if (!web_media_player_ || !web_media_player_->hasVideo()) { 92 if (!web_media_player_ || !web_media_player_->hasVideo()) {
93 running_callback_.Run(false); 93 running_callback_.Run(false);
94 return; 94 return;
95 } 95 }
96 const blink::WebSize resolution = web_media_player_->naturalSize(); 96 const blink::WebSize resolution = web_media_player_->naturalSize();
(...skipping 11 matching lines...) Expand all
108 std::min(static_cast<float>(media::limits::kMaxFramesPerSecond), 108 std::min(static_cast<float>(media::limits::kMaxFramesPerSecond),
109 params.requested_format.frame_rate)); 109 params.requested_format.frame_rate));
110 110
111 running_callback_.Run(true); 111 running_callback_.Run(true);
112 base::ThreadTaskRunnerHandle::Get()->PostTask( 112 base::ThreadTaskRunnerHandle::Get()->PostTask(
113 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, 113 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame,
114 weak_factory_.GetWeakPtr())); 114 weak_factory_.GetWeakPtr()));
115 } 115 }
116 116
117 void HtmlVideoElementCapturerSource::StopCapture() { 117 void HtmlVideoElementCapturerSource::StopCapture() {
118 DVLOG(3) << __func__; 118 DVLOG(2) << __func__;
119 DCHECK(thread_checker_.CalledOnValidThread()); 119 DCHECK(thread_checker_.CalledOnValidThread());
120 running_callback_.Reset(); 120 running_callback_.Reset();
121 new_frame_callback_.Reset(); 121 new_frame_callback_.Reset();
122 next_capture_time_ = base::TimeTicks(); 122 next_capture_time_ = base::TimeTicks();
123 } 123 }
124 124
125 void HtmlVideoElementCapturerSource::sendNewFrame() { 125 void HtmlVideoElementCapturerSource::sendNewFrame() {
126 DVLOG(3) << __func__; 126 DVLOG(3) << __func__;
127 TRACE_EVENT0("video", "HtmlVideoElementCapturerSource::sendNewFrame"); 127 TRACE_EVENT0("video", "HtmlVideoElementCapturerSource::sendNewFrame");
128 DCHECK(thread_checker_.CalledOnValidThread()); 128 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 next_capture_time_ = current_time; 198 next_capture_time_ = current_time;
199 } 199 }
200 // Schedule next capture. 200 // Schedule next capture.
201 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 201 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
202 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, 202 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame,
203 weak_factory_.GetWeakPtr()), 203 weak_factory_.GetWeakPtr()),
204 next_capture_time_ - current_time); 204 next_capture_time_ - current_time);
205 } 205 }
206 206
207 } // namespace content 207 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/mediacapturefromelement/HTMLMediaElementCapture-capture.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698