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 "media/base/filter_collection.h" | 8 #include "media/base/filter_collection.h" |
9 #include "media/filters/decrypting_audio_decoder.h" | 9 #include "media/filters/chunk_demuxer.h" |
10 #include "media/filters/decrypting_video_decoder.h" | 10 #include "media/filters/decrypting_video_decoder.h" |
11 #include "media/filters/chunk_demuxer.h" | |
12 #include "media/filters/dummy_demuxer.h" | 11 #include "media/filters/dummy_demuxer.h" |
13 #include "media/filters/ffmpeg_audio_decoder.h" | 12 #include "media/filters/ffmpeg_audio_decoder.h" |
14 #include "media/filters/ffmpeg_demuxer.h" | 13 #include "media/filters/ffmpeg_demuxer.h" |
15 #include "media/filters/ffmpeg_video_decoder.h" | 14 #include "media/filters/ffmpeg_video_decoder.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
17 #include "webkit/media/crypto/proxy_decryptor.h" | 16 #include "webkit/media/crypto/proxy_decryptor.h" |
18 #include "webkit/media/media_stream_client.h" | 17 #include "webkit/media/media_stream_client.h" |
19 | 18 |
20 namespace webkit_media { | 19 namespace webkit_media { |
21 | 20 |
22 // Constructs and adds the default audio/video decoders to |filter_collection|. | 21 // Constructs and adds the default audio/video decoders to |filter_collection|. |
23 // Note that decoders in the |filter_collection| are ordered. The first | 22 // Note that decoders in the |filter_collection| are ordered. The first |
24 // audio/video decoder in the |filter_collection| that supports the input | 23 // 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 | 24 // 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 | 25 // pipeline. This is done by trying to initialize the decoder with the input |
27 // stream. Some decoder may only accept certain types of streams. For example, | 26 // stream. Some decoder may only accept certain types of streams. For example, |
28 // DecryptingVideoDecoder only supports encrypted video stream. | 27 // DecryptingVideoDecoder only supports encrypted video stream. |
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 ProxyDecryptor* proxy_decryptor) { | 31 ProxyDecryptor* proxy_decryptor) { |
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 if (proxy_decryptor) { | 36 if (proxy_decryptor) { |
38 scoped_refptr<media::DecryptingAudioDecoder> decrypting_audio_decoder = | |
39 new media::DecryptingAudioDecoder( | |
40 message_loop, | |
41 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, | |
42 base::Unretained(proxy_decryptor))); | |
43 filter_collection->GetAudioDecoders()->push_back(decrypting_audio_decoder); | |
44 | |
45 scoped_refptr<media::DecryptingVideoDecoder> decrypting_video_decoder = | 37 scoped_refptr<media::DecryptingVideoDecoder> decrypting_video_decoder = |
46 new media::DecryptingVideoDecoder( | 38 new media::DecryptingVideoDecoder( |
47 message_loop, | 39 message_loop, |
48 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, | 40 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, |
49 base::Unretained(proxy_decryptor))); | 41 base::Unretained(proxy_decryptor))); |
50 // TODO(xhwang): Ideally we should have decrypting video decoder after | 42 // TODO(xhwang): Ideally we should have decrypting video decoder after |
51 // regular video decoder since in the real world most videos are not | 43 // regular video decoder since in the real world most videos are not |
52 // encrypted. For now FFmpegVideoDecoder can also do decryption | 44 // encrypted. For now FFmpegVideoDecoder can also do decryption |
53 // (decrypt-only), and we perfer DecryptingVideoDecoder (decrypt-and-decode) | 45 // (decrypt-only), and we perfer DecryptingVideoDecoder (decrypt-and-decode) |
54 // to FFmpegVideoDecoder. Fix this order when we move decryption out of | 46 // to FFmpegVideoDecoder. Fix this order when we move decryption out of |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 media::FilterCollection* filter_collection, | 100 media::FilterCollection* filter_collection, |
109 ProxyDecryptor* proxy_decryptor) { | 101 ProxyDecryptor* proxy_decryptor) { |
110 filter_collection->SetDemuxer(new media::FFmpegDemuxer( | 102 filter_collection->SetDemuxer(new media::FFmpegDemuxer( |
111 message_loop, data_source)); | 103 message_loop, data_source)); |
112 | 104 |
113 AddDefaultDecodersToCollection(message_loop, filter_collection, | 105 AddDefaultDecodersToCollection(message_loop, filter_collection, |
114 proxy_decryptor); | 106 proxy_decryptor); |
115 } | 107 } |
116 | 108 |
117 } // webkit_media | 109 } // webkit_media |
OLD | NEW |