Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: webkit/media/filter_helpers.cc

Issue 11198017: Add DecryptingAudioDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/media.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/message_loop_factory.h" 9 #include "media/base/message_loop_factory.h"
10 #include "media/filters/decrypting_audio_decoder.h"
10 #include "media/filters/decrypting_video_decoder.h" 11 #include "media/filters/decrypting_video_decoder.h"
11 #include "media/filters/chunk_demuxer.h" 12 #include "media/filters/chunk_demuxer.h"
12 #include "media/filters/dummy_demuxer.h" 13 #include "media/filters/dummy_demuxer.h"
13 #include "media/filters/ffmpeg_audio_decoder.h" 14 #include "media/filters/ffmpeg_audio_decoder.h"
14 #include "media/filters/ffmpeg_demuxer.h" 15 #include "media/filters/ffmpeg_demuxer.h"
15 #include "media/filters/ffmpeg_video_decoder.h" 16 #include "media/filters/ffmpeg_video_decoder.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
17 #include "webkit/media/crypto/proxy_decryptor.h" 18 #include "webkit/media/crypto/proxy_decryptor.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. For example, 28 // stream. Some decoder may only accept certain types of streams. For example,
28 // DecryptingVideoDecoder only supports encrypted video stream. 29 // DecryptingVideoDecoder only supports encrypted video stream.
29 static void AddDefaultDecodersToCollection( 30 static void AddDefaultDecodersToCollection(
30 media::MessageLoopFactory* message_loop_factory, 31 media::MessageLoopFactory* message_loop_factory,
31 media::FilterCollection* filter_collection, 32 media::FilterCollection* filter_collection,
32 ProxyDecryptor* proxy_decryptor) { 33 ProxyDecryptor* proxy_decryptor) {
33 scoped_refptr<media::FFmpegAudioDecoder> ffmpeg_audio_decoder = 34 scoped_refptr<media::FFmpegAudioDecoder> ffmpeg_audio_decoder =
34 new media::FFmpegAudioDecoder( 35 new media::FFmpegAudioDecoder(
35 base::Bind(&media::MessageLoopFactory::GetMessageLoop, 36 base::Bind(&media::MessageLoopFactory::GetMessageLoop,
36 base::Unretained(message_loop_factory), 37 base::Unretained(message_loop_factory),
37 media::MessageLoopFactory::kDecoder)); 38 media::MessageLoopFactory::kDecoder));
38 39
40 scoped_refptr<media::DecryptingAudioDecoder> decrypting_audio_decoder =
41 new media::DecryptingAudioDecoder(
42 base::Bind(&media::MessageLoopFactory::GetMessageLoop,
43 base::Unretained(message_loop_factory),
44 media::MessageLoopFactory::kDecoder),
45 base::Bind(&ProxyDecryptor::RequestDecryptorNotification,
46 base::Unretained(proxy_decryptor)));
47
48 filter_collection->GetAudioDecoders()->push_back(ffmpeg_audio_decoder);
49 filter_collection->GetAudioDecoders()->push_back(decrypting_audio_decoder);
50
39 scoped_refptr<media::DecryptingVideoDecoder> decrypting_video_decoder = 51 scoped_refptr<media::DecryptingVideoDecoder> decrypting_video_decoder =
40 new media::DecryptingVideoDecoder( 52 new media::DecryptingVideoDecoder(
41 base::Bind(&media::MessageLoopFactory::GetMessageLoop, 53 base::Bind(&media::MessageLoopFactory::GetMessageLoop,
42 base::Unretained(message_loop_factory), 54 base::Unretained(message_loop_factory),
43 media::MessageLoopFactory::kDecoder), 55 media::MessageLoopFactory::kDecoder),
44 base::Bind(&ProxyDecryptor::RequestDecryptorNotification, 56 base::Bind(&ProxyDecryptor::RequestDecryptorNotification,
45 base::Unretained(proxy_decryptor))); 57 base::Unretained(proxy_decryptor)));
46 58
47 scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder = 59 scoped_refptr<media::FFmpegVideoDecoder> ffmpeg_video_decoder =
48 new media::FFmpegVideoDecoder( 60 new media::FFmpegVideoDecoder(
49 base::Bind(&media::MessageLoopFactory::GetMessageLoop, 61 base::Bind(&media::MessageLoopFactory::GetMessageLoop,
50 base::Unretained(message_loop_factory), 62 base::Unretained(message_loop_factory),
51 media::MessageLoopFactory::kDecoder), 63 media::MessageLoopFactory::kDecoder),
52 proxy_decryptor); 64 proxy_decryptor);
53 65
54 filter_collection->GetAudioDecoders()->push_back(ffmpeg_audio_decoder); 66 // TODO(xhwang): Ideally we should have decrypting video decoder after
67 // regular video decoder since in the real world most videos are not
68 // encrypted. For now FFmpegVideoDecoder can also do decryption
69 // (decrypt-only), and we perfer DecryptingVideoDecoder (decrypt-and-decode)
70 // to FFmpegVideoDecoder. Fix this order when we move decryption out of
71 // FFmpegVideoDecoder.
55 filter_collection->GetVideoDecoders()->push_back(decrypting_video_decoder); 72 filter_collection->GetVideoDecoders()->push_back(decrypting_video_decoder);
56 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); 73 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder);
57 } 74 }
58 75
59 bool BuildMediaStreamCollection(const WebKit::WebURL& url, 76 bool BuildMediaStreamCollection(const WebKit::WebURL& url,
60 MediaStreamClient* client, 77 MediaStreamClient* client,
61 media::MessageLoopFactory* message_loop_factory, 78 media::MessageLoopFactory* message_loop_factory,
62 media::FilterCollection* filter_collection) { 79 media::FilterCollection* filter_collection) {
63 if (!client) 80 if (!client)
64 return false; 81 return false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 filter_collection->SetDemuxer(new media::FFmpegDemuxer( 121 filter_collection->SetDemuxer(new media::FFmpegDemuxer(
105 message_loop_factory->GetMessageLoop( 122 message_loop_factory->GetMessageLoop(
106 media::MessageLoopFactory::kPipeline), 123 media::MessageLoopFactory::kPipeline),
107 data_source)); 124 data_source));
108 125
109 AddDefaultDecodersToCollection(message_loop_factory, filter_collection, 126 AddDefaultDecodersToCollection(message_loop_factory, filter_collection,
110 proxy_decryptor); 127 proxy_decryptor);
111 } 128 }
112 129
113 } // webkit_media 130 } // webkit_media
OLDNEW
« no previous file with comments | « media/media.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698