| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/media/video_capture_impl_manager.h" | 5 #include "content/renderer/media/video_capture_impl_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "content/common/child_process.h" | 8 #include "content/renderer/video_capture_message_filter_creator.h" |
| 9 #include "content/common/child_thread.h" | |
| 10 #include "content/common/video_capture_messages.h" | |
| 11 #include "content/common/view_messages.h" | |
| 12 #include "media/base/message_loop_factory_impl.h" | 9 #include "media/base/message_loop_factory_impl.h" |
| 13 | 10 |
| 14 namespace { | |
| 15 | |
| 16 // VideoCaptureMessageFilterCreator is to be used as a singleton so we can get | |
| 17 // access to a shared VideoCaptureMessageFilter. | |
| 18 // Example usage: | |
| 19 // VideoCaptureMessageFilter* filter = | |
| 20 // VideoCaptureMessageFilterCreator::SharedFilter(); | |
| 21 | |
| 22 class VideoCaptureMessageFilterCreator { | |
| 23 public: | |
| 24 VideoCaptureMessageFilterCreator() { | |
| 25 int routing_id; | |
| 26 ChildThread::current()->Send( | |
| 27 new ViewHostMsg_GenerateRoutingID(&routing_id)); | |
| 28 filter_ = new VideoCaptureMessageFilter(routing_id); | |
| 29 filter_->AddFilter(); | |
| 30 } | |
| 31 | |
| 32 static VideoCaptureMessageFilter* SharedFilter() { | |
| 33 return GetInstance()->filter_.get(); | |
| 34 } | |
| 35 | |
| 36 static VideoCaptureMessageFilterCreator* GetInstance() { | |
| 37 return Singleton<VideoCaptureMessageFilterCreator>::get(); | |
| 38 } | |
| 39 | |
| 40 private: | |
| 41 scoped_refptr<VideoCaptureMessageFilter> filter_; | |
| 42 }; | |
| 43 | |
| 44 } // namespace | |
| 45 | |
| 46 VideoCaptureImplManager::VideoCaptureImplManager() { | 11 VideoCaptureImplManager::VideoCaptureImplManager() { |
| 47 ml_factory_.reset(new media::MessageLoopFactoryImpl()); | 12 ml_factory_.reset(new media::MessageLoopFactoryImpl()); |
| 48 ml_proxy_ = ml_factory_->GetMessageLoopProxy("VC manager"); | 13 ml_proxy_ = ml_factory_->GetMessageLoopProxy("VC manager"); |
| 49 } | 14 } |
| 50 | 15 |
| 51 VideoCaptureImplManager::~VideoCaptureImplManager() {} | 16 VideoCaptureImplManager::~VideoCaptureImplManager() {} |
| 52 | 17 |
| 53 // static | 18 // static |
| 54 media::VideoCapture* VideoCaptureImplManager::AddDevice( | 19 media::VideoCapture* VideoCaptureImplManager::AddDevice( |
| 55 media::VideoCaptureSessionId id, | 20 media::VideoCaptureSessionId id, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 74 |
| 110 VideoCaptureImplManager::Device::Device( | 75 VideoCaptureImplManager::Device::Device( |
| 111 VideoCaptureImpl* device, | 76 VideoCaptureImpl* device, |
| 112 media::VideoCapture::EventHandler* handler) | 77 media::VideoCapture::EventHandler* handler) |
| 113 : vc(device) { | 78 : vc(device) { |
| 114 clients.push_front(handler); | 79 clients.push_front(handler); |
| 115 } | 80 } |
| 116 | 81 |
| 117 VideoCaptureImplManager::Device::~Device() {} | 82 VideoCaptureImplManager::Device::~Device() {} |
| 118 | 83 |
| OLD | NEW |