2014-02-05 21:35:45 +01: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 file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|
|
|
|
|
|
|
|
#include "base/callback.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
|
|
|
#include "base/memory/singleton.h"
|
|
|
|
#include "base/observer_list.h"
|
|
|
|
#include "content/public/browser/media_observer.h"
|
|
|
|
#include "content/public/common/media_stream_request.h"
|
|
|
|
|
|
|
|
class PrefRegistrySimple;
|
|
|
|
class PrefService;
|
|
|
|
|
|
|
|
// This singleton is used to receive updates about media events from the content
|
|
|
|
// layer. Based on chrome/browser/media/media_capture_devices_dispatcher.[h|cc].
|
|
|
|
class CefMediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|
|
|
public:
|
|
|
|
static CefMediaCaptureDevicesDispatcher* GetInstance();
|
|
|
|
|
|
|
|
// Registers the preferences related to Media Stream default devices.
|
|
|
|
static void RegisterPrefs(PrefRegistrySimple* registry);
|
|
|
|
|
|
|
|
// Helper to get the default devices which can be used by the media request,
|
|
|
|
// if the return list is empty, it means there is no available device on the
|
2014-04-04 18:50:38 +02:00
|
|
|
// OS. Called on the UI thread.
|
2014-02-05 21:35:45 +01:00
|
|
|
void GetDefaultDevices(PrefService* prefs,
|
|
|
|
bool audio,
|
|
|
|
bool video,
|
|
|
|
content::MediaStreamDevices* devices);
|
|
|
|
|
|
|
|
// Helper for picking the device that was requested for an OpenDevice request.
|
|
|
|
// If the device requested is not available it will revert to using the first
|
|
|
|
// available one instead or will return an empty list if no devices of the
|
2014-04-04 18:50:38 +02:00
|
|
|
// requested kind are present. Called on the UI thread.
|
2014-02-05 21:35:45 +01:00
|
|
|
void GetRequestedDevice(const std::string& requested_device_id,
|
|
|
|
bool audio,
|
|
|
|
bool video,
|
|
|
|
content::MediaStreamDevices* devices);
|
|
|
|
|
|
|
|
// Overridden from content::MediaObserver:
|
2014-04-04 18:50:38 +02:00
|
|
|
virtual void OnAudioCaptureDevicesChanged() OVERRIDE;
|
|
|
|
virtual void OnVideoCaptureDevicesChanged() OVERRIDE;
|
2014-02-05 21:35:45 +01:00
|
|
|
virtual void OnMediaRequestStateChanged(
|
2013-07-24 22:15:18 +02:00
|
|
|
int render_process_id,
|
|
|
|
int render_view_id,
|
|
|
|
int page_request_id,
|
2014-02-05 21:35:45 +01:00
|
|
|
const GURL& security_origin,
|
2013-07-24 22:15:18 +02:00
|
|
|
const content::MediaStreamDevice& device,
|
2014-02-05 21:35:45 +01:00
|
|
|
content::MediaRequestState state) OVERRIDE;
|
2013-07-24 22:15:18 +02:00
|
|
|
virtual void OnCreatingAudioStream(int render_process_id,
|
2014-02-05 21:35:45 +01:00
|
|
|
int render_view_id) OVERRIDE;
|
2014-04-04 18:50:38 +02:00
|
|
|
virtual void OnAudioStreamPlaying(
|
|
|
|
int render_process_id,
|
|
|
|
int render_frame_id,
|
|
|
|
int stream_id,
|
|
|
|
const ReadPowerAndClipCallback& power_read_callback) OVERRIDE;
|
|
|
|
virtual void OnAudioStreamStopped(
|
|
|
|
int render_process_id,
|
|
|
|
int render_frame_id,
|
|
|
|
int stream_id) OVERRIDE;
|
2014-02-05 21:35:45 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend struct DefaultSingletonTraits<CefMediaCaptureDevicesDispatcher>;
|
|
|
|
|
|
|
|
CefMediaCaptureDevicesDispatcher();
|
|
|
|
virtual ~CefMediaCaptureDevicesDispatcher();
|
|
|
|
|
2014-04-04 18:50:38 +02:00
|
|
|
const content::MediaStreamDevices& GetAudioCaptureDevices();
|
|
|
|
const content::MediaStreamDevices& GetVideoCaptureDevices();
|
2014-02-05 21:35:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|