blob: 546265049ca8c8e9c7b2da19efef3fc777715250 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
mallinath@webrtc.org12984f02012-02-16 18:18:21 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
12#define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020015
fischman@webrtc.org69fc3152013-09-25 17:01:42 +000016#include <vector>
pbos@webrtc.org4ca7d3f2013-08-12 19:51:57 +000017
Yves Gerey3e707812018-11-28 16:47:49 +010018#include "api/video/video_rotation.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/video_capture/video_capture.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "modules/video_capture/video_capture_defines.h"
Niels Möller5b5de212020-10-28 17:18:56 +010021#include "rtc_base/synchronization/mutex.h"
22#include "rtc_base/thread_annotations.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
Yves Gerey665174f2018-06-19 15:03:05 +020024namespace webrtc {
25namespace videocapturemodule {
26class DeviceInfoImpl : public VideoCaptureModule::DeviceInfo {
27 public:
28 DeviceInfoImpl();
Mirko Bonadei5aec1f62018-08-29 13:27:15 +020029 ~DeviceInfoImpl(void) override;
30 int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) override;
31 int32_t GetCapability(const char* deviceUniqueIdUTF8,
Ali Tofigh62238092022-01-25 13:27:19 +010032 uint32_t deviceCapabilityNumber,
Mirko Bonadei5aec1f62018-08-29 13:27:15 +020033 VideoCaptureCapability& capability) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000034
Mirko Bonadei5aec1f62018-08-29 13:27:15 +020035 int32_t GetBestMatchedCapability(const char* deviceUniqueIdUTF8,
36 const VideoCaptureCapability& requested,
37 VideoCaptureCapability& resulting) override;
38 int32_t GetOrientation(const char* deviceUniqueIdUTF8,
39 VideoRotation& orientation) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000040
Yves Gerey665174f2018-06-19 15:03:05 +020041 protected:
42 /* Initialize this object*/
niklase@google.com470e71d2011-07-07 08:21:25 +000043
Yves Gerey665174f2018-06-19 15:03:05 +020044 virtual int32_t Init() = 0;
45 /*
46 * Fills the member variable _captureCapabilities with capabilities for the
47 * given device name.
48 */
Niels Möller5b5de212020-10-28 17:18:56 +010049 virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8)
50 RTC_EXCLUSIVE_LOCKS_REQUIRED(_apiLock) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000051
Yves Gerey665174f2018-06-19 15:03:05 +020052 protected:
53 // Data members
54 typedef std::vector<VideoCaptureCapability> VideoCaptureCapabilities;
Niels Möller5b5de212020-10-28 17:18:56 +010055 VideoCaptureCapabilities _captureCapabilities RTC_GUARDED_BY(_apiLock);
56 Mutex _apiLock;
57 char* _lastUsedDeviceName RTC_GUARDED_BY(_apiLock);
58 uint32_t _lastUsedDeviceNameLength RTC_GUARDED_BY(_apiLock);
niklase@google.com470e71d2011-07-07 08:21:25 +000059};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000060} // namespace videocapturemodule
61} // namespace webrtc
Yves Gerey665174f2018-06-19 15:03:05 +020062#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_