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

Side by Side Diff: content/browser/renderer_host/media/video_capture_provider_switcher.cc

Issue 2867213004: [Mojo Video Capture] Hook up video capture service behind a feature flag (Closed)
Patch Set: Fix mojo::MakeRequest(&device) happening after base::Passed(&device). Created 3 years, 7 months 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 "content/browser/renderer_host/media/video_capture_provider_switcher.h"
6
7 namespace content {
8
9 VideoCaptureProviderSwitcher::VideoCaptureProviderSwitcher(
10 std::unique_ptr<VideoCaptureProvider> media_device_capture_provider,
11 std::unique_ptr<VideoCaptureProvider> other_types_capture_provider)
12 : media_device_capture_provider_(std::move(media_device_capture_provider)),
13 other_types_capture_provider_(std::move(other_types_capture_provider)) {}
14
15 VideoCaptureProviderSwitcher::~VideoCaptureProviderSwitcher() = default;
16
17 void VideoCaptureProviderSwitcher::Uninitialize() {
18 media_device_capture_provider_->Uninitialize();
19 other_types_capture_provider_->Uninitialize();
20 }
21
22 void VideoCaptureProviderSwitcher::GetDeviceInfosAsync(
23 const base::Callback<void(
24 const std::vector<media::VideoCaptureDeviceInfo>&)>& result_callback) {
25 media_device_capture_provider_->GetDeviceInfosAsync(result_callback);
26 }
27
28 std::unique_ptr<VideoCaptureDeviceLauncher>
29 VideoCaptureProviderSwitcher::CreateDeviceLauncher() {
30 return base::MakeUnique<VideoCaptureDeviceLauncherSwitcher>(
31 media_device_capture_provider_->CreateDeviceLauncher(),
32 other_types_capture_provider_->CreateDeviceLauncher());
33 }
34
35 VideoCaptureDeviceLauncherSwitcher::VideoCaptureDeviceLauncherSwitcher(
36 std::unique_ptr<VideoCaptureDeviceLauncher> media_device_launcher,
37 std::unique_ptr<VideoCaptureDeviceLauncher> other_types_launcher)
38 : media_device_launcher_(std::move(media_device_launcher)),
39 other_types_launcher_(std::move(other_types_launcher)) {}
40
41 VideoCaptureDeviceLauncherSwitcher::~VideoCaptureDeviceLauncherSwitcher() =
42 default;
43
44 void VideoCaptureDeviceLauncherSwitcher::LaunchDeviceAsync(
45 const std::string& device_id,
46 MediaStreamType stream_type,
47 const media::VideoCaptureParams& params,
48 base::WeakPtr<media::VideoFrameReceiver> receiver,
49 Callbacks* callbacks,
50 base::OnceClosure done_cb) {
51 last_launched_stream_type_ = stream_type;
52 if (stream_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
53 return media_device_launcher_->LaunchDeviceAsync(
54 device_id, stream_type, params, std::move(receiver), callbacks,
55 std::move(done_cb));
56 } else {
mcasas 2017/05/10 02:33:33 No need for else after a return. https://chromium.
chfremer 2017/05/10 17:59:39 Done.
57 return other_types_launcher_->LaunchDeviceAsync(
58 device_id, stream_type, params, std::move(receiver), callbacks,
59 std::move(done_cb));
60 }
61 }
62
63 void VideoCaptureDeviceLauncherSwitcher::AbortLaunch() {
64 if (!last_launched_stream_type_.has_value())
65 return;
66 if (last_launched_stream_type_.value() ==
67 content::MEDIA_DEVICE_VIDEO_CAPTURE) {
68 media_device_launcher_->AbortLaunch();
69 } else {
70 other_types_launcher_->AbortLaunch();
71 }
mcasas 2017/05/10 02:33:33 Instead of |last_launched_stream_type_|, bind a me
chfremer 2017/05/10 17:59:39 Done.
72 }
73
74 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698