Home | History | Annotate | Download | only in media
      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 WebAudioSourceProvider;
     22 class WebMediaStreamCenterClient;
     23 }
     24 
     25 namespace content {
     26 class PeerConnectionDependencyFactory;
     27 
     28 class CONTENT_EXPORT MediaStreamCenter
     29     : NON_EXPORTED_BASE(public blink::WebMediaStreamCenter),
     30       public RenderProcessObserver {
     31  public:
     32   MediaStreamCenter(blink::WebMediaStreamCenterClient* client,
     33                     PeerConnectionDependencyFactory* factory);
     34   virtual ~MediaStreamCenter();
     35 
     36  private:
     37   virtual bool getMediaStreamTrackSources(
     38       const blink::WebMediaStreamTrackSourcesRequest& request) OVERRIDE;
     39 
     40   virtual void didCreateMediaStreamTrack(
     41       const blink::WebMediaStreamTrack& track) OVERRIDE;
     42 
     43   virtual void didEnableMediaStreamTrack(
     44       const blink::WebMediaStreamTrack& track) OVERRIDE;
     45 
     46   virtual void didDisableMediaStreamTrack(
     47       const blink::WebMediaStreamTrack& track) OVERRIDE;
     48 
     49   virtual void didStopLocalMediaStream(
     50       const blink::WebMediaStream& stream) OVERRIDE;
     51 
     52   virtual bool didStopMediaStreamTrack(
     53       const blink::WebMediaStreamTrack& track) OVERRIDE;
     54 
     55   virtual blink::WebAudioSourceProvider*
     56       createWebAudioSourceFromMediaStreamTrack(
     57           const blink::WebMediaStreamTrack& track) OVERRIDE;
     58 
     59 
     60   virtual void didCreateMediaStream(
     61       blink::WebMediaStream& stream) OVERRIDE;
     62 
     63   virtual bool didAddMediaStreamTrack(
     64       const blink::WebMediaStream& stream,
     65       const blink::WebMediaStreamTrack& track) OVERRIDE;
     66 
     67   virtual bool didRemoveMediaStreamTrack(
     68       const blink::WebMediaStream& stream,
     69       const blink::WebMediaStreamTrack& track) OVERRIDE;
     70 
     71   // RenderProcessObserver implementation.
     72   virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
     73 
     74   void OnGetSourcesComplete(int request_id,
     75                             const content::StreamDeviceInfoArray& devices);
     76 
     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_;
     80 
     81   // A strictly increasing id that's used to label incoming GetSources()
     82   // requests.
     83   int next_request_id_;
     84 
     85   typedef std::map<int, blink::WebMediaStreamTrackSourcesRequest> RequestMap;
     86   // Maps request ids to request objects.
     87   RequestMap requests_;
     88 
     89   DISALLOW_COPY_AND_ASSIGN(MediaStreamCenter);
     90 };
     91 
     92 }  // namespace content
     93 
     94 #endif  // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CENTER_H_
     95