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