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