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

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

Issue 2902203002: [Mojo Video Capture] Hook up connection lost events (Closed)
Patch Set: Fix duplicate member introduced during merging Created 3 years, 6 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
« no previous file with comments | « content/browser/renderer_host/media/video_capture_provider.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/renderer_host/media/video_capture_provider_switcher.h" 5 #include "content/browser/renderer_host/media/video_capture_provider_switcher.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 namespace { 11 namespace {
12 12
13 class VideoCaptureDeviceLauncherSwitcher : public VideoCaptureDeviceLauncher { 13 class VideoCaptureDeviceLauncherSwitcher : public VideoCaptureDeviceLauncher {
14 public: 14 public:
15 VideoCaptureDeviceLauncherSwitcher( 15 VideoCaptureDeviceLauncherSwitcher(
16 std::unique_ptr<VideoCaptureDeviceLauncher> media_device_launcher, 16 std::unique_ptr<VideoCaptureDeviceLauncher> media_device_launcher,
17 std::unique_ptr<VideoCaptureDeviceLauncher> other_types_launcher) 17 std::unique_ptr<VideoCaptureDeviceLauncher> other_types_launcher)
18 : media_device_launcher_(std::move(media_device_launcher)), 18 : media_device_launcher_(std::move(media_device_launcher)),
19 other_types_launcher_(std::move(other_types_launcher)) {} 19 other_types_launcher_(std::move(other_types_launcher)) {}
20 20
21 ~VideoCaptureDeviceLauncherSwitcher() override {} 21 ~VideoCaptureDeviceLauncherSwitcher() override {}
22 22
23 void LaunchDeviceAsync(const std::string& device_id, 23 void LaunchDeviceAsync(const std::string& device_id,
24 MediaStreamType stream_type, 24 MediaStreamType stream_type,
25 const media::VideoCaptureParams& params, 25 const media::VideoCaptureParams& params,
26 base::WeakPtr<media::VideoFrameReceiver> receiver, 26 base::WeakPtr<media::VideoFrameReceiver> receiver,
27 base::OnceClosure connection_lost_cb,
27 Callbacks* callbacks, 28 Callbacks* callbacks,
28 base::OnceClosure done_cb) override { 29 base::OnceClosure done_cb) override {
29 if (stream_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) { 30 if (stream_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
30 // Use of Unretained() is safe, because |media_device_launcher_| is owned 31 // Use of Unretained() is safe, because |media_device_launcher_| is owned
31 // by |this|. 32 // by |this|.
32 abort_launch_cb_ = 33 abort_launch_cb_ =
33 base::Bind(&VideoCaptureDeviceLauncher::AbortLaunch, 34 base::Bind(&VideoCaptureDeviceLauncher::AbortLaunch,
34 base::Unretained(media_device_launcher_.get())); 35 base::Unretained(media_device_launcher_.get()));
35 return media_device_launcher_->LaunchDeviceAsync( 36 return media_device_launcher_->LaunchDeviceAsync(
36 device_id, stream_type, params, std::move(receiver), callbacks, 37 device_id, stream_type, params, std::move(receiver),
37 std::move(done_cb)); 38 std::move(connection_lost_cb), callbacks, std::move(done_cb));
38 } 39 }
39 // Use of Unretained() is safe, because |other_types_launcher_| is owned by 40 // Use of Unretained() is safe, because |other_types_launcher_| is owned by
40 // |this|. 41 // |this|.
41 abort_launch_cb_ = 42 abort_launch_cb_ =
42 base::Bind(&VideoCaptureDeviceLauncher::AbortLaunch, 43 base::Bind(&VideoCaptureDeviceLauncher::AbortLaunch,
43 base::Unretained(other_types_launcher_.get())); 44 base::Unretained(other_types_launcher_.get()));
44 return other_types_launcher_->LaunchDeviceAsync( 45 return other_types_launcher_->LaunchDeviceAsync(
45 device_id, stream_type, params, std::move(receiver), callbacks, 46 device_id, stream_type, params, std::move(receiver),
46 std::move(done_cb)); 47 std::move(connection_lost_cb), callbacks, std::move(done_cb));
47 } 48 }
48 49
49 void AbortLaunch() override { 50 void AbortLaunch() override {
50 if (abort_launch_cb_.is_null()) 51 if (abort_launch_cb_.is_null())
51 return; 52 return;
52 base::ResetAndReturn(&abort_launch_cb_).Run(); 53 base::ResetAndReturn(&abort_launch_cb_).Run();
53 } 54 }
54 55
55 private: 56 private:
56 const std::unique_ptr<VideoCaptureDeviceLauncher> media_device_launcher_; 57 const std::unique_ptr<VideoCaptureDeviceLauncher> media_device_launcher_;
(...skipping 22 matching lines...) Expand all
79 } 80 }
80 81
81 std::unique_ptr<VideoCaptureDeviceLauncher> 82 std::unique_ptr<VideoCaptureDeviceLauncher>
82 VideoCaptureProviderSwitcher::CreateDeviceLauncher() { 83 VideoCaptureProviderSwitcher::CreateDeviceLauncher() {
83 return base::MakeUnique<VideoCaptureDeviceLauncherSwitcher>( 84 return base::MakeUnique<VideoCaptureDeviceLauncherSwitcher>(
84 media_device_capture_provider_->CreateDeviceLauncher(), 85 media_device_capture_provider_->CreateDeviceLauncher(),
85 other_types_capture_provider_->CreateDeviceLauncher()); 86 other_types_capture_provider_->CreateDeviceLauncher());
86 } 87 }
87 88
88 } // namespace content 89 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698