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. 4 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CENTER_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CENTER_H_ 7 8 #include <map> 9 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" 19 20 namespace blink { 21 class WebMediaStreamCenterClient; 22 } 23 24 namespace content { 25 class MediaStreamDependencyFactory; 26 27 class CONTENT_EXPORT MediaStreamCenter 28 : NON_EXPORTED_BASE(public blink::WebMediaStreamCenter), 29 public RenderProcessObserver { 30 public: 31 MediaStreamCenter(blink::WebMediaStreamCenterClient* client, 32 MediaStreamDependencyFactory* factory); 33 virtual ~MediaStreamCenter(); 34 35 private: 36 virtual bool getMediaStreamTrackSources( 37 const blink::WebMediaStreamTrackSourcesRequest& request) OVERRIDE; 38 39 virtual void didCreateMediaStreamTrack( 40 const blink::WebMediaStreamTrack& track) OVERRIDE; 41 42 virtual void didEnableMediaStreamTrack( 43 const blink::WebMediaStreamTrack& track) OVERRIDE; 44 45 virtual void didDisableMediaStreamTrack( 46 const blink::WebMediaStreamTrack& track) OVERRIDE; 47 48 virtual void didStopLocalMediaStream( 49 const blink::WebMediaStream& stream) OVERRIDE; 50 51 virtual bool didStopMediaStreamTrack( 52 const blink::WebMediaStreamTrack& track) OVERRIDE; 53 54 virtual void didCreateMediaStream( 55 blink::WebMediaStream& stream) OVERRIDE; 56 57 virtual bool didAddMediaStreamTrack( 58 const blink::WebMediaStream& stream, 59 const blink::WebMediaStreamTrack& track) OVERRIDE; 60 61 virtual bool didRemoveMediaStreamTrack( 62 const blink::WebMediaStream& stream, 63 const blink::WebMediaStreamTrack& track) OVERRIDE; 64 65 // RenderProcessObserver implementation. 66 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; 67 68 void OnGetSourcesComplete(int request_id, 69 const content::StreamDeviceInfoArray& devices); 70 71 // |rtc_factory_| is a weak pointer and is owned by the RenderThreadImpl. 72 // It is valid as long as RenderThreadImpl exist. 73 MediaStreamDependencyFactory* rtc_factory_; 74 75 // A strictly increasing id that's used to label incoming GetSources() 76 // requests. 77 int next_request_id_; 78 79 typedef std::map<int, blink::WebMediaStreamTrackSourcesRequest> RequestMap; 80 // Maps request ids to request objects. 81 RequestMap requests_; 82 83 DISALLOW_COPY_AND_ASSIGN(MediaStreamCenter); 84 }; 85 86 } // namespace content 87 88 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CENTER_H_ 89