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/decrypting_audio_decoder.h" |
10 #include "media/filters/decrypting_video_decoder.h" | 10 #include "media/filters/decrypting_video_decoder.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // 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 |
26 // 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 |
27 // stream. Some decoder may only accept certain types of streams. For example, | 27 // stream. Some decoder may only accept certain types of streams. For example, |
28 // DecryptingVideoDecoder only supports encrypted video stream. | 28 // DecryptingVideoDecoder only supports encrypted video stream. |
29 static void AddDefaultDecodersToCollection( | 29 static void AddDefaultDecodersToCollection( |
30 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 30 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
31 media::FilterCollection* filter_collection, | 31 media::FilterCollection* filter_collection, |
32 ProxyDecryptor* proxy_decryptor) { | 32 ProxyDecryptor* proxy_decryptor) { |
33 scoped_refptr<media::FFmpegAudioDecoder> ffmpeg_audio_decoder = | 33 scoped_refptr<media::FFmpegAudioDecoder> ffmpeg_audio_decoder = |
34 new media::FFmpegAudioDecoder(message_loop); | 34 new media::FFmpegAudioDecoder(message_loop); |
| 35 filter_collection->GetAudioDecoders()->push_back(ffmpeg_audio_decoder); |
35 | 36 |
36 scoped_refptr<media::DecryptingAudioDecoder> decrypting_audio_decoder = | 37 if (proxy_decryptor) { |
37 new media::DecryptingAudioDecoder( | 38 scoped_refptr<media::DecryptingAudioDecoder> decrypting_audio_decoder = |
38 message_loop, | 39 new media::DecryptingAudioDecoder( |
39 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, | 40 message_loop, |
40 base::Unretained(proxy_decryptor))); | 41 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, |
| 42 base::Unretained(proxy_decryptor))); |
| 43 filter_collection->GetAudioDecoders()->push_back(decrypting_audio_decoder); |
41 | 44 |
42 filter_collection->GetAudioDecoders()->push_back(ffmpeg_audio_decoder); | 45 scoped_refptr<media::DecryptingVideoDecoder> decrypting_video_decoder = |
43 filter_collection->GetAudioDecoders()->push_back(decrypting_audio_decoder); | 46 new media::DecryptingVideoDecoder( |
44 | 47 message_loop, |
45 scoped_refptr<media::DecryptingVideoDecoder> decrypting_video_decoder = | 48 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, |
46 new media::DecryptingVideoDecoder( | 49 base::Unretained(proxy_decryptor))); |
47 message_loop, | 50 // TODO(xhwang): Ideally we should have decrypting video decoder after |
48 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, | 51 // regular video decoder since in the real world most videos are not |
49 base::Unretained(proxy_decryptor))); | 52 // encrypted. For now FFmpegVideoDecoder can also do decryption |
| 53 // (decrypt-only), and we perfer DecryptingVideoDecoder (decrypt-and-decode) |
| 54 // to FFmpegVideoDecoder. Fix this order when we move decryption out of |
| 55 // FFmpegVideoDecoder. |
| 56 filter_collection->GetVideoDecoders()->push_back(decrypting_video_decoder); |
| 57 } |
50 | 58 |
51 scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder = | 59 scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder = |
52 new media::FFmpegVideoDecoder(message_loop, proxy_decryptor); | 60 new media::FFmpegVideoDecoder(message_loop, proxy_decryptor); |
53 | |
54 // TODO(xhwang): Ideally we should have decrypting video decoder after | |
55 // regular video decoder since in the real world most videos are not | |
56 // encrypted. For now FFmpegVideoDecoder can also do decryption | |
57 // (decrypt-only), and we perfer DecryptingVideoDecoder (decrypt-and-decode) | |
58 // to FFmpegVideoDecoder. Fix this order when we move decryption out of | |
59 // FFmpegVideoDecoder. | |
60 filter_collection->GetVideoDecoders()->push_back(decrypting_video_decoder); | |
61 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); | 61 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); |
62 } | 62 } |
63 | 63 |
64 bool BuildMediaStreamCollection( | 64 bool BuildMediaStreamCollection( |
65 const WebKit::WebURL& url, | 65 const WebKit::WebURL& url, |
66 MediaStreamClient* client, | 66 MediaStreamClient* client, |
67 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 67 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
68 media::FilterCollection* filter_collection) { | 68 media::FilterCollection* filter_collection) { |
69 if (!client) | 69 if (!client) |
70 return false; | 70 return false; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 media::FilterCollection* filter_collection, | 108 media::FilterCollection* filter_collection, |
109 ProxyDecryptor* proxy_decryptor) { | 109 ProxyDecryptor* proxy_decryptor) { |
110 filter_collection->SetDemuxer(new media::FFmpegDemuxer( | 110 filter_collection->SetDemuxer(new media::FFmpegDemuxer( |
111 message_loop, data_source)); | 111 message_loop, data_source)); |
112 | 112 |
113 AddDefaultDecodersToCollection(message_loop, filter_collection, | 113 AddDefaultDecodersToCollection(message_loop, filter_collection, |
114 proxy_decryptor); | 114 proxy_decryptor); |
115 } | 115 } |
116 | 116 |
117 } // webkit_media | 117 } // webkit_media |
OLD | NEW |