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

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

Issue 1892673002: VideoTrackRecorder: add support for more codecs on construction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: emircan@ nits Created 4 years, 8 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 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/video_track_recorder.h" 5 #include "content/renderer/media/video_track_recorder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 last_frame_timestamp_ = frame->timestamp(); 376 last_frame_timestamp_ = frame->timestamp();
377 // Make sure |predicted_frame_duration| is in a safe range of values. 377 // Make sure |predicted_frame_duration| is in a safe range of values.
378 const TimeDelta kMaxFrameDuration = TimeDelta::FromSecondsD(1.0 / 8); 378 const TimeDelta kMaxFrameDuration = TimeDelta::FromSecondsD(1.0 / 8);
379 const TimeDelta kMinFrameDuration = TimeDelta::FromMilliseconds(1); 379 const TimeDelta kMinFrameDuration = TimeDelta::FromMilliseconds(1);
380 return std::min(kMaxFrameDuration, std::max(predicted_frame_duration, 380 return std::min(kMaxFrameDuration, std::max(predicted_frame_duration,
381 kMinFrameDuration)); 381 kMinFrameDuration));
382 } 382 }
383 383
384 VideoTrackRecorder::VideoTrackRecorder( 384 VideoTrackRecorder::VideoTrackRecorder(
385 bool use_vp9, 385 CodecId codec,
386 const blink::WebMediaStreamTrack& track, 386 const blink::WebMediaStreamTrack& track,
387 const OnEncodedVideoCB& on_encoded_video_callback, 387 const OnEncodedVideoCB& on_encoded_video_callback,
388 int32_t bits_per_second) 388 int32_t bits_per_second)
389 : track_(track), 389 : track_(track),
390 encoder_( 390 encoder_(new VpxEncoder(codec == CodecId::VP9,
391 new VpxEncoder(use_vp9, on_encoded_video_callback, bits_per_second)) { 391 on_encoded_video_callback,
392 bits_per_second)) {
392 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 393 DCHECK(main_render_thread_checker_.CalledOnValidThread());
393 DCHECK(!track_.isNull()); 394 DCHECK(!track_.isNull());
394 DCHECK(track_.getExtraData()); 395 DCHECK(track_.getExtraData());
395 396
396 // StartFrameEncode() will be called on Render IO thread. 397 // StartFrameEncode() will be called on Render IO thread.
397 MediaStreamVideoSink::ConnectToTrack( 398 MediaStreamVideoSink::ConnectToTrack(
398 track_, 399 track_,
399 base::Bind(&VideoTrackRecorder::VpxEncoder::StartFrameEncode, encoder_)); 400 base::Bind(&VideoTrackRecorder::VpxEncoder::StartFrameEncode, encoder_));
400 } 401 }
401 402
(...skipping 15 matching lines...) Expand all
417 encoder_->set_paused(false); 418 encoder_->set_paused(false);
418 } 419 }
419 420
420 void VideoTrackRecorder::OnVideoFrameForTesting( 421 void VideoTrackRecorder::OnVideoFrameForTesting(
421 const scoped_refptr<media::VideoFrame>& frame, 422 const scoped_refptr<media::VideoFrame>& frame,
422 base::TimeTicks timestamp) { 423 base::TimeTicks timestamp) {
423 encoder_->StartFrameEncode(frame, timestamp); 424 encoder_->StartFrameEncode(frame, timestamp);
424 } 425 }
425 426
426 } // namespace content 427 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/video_track_recorder.h ('k') | content/renderer/media/video_track_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698