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"
19 class ResourceContext
;
20 } // namespace content
22 namespace media_stream
{
24 // MediaStreamDispatcherHost is a delegate for Media Stream API messages used by
25 // MediaStreamImpl. It's the complement of MediaStreamDispatcher
26 // (owned by RenderView).
27 class CONTENT_EXPORT MediaStreamDispatcherHost
28 : public content::BrowserMessageFilter
,
29 public MediaStreamRequester
{
31 MediaStreamDispatcherHost(content::ResourceContext
* resource_context
,
32 int render_process_id
,
33 media::AudioManager
* audio_manager
);
34 virtual ~MediaStreamDispatcherHost();
36 // MediaStreamRequester implementation.
37 virtual void StreamGenerated(
38 const std::string
& label
,
39 const StreamDeviceInfoArray
& audio_devices
,
40 const StreamDeviceInfoArray
& video_devices
) OVERRIDE
;
41 virtual void StreamGenerationFailed(const std::string
& label
) OVERRIDE
;
42 virtual void AudioDeviceFailed(const std::string
& label
, int index
) OVERRIDE
;
43 virtual void VideoDeviceFailed(const std::string
& label
, int index
) OVERRIDE
;
44 virtual void DevicesEnumerated(const std::string
& label
,
45 const StreamDeviceInfoArray
& devices
) OVERRIDE
;
46 virtual void DevicesEnumerationFailed(const std::string
& label
) OVERRIDE
;
47 virtual void DeviceOpened(const std::string
& label
,
48 const StreamDeviceInfo
& video_device
) OVERRIDE
;
49 virtual void DeviceOpenFailed(const std::string
& label
) OVERRIDE
;
51 // content::BrowserMessageFilter implementation.
52 virtual bool OnMessageReceived(const IPC::Message
& message
,
53 bool* message_was_ok
) OVERRIDE
;
54 virtual void OnChannelClosing() OVERRIDE
;
57 friend class MockMediaStreamDispatcherHost
;
59 void OnGenerateStream(int render_view_id
,
61 const StreamOptions
& components
,
62 const std::string
& security_origin
);
64 void OnStopGeneratedStream(int render_view_id
, const std::string
& label
);
66 void OnEnumerateDevices(int render_view_id
,
68 media_stream::MediaStreamType type
,
69 const std::string
& security_origin
);
71 void OnOpenDevice(int render_view_id
,
73 const std::string
& device_id
,
74 media_stream::MediaStreamType type
,
75 const std::string
& security_origin
);
77 // Returns the media stream manager to forward events to,
78 // creating one if needed.
79 MediaStreamManager
* manager();
81 content::ResourceContext
* resource_context_
;
82 int render_process_id_
;
83 media::AudioManager
* audio_manager_
;
86 typedef std::map
<std::string
, StreamRequest
> StreamMap
;
87 // Streams generated for this host.
90 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcherHost
);
93 } // namespace media_stream
95 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_