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