Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: services/video_capture/video_capture_device_proxy_impl.cc

Issue 2502483003: [Mojo Video Capture] Cleanup naming of classes/files in services/video_capture (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "services/video_capture/video_capture_device_proxy_impl.h"
6
7 #include "base/logging.h"
8 #include "media/capture/video/video_capture_buffer_pool_impl.h"
9 #include "media/capture/video/video_capture_jpeg_decoder.h"
10 #include "services/video_capture/buffer_tracker_factory_impl.h"
11 #include "services/video_capture/receiver_mojo_to_media_adapter.h"
12
13 namespace video_capture {
14
15 VideoCaptureDeviceProxyImpl::VideoCaptureDeviceProxyImpl(
16 std::unique_ptr<media::VideoCaptureDevice> device,
17 const media::VideoCaptureJpegDecoderFactoryCB&
18 jpeg_decoder_factory_callback)
19 : device_(std::move(device)),
20 jpeg_decoder_factory_callback_(jpeg_decoder_factory_callback),
21 device_running_(false) {}
22
23 VideoCaptureDeviceProxyImpl::~VideoCaptureDeviceProxyImpl() {
24 if (device_running_)
25 device_->StopAndDeAllocate();
26 }
27
28 void VideoCaptureDeviceProxyImpl::Start(
29 const VideoCaptureSettings& requested_settings,
30 mojom::VideoFrameReceiverPtr receiver) {
31 media::VideoCaptureParams params;
32 requested_settings.ConvertToMediaVideoCaptureParams(&params);
33 receiver.set_connection_error_handler(
34 base::Bind(&VideoCaptureDeviceProxyImpl::OnClientConnectionErrorOrClose,
35 base::Unretained(this)));
36
37 auto media_receiver =
38 base::MakeUnique<ReceiverMojoToMediaAdapter>(std::move(receiver));
39
40 // Create a dedicated buffer pool for the device usage session.
41 const int kMaxBufferCount = 2;
42 auto buffer_tracker_factory = base::MakeUnique<BufferTrackerFactoryImpl>();
43 scoped_refptr<media::VideoCaptureBufferPool> buffer_pool(
44 new media::VideoCaptureBufferPoolImpl(std::move(buffer_tracker_factory),
45 kMaxBufferCount));
46
47 auto device_client = base::MakeUnique<media::VideoCaptureDeviceClient>(
48 std::move(media_receiver), buffer_pool, jpeg_decoder_factory_callback_);
49
50 device_->AllocateAndStart(params, std::move(device_client));
51 device_running_ = true;
52 }
53
54 void VideoCaptureDeviceProxyImpl::Stop() {
55 device_->StopAndDeAllocate();
56 device_running_ = false;
57 }
58
59 void VideoCaptureDeviceProxyImpl::OnClientConnectionErrorOrClose() {
60 if (device_running_) {
61 device_->StopAndDeAllocate();
62 device_running_ = false;
63 }
64 }
65
66 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/video_capture_device_proxy_impl.h ('k') | services/video_capture/video_capture_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698