| 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/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "media/base/audio_decoder_config.h" | 10 #include "media/base/audio_decoder_config.h" |
| 11 #include "media/base/stream_parser_buffer.h" | 11 #include "media/base/stream_parser_buffer.h" |
| 12 #include "media/base/video_decoder_config.h" | 12 #include "media/base/video_decoder_config.h" |
| 13 #include "media/filters/chunk_demuxer_client.h" | 13 #include "media/filters/chunk_demuxer_client.h" |
| 14 #include "media/mp4/mp4_stream_parser.h" |
| 14 #include "media/webm/webm_stream_parser.h" | 15 #include "media/webm/webm_stream_parser.h" |
| 15 | 16 |
| 16 namespace media { | 17 namespace media { |
| 17 | 18 |
| 18 struct CodecInfo { | 19 struct CodecInfo { |
| 19 const char* name; | 20 const char* name; |
| 20 DemuxerStream::Type type; | 21 DemuxerStream::Type type; |
| 21 }; | 22 }; |
| 22 | 23 |
| 23 typedef StreamParser* (*ParserFactoryFunction)(); | 24 typedef StreamParser* (*ParserFactoryFunction)(); |
| 24 | 25 |
| 25 struct SupportedTypeInfo { | 26 struct SupportedTypeInfo { |
| 26 const char* type; | 27 const char* type; |
| 27 const ParserFactoryFunction factory_function; | 28 const ParserFactoryFunction factory_function; |
| 28 const CodecInfo** codecs; | 29 const CodecInfo** codecs; |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 static const CodecInfo kVP8CodecInfo = { "vp8", DemuxerStream::VIDEO }; | 32 static const CodecInfo kVP8CodecInfo = { "vp8", DemuxerStream::VIDEO }; |
| 32 static const CodecInfo kVorbisCodecInfo = { "vorbis", DemuxerStream::AUDIO }; | 33 static const CodecInfo kVorbisCodecInfo = { "vorbis", DemuxerStream::AUDIO }; |
| 33 | 34 |
| 35 // TODO(strobe): Perform matching against supported profiles and levels, or |
| 36 // simply accept codecs that match a prefix. |
| 37 static const CodecInfo kH264CodecInfo = { "avc1.4D4041", DemuxerStream::VIDEO }; |
| 38 static const CodecInfo kAACCodecInfo = { "mp4a.40.2", DemuxerStream::AUDIO }; |
| 39 |
| 34 static const CodecInfo* kVideoWebMCodecs[] = { | 40 static const CodecInfo* kVideoWebMCodecs[] = { |
| 35 &kVP8CodecInfo, | 41 &kVP8CodecInfo, |
| 36 &kVorbisCodecInfo, | 42 &kVorbisCodecInfo, |
| 37 NULL | 43 NULL |
| 38 }; | 44 }; |
| 39 | 45 |
| 40 static const CodecInfo* kAudioWebMCodecs[] = { | 46 static const CodecInfo* kAudioWebMCodecs[] = { |
| 41 &kVorbisCodecInfo, | 47 &kVorbisCodecInfo, |
| 42 NULL | 48 NULL |
| 43 }; | 49 }; |
| 44 | 50 |
| 51 static const CodecInfo* kVideoMP4Codecs[] = { |
| 52 &kH264CodecInfo, |
| 53 &kAACCodecInfo, |
| 54 NULL |
| 55 }; |
| 56 |
| 57 static const CodecInfo* kAudioMP4Codecs[] = { |
| 58 &kAACCodecInfo, |
| 59 NULL |
| 60 }; |
| 61 |
| 45 static StreamParser* BuildWebMParser() { | 62 static StreamParser* BuildWebMParser() { |
| 46 return new WebMStreamParser(); | 63 return new WebMStreamParser(); |
| 47 } | 64 } |
| 48 | 65 |
| 66 static StreamParser* BuildMP4Parser() { |
| 67 return new mp4::MP4StreamParser(); |
| 68 } |
| 69 |
| 49 static const SupportedTypeInfo kSupportedTypeInfo[] = { | 70 static const SupportedTypeInfo kSupportedTypeInfo[] = { |
| 50 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, | 71 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, |
| 51 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, | 72 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, |
| 73 { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs }, |
| 74 { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs }, |
| 52 }; | 75 }; |
| 53 | 76 |
| 54 // Checks to see if the specified |type| and |codecs| list are supported. | 77 // Checks to see if the specified |type| and |codecs| list are supported. |
| 55 // Returns true if |type| and all codecs listed in |codecs| are supported. | 78 // Returns true if |type| and all codecs listed in |codecs| are supported. |
| 56 // |factory_function| contains a function that can build a StreamParser | 79 // |factory_function| contains a function that can build a StreamParser |
| 57 // for this type. | 80 // for this type. |
| 58 // |has_audio| is true if an audio codec was specified. | 81 // |has_audio| is true if an audio codec was specified. |
| 59 // |has_video| is true if a video codec was specified. | 82 // |has_video| is true if a video codec was specified. |
| 60 // Returns false otherwise. The values of |factory_function|, |has_audio|, | 83 // Returns false otherwise. The values of |factory_function|, |has_audio|, |
| 61 // and |has_video| are undefined. | 84 // and |has_video| are undefined. |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 // TODO(vrk): There should be a special case for the first appends where all | 1029 // TODO(vrk): There should be a special case for the first appends where all |
| 1007 // streams (for both demuxed and muxed case) begin at the earliest stream | 1030 // streams (for both demuxed and muxed case) begin at the earliest stream |
| 1008 // timestamp. (crbug.com/132815) | 1031 // timestamp. (crbug.com/132815) |
| 1009 if (audio_ && source_id == source_id_audio_) | 1032 if (audio_ && source_id == source_id_audio_) |
| 1010 audio_->OnNewMediaSegment(start_timestamp); | 1033 audio_->OnNewMediaSegment(start_timestamp); |
| 1011 if (video_ && source_id == source_id_video_) | 1034 if (video_ && source_id == source_id_video_) |
| 1012 video_->OnNewMediaSegment(start_timestamp); | 1035 video_->OnNewMediaSegment(start_timestamp); |
| 1013 } | 1036 } |
| 1014 | 1037 |
| 1015 } // namespace media | 1038 } // namespace media |
| OLD | NEW |