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
;
23 // MediaStreamDispatcherHost is a delegate for Media Stream API messages used by
24 // MediaStreamImpl. It's the complement of MediaStreamDispatcher
25 // (owned by RenderView).
26 class CONTENT_EXPORT MediaStreamDispatcherHost
: public BrowserMessageFilter
,
27 public MediaStreamRequester
{
29 MediaStreamDispatcherHost(
30 int render_process_id
,
31 const ResourceContext::SaltCallback
& salt_callback
,
32 MediaStreamManager
* media_stream_manager
);
34 // MediaStreamRequester implementation.
35 virtual void StreamGenerated(
38 const std::string
& label
,
39 const StreamDeviceInfoArray
& audio_devices
,
40 const StreamDeviceInfoArray
& video_devices
) OVERRIDE
;
41 virtual void StreamGenerationFailed(
44 content::MediaStreamRequestResult result
) OVERRIDE
;
45 virtual void DeviceStopped(int render_view_id
,
46 const std::string
& label
,
47 const StreamDeviceInfo
& device
) OVERRIDE
;
48 virtual void DevicesEnumerated(int render_view_id
,
50 const std::string
& label
,
51 const StreamDeviceInfoArray
& devices
) OVERRIDE
;
52 virtual void DeviceOpened(int render_view_id
,
54 const std::string
& label
,
55 const StreamDeviceInfo
& video_device
) OVERRIDE
;
57 // BrowserMessageFilter implementation.
58 virtual bool OnMessageReceived(const IPC::Message
& message
,
59 bool* message_was_ok
) OVERRIDE
;
60 virtual void OnChannelClosing() OVERRIDE
;
63 virtual ~MediaStreamDispatcherHost();
66 friend class MockMediaStreamDispatcherHost
;
68 void OnGenerateStream(int render_view_id
,
70 const StreamOptions
& components
,
71 const GURL
& security_origin
,
73 void OnCancelGenerateStream(int render_view_id
,
75 void OnStopStreamDevice(int render_view_id
,
76 const std::string
& device_id
);
78 void OnEnumerateDevices(int render_view_id
,
81 const GURL
& security_origin
);
83 void OnCancelEnumerateDevices(int render_view_id
,
86 void OnOpenDevice(int render_view_id
,
88 const std::string
& device_id
,
90 const GURL
& security_origin
);
92 void OnCloseDevice(int render_view_id
,
93 const std::string
& label
);
95 void StoreRequest(int render_view_id
,
97 const std::string
& label
);;
99 bool IsURLAllowed(const GURL
& url
);
101 int render_process_id_
;
102 ResourceContext::SaltCallback salt_callback_
;
103 MediaStreamManager
* media_stream_manager_
;
105 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcherHost
);
108 } // namespace content
110 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_