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

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

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
« no previous file with comments | « no previous file | media/filters/source_buffer.cc » ('j') | media/filters/source_buffer.cc » ('J')
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/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/webm/webm_stream_parser.h" 14 #include "media/webm/webm_stream_parser.h"
15 #include "media/mp4/mp4_stream_parser.h"
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 includes should be alphabetical
strobe_ 2012/06/07 16:33:54 Done.
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[] = {
47 &kVP8CodecInfo,
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 remove. VP8 should not be allowed in an audio only
strobe_ 2012/06/07 16:33:54 Done. Sorry, copy and paste error.
41 &kVorbisCodecInfo, 48 &kVorbisCodecInfo,
42 NULL 49 NULL
43 }; 50 };
44 51
52 static const CodecInfo* kVideoMP4Codecs[] = {
53 &kH264CodecInfo,
54 &kAACCodecInfo,
55 NULL
56 };
57
58 static const CodecInfo* kAudioMP4Codecs[] = {
59 &kAACCodecInfo,
60 NULL
61 };
62
45 static StreamParser* BuildWebMParser() { 63 static StreamParser* BuildWebMParser() {
46 return new WebMStreamParser(); 64 return new WebMStreamParser();
47 } 65 }
48 66
67 static StreamParser* BuildMP4Parser() {
68 return new MP4StreamParser();
69 }
70
49 static const SupportedTypeInfo kSupportedTypeInfo[] = { 71 static const SupportedTypeInfo kSupportedTypeInfo[] = {
50 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, 72 { "video/webm", &BuildWebMParser, kVideoWebMCodecs },
51 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, 73 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs },
74 { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs },
75 { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs },
52 }; 76 };
53 77
54 // Checks to see if the specified |type| and |codecs| list are supported. 78 // 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. 79 // Returns true if |type| and all codecs listed in |codecs| are supported.
56 // |factory_function| contains a function that can build a StreamParser 80 // |factory_function| contains a function that can build a StreamParser
57 // for this type. 81 // for this type.
58 // |has_audio| is true if an audio codec was specified. 82 // |has_audio| is true if an audio codec was specified.
59 // |has_video| is true if a video codec was specified. 83 // |has_video| is true if a video codec was specified.
60 // Returns false otherwise. The values of |factory_function|, |has_audio|, 84 // Returns false otherwise. The values of |factory_function|, |has_audio|,
61 // and |has_video| are undefined. 85 // and |has_video| are undefined.
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 533
510 base::AutoLock auto_lock(lock_); 534 base::AutoLock auto_lock(lock_);
511 535
512 return source_buffer_->GetBufferedRanges(ranges_out); 536 return source_buffer_->GetBufferedRanges(ranges_out);
513 } 537 }
514 538
515 bool ChunkDemuxer::AppendData(const std::string& id, 539 bool ChunkDemuxer::AppendData(const std::string& id,
516 const uint8* data, 540 const uint8* data,
517 size_t length) { 541 size_t length) {
518 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; 542 DVLOG(1) << "AppendData(" << id << ", " << length << ")";
519
520 // TODO(acolwell): Remove when http://webk.it/83788 fix lands.
521 if (source_id_.empty()) {
522 std::vector<std::string> codecs(2);
523 codecs[0] = "vp8";
524 codecs[1] = "vorbis";
525 AddId(id, "video/webm", codecs);
526 }
527
528 DCHECK(!source_id_.empty()); 543 DCHECK(!source_id_.empty());
529 DCHECK_EQ(source_id_, id); 544 DCHECK_EQ(source_id_, id);
530 DCHECK(!id.empty()); 545 DCHECK(!id.empty());
531 DCHECK(data); 546 DCHECK(data);
532 DCHECK_GT(length, 0u); 547 DCHECK_GT(length, 0u);
533 548
534 int64 buffered_bytes = 0; 549 int64 buffered_bytes = 0;
535 550
536 PipelineStatusCB cb; 551 PipelineStatusCB cb;
537 { 552 {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 return true; 790 return true;
776 } 791 }
777 792
778 bool ChunkDemuxer::OnKeyNeeded(scoped_array<uint8> init_data, 793 bool ChunkDemuxer::OnKeyNeeded(scoped_array<uint8> init_data,
779 int init_data_size) { 794 int init_data_size) {
780 client_->KeyNeeded(init_data.Pass(), init_data_size); 795 client_->KeyNeeded(init_data.Pass(), init_data_size);
781 return true; 796 return true;
782 } 797 }
783 798
784 } // namespace media 799 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/source_buffer.cc » ('j') | media/filters/source_buffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698