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

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.h

Issue 2634263002: Pass camera facing info to audio client (Closed)
Patch Set: Moved to chrome_browser_main_chromeos.cc Created 3 years, 10 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // VideoCaptureManager is used to open/close, start/stop, enumerate available 5 // VideoCaptureManager is used to open/close, start/stop, enumerate available
6 // video capture devices, and manage VideoCaptureController's. 6 // video capture devices, and manage VideoCaptureController's.
7 // All functions are expected to be called from Browser::IO thread. Some helper 7 // All functions are expected to be called from Browser::IO thread. Some helper
8 // functions (*OnDeviceThread) will dispatch operations to the device thread. 8 // functions (*OnDeviceThread) will dispatch operations to the device thread.
9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. 9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice.
10 // A device can only be opened once. 10 // A device can only be opened once.
11 11
12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ 13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
14 14
15 #include <list> 15 #include <list>
16 #include <map> 16 #include <map>
17 #include <set> 17 #include <set>
18 #include <string> 18 #include <string>
19 19
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
22 #include "base/memory/weak_ptr.h" 22 #include "base/memory/weak_ptr.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/observer_list.h"
24 #include "base/process/process_handle.h" 25 #include "base/process/process_handle.h"
25 #include "base/threading/thread_checker.h" 26 #include "base/threading/thread_checker.h"
26 #include "base/timer/elapsed_timer.h" 27 #include "base/timer/elapsed_timer.h"
27 #include "build/build_config.h" 28 #include "build/build_config.h"
28 #include "content/browser/renderer_host/media/media_stream_provider.h" 29 #include "content/browser/renderer_host/media/media_stream_provider.h"
29 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" 30 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h"
30 #include "content/common/content_export.h" 31 #include "content/common/content_export.h"
31 #include "content/common/media/media_stream_options.h" 32 #include "content/common/media/media_stream_options.h"
33 #include "media/base/video_facing.h"
32 #include "media/capture/video/video_capture_device.h" 34 #include "media/capture/video/video_capture_device.h"
33 #include "media/capture/video/video_capture_device_factory.h" 35 #include "media/capture/video/video_capture_device_factory.h"
34 #include "media/capture/video_capture_types.h" 36 #include "media/capture/video_capture_types.h"
35 37
36 #if defined(OS_ANDROID) 38 #if defined(OS_ANDROID)
37 #include "base/android/application_status_listener.h" 39 #include "base/android/application_status_listener.h"
38 #endif 40 #endif
39 41
40 namespace content { 42 namespace content {
41 class VideoCaptureController; 43 class VideoCaptureController;
42 class VideoCaptureControllerEventHandler; 44 class VideoCaptureControllerEventHandler;
43 45
44 // VideoCaptureManager opens/closes and start/stops video capture devices. 46 // VideoCaptureManager opens/closes and start/stops video capture devices.
45 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider { 47 class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
46 public: 48 public:
47 using VideoCaptureDevice = media::VideoCaptureDevice; 49 using VideoCaptureDevice = media::VideoCaptureDevice;
48 50
49 // Callback used to signal the completion of a controller lookup. 51 // Callback used to signal the completion of a controller lookup.
50 using DoneCB = 52 using DoneCB =
51 base::Callback<void(const base::WeakPtr<VideoCaptureController>&)>; 53 base::Callback<void(const base::WeakPtr<VideoCaptureController>&)>;
52 54
53 VideoCaptureManager( 55 VideoCaptureManager(
54 std::unique_ptr<media::VideoCaptureDeviceFactory> factory, 56 std::unique_ptr<media::VideoCaptureDeviceFactory> factory,
55 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner); 57 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner);
56 58
59 // AddVideoCaptureObserver() can be called only before any devices are opened.
60 // RemoveAllVideoCaptureObservers() can be called only after all devices
61 // are closed.
62 // They can be called more than once and it's ok to not call at all if the
63 // client is not interested in receiving media::VideoCaptureObserver callacks.
64 // This methods can be called on whatever thread. The callbacks of
65 // media::VideoCaptureObserver arrive on browser IO thread.
66 void AddVideoCaptureObserver(media::VideoCaptureObserver* observer);
67 void RemoveAllVideoCaptureObservers();
68
57 // Implements MediaStreamProvider. 69 // Implements MediaStreamProvider.
58 void RegisterListener(MediaStreamProviderListener* listener) override; 70 void RegisterListener(MediaStreamProviderListener* listener) override;
59 void UnregisterListener() override; 71 void UnregisterListener() override;
60 int Open(const StreamDeviceInfo& device) override; 72 int Open(const StreamDeviceInfo& device) override;
61 void Close(int capture_session_id) override; 73 void Close(int capture_session_id) override;
62 74
63 // Called by VideoCaptureHost to locate a capture device for |capture_params|, 75 // Called by VideoCaptureHost to locate a capture device for |capture_params|,
64 // adding the Host as a client of the device's controller if successful. The 76 // adding the Host as a client of the device's controller if successful. The
65 // value of |session_id| controls which device is selected; 77 // value of |session_id| controls which device is selected;
66 // this value should be a session id previously returned by Open(). 78 // this value should be a session id previously returned by Open().
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // Queue to keep photo-associated requests waiting for a device to initialize, 346 // Queue to keep photo-associated requests waiting for a device to initialize,
335 // bundles a session id integer and an associated photo-related request. 347 // bundles a session id integer and an associated photo-related request.
336 std::list<std::pair<int, base::Callback<void(media::VideoCaptureDevice*)>>> 348 std::list<std::pair<int, base::Callback<void(media::VideoCaptureDevice*)>>>
337 photo_request_queue_; 349 photo_request_queue_;
338 350
339 // Device creation factory injected on construction from MediaStreamManager or 351 // Device creation factory injected on construction from MediaStreamManager or
340 // from the test harness. 352 // from the test harness.
341 std::unique_ptr<media::VideoCaptureDeviceFactory> 353 std::unique_ptr<media::VideoCaptureDeviceFactory>
342 video_capture_device_factory_; 354 video_capture_device_factory_;
343 355
356 base::ObserverList<media::VideoCaptureObserver> capture_observers_;
357
344 // Local cache of the enumerated video capture devices' names and capture 358 // Local cache of the enumerated video capture devices' names and capture
345 // supported formats. A snapshot of the current devices and their capabilities 359 // supported formats. A snapshot of the current devices and their capabilities
346 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and 360 // is composed in VideoCaptureDeviceFactory::EnumerateDeviceNames() and
347 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update 361 // ConsolidateDevicesInfoOnDeviceThread(), and this snapshot is used to update
348 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will 362 // this list in OnDevicesInfoEnumerated(). GetDeviceSupportedFormats() will
349 // use this list if the device is not started, otherwise it will retrieve the 363 // use this list if the device is not started, otherwise it will retrieve the
350 // active device capture format from the VideoCaptureController associated. 364 // active device capture format from the VideoCaptureController associated.
351 DeviceInfos devices_info_cache_; 365 DeviceInfos devices_info_cache_;
352 366
353 // Map used by DesktopCapture. 367 // Map used by DesktopCapture.
354 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> 368 std::map<media::VideoCaptureSessionId, gfx::NativeViewId>
355 notification_window_ids_; 369 notification_window_ids_;
356 370
357 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); 371 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager);
358 }; 372 };
359 373
360 } // namespace content 374 } // namespace content
361 375
362 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ 376 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698