OLD | NEW |
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.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/metrics/sparse_histogram.h" |
17 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
19 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
20 #include "base/time.h" | 21 #include "base/time.h" |
21 #include "media/base/audio_decoder_config.h" | 22 #include "media/base/audio_decoder_config.h" |
22 #include "media/base/bind_to_loop.h" | 23 #include "media/base/bind_to_loop.h" |
23 #include "media/base/decoder_buffer.h" | 24 #include "media/base/decoder_buffer.h" |
24 #include "media/base/decrypt_config.h" | 25 #include "media/base/decrypt_config.h" |
25 #include "media/base/limits.h" | 26 #include "media/base/limits.h" |
26 #include "media/base/media_switches.h" | 27 #include "media/base/media_switches.h" |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 bool found_video_stream = false; | 459 bool found_video_stream = false; |
459 | 460 |
460 base::TimeDelta max_duration; | 461 base::TimeDelta max_duration; |
461 for (size_t i = 0; i < format_context->nb_streams; ++i) { | 462 for (size_t i = 0; i < format_context->nb_streams; ++i) { |
462 AVCodecContext* codec_context = format_context->streams[i]->codec; | 463 AVCodecContext* codec_context = format_context->streams[i]->codec; |
463 AVMediaType codec_type = codec_context->codec_type; | 464 AVMediaType codec_type = codec_context->codec_type; |
464 | 465 |
465 if (codec_type == AVMEDIA_TYPE_AUDIO) { | 466 if (codec_type == AVMEDIA_TYPE_AUDIO) { |
466 if (found_audio_stream) | 467 if (found_audio_stream) |
467 continue; | 468 continue; |
| 469 // Log the codec detected, whether it is supported or not. |
| 470 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedAudioCodec", |
| 471 codec_context->codec_id); |
468 // Ensure the codec is supported. | 472 // Ensure the codec is supported. |
469 if (CodecIDToAudioCodec(codec_context->codec_id) == kUnknownAudioCodec) | 473 if (CodecIDToAudioCodec(codec_context->codec_id) == kUnknownAudioCodec) |
470 continue; | 474 continue; |
471 found_audio_stream = true; | 475 found_audio_stream = true; |
472 } else if (codec_type == AVMEDIA_TYPE_VIDEO) { | 476 } else if (codec_type == AVMEDIA_TYPE_VIDEO) { |
473 if (found_video_stream) | 477 if (found_video_stream) |
474 continue; | 478 continue; |
| 479 // Log the codec detected, whether it is supported or not. |
| 480 UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedVideoCodec", |
| 481 codec_context->codec_id); |
475 // Ensure the codec is supported. | 482 // Ensure the codec is supported. |
476 if (CodecIDToVideoCodec(codec_context->codec_id) == kUnknownVideoCodec) | 483 if (CodecIDToVideoCodec(codec_context->codec_id) == kUnknownVideoCodec) |
477 continue; | 484 continue; |
478 found_video_stream = true; | 485 found_video_stream = true; |
479 } else { | 486 } else { |
480 continue; | 487 continue; |
481 } | 488 } |
482 | 489 |
483 AVStream* stream = format_context->streams[i]; | 490 AVStream* stream = format_context->streams[i]; |
484 scoped_refptr<FFmpegDemuxerStream> demuxer_stream( | 491 scoped_refptr<FFmpegDemuxerStream> demuxer_stream( |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 737 } |
731 for (size_t i = 0; i < buffered.size(); ++i) | 738 for (size_t i = 0; i < buffered.size(); ++i) |
732 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 739 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
733 } | 740 } |
734 | 741 |
735 void FFmpegDemuxer::OnDataSourceError() { | 742 void FFmpegDemuxer::OnDataSourceError() { |
736 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 743 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
737 } | 744 } |
738 | 745 |
739 } // namespace media | 746 } // namespace media |
OLD | NEW |