OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "webkit/media/filter_helpers.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/command_line.h" | |
9 #include "media/base/filter_collection.h" | |
10 #include "media/base/media_switches.h" | |
11 #include "media/filters/chunk_demuxer.h" | |
12 #include "media/filters/ffmpeg_audio_decoder.h" | |
13 #include "media/filters/ffmpeg_demuxer.h" | |
14 #include "media/filters/ffmpeg_video_decoder.h" | |
15 #include "media/filters/opus_audio_decoder.h" | |
16 #include "media/filters/vpx_video_decoder.h" | |
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | |
18 | |
19 namespace webkit_media { | |
20 | |
21 void AddDefaultAudioDecoders( | |
22 const scoped_refptr<base::MessageLoopProxy>& message_loop, | |
23 ScopedVector<media::AudioDecoder>* audio_decoders) { | |
24 audio_decoders->push_back(new media::FFmpegAudioDecoder(message_loop)); | |
25 | |
26 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
27 if (cmd_line->HasSwitch(switches::kEnableOpusPlayback)) { | |
28 audio_decoders->push_back(new media::OpusAudioDecoder(message_loop)); | |
29 } | |
30 } | |
31 | |
32 // Constructs and adds the default video decoders to |filter_collection|. | |
33 // | |
34 // Note that decoders in the |filter_collection| are initialized in order. | |
35 static void AddDefaultDecodersToCollection( | |
36 const scoped_refptr<base::MessageLoopProxy>& message_loop, | |
37 media::FilterCollection* filter_collection) { | |
38 | |
39 scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder = | |
40 new media::FFmpegVideoDecoder(message_loop); | |
41 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); | |
42 | |
43 // TODO(phajdan.jr): Remove ifdefs when libvpx with vp9 support is released | |
44 // (http://crbug.com/174287) . | |
45 #if !defined(MEDIA_DISABLE_LIBVPX) | |
46 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
47 if (cmd_line->HasSwitch(switches::kEnableVp9Playback)) { | |
48 scoped_refptr<media::VpxVideoDecoder> vpx_video_decoder = | |
49 new media::VpxVideoDecoder(message_loop); | |
50 filter_collection->GetVideoDecoders()->push_back(vpx_video_decoder); | |
51 } | |
52 #endif // !defined(MEDIA_DISABLE_LIBVPX) | |
53 } | |
54 | |
55 void BuildMediaSourceCollection( | |
56 const scoped_refptr<media::ChunkDemuxer>& demuxer, | |
57 const scoped_refptr<base::MessageLoopProxy>& message_loop, | |
58 media::FilterCollection* filter_collection) { | |
59 DCHECK(demuxer); | |
60 filter_collection->SetDemuxer(demuxer); | |
61 | |
62 // Remove GPUVideoDecoder until it supports codec config changes. | |
63 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. | |
64 DCHECK_LE(filter_collection->GetVideoDecoders()->size(), 1u); | |
65 filter_collection->GetVideoDecoders()->clear(); | |
66 | |
67 AddDefaultDecodersToCollection(message_loop, filter_collection); | |
68 } | |
69 | |
70 void BuildDefaultCollection( | |
71 const scoped_refptr<media::DataSource>& data_source, | |
72 const scoped_refptr<base::MessageLoopProxy>& message_loop, | |
73 media::FilterCollection* filter_collection, | |
74 const media::FFmpegNeedKeyCB& need_key_cb) { | |
75 filter_collection->SetDemuxer(new media::FFmpegDemuxer( | |
76 message_loop, data_source, need_key_cb)); | |
77 | |
78 AddDefaultDecodersToCollection(message_loop, filter_collection); | |
79 } | |
80 | |
81 } // webkit_media | |
OLD | NEW |