| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/media/capture/image_capture_impl.h" | 5 #include "content/browser/media/capture/image_capture_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "content/browser/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
| 11 #include "content/browser/renderer_host/media/media_stream_manager.h" | 11 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 12 #include "content/browser/renderer_host/media/video_capture_manager.h" | 12 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 13 #include "content/common/media/media_stream_options.h" | 13 #include "content/common/media/media_stream_options.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
| 16 #include "media/capture/video/video_capture_device.h" | 16 #include "media/capture/video/video_capture_device.h" |
| 17 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 void RunGetCapabilitiesCallbackOnUIThread( | 23 void RunGetCapabilitiesCallbackOnUIThread( |
| 23 const ImageCaptureImpl::GetCapabilitiesCallback& callback, | 24 const ImageCaptureImpl::GetCapabilitiesCallback& callback, |
| 24 media::mojom::PhotoCapabilitiesPtr capabilities) { | 25 media::mojom::PhotoCapabilitiesPtr capabilities) { |
| 25 BrowserThread::PostTask( | 26 BrowserThread::PostTask( |
| 26 BrowserThread::UI, FROM_HERE, | 27 BrowserThread::UI, FROM_HERE, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 media_stream_manager->VideoDeviceIdToSessionId(source_id); | 110 media_stream_manager->VideoDeviceIdToSessionId(source_id); |
| 110 | 111 |
| 111 if (session_id == StreamDeviceInfo::kNoId) | 112 if (session_id == StreamDeviceInfo::kNoId) |
| 112 return; | 113 return; |
| 113 media_stream_manager->video_capture_manager()->TakePhoto(session_id, | 114 media_stream_manager->video_capture_manager()->TakePhoto(session_id, |
| 114 std::move(callback)); | 115 std::move(callback)); |
| 115 } | 116 } |
| 116 | 117 |
| 117 } // anonymous namespace | 118 } // anonymous namespace |
| 118 | 119 |
| 119 // static | 120 ImageCaptureImpl::ImageCaptureImpl() {} |
| 120 void ImageCaptureImpl::Create( | |
| 121 mojo::InterfaceRequest<media::mojom::ImageCapture> request) { | |
| 122 // |binding_| will take ownership of ImageCaptureImpl. | |
| 123 new ImageCaptureImpl(std::move(request)); | |
| 124 } | |
| 125 | 121 |
| 126 ImageCaptureImpl::~ImageCaptureImpl() {} | 122 ImageCaptureImpl::~ImageCaptureImpl() {} |
| 127 | 123 |
| 124 // static |
| 125 void ImageCaptureImpl::Create(media::mojom::ImageCaptureRequest request) { |
| 126 mojo::MakeStrongBinding(base::MakeUnique<ImageCaptureImpl>(), |
| 127 std::move(request)); |
| 128 } |
| 129 |
| 128 void ImageCaptureImpl::GetCapabilities( | 130 void ImageCaptureImpl::GetCapabilities( |
| 129 const std::string& source_id, | 131 const std::string& source_id, |
| 130 const GetCapabilitiesCallback& callback) { | 132 const GetCapabilitiesCallback& callback) { |
| 131 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 133 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 132 | 134 |
| 133 media::ScopedResultCallback<GetCapabilitiesCallback> scoped_callback( | 135 media::ScopedResultCallback<GetCapabilitiesCallback> scoped_callback( |
| 134 base::Bind(&RunGetCapabilitiesCallbackOnUIThread, callback), | 136 base::Bind(&RunGetCapabilitiesCallbackOnUIThread, callback), |
| 135 media::BindToCurrentLoop(base::Bind(&RunFailedGetCapabilitiesCallback))); | 137 media::BindToCurrentLoop(base::Bind(&RunFailedGetCapabilitiesCallback))); |
| 136 | 138 |
| 137 BrowserThread::PostTask( | 139 BrowserThread::PostTask( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 165 base::Bind(&RunTakePhotoCallbackOnUIThread, callback), | 167 base::Bind(&RunTakePhotoCallbackOnUIThread, callback), |
| 166 media::BindToCurrentLoop(base::Bind(&RunFailedTakePhotoCallback))); | 168 media::BindToCurrentLoop(base::Bind(&RunFailedTakePhotoCallback))); |
| 167 | 169 |
| 168 BrowserThread::PostTask( | 170 BrowserThread::PostTask( |
| 169 BrowserThread::IO, FROM_HERE, | 171 BrowserThread::IO, FROM_HERE, |
| 170 base::Bind(&TakePhotoOnIOThread, source_id, | 172 base::Bind(&TakePhotoOnIOThread, source_id, |
| 171 BrowserMainLoop::GetInstance()->media_stream_manager(), | 173 BrowserMainLoop::GetInstance()->media_stream_manager(), |
| 172 base::Passed(&scoped_callback))); | 174 base::Passed(&scoped_callback))); |
| 173 } | 175 } |
| 174 | 176 |
| 175 ImageCaptureImpl::ImageCaptureImpl( | |
| 176 mojo::InterfaceRequest<media::mojom::ImageCapture> request) | |
| 177 : binding_(this, std::move(request)) {} | |
| 178 | |
| 179 } // namespace content | 177 } // namespace content |
| OLD | NEW |