media_stream_device_enumerator.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2020 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. #ifndef COMPONENTS_WEBRTC_MEDIA_STREAM_DEVICE_ENUMERATOR_H_
  5. #define COMPONENTS_WEBRTC_MEDIA_STREAM_DEVICE_ENUMERATOR_H_
  6. #include <string>
  7. #include "third_party/blink/public/common/mediastream/media_stream_request.h"
  8. #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-forward.h"
  9. namespace content {
  10. class BrowserContext;
  11. }
  12. namespace webrtc {
  13. // Enumerates system devices for MediaStreamDevicesController.
  14. class MediaStreamDeviceEnumerator {
  15. public:
  16. // Helper to get the default devices which can be used by the media request.
  17. // Uses the first available devices if the default devices are not available.
  18. // If the return list is empty, it means there is no available device on the
  19. // OS.
  20. virtual const blink::MediaStreamDevices& GetAudioCaptureDevices() const = 0;
  21. virtual const blink::MediaStreamDevices& GetVideoCaptureDevices() const = 0;
  22. // Helper to get the default devices which can be used by the media request.
  23. // Uses the first available devices if the default devices are not available.
  24. // If the return list is empty, it means there is no available device on the
  25. // OS.
  26. virtual void GetDefaultDevicesForBrowserContext(
  27. content::BrowserContext* context,
  28. bool audio,
  29. bool video,
  30. blink::mojom::StreamDevices& devices) = 0;
  31. // Helpers for picking particular requested devices, identified by raw id.
  32. // If the device requested is not available it will return nullptr.
  33. virtual const blink::MediaStreamDevice* GetRequestedAudioDevice(
  34. const std::string& requested_audio_device_id) = 0;
  35. virtual const blink::MediaStreamDevice* GetRequestedVideoDevice(
  36. const std::string& requested_video_device_id) = 0;
  37. protected:
  38. virtual ~MediaStreamDeviceEnumerator() = default;
  39. };
  40. } // namespace webrtc
  41. #endif // COMPONENTS_WEBRTC_MEDIA_STREAM_DEVICE_ENUMERATOR_H_