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

Side by Side Diff: media/cast/test/fake_media_source.cc

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/cast/test/fake_media_source.h" 5 #include "media/cast/test/fake_media_source.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/scoped_file.h" 10 #include "base/files/scoped_file.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (keep_frames_) 282 if (keep_frames_)
283 inserted_video_frame_queue_.push(video_frame); 283 inserted_video_frame_queue_.push(video_frame);
284 video_frame_input_->InsertRawVideoFrame(video_frame, 284 video_frame_input_->InsertRawVideoFrame(video_frame,
285 start_time_ + video_time); 285 start_time_ + video_time);
286 286
287 // Send just enough audio data to match next video frame's time. 287 // Send just enough audio data to match next video frame's time.
288 base::TimeDelta audio_time = AudioFrameTime(audio_frame_count_); 288 base::TimeDelta audio_time = AudioFrameTime(audio_frame_count_);
289 while (audio_time < video_time) { 289 while (audio_time < video_time) {
290 if (is_transcoding_audio()) { 290 if (is_transcoding_audio()) {
291 Decode(true); 291 Decode(true);
292 CHECK(!audio_bus_queue_.empty()) << "No audio decoded."; 292 // No audio decoded.
293 CHECK(!audio_bus_queue_.empty());
293 std::unique_ptr<AudioBus> bus(audio_bus_queue_.front()); 294 std::unique_ptr<AudioBus> bus(audio_bus_queue_.front());
294 audio_bus_queue_.pop(); 295 audio_bus_queue_.pop();
295 audio_frame_input_->InsertAudio(std::move(bus), start_time_ + audio_time); 296 audio_frame_input_->InsertAudio(std::move(bus), start_time_ + audio_time);
296 } else { 297 } else {
297 audio_frame_input_->InsertAudio( 298 audio_frame_input_->InsertAudio(
298 audio_bus_factory_->NextAudioBus( 299 audio_bus_factory_->NextAudioBus(
299 base::TimeDelta::FromMilliseconds(kAudioFrameMs)), 300 base::TimeDelta::FromMilliseconds(kAudioFrameMs)),
300 start_time_ + audio_time); 301 start_time_ + audio_time);
301 } 302 }
302 audio_time = AudioFrameTime(++audio_frame_count_); 303 audio_time = AudioFrameTime(++audio_frame_count_);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 423
423 base::TimeDelta FakeMediaSource::ScaleTimestamp(base::TimeDelta timestamp) { 424 base::TimeDelta FakeMediaSource::ScaleTimestamp(base::TimeDelta timestamp) {
424 return base::TimeDelta::FromSecondsD(timestamp.InSecondsF() / playback_rate_); 425 return base::TimeDelta::FromSecondsD(timestamp.InSecondsF() / playback_rate_);
425 } 426 }
426 427
427 base::TimeDelta FakeMediaSource::AudioFrameTime(int frame_number) { 428 base::TimeDelta FakeMediaSource::AudioFrameTime(int frame_number) {
428 return frame_number * base::TimeDelta::FromMilliseconds(kAudioFrameMs); 429 return frame_number * base::TimeDelta::FromMilliseconds(kAudioFrameMs);
429 } 430 }
430 431
431 void FakeMediaSource::Rewind() { 432 void FakeMediaSource::Rewind() {
432 CHECK(av_seek_frame(av_format_context_, -1, 0, AVSEEK_FLAG_BACKWARD) >= 0) 433 // Failed to rewind to the beginning.
433 << "Failed to rewind to the beginning."; 434 CHECK(av_seek_frame(av_format_context_, -1, 0, AVSEEK_FLAG_BACKWARD) >= 0);
434 } 435 }
435 436
436 ScopedAVPacket FakeMediaSource::DemuxOnePacket(bool* audio) { 437 ScopedAVPacket FakeMediaSource::DemuxOnePacket(bool* audio) {
437 ScopedAVPacket packet(new AVPacket()); 438 ScopedAVPacket packet(new AVPacket());
438 if (av_read_frame(av_format_context_, packet.get()) < 0) { 439 if (av_read_frame(av_format_context_, packet.get()) < 0) {
439 VLOG(1) << "Failed to read one AVPacket."; 440 VLOG(1) << "Failed to read one AVPacket.";
440 packet.reset(); 441 packet.reset();
441 return packet; 442 return packet;
442 } 443 }
443 444
(...skipping 15 matching lines...) Expand all
459 AVFrame* avframe = av_frame_alloc(); 460 AVFrame* avframe = av_frame_alloc();
460 461
461 // Make a shallow copy of packet so we can slide packet.data as frames are 462 // Make a shallow copy of packet so we can slide packet.data as frames are
462 // decoded from the packet; otherwise av_packet_unref() will corrupt memory. 463 // decoded from the packet; otherwise av_packet_unref() will corrupt memory.
463 AVPacket packet_temp = *packet.get(); 464 AVPacket packet_temp = *packet.get();
464 465
465 do { 466 do {
466 int frame_decoded = 0; 467 int frame_decoded = 0;
467 int result = avcodec_decode_audio4(av_audio_context_.get(), avframe, 468 int result = avcodec_decode_audio4(av_audio_context_.get(), avframe,
468 &frame_decoded, &packet_temp); 469 &frame_decoded, &packet_temp);
469 CHECK(result >= 0) << "Failed to decode audio."; 470 // Failed to decode audio.
471 CHECK(result >= 0);
470 packet_temp.size -= result; 472 packet_temp.size -= result;
471 packet_temp.data += result; 473 packet_temp.data += result;
472 if (!frame_decoded) 474 if (!frame_decoded)
473 continue; 475 continue;
474 476
475 int frames_read = avframe->nb_samples; 477 int frames_read = avframe->nb_samples;
476 if (frames_read < 0) 478 if (frames_read < 0)
477 break; 479 break;
478 480
479 if (!audio_sent_ts_) { 481 if (!audio_sent_ts_) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 output_audio_params_.sample_rate() / kAudioPacketsPerSecond)); 532 output_audio_params_.sample_rate() / kAudioPacketsPerSecond));
531 audio_converter_->Convert(resampled_bus.get()); 533 audio_converter_->Convert(resampled_bus.get());
532 audio_bus_queue_.push(resampled_bus.release()); 534 audio_bus_queue_.push(resampled_bus.release());
533 } 535 }
534 } 536 }
535 537
536 void FakeMediaSource::DecodeVideo(ScopedAVPacket packet) { 538 void FakeMediaSource::DecodeVideo(ScopedAVPacket packet) {
537 // Video. 539 // Video.
538 int got_picture; 540 int got_picture;
539 AVFrame* avframe = av_frame_alloc(); 541 AVFrame* avframe = av_frame_alloc();
542 // Video decode error.
540 CHECK(avcodec_decode_video2(av_video_context_.get(), avframe, &got_picture, 543 CHECK(avcodec_decode_video2(av_video_context_.get(), avframe, &got_picture,
541 packet.get()) >= 0) 544 packet.get()) >= 0);
542 << "Video decode error.";
543 if (!got_picture) { 545 if (!got_picture) {
544 av_frame_free(&avframe); 546 av_frame_free(&avframe);
545 return; 547 return;
546 } 548 }
547 gfx::Size size(av_video_context_->width, av_video_context_->height); 549 gfx::Size size(av_video_context_->width, av_video_context_->height);
548 550
549 if (!video_first_pts_set_) { 551 if (!video_first_pts_set_) {
550 video_first_pts_ = avframe->pts; 552 video_first_pts_ = avframe->pts;
551 video_first_pts_set_ = true; 553 video_first_pts_set_ = true;
552 } 554 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 AVStream* FakeMediaSource::av_audio_stream() { 623 AVStream* FakeMediaSource::av_audio_stream() {
622 return av_format_context_->streams[audio_stream_index_]; 624 return av_format_context_->streams[audio_stream_index_];
623 } 625 }
624 626
625 AVStream* FakeMediaSource::av_video_stream() { 627 AVStream* FakeMediaSource::av_video_stream() {
626 return av_format_context_->streams[video_stream_index_]; 628 return av_format_context_->streams[video_stream_index_];
627 } 629 }
628 630
629 } // namespace cast 631 } // namespace cast
630 } // namespace media 632 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698