| 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 "services/video_capture/device_media_to_mojo_adapter.h" | 5 #include "services/video_capture/device_media_to_mojo_adapter.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/capture/video/video_capture_buffer_pool_impl.h" | 8 #include "media/capture/video/video_capture_buffer_pool_impl.h" |
| 9 #include "media/capture/video/video_capture_jpeg_decoder.h" | 9 #include "media/capture/video/video_capture_jpeg_decoder.h" |
| 10 #include "services/video_capture/buffer_tracker_factory_impl.h" | 10 #include "services/video_capture/buffer_tracker_factory_impl.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 base::MakeUnique<ReceiverMojoToMediaAdapter>(std::move(receiver)); | 36 base::MakeUnique<ReceiverMojoToMediaAdapter>(std::move(receiver)); |
| 37 | 37 |
| 38 // Create a dedicated buffer pool for the device usage session. | 38 // Create a dedicated buffer pool for the device usage session. |
| 39 const int kMaxBufferCount = 2; | 39 const int kMaxBufferCount = 2; |
| 40 auto buffer_tracker_factory = base::MakeUnique<BufferTrackerFactoryImpl>(); | 40 auto buffer_tracker_factory = base::MakeUnique<BufferTrackerFactoryImpl>(); |
| 41 scoped_refptr<media::VideoCaptureBufferPool> buffer_pool( | 41 scoped_refptr<media::VideoCaptureBufferPool> buffer_pool( |
| 42 new media::VideoCaptureBufferPoolImpl(std::move(buffer_tracker_factory), | 42 new media::VideoCaptureBufferPoolImpl(std::move(buffer_tracker_factory), |
| 43 kMaxBufferCount)); | 43 kMaxBufferCount)); |
| 44 | 44 |
| 45 auto device_client = base::MakeUnique<media::VideoCaptureDeviceClient>( | 45 auto device_client = base::MakeUnique<media::VideoCaptureDeviceClient>( |
| 46 std::move(media_receiver), buffer_pool, jpeg_decoder_factory_callback_); | 46 std::move(media_receiver), buffer_pool, jpeg_decoder_factory_callback_, |
| 47 base::ThreadTaskRunnerHandle::Get()); |
| 47 | 48 |
| 48 device_->AllocateAndStart(params, std::move(device_client)); | 49 device_->AllocateAndStart(params, std::move(device_client)); |
| 49 device_running_ = true; | 50 device_running_ = true; |
| 50 } | 51 } |
| 51 | 52 |
| 52 void DeviceMediaToMojoAdapter::Stop() { | 53 void DeviceMediaToMojoAdapter::Stop() { |
| 53 if (device_running_ == false) | 54 if (device_running_ == false) |
| 54 return; | 55 return; |
| 55 device_->StopAndDeAllocate(); | 56 device_->StopAndDeAllocate(); |
| 56 device_running_ = false; | 57 device_running_ = false; |
| 57 } | 58 } |
| 58 | 59 |
| 59 void DeviceMediaToMojoAdapter::OnClientConnectionErrorOrClose() { | 60 void DeviceMediaToMojoAdapter::OnClientConnectionErrorOrClose() { |
| 60 Stop(); | 61 Stop(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 } // namespace video_capture | 64 } // namespace video_capture |
| OLD | NEW |