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

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: 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
« media/base/video_frame.cc ('K') | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
506 // Log the codec detected, whether it is supported or not. 508 // Log the codec detected, whether it is supported or not.
507 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedAudioCodec", 509 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedAudioCodec",
508 codec_context->codec_id); 510 codec_context->codec_id);
509 // Ensure the codec is supported. IsValidConfig() also checks that the 511 // Ensure the codec is supported. IsValidConfig() also checks that the
510 // channel layout and sample format are valid. 512 // channel layout and sample format are valid.
511 AudioDecoderConfig audio_config; 513 AudioDecoderConfig audio_config;
512 AVStreamToAudioDecoderConfig(stream, &audio_config, false); 514 AVStreamToAudioDecoderConfig(stream, &audio_config, false);
515
516 // Logging
517 media_log_->SetStringProperty("audio_codec_name",
518 codec_context->codec_name);
519 media_log_->SetIntegerProperty("audio_sample_rate",
520 codec_context->sample_rate);
521 media_log_->SetIntegerProperty("audio_channels_count",
522 codec_context->channels);
523 media_log_->SetIntegerProperty("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
519 // Log the codec detected, whether it is supported or not. 533 // Log the codec detected, whether it is supported or not.
520 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedVideoCodec", 534 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedVideoCodec",
521 codec_context->codec_id); 535 codec_context->codec_id);
522 // Ensure the codec is supported. IsValidConfig() also checks that the 536 // Ensure the codec is supported. IsValidConfig() also checks that the
523 // frame size and visible size are valid. 537 // frame size and visible size are valid.
524 VideoDecoderConfig video_config; 538 VideoDecoderConfig video_config;
525 AVStreamToVideoDecoderConfig(stream, &video_config, false); 539 AVStreamToVideoDecoderConfig(stream, &video_config, false);
540
541 // Logging
542 std::string codec_name = avcodec_get_name(codec_context->codec_id);
543 media_log_->SetStringProperty("video_codec_name", codec_name);
544 media_log_->SetIntegerProperty("width", codec_context->width);
545 media_log_->SetIntegerProperty("height", codec_context->height);
546 media_log_->SetIntegerProperty("coded_width", codec_context->coded_width);
547 media_log_->SetIntegerProperty("coded_height",
548 codec_context->coded_height);
549 media_log_->SetStringProperty(
550 "time_base", base::StringPrintf("%d/%d",
551 codec_context->time_base.num,
552 codec_context->time_base.den));
553 media_log_->SetStringProperty("video_format",
554 VideoFrame::FormatToString(video_config.format()));
555 media_log_->SetBooleanProperty("video_is_encrypted",
556 video_config.is_encrypted());
557
526 if (!video_config.IsValidConfig()) 558 if (!video_config.IsValidConfig())
527 continue; 559 continue;
528 found_video_stream = true; 560 found_video_stream = true;
529 } else { 561 } else {
530 continue; 562 continue;
531 } 563 }
532 564
533 streams_[i] = new FFmpegDemuxerStream(this, stream); 565 streams_[i] = new FFmpegDemuxerStream(this, stream);
534 max_duration = std::max(max_duration, streams_[i]->duration()); 566 max_duration = std::max(max_duration, streams_[i]->duration());
535 567
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // initializing. 604 // initializing.
573 host_->SetDuration(max_duration); 605 host_->SetDuration(max_duration);
574 duration_known_ = (max_duration != kInfiniteDuration()); 606 duration_known_ = (max_duration != kInfiniteDuration());
575 607
576 int64 filesize_in_bytes = 0; 608 int64 filesize_in_bytes = 0;
577 url_protocol_.GetSize(&filesize_in_bytes); 609 url_protocol_.GetSize(&filesize_in_bytes);
578 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes); 610 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes);
579 if (bitrate_ > 0) 611 if (bitrate_ > 0)
580 data_source_->SetBitrate(bitrate_); 612 data_source_->SetBitrate(bitrate_);
581 613
614 media_log_->SetBooleanProperty("found_audio_stream", found_audio_stream);
615 media_log_->SetBooleanProperty("found_video_stream", found_video_stream);
616 media_log_->SetDoubleProperty("max_duration", max_duration.InSecondsF());
617 media_log_->SetDoubleProperty("start_time", start_time_.InSecondsF());
618 media_log_->SetStringProperty("filesize_in_bytes",
619 std::to_string(filesize_in_bytes));
620 media_log_->SetIntegerProperty("bitrate", bitrate_);
621
582 status_cb.Run(PIPELINE_OK); 622 status_cb.Run(PIPELINE_OK);
583 } 623 }
584 624
585 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) { 625 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) {
586 DCHECK(message_loop_->BelongsToCurrentThread()); 626 DCHECK(message_loop_->BelongsToCurrentThread());
587 CHECK(pending_seek_); 627 CHECK(pending_seek_);
588 pending_seek_ = false; 628 pending_seek_ = false;
589 629
590 if (!blocking_thread_.IsRunning()) { 630 if (!blocking_thread_.IsRunning()) {
591 cb.Run(PIPELINE_ERROR_ABORT); 631 cb.Run(PIPELINE_ERROR_ABORT);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 817 }
778 for (size_t i = 0; i < buffered.size(); ++i) 818 for (size_t i = 0; i < buffered.size(); ++i)
779 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 819 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
780 } 820 }
781 821
782 void FFmpegDemuxer::OnDataSourceError() { 822 void FFmpegDemuxer::OnDataSourceError() {
783 host_->OnDemuxerError(PIPELINE_ERROR_READ); 823 host_->OnDemuxerError(PIPELINE_ERROR_READ);
784 } 824 }
785 825
786 } // namespace media 826 } // namespace media
OLDNEW
« media/base/video_frame.cc ('K') | « media/base/video_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698