| 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/base/message_loop_factory.h" | 9 #include "media/base/message_loop_factory.h" |
| 10 #include "media/filters/chunk_demuxer_factory.h" | 10 #include "media/filters/chunk_demuxer.h" |
| 11 #include "media/filters/dummy_demuxer_factory.h" | 11 #include "media/filters/dummy_demuxer.h" |
| 12 #include "media/filters/ffmpeg_audio_decoder.h" | 12 #include "media/filters/ffmpeg_audio_decoder.h" |
| 13 #include "media/filters/ffmpeg_demuxer_factory.h" | 13 #include "media/filters/ffmpeg_demuxer.h" |
| 14 #include "media/filters/ffmpeg_video_decoder.h" | 14 #include "media/filters/ffmpeg_video_decoder.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 16 #include "webkit/media/media_stream_client.h" | 16 #include "webkit/media/media_stream_client.h" |
| 17 | 17 |
| 18 namespace webkit_media { | 18 namespace webkit_media { |
| 19 | 19 |
| 20 // Constructs and adds the default audio/video decoders to |filter_collection|. | 20 // Constructs and adds the default audio/video decoders to |filter_collection|. |
| 21 static void AddDefaultDecodersToCollection( | 21 static void AddDefaultDecodersToCollection( |
| 22 media::MessageLoopFactory* message_loop_factory, | 22 media::MessageLoopFactory* message_loop_factory, |
| 23 media::FilterCollection* filter_collection, | 23 media::FilterCollection* filter_collection, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 53 do { | 53 do { |
| 54 filter_collection->SelectVideoDecoder(&old_videodecoder); | 54 filter_collection->SelectVideoDecoder(&old_videodecoder); |
| 55 } while (old_videodecoder); | 55 } while (old_videodecoder); |
| 56 | 56 |
| 57 filter_collection->AddVideoDecoder(video_decoder); | 57 filter_collection->AddVideoDecoder(video_decoder); |
| 58 | 58 |
| 59 // TODO(vrk/wjia): Setting true for local_source is under the assumption | 59 // TODO(vrk/wjia): Setting true for local_source is under the assumption |
| 60 // that the MediaStream represents a local webcam. This will need to | 60 // that the MediaStream represents a local webcam. This will need to |
| 61 // change in the future when GetVideoDecoder is no longer hardcoded to | 61 // change in the future when GetVideoDecoder is no longer hardcoded to |
| 62 // only return CaptureVideoDecoders. | 62 // only return CaptureVideoDecoders. |
| 63 scoped_ptr<media::DemuxerFactory> demuxer_factory( | 63 // |
| 64 new media::DummyDemuxerFactory(true, false, true)); | 64 // See http://crbug.com/120426 for details. |
| 65 filter_collection->SetDemuxerFactory(demuxer_factory.Pass()); | 65 filter_collection->SetDemuxer(new media::DummyDemuxer(true, false, true)); |
| 66 | 66 |
| 67 return true; | 67 return true; |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool BuildMediaSourceCollection( | 70 bool BuildMediaSourceCollection( |
| 71 const WebKit::WebURL& url, | 71 const WebKit::WebURL& url, |
| 72 const WebKit::WebURL& media_source_url, | 72 const WebKit::WebURL& media_source_url, |
| 73 media::ChunkDemuxerClient* client, | 73 media::ChunkDemuxerClient* client, |
| 74 media::MessageLoopFactory* message_loop_factory, | 74 media::MessageLoopFactory* message_loop_factory, |
| 75 media::FilterCollection* filter_collection, | 75 media::FilterCollection* filter_collection, |
| 76 scoped_refptr<media::FFmpegVideoDecoder>* video_decoder) { | 76 scoped_refptr<media::FFmpegVideoDecoder>* video_decoder) { |
| 77 if (media_source_url.isEmpty() || url != media_source_url) | 77 if (media_source_url.isEmpty() || url != media_source_url) |
| 78 return false; | 78 return false; |
| 79 | 79 |
| 80 scoped_ptr<media::DemuxerFactory> demuxer_factory( | 80 filter_collection->SetDemuxer(new media::ChunkDemuxer(client)); |
| 81 new media::ChunkDemuxerFactory(client)); | |
| 82 filter_collection->SetDemuxerFactory(demuxer_factory.Pass()); | |
| 83 | 81 |
| 84 AddDefaultDecodersToCollection(message_loop_factory, filter_collection, | 82 AddDefaultDecodersToCollection(message_loop_factory, filter_collection, |
| 85 video_decoder); | 83 video_decoder); |
| 86 return true; | 84 return true; |
| 87 } | 85 } |
| 88 | 86 |
| 89 void BuildDefaultCollection( | 87 void BuildDefaultCollection( |
| 90 const scoped_refptr<media::DataSource>& data_source, | 88 const scoped_refptr<media::DataSource>& data_source, |
| 89 bool local_source, |
| 91 media::MessageLoopFactory* message_loop_factory, | 90 media::MessageLoopFactory* message_loop_factory, |
| 92 media::FilterCollection* filter_collection, | 91 media::FilterCollection* filter_collection, |
| 93 scoped_refptr<media::FFmpegVideoDecoder>* video_decoder) { | 92 scoped_refptr<media::FFmpegVideoDecoder>* video_decoder) { |
| 94 scoped_ptr<media::DemuxerFactory> demuxer_factory( | 93 filter_collection->SetDemuxer(new media::FFmpegDemuxer( |
| 95 new media::FFmpegDemuxerFactory( | 94 message_loop_factory->GetMessageLoop("PipelineThread"), |
| 96 data_source, message_loop_factory->GetMessageLoop("PipelineThread"))); | 95 data_source, |
| 97 filter_collection->SetDemuxerFactory(demuxer_factory.Pass()); | 96 local_source)); |
| 98 | 97 |
| 99 AddDefaultDecodersToCollection(message_loop_factory, filter_collection, | 98 AddDefaultDecodersToCollection(message_loop_factory, filter_collection, |
| 100 video_decoder); | 99 video_decoder); |
| 101 } | 100 } |
| 102 | 101 |
| 103 } // webkit_media | 102 } // webkit_media |
| OLD | NEW |