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

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 21953003: Added logging calls to FFmpegDemuxer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed something that got lost in the git madness Created 7 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/callback_helpers.h" 13 #include "base/callback_helpers.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/metrics/sparse_histogram.h" 17 #include "base/metrics/sparse_histogram.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h"
20 #include "base/task_runner_util.h" 21 #include "base/task_runner_util.h"
21 #include "base/time/time.h" 22 #include "base/time/time.h"
22 #include "media/base/audio_decoder_config.h" 23 #include "media/base/audio_decoder_config.h"
23 #include "media/base/bind_to_loop.h" 24 #include "media/base/bind_to_loop.h"
24 #include "media/base/decoder_buffer.h" 25 #include "media/base/decoder_buffer.h"
25 #include "media/base/decrypt_config.h" 26 #include "media/base/decrypt_config.h"
26 #include "media/base/limits.h" 27 #include "media/base/limits.h"
27 #include "media/base/media_log.h" 28 #include "media/base/media_log.h"
28 #include "media/base/media_switches.h" 29 #include "media/base/media_switches.h"
29 #include "media/base/video_decoder_config.h" 30 #include "media/base/video_decoder_config.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 497
497 base::TimeDelta max_duration; 498 base::TimeDelta max_duration;
498 for (size_t i = 0; i < format_context->nb_streams; ++i) { 499 for (size_t i = 0; i < format_context->nb_streams; ++i) {
499 AVStream* stream = format_context->streams[i]; 500 AVStream* stream = format_context->streams[i];
500 AVCodecContext* codec_context = stream->codec; 501 AVCodecContext* codec_context = stream->codec;
501 AVMediaType codec_type = codec_context->codec_type; 502 AVMediaType codec_type = codec_context->codec_type;
502 503
503 if (codec_type == AVMEDIA_TYPE_AUDIO) { 504 if (codec_type == AVMEDIA_TYPE_AUDIO) {
504 if (found_audio_stream) 505 if (found_audio_stream)
505 continue; 506 continue;
507
508 // Logging
509 std::string codec_name = codec_context->codec_name;
scherkus (not reviewing) 2013/08/02 21:53:48 if you're putting the logging here, then we should
Ty Overby 2013/08/02 23:04:27 Done.
510 media_log_->SetProperty("audio_codec_name", codec_name);
511 media_log_->SetProperty("audio_sample_rate", codec_context->sample_rate);
512 media_log_->SetProperty("audio_channels", codec_context->channels);
513
514
506 // Log the codec detected, whether it is supported or not. 515 // Log the codec detected, whether it is supported or not.
507 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedAudioCodec", 516 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedAudioCodec",
508 codec_context->codec_id); 517 codec_context->codec_id);
509 // Ensure the codec is supported. IsValidConfig() also checks that the 518 // Ensure the codec is supported. IsValidConfig() also checks that the
510 // channel layout and sample format are valid. 519 // channel layout and sample format are valid.
511 AudioDecoderConfig audio_config; 520 AudioDecoderConfig audio_config;
512 AVStreamToAudioDecoderConfig(stream, &audio_config, false); 521 AVStreamToAudioDecoderConfig(stream, &audio_config, false);
522
523 media_log_->SetProperty("audio_samples_per_second",
524 audio_config.samples_per_second());
525
513 if (!audio_config.IsValidConfig()) 526 if (!audio_config.IsValidConfig())
514 continue; 527 continue;
515 found_audio_stream = true; 528 found_audio_stream = true;
516 } else if (codec_type == AVMEDIA_TYPE_VIDEO) { 529 } else if (codec_type == AVMEDIA_TYPE_VIDEO) {
517 if (found_video_stream) 530 if (found_video_stream)
518 continue; 531 continue;
532
533 // Logging
534 std::string codec_name = avcodec_get_name(codec_context->codec_id);
535 media_log_->SetProperty("video_codec_name", codec_name);
536 media_log_->SetProperty("width", codec_context->width);
537 media_log_->SetProperty("height", codec_context->height);
538 media_log_->SetProperty("coded_width", codec_context->coded_width);
539 media_log_->SetProperty("coded_height", codec_context->coded_height);
540 media_log_->SetProperty("ticks_per_frame",
scherkus (not reviewing) 2013/08/02 21:53:48 I wouldn't bother logging this one
Ty Overby 2013/08/02 23:04:27 Done.
541 codec_context->ticks_per_frame);
542
543 std::string base_time = "";
544 base::SStringPrintf(&base_time, "%d/%d",
scherkus (not reviewing) 2013/08/02 21:53:48 you can use StringPrintf() (no leading S) and pass
Ty Overby 2013/08/02 23:04:27 Done.
545 codec_context->time_base.num,
546 codec_context->time_base.den);
547 media_log_->SetProperty("time_base", base_time);
scherkus (not reviewing) 2013/08/02 21:53:48 this might not end up being very useful informatio
Ty Overby 2013/08/02 23:04:27 Ok, well it's easy to add/remove if it proves usef
548
519 // Log the codec detected, whether it is supported or not. 549 // Log the codec detected, whether it is supported or not.
520 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedVideoCodec", 550 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedVideoCodec",
521 codec_context->codec_id); 551 codec_context->codec_id);
522 // Ensure the codec is supported. IsValidConfig() also checks that the 552 // Ensure the codec is supported. IsValidConfig() also checks that the
523 // frame size and visible size are valid. 553 // frame size and visible size are valid.
524 VideoDecoderConfig video_config; 554 VideoDecoderConfig video_config;
525 AVStreamToVideoDecoderConfig(stream, &video_config, false); 555 AVStreamToVideoDecoderConfig(stream, &video_config, false);
556
557 media_log_->SetProperty("video_decoder_config",
scherkus (not reviewing) 2013/08/02 21:53:48 don't bother logging -- it'll duplicates other stu
Ty Overby 2013/08/02 23:04:27 Done.
558 video_config.AsHumanReadableString());
559 media_log_->SetProperty("pixel_format", video_config.FormatName());
scherkus (not reviewing) 2013/08/02 21:53:48 nit: s/pixel_format/video_format/
Ty Overby 2013/08/02 23:04:27 Done.
560 media_log_->SetProperty("video_is_encrypted",
561 video_config.is_encrypted());
562
526 if (!video_config.IsValidConfig()) 563 if (!video_config.IsValidConfig())
527 continue; 564 continue;
528 found_video_stream = true; 565 found_video_stream = true;
529 } else { 566 } else {
530 continue; 567 continue;
531 } 568 }
532 569
533 streams_[i] = new FFmpegDemuxerStream(this, stream); 570 streams_[i] = new FFmpegDemuxerStream(this, stream);
534 max_duration = std::max(max_duration, streams_[i]->duration()); 571 max_duration = std::max(max_duration, streams_[i]->duration());
535 572
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // initializing. 609 // initializing.
573 host_->SetDuration(max_duration); 610 host_->SetDuration(max_duration);
574 duration_known_ = (max_duration != kInfiniteDuration()); 611 duration_known_ = (max_duration != kInfiniteDuration());
575 612
576 int64 filesize_in_bytes = 0; 613 int64 filesize_in_bytes = 0;
577 url_protocol_.GetSize(&filesize_in_bytes); 614 url_protocol_.GetSize(&filesize_in_bytes);
578 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes); 615 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes);
579 if (bitrate_ > 0) 616 if (bitrate_ > 0)
580 data_source_->SetBitrate(bitrate_); 617 data_source_->SetBitrate(bitrate_);
581 618
619 media_log_->SetProperty("found_audio_stream", found_audio_stream);
620 media_log_->SetProperty("found_video_stream", found_video_stream);
621 media_log_->SetProperty("max_duration", max_duration.InMillisecondsF());
scherkus (not reviewing) 2013/08/02 21:53:48 nit: I'd use InSecondsF
Ty Overby 2013/08/02 23:04:27 Done.
622 media_log_->SetProperty("start_time", start_time_.InMillisecondsF());
623 media_log_->SetProperty("filesize_in_bytes",(int) filesize_in_bytes);
scherkus (not reviewing) 2013/08/02 21:53:48 this will need to be converted to a string due to
Ty Overby 2013/08/02 23:04:27 Oh wow. Done.
624 media_log_->SetProperty("bitrate", bitrate_);
625
582 status_cb.Run(PIPELINE_OK); 626 status_cb.Run(PIPELINE_OK);
583 } 627 }
584 628
585 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) { 629 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) {
586 DCHECK(message_loop_->BelongsToCurrentThread()); 630 DCHECK(message_loop_->BelongsToCurrentThread());
587 CHECK(pending_seek_); 631 CHECK(pending_seek_);
588 pending_seek_ = false; 632 pending_seek_ = false;
589 633
590 if (!blocking_thread_.IsRunning()) { 634 if (!blocking_thread_.IsRunning()) {
591 cb.Run(PIPELINE_ERROR_ABORT); 635 cb.Run(PIPELINE_ERROR_ABORT);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 821 }
778 for (size_t i = 0; i < buffered.size(); ++i) 822 for (size_t i = 0; i < buffered.size(); ++i)
779 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 823 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
780 } 824 }
781 825
782 void FFmpegDemuxer::OnDataSourceError() { 826 void FFmpegDemuxer::OnDataSourceError() {
783 host_->OnDemuxerError(PIPELINE_ERROR_READ); 827 host_->OnDemuxerError(PIPELINE_ERROR_READ);
784 } 828 }
785 829
786 } // namespace media 830 } // namespace media
OLDNEW
« media/base/video_decoder_config.cc ('K') | « media/base/video_decoder_config.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698