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_RENDERER_MEDIA_MEDIA_STREAM_CENTER_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CENTER_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "content/common/content_export.h"
13 #include "content/common/media/media_stream_options.h"
14 #include "content/public/renderer/render_process_observer.h"
15 #include "third_party/WebKit/public/platform/WebMediaStream.h"
16 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
17 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
18 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h"
21 class WebAudioSourceProvider
;
22 class WebMediaStreamCenterClient
;
26 class PeerConnectionDependencyFactory
;
28 class CONTENT_EXPORT MediaStreamCenter
29 : NON_EXPORTED_BASE(public blink::WebMediaStreamCenter
),
30 public RenderProcessObserver
{
32 MediaStreamCenter(blink::WebMediaStreamCenterClient
* client
,
33 PeerConnectionDependencyFactory
* factory
);
34 virtual ~MediaStreamCenter();
37 virtual bool getMediaStreamTrackSources(
38 const blink::WebMediaStreamTrackSourcesRequest
& request
) OVERRIDE
;
40 virtual void didCreateMediaStreamTrack(
41 const blink::WebMediaStreamTrack
& track
) OVERRIDE
;
43 virtual void didEnableMediaStreamTrack(
44 const blink::WebMediaStreamTrack
& track
) OVERRIDE
;
46 virtual void didDisableMediaStreamTrack(
47 const blink::WebMediaStreamTrack
& track
) OVERRIDE
;
49 virtual void didStopLocalMediaStream(
50 const blink::WebMediaStream
& stream
) OVERRIDE
;
52 virtual bool didStopMediaStreamTrack(
53 const blink::WebMediaStreamTrack
& track
) OVERRIDE
;
55 virtual blink::WebAudioSourceProvider
*
56 createWebAudioSourceFromMediaStreamTrack(
57 const blink::WebMediaStreamTrack
& track
) OVERRIDE
;
60 virtual void didCreateMediaStream(
61 blink::WebMediaStream
& stream
) OVERRIDE
;
63 virtual bool didAddMediaStreamTrack(
64 const blink::WebMediaStream
& stream
,
65 const blink::WebMediaStreamTrack
& track
) OVERRIDE
;
67 virtual bool didRemoveMediaStreamTrack(
68 const blink::WebMediaStream
& stream
,
69 const blink::WebMediaStreamTrack
& track
) OVERRIDE
;
71 // RenderProcessObserver implementation.
72 virtual bool OnControlMessageReceived(const IPC::Message
& message
) OVERRIDE
;
74 void OnGetSourcesComplete(int request_id
,
75 const content::StreamDeviceInfoArray
& devices
);
77 // |rtc_factory_| is a weak pointer and is owned by the RenderThreadImpl.
78 // It is valid as long as RenderThreadImpl exist.
79 PeerConnectionDependencyFactory
* rtc_factory_
;
81 // A strictly increasing id that's used to label incoming GetSources()
85 typedef std::map
<int, blink::WebMediaStreamTrackSourcesRequest
> RequestMap
;
86 // Maps request ids to request objects.
89 DISALLOW_COPY_AND_ASSIGN(MediaStreamCenter
);
92 } // namespace content
94 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CENTER_H_