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 "media/filters/vpx_video_decoder.h" |
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
19 #include "webkit/media/media_stream_client.h" | 19 #include "webkit/media/media_stream_client.h" |
scherkus (not reviewing)
2013/02/27 06:00:16
can we remove this?
wuchengli
2013/02/27 21:37:41
Done.
| |
20 | 20 |
21 namespace webkit_media { | 21 namespace webkit_media { |
22 | 22 |
23 // Constructs and adds the default audio/video decoders to |filter_collection|. | 23 // Constructs and adds the default audio/video decoders to |filter_collection|. |
24 // Note that decoders in the |filter_collection| are ordered. The first | 24 // Note that decoders in the |filter_collection| are ordered. The first |
25 // audio/video decoder in the |filter_collection| that supports the input | 25 // audio/video decoder in the |filter_collection| that supports the input |
26 // 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 |
27 // 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 |
28 // stream. Some decoder may only accept certain types of streams. | 28 // stream. Some decoder may only accept certain types of streams. |
29 static void AddDefaultDecodersToCollection( | 29 static void AddDefaultDecodersToCollection( |
(...skipping 15 matching lines...) Expand all Loading... | |
45 new media::FFmpegVideoDecoder(message_loop); | 45 new media::FFmpegVideoDecoder(message_loop); |
46 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); | 46 filter_collection->GetVideoDecoders()->push_back(ffmpeg_video_decoder); |
47 | 47 |
48 if (cmd_line->HasSwitch(switches::kEnableVp9Playback)) { | 48 if (cmd_line->HasSwitch(switches::kEnableVp9Playback)) { |
49 scoped_refptr<media::VpxVideoDecoder> vpx_video_decoder = | 49 scoped_refptr<media::VpxVideoDecoder> vpx_video_decoder = |
50 new media::VpxVideoDecoder(message_loop); | 50 new media::VpxVideoDecoder(message_loop); |
51 filter_collection->GetVideoDecoders()->push_back(vpx_video_decoder); | 51 filter_collection->GetVideoDecoders()->push_back(vpx_video_decoder); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 bool BuildMediaStreamCollection( | |
56 const WebKit::WebURL& url, | |
57 MediaStreamClient* client, | |
58 const scoped_refptr<base::MessageLoopProxy>& message_loop, | |
59 media::FilterCollection* filter_collection) { | |
60 if (!client) | |
61 return false; | |
62 | |
63 scoped_refptr<media::VideoDecoder> video_decoder = client->GetVideoDecoder( | |
64 url, message_loop); | |
65 if (!video_decoder) | |
66 return false; | |
67 | |
68 // Remove all other decoders and just use the MediaStream one. | |
69 // NOTE: http://crbug.com/110800 is about replacing this ad-hockery with | |
70 // something more designed. | |
71 filter_collection->GetVideoDecoders()->clear(); | |
72 filter_collection->GetVideoDecoders()->push_back(video_decoder); | |
73 | |
74 filter_collection->SetDemuxer(new media::DummyDemuxer(true, false)); | |
75 | |
76 return true; | |
77 } | |
78 | |
79 void BuildMediaSourceCollection( | 55 void BuildMediaSourceCollection( |
80 const scoped_refptr<media::ChunkDemuxer>& demuxer, | 56 const scoped_refptr<media::ChunkDemuxer>& demuxer, |
81 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 57 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
82 media::FilterCollection* filter_collection) { | 58 media::FilterCollection* filter_collection) { |
83 DCHECK(demuxer); | 59 DCHECK(demuxer); |
84 filter_collection->SetDemuxer(demuxer); | 60 filter_collection->SetDemuxer(demuxer); |
85 | 61 |
86 // Remove GPUVideoDecoder until it supports codec config changes. | 62 // Remove GPUVideoDecoder until it supports codec config changes. |
87 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. | 63 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. |
88 DCHECK_LE(filter_collection->GetVideoDecoders()->size(), 1u); | 64 DCHECK_LE(filter_collection->GetVideoDecoders()->size(), 1u); |
89 filter_collection->GetVideoDecoders()->clear(); | 65 filter_collection->GetVideoDecoders()->clear(); |
90 | 66 |
91 AddDefaultDecodersToCollection(message_loop, filter_collection); | 67 AddDefaultDecodersToCollection(message_loop, filter_collection); |
92 } | 68 } |
93 | 69 |
94 void BuildDefaultCollection( | 70 void BuildDefaultCollection( |
95 const scoped_refptr<media::DataSource>& data_source, | 71 const scoped_refptr<media::DataSource>& data_source, |
96 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 72 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
97 media::FilterCollection* filter_collection) { | 73 media::FilterCollection* filter_collection) { |
98 filter_collection->SetDemuxer(new media::FFmpegDemuxer( | 74 filter_collection->SetDemuxer(new media::FFmpegDemuxer( |
99 message_loop, data_source)); | 75 message_loop, data_source)); |
100 | 76 |
101 AddDefaultDecodersToCollection(message_loop, filter_collection); | 77 AddDefaultDecodersToCollection(message_loop, filter_collection); |
102 } | 78 } |
103 | 79 |
104 } // webkit_media | 80 } // webkit_media |
OLD | NEW |