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
);
35 // MediaStreamRequester implementation.
36 void StreamGenerated(int render_frame_id
,
38 const std::string
& label
,
39 const StreamDeviceInfoArray
& audio_devices
,
40 const StreamDeviceInfoArray
& video_devices
) override
;
41 void StreamGenerationFailed(
44 content::MediaStreamRequestResult result
) override
;
45 void DeviceStopped(int render_frame_id
,
46 const std::string
& label
,
47 const StreamDeviceInfo
& device
) override
;
48 void DevicesEnumerated(int render_frame_id
,
50 const std::string
& label
,
51 const StreamDeviceInfoArray
& devices
) override
;
52 void DeviceOpened(int render_frame_id
,
54 const std::string
& label
,
55 const StreamDeviceInfo
& video_device
) override
;
57 // BrowserMessageFilter implementation.
58 bool OnMessageReceived(const IPC::Message
& message
) override
;
59 void OnChannelClosing() override
;
62 ~MediaStreamDispatcherHost() override
;
65 friend class MockMediaStreamDispatcherHost
;
67 void OnGenerateStream(int render_frame_id
,
69 const StreamOptions
& components
,
70 const GURL
& security_origin
,
72 void OnCancelGenerateStream(int render_frame_id
,
74 void OnStopStreamDevice(int render_frame_id
,
75 const std::string
& device_id
);
77 void OnEnumerateDevices(int render_frame_id
,
80 const GURL
& security_origin
);
82 void OnCancelEnumerateDevices(int render_frame_id
,
85 void OnOpenDevice(int render_frame_id
,
87 const std::string
& device_id
,
89 const GURL
& security_origin
);
91 void OnCloseDevice(int render_frame_id
,
92 const std::string
& label
);
94 void StoreRequest(int render_frame_id
,
96 const std::string
& label
);
98 bool IsURLAllowed(const GURL
& url
);
100 int render_process_id_
;
101 ResourceContext::SaltCallback salt_callback_
;
102 MediaStreamManager
* media_stream_manager_
;
104 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcherHost
);
107 } // namespace content
109 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_