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 "webkit/media/filter_helpers.h" | 5 #include "webkit/media/filter_helpers.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "media/base/filter_collection.h" | 9 #include "media/base/filter_collection.h" |
10 #include "media/base/media_switches.h" | 10 #include "media/base/media_switches.h" |
11 #include "media/filters/chunk_demuxer.h" | 11 #include "media/filters/chunk_demuxer.h" |
12 #include "media/filters/dummy_demuxer.h" | 12 #include "media/filters/dummy_demuxer.h" |
13 #include "media/filters/ffmpeg_audio_decoder.h" | 13 #include "media/filters/ffmpeg_audio_decoder.h" |
14 #include "media/filters/ffmpeg_demuxer.h" | 14 #include "media/filters/ffmpeg_demuxer.h" |
15 #include "media/filters/ffmpeg_video_decoder.h" | 15 #include "media/filters/ffmpeg_video_decoder.h" |
16 #include "media/filters/opus_audio_decoder.h" | 16 #include "media/filters/opus_audio_decoder.h" |
17 #include "media/filters/vpx_video_decoder.h" | |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
19 #include "webkit/media/media_stream_client.h" | 18 #include "webkit/media/media_stream_client.h" |
20 | 19 |
21 namespace webkit_media { | 20 namespace webkit_media { |
22 | 21 |
23 // Constructs and adds the default audio/video decoders to |filter_collection|. | 22 // Constructs and adds the default audio/video decoders to |filter_collection|. |
24 // Note that decoders in the |filter_collection| are ordered. The first | 23 // Note that decoders in the |filter_collection| are ordered. The first |
25 // audio/video decoder in the |filter_collection| that supports the input | 24 // audio/video decoder in the |filter_collection| that supports the input |
26 // audio/video stream will be selected as the audio/video decoder in the media | 25 // audio/video stream will be selected as the audio/video decoder in the media |
27 // pipeline. This is done by trying to initialize the decoder with the input | 26 // pipeline. This is done by trying to initialize the decoder with the input |
28 // stream. Some decoder may only accept certain types of streams. | 27 // stream. Some decoder may only accept certain types of streams. |
29 static void AddDefaultDecodersToCollection( | 28 static void AddDefaultDecodersToCollection( |
30 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 29 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
31 media::FilterCollection* filter_collection) { | 30 media::FilterCollection* filter_collection) { |
32 | 31 |
33 scoped_refptr<media::FFmpegAudioDecoder> ffmpeg_audio_decoder = | 32 scoped_refptr<media::FFmpegAudioDecoder> ffmpeg_audio_decoder = |
34 new media::FFmpegAudioDecoder(message_loop); | 33 new media::FFmpegAudioDecoder(message_loop); |
35 filter_collection->GetAudioDecoders()->push_back(ffmpeg_audio_decoder); | 34 filter_collection->GetAudioDecoders()->push_back(ffmpeg_audio_decoder); |
36 | 35 |
37 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 36 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
38 if (cmd_line->HasSwitch(switches::kEnableOpusPlayback)) { | 37 if (cmd_line->HasSwitch(switches::kEnableOpusPlayback)) { |
39 scoped_refptr<media::OpusAudioDecoder> opus_audio_decoder = | 38 scoped_refptr<media::OpusAudioDecoder> opus_audio_decoder = |
40 new media::OpusAudioDecoder(message_loop); | 39 new media::OpusAudioDecoder(message_loop); |
41 filter_collection->GetAudioDecoders()->push_back(opus_audio_decoder); | 40 filter_collection->GetAudioDecoders()->push_back(opus_audio_decoder); |
42 } | 41 } |
43 | 42 |
44 scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder = | 43 scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder = |
45 new media::FFmpegVideoDecoder(message_loop); | 44 new media::FFmpegVideoDecoder(message_loop); |
46 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); | 45 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); |
47 | |
48 if (cmd_line->HasSwitch(switches::kEnableVp9Playback)) { | |
49 scoped_refptr<media::VpxVideoDecoder> vpx_video_decoder = | |
50 new media::VpxVideoDecoder(message_loop); | |
51 filter_collection->GetVideoDecoders()->push_back(vpx_video_decoder); | |
52 } | |
53 } | 46 } |
54 | 47 |
55 bool BuildMediaStreamCollection( | 48 bool BuildMediaStreamCollection( |
56 const WebKit::WebURL& url, | 49 const WebKit::WebURL& url, |
57 MediaStreamClient* client, | 50 MediaStreamClient* client, |
58 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 51 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
59 media::FilterCollection* filter_collection) { | 52 media::FilterCollection* filter_collection) { |
60 if (!client) | 53 if (!client) |
61 return false; | 54 return false; |
62 | 55 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const scoped_refptr<media::DataSource>& data_source, | 88 const scoped_refptr<media::DataSource>& data_source, |
96 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 89 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
97 media::FilterCollection* filter_collection) { | 90 media::FilterCollection* filter_collection) { |
98 filter_collection->SetDemuxer(new media::FFmpegDemuxer( | 91 filter_collection->SetDemuxer(new media::FFmpegDemuxer( |
99 message_loop, data_source)); | 92 message_loop, data_source)); |
100 | 93 |
101 AddDefaultDecodersToCollection(message_loop, filter_collection); | 94 AddDefaultDecodersToCollection(message_loop, filter_collection); |
102 } | 95 } |
103 | 96 |
104 } // webkit_media | 97 } // webkit_media |
OLD | NEW |