| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/renderer/media/video_track_recorder.h" | 10 #include "content/renderer/media/video_track_recorder.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool MediaRecorderHandler::start(int timeslice) { | 73 bool MediaRecorderHandler::start(int timeslice) { |
| 74 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 74 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 75 DCHECK(!recording_); | 75 DCHECK(!recording_); |
| 76 DCHECK(!media_stream_.isNull()); | 76 DCHECK(!media_stream_.isNull()); |
| 77 DCHECK(!webm_muxer_); | 77 DCHECK(!webm_muxer_); |
| 78 DCHECK(timeslice_.is_zero()); | 78 DCHECK(timeslice_.is_zero()); |
| 79 | 79 |
| 80 timeslice_ = TimeDelta::FromMilliseconds(timeslice); | 80 timeslice_ = TimeDelta::FromMilliseconds(timeslice); |
| 81 slice_origin_timestamp_ = TimeTicks::Now(); | 81 slice_origin_timestamp_ = TimeTicks::Now(); |
| 82 | 82 |
| 83 webm_muxer_.reset( | |
| 84 new media::WebmMuxer(use_vp9_ ? media::kCodecVP9 : media::kCodecVP8, | |
| 85 base::Bind(&MediaRecorderHandler::WriteData, | |
| 86 weak_factory_.GetWeakPtr()))); | |
| 87 | |
| 88 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; | 83 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; |
| 89 media_stream_.videoTracks(video_tracks); | 84 media_stream_.videoTracks(video_tracks); |
| 90 | 85 |
| 86 webm_muxer_.reset( |
| 87 new media::WebmMuxer(use_vp9_ ? media::kCodecVP9 : media::kCodecVP8, |
| 88 video_tracks.size(), 0 /* no audio for now */, |
| 89 base::Bind(&MediaRecorderHandler::WriteData, |
| 90 weak_factory_.GetWeakPtr()))); |
| 91 |
| 91 if (video_tracks.isEmpty()) { | 92 if (video_tracks.isEmpty()) { |
| 92 // TODO(mcasas): Add audio_tracks and update the code in this function | 93 // TODO(mcasas): Add audio_tracks and update the code in this function |
| 93 // correspondingly, see http://crbug.com/528519. As of now, only video | 94 // correspondingly, see http://crbug.com/528519. As of now, only video |
| 94 // tracks are supported. | 95 // tracks are supported. |
| 95 LOG(WARNING) << "Recording no video tracks is not implemented"; | 96 LOG(WARNING) << "Recording no video tracks is not implemented"; |
| 96 return false; | 97 return false; |
| 97 } | 98 } |
| 98 // TODO(mcasas): The muxer API supports only one video track. Extend it to | 99 // TODO(mcasas): The muxer API supports only one video track. Extend it to |
| 99 // several video tracks, see http://crbug.com/528523. | 100 // several video tracks, see http://crbug.com/528523. |
| 100 LOG_IF(WARNING, video_tracks.size() > 1u) << "Recording multiple video" | 101 LOG_IF(WARNING, video_tracks.size() > 1u) << "Recording multiple video" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 172 } |
| 172 | 173 |
| 173 void MediaRecorderHandler::OnVideoFrameForTesting( | 174 void MediaRecorderHandler::OnVideoFrameForTesting( |
| 174 const scoped_refptr<media::VideoFrame>& frame, | 175 const scoped_refptr<media::VideoFrame>& frame, |
| 175 const TimeTicks& timestamp) { | 176 const TimeTicks& timestamp) { |
| 176 for (auto* recorder : video_recorders_) | 177 for (auto* recorder : video_recorders_) |
| 177 recorder->OnVideoFrameForTesting(frame, timestamp); | 178 recorder->OnVideoFrameForTesting(frame, timestamp); |
| 178 } | 179 } |
| 179 | 180 |
| 180 } // namespace content | 181 } // namespace content |
| OLD | NEW |