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

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

Issue 2610163006: MediaRecorder: support |timecode| and remove |m_ignoreMutedMedia|. (Closed)
Patch Set: Rebase video_capture_device_client.cc Created 3 years, 11 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 | content/renderer/media/media_recorder_handler_unittest.cc » ('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/media_recorder_handler.h" 5 #include "content/renderer/media/media_recorder_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 audio_bits_per_second_(0), 54 audio_bits_per_second_(0),
55 codec_id_(VideoTrackRecorder::CodecId::VP8), 55 codec_id_(VideoTrackRecorder::CodecId::VP8),
56 recording_(false), 56 recording_(false),
57 client_(nullptr), 57 client_(nullptr),
58 weak_factory_(this) {} 58 weak_factory_(this) {}
59 59
60 MediaRecorderHandler::~MediaRecorderHandler() { 60 MediaRecorderHandler::~MediaRecorderHandler() {
61 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 61 DCHECK(main_render_thread_checker_.CalledOnValidThread());
62 // Send a |last_in_slice| to our |client_|. 62 // Send a |last_in_slice| to our |client_|.
63 if (client_) 63 if (client_)
64 client_->writeData(nullptr, 0u, true); 64 client_->writeData(
65 nullptr, 0u, true,
66 (TimeTicks::Now() - TimeTicks::UnixEpoch()).InMillisecondsF());
65 } 67 }
66 68
67 bool MediaRecorderHandler::canSupportMimeType( 69 bool MediaRecorderHandler::canSupportMimeType(
68 const blink::WebString& web_type, 70 const blink::WebString& web_type,
69 const blink::WebString& web_codecs) { 71 const blink::WebString& web_codecs) {
70 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 72 DCHECK(main_render_thread_checker_.CalledOnValidThread());
71 // An empty |web_type| means MediaRecorderHandler can choose its preferred 73 // An empty |web_type| means MediaRecorderHandler can choose its preferred
72 // codecs. 74 // codecs.
73 if (web_type.isEmpty()) 75 if (web_type.isEmpty())
74 return true; 76 return true;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 const media::AudioParameters& params, 274 const media::AudioParameters& params,
273 std::unique_ptr<std::string> encoded_data, 275 std::unique_ptr<std::string> encoded_data,
274 base::TimeTicks timestamp) { 276 base::TimeTicks timestamp) {
275 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 277 DCHECK(main_render_thread_checker_.CalledOnValidThread());
276 if (webm_muxer_) 278 if (webm_muxer_)
277 webm_muxer_->OnEncodedAudio(params, std::move(encoded_data), timestamp); 279 webm_muxer_->OnEncodedAudio(params, std::move(encoded_data), timestamp);
278 } 280 }
279 281
280 void MediaRecorderHandler::WriteData(base::StringPiece data) { 282 void MediaRecorderHandler::WriteData(base::StringPiece data) {
281 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 283 DCHECK(main_render_thread_checker_.CalledOnValidThread());
284 const TimeTicks now = TimeTicks::Now();
282 // Non-buffered mode does not need to check timestamps. 285 // Non-buffered mode does not need to check timestamps.
283 if (timeslice_.is_zero()) { 286 if (timeslice_.is_zero()) {
284 client_->writeData(data.data(), data.length(), true /* lastInSlice */); 287 client_->writeData(data.data(), data.length(), true /* lastInSlice */,
288 (now - TimeTicks::UnixEpoch()).InMillisecondsF());
285 return; 289 return;
286 } 290 }
287 291
288 const TimeTicks now = TimeTicks::Now();
289 const bool last_in_slice = now > slice_origin_timestamp_ + timeslice_; 292 const bool last_in_slice = now > slice_origin_timestamp_ + timeslice_;
290 DVLOG_IF(1, last_in_slice) << "Slice finished @ " << now; 293 DVLOG_IF(1, last_in_slice) << "Slice finished @ " << now;
291 if (last_in_slice) 294 if (last_in_slice)
292 slice_origin_timestamp_ = now; 295 slice_origin_timestamp_ = now;
293 client_->writeData(data.data(), data.length(), last_in_slice); 296 client_->writeData(data.data(), data.length(), last_in_slice,
297 (now - TimeTicks::UnixEpoch()).InMillisecondsF());
294 } 298 }
295 299
296 void MediaRecorderHandler::OnVideoFrameForTesting( 300 void MediaRecorderHandler::OnVideoFrameForTesting(
297 const scoped_refptr<media::VideoFrame>& frame, 301 const scoped_refptr<media::VideoFrame>& frame,
298 const TimeTicks& timestamp) { 302 const TimeTicks& timestamp) {
299 for (const auto& recorder : video_recorders_) 303 for (const auto& recorder : video_recorders_)
300 recorder->OnVideoFrameForTesting(frame, timestamp); 304 recorder->OnVideoFrameForTesting(frame, timestamp);
301 } 305 }
302 306
303 void MediaRecorderHandler::OnAudioBusForTesting( 307 void MediaRecorderHandler::OnAudioBusForTesting(
304 const media::AudioBus& audio_bus, 308 const media::AudioBus& audio_bus,
305 const base::TimeTicks& timestamp) { 309 const base::TimeTicks& timestamp) {
306 for (const auto& recorder : audio_recorders_) 310 for (const auto& recorder : audio_recorders_)
307 recorder->OnData(audio_bus, timestamp); 311 recorder->OnData(audio_bus, timestamp);
308 } 312 }
309 313
310 void MediaRecorderHandler::SetAudioFormatForTesting( 314 void MediaRecorderHandler::SetAudioFormatForTesting(
311 const media::AudioParameters& params) { 315 const media::AudioParameters& params) {
312 for (const auto& recorder : audio_recorders_) 316 for (const auto& recorder : audio_recorders_)
313 recorder->OnSetFormat(params); 317 recorder->OnSetFormat(params);
314 } 318 }
315 319
316 } // namespace content 320 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/media_recorder_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698