| 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 <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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 << "Recording multiple video tracks is not implemented. " | 192 << "Recording multiple video tracks is not implemented. " |
| 193 << "Only recording first video track."; | 193 << "Only recording first video track."; |
| 194 const blink::WebMediaStreamTrack& video_track = video_tracks[0]; | 194 const blink::WebMediaStreamTrack& video_track = video_tracks[0]; |
| 195 if (video_track.isNull()) | 195 if (video_track.isNull()) |
| 196 return false; | 196 return false; |
| 197 | 197 |
| 198 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = | 198 const VideoTrackRecorder::OnEncodedVideoCB on_encoded_video_cb = |
| 199 media::BindToCurrentLoop(base::Bind( | 199 media::BindToCurrentLoop(base::Bind( |
| 200 &MediaRecorderHandler::OnEncodedVideo, weak_factory_.GetWeakPtr())); | 200 &MediaRecorderHandler::OnEncodedVideo, weak_factory_.GetWeakPtr())); |
| 201 | 201 |
| 202 video_recorders_.push_back(new VideoTrackRecorder( | 202 video_recorders_.emplace_back(new VideoTrackRecorder( |
| 203 codec_id_, video_track, on_encoded_video_cb, video_bits_per_second_)); | 203 codec_id_, video_track, on_encoded_video_cb, video_bits_per_second_)); |
| 204 } | 204 } |
| 205 | 205 |
| 206 if (use_audio_tracks) { | 206 if (use_audio_tracks) { |
| 207 // TODO(ajose): The muxer API supports only one audio track. Extend it to | 207 // TODO(ajose): The muxer API supports only one audio track. Extend it to |
| 208 // several tracks. | 208 // several tracks. |
| 209 LOG_IF(WARNING, audio_tracks.size() > 1u) | 209 LOG_IF(WARNING, audio_tracks.size() > 1u) |
| 210 << "Recording multiple audio" | 210 << "Recording multiple audio" |
| 211 << " tracks is not implemented. Only recording first audio track."; | 211 << " tracks is not implemented. Only recording first audio track."; |
| 212 const blink::WebMediaStreamTrack& audio_track = audio_tracks[0]; | 212 const blink::WebMediaStreamTrack& audio_track = audio_tracks[0]; |
| 213 if (audio_track.isNull()) | 213 if (audio_track.isNull()) |
| 214 return false; | 214 return false; |
| 215 | 215 |
| 216 const AudioTrackRecorder::OnEncodedAudioCB on_encoded_audio_cb = | 216 const AudioTrackRecorder::OnEncodedAudioCB on_encoded_audio_cb = |
| 217 media::BindToCurrentLoop(base::Bind( | 217 media::BindToCurrentLoop(base::Bind( |
| 218 &MediaRecorderHandler::OnEncodedAudio, weak_factory_.GetWeakPtr())); | 218 &MediaRecorderHandler::OnEncodedAudio, weak_factory_.GetWeakPtr())); |
| 219 | 219 |
| 220 audio_recorders_.push_back(new AudioTrackRecorder( | 220 audio_recorders_.emplace_back(new AudioTrackRecorder( |
| 221 audio_track, on_encoded_audio_cb, audio_bits_per_second_)); | 221 audio_track, on_encoded_audio_cb, audio_bits_per_second_)); |
| 222 } | 222 } |
| 223 | 223 |
| 224 recording_ = true; | 224 recording_ = true; |
| 225 return true; | 225 return true; |
| 226 } | 226 } |
| 227 | 227 |
| 228 void MediaRecorderHandler::stop() { | 228 void MediaRecorderHandler::stop() { |
| 229 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 229 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 230 // Don't check |recording_| since we can go directly from pause() to stop(). | 230 // Don't check |recording_| since we can go directly from pause() to stop(). |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 recorder->OnData(audio_bus, timestamp); | 309 recorder->OnData(audio_bus, timestamp); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void MediaRecorderHandler::SetAudioFormatForTesting( | 312 void MediaRecorderHandler::SetAudioFormatForTesting( |
| 313 const media::AudioParameters& params) { | 313 const media::AudioParameters& params) { |
| 314 for (auto* recorder : audio_recorders_) | 314 for (auto* recorder : audio_recorders_) |
| 315 recorder->OnSetFormat(params); | 315 recorder->OnSetFormat(params); |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace content | 318 } // namespace content |
| OLD | NEW |