| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 259 } |
| 260 | 260 |
| 261 void MediaRecorderHandler::OnEncodedVideo( | 261 void MediaRecorderHandler::OnEncodedVideo( |
| 262 const media::WebmMuxer::VideoParameters& params, | 262 const media::WebmMuxer::VideoParameters& params, |
| 263 std::unique_ptr<std::string> encoded_data, | 263 std::unique_ptr<std::string> encoded_data, |
| 264 TimeTicks timestamp, | 264 TimeTicks timestamp, |
| 265 bool is_key_frame) { | 265 bool is_key_frame) { |
| 266 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 266 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 267 if (!webm_muxer_) | 267 if (!webm_muxer_) |
| 268 return; | 268 return; |
| 269 webm_muxer_->OnEncodedVideo(params, std::move(encoded_data), timestamp, | 269 if (!webm_muxer_->OnEncodedVideo(params, std::move(encoded_data), timestamp, |
| 270 is_key_frame); | 270 is_key_frame)) { |
| 271 DLOG(ERROR) << "Error muxing video data"; |
| 272 client_->onError("Error muxing video data"); |
| 273 } |
| 271 } | 274 } |
| 272 | 275 |
| 273 void MediaRecorderHandler::OnEncodedAudio( | 276 void MediaRecorderHandler::OnEncodedAudio( |
| 274 const media::AudioParameters& params, | 277 const media::AudioParameters& params, |
| 275 std::unique_ptr<std::string> encoded_data, | 278 std::unique_ptr<std::string> encoded_data, |
| 276 base::TimeTicks timestamp) { | 279 base::TimeTicks timestamp) { |
| 277 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 280 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 278 if (webm_muxer_) | 281 if (!webm_muxer_) |
| 279 webm_muxer_->OnEncodedAudio(params, std::move(encoded_data), timestamp); | 282 return; |
| 283 if (!webm_muxer_->OnEncodedAudio(params, std::move(encoded_data), |
| 284 timestamp)) { |
| 285 DLOG(ERROR) << "Error muxing audio data"; |
| 286 client_->onError("Error muxing audio data"); |
| 287 } |
| 280 } | 288 } |
| 281 | 289 |
| 282 void MediaRecorderHandler::WriteData(base::StringPiece data) { | 290 void MediaRecorderHandler::WriteData(base::StringPiece data) { |
| 283 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 291 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 284 const TimeTicks now = TimeTicks::Now(); | 292 const TimeTicks now = TimeTicks::Now(); |
| 285 // Non-buffered mode does not need to check timestamps. | 293 // Non-buffered mode does not need to check timestamps. |
| 286 if (timeslice_.is_zero()) { | 294 if (timeslice_.is_zero()) { |
| 287 client_->writeData(data.data(), data.length(), true /* lastInSlice */, | 295 client_->writeData(data.data(), data.length(), true /* lastInSlice */, |
| 288 (now - TimeTicks::UnixEpoch()).InMillisecondsF()); | 296 (now - TimeTicks::UnixEpoch()).InMillisecondsF()); |
| 289 return; | 297 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 311 recorder->OnData(audio_bus, timestamp); | 319 recorder->OnData(audio_bus, timestamp); |
| 312 } | 320 } |
| 313 | 321 |
| 314 void MediaRecorderHandler::SetAudioFormatForTesting( | 322 void MediaRecorderHandler::SetAudioFormatForTesting( |
| 315 const media::AudioParameters& params) { | 323 const media::AudioParameters& params) { |
| 316 for (const auto& recorder : audio_recorders_) | 324 for (const auto& recorder : audio_recorders_) |
| 317 recorder->OnSetFormat(params); | 325 recorder->OnSetFormat(params); |
| 318 } | 326 } |
| 319 | 327 |
| 320 } // namespace content | 328 } // namespace content |
| OLD | NEW |