#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_
#include <map>
+#include <set>
#include <string>
#include "base/basictypes.h"
#include "content/common/content_export.h"
#include "content/common/media/media_stream_options.h"
#include "content/public/browser/media_request_state.h"
-
-namespace base {
-class Thread;
-}
+#include "content/public/browser/resource_context.h"
namespace media {
class AudioManager;
class MediaStreamDeviceSettings;
class MediaStreamRequester;
class MediaStreamUIProxy;
-class ResourceContext;
class VideoCaptureManager;
// MediaStreamManager is used to generate and close new media devices, not to
void GenerateStream(MediaStreamRequester* requester,
int render_process_id,
int render_view_id,
- ResourceContext* rc,
+ const ResourceContext::SaltCallback& sc,
int page_request_id,
const StreamOptions& components,
const GURL& security_origin);
// plug/unplug. The new device lists will be delivered via media observer to
// MediaCaptureDevicesDispatcher.
virtual std::string EnumerateDevices(MediaStreamRequester* requester,
- int render_process_id,
- int render_view_id,
- ResourceContext* rc,
- int page_request_id,
- MediaStreamType type,
- const GURL& security_origin);
+ int render_process_id,
+ int render_view_id,
+ const ResourceContext::SaltCallback& sc,
+ int page_request_id,
+ MediaStreamType type,
+ const GURL& security_origin);
// Open a device identified by |device_id|. |type| must be either
// MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE.
void OpenDevice(MediaStreamRequester* requester,
int render_process_id,
int render_view_id,
- ResourceContext* rc,
+ const ResourceContext::SaltCallback& sc,
int page_request_id,
const std::string& device_id,
MediaStreamType type,
// too late. (see http://crbug.com/247525#c14).
virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
- // Sends log messages to the render processes making device requests, to be
- // used by the webrtcLoggingPrivate API if requested.
- void AddLogMessageOnUIThread(const std::string& message);
+ // Sends log messages to the render process hosts whose corresponding render
+ // processes are making device requests, to be used by the
+ // webrtcLoggingPrivate API if requested.
+ void AddLogMessageOnIOThread(const std::string& message);
// Adds |message| to native logs for outstanding device requests, for use by
- // render processes requesting logging from webrtcLoggingPrivate API. Safe to
- // call from any thread.
+ // render processes hosts whose corresponding render processes are requesting
+ // logging from webrtcLoggingPrivate API. Safe to call from any thread.
static void SendMessageToNativeLog(const std::string& message);
protected:
void TranslateDeviceIdToSourceId(DeviceRequest* request,
MediaStreamDevice* device);
+ // Helper method that sends log messages to the render process hosts whose
+ // corresponding render processes are in |render_process_ids|, to be used by
+ // the webrtcLoggingPrivate API if requested.
+ void AddLogMessageOnUIThread(const std::set<int>& render_process_ids,
+ const std::string& message);
+
// Finds and returns the device id corresponding to the given
// |source_id|. Returns true if there was a raw device id that matched the
// given |source_id|, false if nothing matched it.
bool TranslateSourceIdToDeviceId(
MediaStreamType stream_type,
- ResourceContext* rc,
+ const ResourceContext::SaltCallback& rc,
const GURL& security_origin,
const std::string& source_id,
std::string* device_id) const;
- // Device thread shared by VideoCaptureManager and AudioInputDeviceManager.
- scoped_ptr<base::Thread> device_thread_;
+ // Task runner shared by VideoCaptureManager and AudioInputDeviceManager.
+ // Note: Enumeration tasks may take seconds to complete so must never be run
+ // on any of the BrowserThreads (UI, IO, etc). See http://crbug.com/256945.
+ scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
media::AudioManager* const audio_manager_; // not owned
scoped_refptr<AudioInputDeviceManager> audio_input_device_manager_;
// AudioInputDeviceManager, in order to only enumerate when necessary.
int active_enumeration_ref_count_[NUM_MEDIA_TYPES];
- // All non-closed request.
+ // All non-closed request. Must be accessed on IO thread.
DeviceRequests requests_;
// Hold a pointer to the IO loop to check we delete the device thread and