Update browser/media/* for Chrome 30
I took the latest versions of these files from chrome/browser/media, then pared them down to remove all Chrome-isms and uses of UI to prompt the user about allowing access to devices.
This commit is contained in:
parent
aa4f991659
commit
d1623535e8
4 changed files with 211 additions and 96 deletions
|
@ -8,8 +8,8 @@
|
|||
#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/browser/web_contents_delegate.h"
|
||||
#include "content/public/common/media_stream_request.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -20,20 +20,35 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
public:
|
||||
static MediaCaptureDevicesDispatcher* GetInstance();
|
||||
|
||||
// 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
|
||||
// requested kind are present.
|
||||
void GetRequestedDevice(const std::string& requested_device_id,
|
||||
bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices);
|
||||
// Methods for observers. Called on UI thread.
|
||||
const content::MediaStreamDevices& GetAudioCaptureDevices();
|
||||
const content::MediaStreamDevices& GetVideoCaptureDevices();
|
||||
|
||||
// Helper to get the default devices which can be used by the media request.
|
||||
// Uses the first available devices if the default devices are not available.
|
||||
// If the return list is empty, it means there is no available device on the
|
||||
// OS.
|
||||
// Called on the UI thread.
|
||||
void GetDefaultDevices(bool audio,
|
||||
bool video,
|
||||
content::MediaStreamDevices* devices);
|
||||
|
||||
const content::MediaStreamDevices& GetAudioCaptureDevices();
|
||||
const content::MediaStreamDevices& GetVideoCaptureDevices();
|
||||
// Helpers for picking particular requested devices, identified by raw id.
|
||||
// If the device requested is not available it will return NULL.
|
||||
const content::MediaStreamDevice*
|
||||
GetRequestedAudioDevice(const std::string& requested_audio_device_id);
|
||||
const content::MediaStreamDevice*
|
||||
GetRequestedVideoDevice(const std::string& requested_video_device_id);
|
||||
|
||||
// Returns the first available audio or video device, or NULL if no devices
|
||||
// are available.
|
||||
const content::MediaStreamDevice* GetFirstAvailableAudioDevice();
|
||||
const content::MediaStreamDevice* GetFirstAvailableVideoDevice();
|
||||
|
||||
// Unittests that do not require actual device enumeration should call this
|
||||
// API on the singleton. It is safe to call this multiple times on the
|
||||
// signleton.
|
||||
void DisableDeviceEnumerationForTesting();
|
||||
|
||||
// Overridden from content::MediaObserver:
|
||||
virtual void OnAudioCaptureDevicesChanged(
|
||||
|
@ -43,13 +58,18 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
virtual void OnMediaRequestStateChanged(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
int page_request_id,
|
||||
const content::MediaStreamDevice& device,
|
||||
content::MediaRequestState state) OVERRIDE;
|
||||
virtual void OnAudioStreamPlayingChanged(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
int stream_id,
|
||||
bool playing) OVERRIDE {}
|
||||
bool is_playing,
|
||||
float power_dBFS,
|
||||
bool clipped) OVERRIDE;
|
||||
virtual void OnCreatingAudioStream(int render_process_id,
|
||||
int render_view_id) OVERRIDE;
|
||||
|
||||
private:
|
||||
friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
|
||||
|
@ -60,11 +80,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
// Called by the MediaObserver() functions, executed on UI thread.
|
||||
void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices);
|
||||
void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices);
|
||||
void UpdateMediaRequestStateOnUIThread(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
const content::MediaStreamDevice& device,
|
||||
content::MediaRequestState state);
|
||||
|
||||
// A list of cached audio capture devices.
|
||||
content::MediaStreamDevices audio_devices_;
|
||||
|
@ -75,8 +90,13 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
// Flag to indicate if device enumeration has been done/doing.
|
||||
// Only accessed on UI thread.
|
||||
bool devices_enumerated_;
|
||||
|
||||
// Flag used by unittests to disable device enumeration.
|
||||
bool is_device_enumeration_disabled_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue