2013-07-31 18:08:45 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|
2013-07-31 18:08:45 +00:00
|
|
|
|
2022-07-20 08:09:14 +00:00
|
|
|
#include "components/webrtc/media_stream_device_enumerator_impl.h"
|
2013-07-31 18:08:45 +00:00
|
|
|
#include "content/public/browser/media_observer.h"
|
2019-01-21 16:28:04 +00:00
|
|
|
#include "content/public/browser/media_stream_request.h"
|
|
|
|
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
2022-06-01 06:12:47 +00:00
|
|
|
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
|
2013-07-31 18:08:45 +00:00
|
|
|
|
2018-10-19 18:51:43 +00:00
|
|
|
namespace electron {
|
2013-07-31 18:08:45 +00:00
|
|
|
|
|
|
|
// This singleton is used to receive updates about media events from the content
|
|
|
|
// layer.
|
2022-07-20 08:09:14 +00:00
|
|
|
class MediaCaptureDevicesDispatcher
|
|
|
|
: public content::MediaObserver,
|
|
|
|
public webrtc::MediaStreamDeviceEnumeratorImpl {
|
2013-07-31 18:08:45 +00:00
|
|
|
public:
|
|
|
|
static MediaCaptureDevicesDispatcher* GetInstance();
|
|
|
|
|
|
|
|
// Overridden from content::MediaObserver:
|
2015-06-05 04:07:27 +00:00
|
|
|
void OnAudioCaptureDevicesChanged() override;
|
|
|
|
void OnVideoCaptureDevicesChanged() override;
|
2018-04-18 01:46:27 +00:00
|
|
|
void OnMediaRequestStateChanged(int render_process_id,
|
|
|
|
int render_view_id,
|
|
|
|
int page_request_id,
|
|
|
|
const GURL& security_origin,
|
2019-07-03 01:22:09 +00:00
|
|
|
blink::mojom::MediaStreamType stream_type,
|
2018-04-18 01:46:27 +00:00
|
|
|
content::MediaRequestState state) override;
|
2015-06-05 04:07:27 +00:00
|
|
|
void OnCreatingAudioStream(int render_process_id,
|
|
|
|
int render_view_id) override;
|
2016-07-04 06:06:05 +00:00
|
|
|
void OnSetCapturingLinkSecured(int render_process_id,
|
|
|
|
int render_frame_id,
|
|
|
|
int page_request_id,
|
2019-07-03 01:22:09 +00:00
|
|
|
blink::mojom::MediaStreamType stream_type,
|
2016-07-04 06:06:05 +00:00
|
|
|
bool is_secure) override;
|
2024-02-29 09:31:13 +00:00
|
|
|
const std::optional<blink::MediaStreamDevice>
|
|
|
|
GetPreferredAudioDeviceForBrowserContext(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const std::vector<std::string>& eligible_audio_device_ids) const override;
|
|
|
|
const std::optional<blink::MediaStreamDevice>
|
|
|
|
GetPreferredVideoDeviceForBrowserContext(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const std::vector<std::string>& eligible_video_device_ids) const override;
|
2013-07-31 18:08:45 +00:00
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
MediaCaptureDevicesDispatcher(const MediaCaptureDevicesDispatcher&) = delete;
|
|
|
|
MediaCaptureDevicesDispatcher& operator=(
|
|
|
|
const MediaCaptureDevicesDispatcher&) = delete;
|
|
|
|
|
2013-07-31 18:08:45 +00:00
|
|
|
private:
|
2024-02-23 09:35:20 +00:00
|
|
|
friend base::NoDestructor<MediaCaptureDevicesDispatcher>;
|
2013-07-31 18:08:45 +00:00
|
|
|
|
|
|
|
MediaCaptureDevicesDispatcher();
|
2018-04-17 23:03:51 +00:00
|
|
|
~MediaCaptureDevicesDispatcher() override;
|
2013-07-31 18:08:45 +00:00
|
|
|
};
|
|
|
|
|
2018-10-19 18:51:43 +00:00
|
|
|
} // namespace electron
|
2013-07-31 18:08:45 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|