1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_
12 #include "content/browser/renderer_host/media/media_stream_manager.h"
13 #include "content/browser/renderer_host/media/media_stream_requester.h"
14 #include "content/common/content_export.h"
15 #include "content/common/media/media_stream_options.h"
16 #include "content/public/browser/browser_message_filter.h"
17 #include "content/public/browser/resource_context.h"
21 class MediaStreamManager
;
22 class ResourceContext
;
24 // MediaStreamDispatcherHost is a delegate for Media Stream API messages used by
25 // MediaStreamImpl. There is one MediaStreamDispatcherHost per
26 // RenderProcessHost, the former owned by the latter.
27 class CONTENT_EXPORT MediaStreamDispatcherHost
: public BrowserMessageFilter
,
28 public MediaStreamRequester
{
30 MediaStreamDispatcherHost(
31 int render_process_id
,
32 const ResourceContext::SaltCallback
& salt_callback
,
33 MediaStreamManager
* media_stream_manager
,
34 ResourceContext
* resource_context
);
36 // MediaStreamRequester implementation.
37 virtual void StreamGenerated(
40 const std::string
& label
,
41 const StreamDeviceInfoArray
& audio_devices
,
42 const StreamDeviceInfoArray
& video_devices
) OVERRIDE
;
43 virtual void StreamGenerationFailed(
46 content::MediaStreamRequestResult result
) OVERRIDE
;
47 virtual void DeviceStopped(int render_frame_id
,
48 const std::string
& label
,
49 const StreamDeviceInfo
& device
) OVERRIDE
;
50 virtual void DevicesEnumerated(int render_frame_id
,
52 const std::string
& label
,
53 const StreamDeviceInfoArray
& devices
) OVERRIDE
;
54 virtual void DeviceOpened(int render_frame_id
,
56 const std::string
& label
,
57 const StreamDeviceInfo
& video_device
) OVERRIDE
;
59 // BrowserMessageFilter implementation.
60 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
61 virtual void OnChannelClosing() OVERRIDE
;
64 virtual ~MediaStreamDispatcherHost();
67 friend class MockMediaStreamDispatcherHost
;
69 void OnGenerateStream(int render_frame_id
,
71 const StreamOptions
& components
,
72 const GURL
& security_origin
,
74 void OnCancelGenerateStream(int render_frame_id
,
76 void OnStopStreamDevice(int render_frame_id
,
77 const std::string
& device_id
);
79 void OnEnumerateDevices(int render_frame_id
,
82 const GURL
& security_origin
);
84 void OnCancelEnumerateDevices(int render_frame_id
,
87 void OnOpenDevice(int render_frame_id
,
89 const std::string
& device_id
,
91 const GURL
& security_origin
);
93 void OnCloseDevice(int render_frame_id
,
94 const std::string
& label
);
96 void StoreRequest(int render_frame_id
,
98 const std::string
& label
);
100 bool IsURLAllowed(const GURL
& url
);
102 int render_process_id_
;
103 ResourceContext::SaltCallback salt_callback_
;
104 MediaStreamManager
* media_stream_manager_
;
106 // Owned by ProfileIOData which is guaranteed to outlive MSDH.
107 ResourceContext
* const resource_context_
;
109 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcherHost
);
112 } // namespace content
114 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_