OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "content/public/renderer/render_view_observer.h" | 18 #include "content/public/renderer/render_view_observer.h" |
19 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" | 19 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |
20 #include "third_party/libjingle/source/talk/app/webrtc/mediastream.h" | 20 #include "third_party/libjingle/source/talk/app/webrtc/mediastream.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaRequest.h
" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaRequest.h
" |
23 #include "webkit/media/media_stream_client.h" | 23 #include "webkit/media/media_stream_client.h" |
24 | 24 |
25 namespace WebKit { | 25 namespace WebKit { |
26 class WebMediaStreamDescriptor; | 26 class WebMediaStreamDescriptor; |
27 } | 27 } |
28 | 28 |
29 class MediaStreamDispatcher; | |
30 class MediaStreamDependencyFactory; | 29 class MediaStreamDependencyFactory; |
31 class VideoCaptureImplManager; | 30 class VideoCaptureImplManager; |
32 | 31 |
| 32 namespace content { |
| 33 class MediaStreamDispatcher; |
| 34 |
33 // MediaStreamImpl is a delegate for the Media Stream API messages used by | 35 // MediaStreamImpl is a delegate for the Media Stream API messages used by |
34 // WebKit. It ties together WebKit, native PeerConnection in libjingle and | 36 // WebKit. It ties together WebKit, native PeerConnection in libjingle and |
35 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost) | 37 // MediaStreamManager (via MediaStreamDispatcher and MediaStreamDispatcherHost) |
36 // in the browser process. It must be created, called and destroyed on the | 38 // in the browser process. It must be created, called and destroyed on the |
37 // render thread. | 39 // render thread. |
38 // MediaStreamImpl have weak pointers to a MediaStreamDispatcher. | 40 // MediaStreamImpl have weak pointers to a MediaStreamDispatcher. |
39 class CONTENT_EXPORT MediaStreamImpl | 41 class CONTENT_EXPORT MediaStreamImpl |
40 : public content::RenderViewObserver, | 42 : public RenderViewObserver, |
41 NON_EXPORTED_BASE(public WebKit::WebUserMediaClient), | 43 NON_EXPORTED_BASE(public WebKit::WebUserMediaClient), |
42 NON_EXPORTED_BASE(public webkit_media::MediaStreamClient), | 44 NON_EXPORTED_BASE(public webkit_media::MediaStreamClient), |
43 public MediaStreamDispatcherEventHandler, | 45 public MediaStreamDispatcherEventHandler, |
44 public base::SupportsWeakPtr<MediaStreamImpl>, | 46 public base::SupportsWeakPtr<MediaStreamImpl>, |
45 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 47 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
46 public: | 48 public: |
47 MediaStreamImpl( | 49 MediaStreamImpl( |
48 content::RenderView* render_view, | 50 RenderView* render_view, |
49 MediaStreamDispatcher* media_stream_dispatcher, | 51 MediaStreamDispatcher* media_stream_dispatcher, |
50 VideoCaptureImplManager* vc_manager, | 52 VideoCaptureImplManager* vc_manager, |
51 MediaStreamDependencyFactory* dependency_factory); | 53 MediaStreamDependencyFactory* dependency_factory); |
52 virtual ~MediaStreamImpl(); | 54 virtual ~MediaStreamImpl(); |
53 | 55 |
54 // Return true when the |url| is media stream. | 56 // Return true when the |url| is media stream. |
55 // This static function has the same functionalilty as IsMediaStream | 57 // This static function has the same functionalilty as IsMediaStream |
56 // except that it doesn't require an instance of this class. | 58 // except that it doesn't require an instance of this class. |
57 // This can save some overhead time when the |url| is not media stream. | 59 // This can save some overhead time when the |url| is not media stream. |
58 static bool CheckMediaStream(const GURL& url); | 60 static bool CheckMediaStream(const GURL& url); |
(...skipping 27 matching lines...) Expand all Loading... |
86 virtual void OnDevicesEnumerated( | 88 virtual void OnDevicesEnumerated( |
87 int request_id, | 89 int request_id, |
88 const media_stream::StreamDeviceInfoArray& device_array) OVERRIDE; | 90 const media_stream::StreamDeviceInfoArray& device_array) OVERRIDE; |
89 virtual void OnDevicesEnumerationFailed(int request_id) OVERRIDE; | 91 virtual void OnDevicesEnumerationFailed(int request_id) OVERRIDE; |
90 virtual void OnDeviceOpened( | 92 virtual void OnDeviceOpened( |
91 int request_id, | 93 int request_id, |
92 const std::string& label, | 94 const std::string& label, |
93 const media_stream::StreamDeviceInfo& device_info) OVERRIDE; | 95 const media_stream::StreamDeviceInfo& device_info) OVERRIDE; |
94 virtual void OnDeviceOpenFailed(int request_id) OVERRIDE; | 96 virtual void OnDeviceOpenFailed(int request_id) OVERRIDE; |
95 | 97 |
96 // content::RenderViewObserver OVERRIDE | 98 // RenderViewObserver OVERRIDE |
97 virtual void FrameWillClose(WebKit::WebFrame* frame) OVERRIDE; | 99 virtual void FrameWillClose(WebKit::WebFrame* frame) OVERRIDE; |
98 | 100 |
99 protected: | 101 protected: |
100 // Stops a local MediaStream by notifying the MediaStreamDispatcher that the | 102 // Stops a local MediaStream by notifying the MediaStreamDispatcher that the |
101 // stream no longer may be used. | 103 // stream no longer may be used. |
102 void OnLocalMediaStreamStop(const std::string& label); | 104 void OnLocalMediaStreamStop(const std::string& label); |
103 // This function is virtual for test purposes. A test can override this to | 105 // This function is virtual for test purposes. A test can override this to |
104 // test requesting local media streams. The function notifies WebKit that the | 106 // test requesting local media streams. The function notifies WebKit that the |
105 // |request| have completed and generated the MediaStream |stream|. | 107 // |request| have completed and generated the MediaStream |stream|. |
106 virtual void CompleteGetUserMediaRequest( | 108 virtual void CompleteGetUserMediaRequest( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 MediaStreamDispatcher* media_stream_dispatcher_; | 156 MediaStreamDispatcher* media_stream_dispatcher_; |
155 | 157 |
156 scoped_refptr<VideoCaptureImplManager> vc_manager_; | 158 scoped_refptr<VideoCaptureImplManager> vc_manager_; |
157 | 159 |
158 MediaRequestMap user_media_requests_; | 160 MediaRequestMap user_media_requests_; |
159 LocalNativeStreamMap local_media_streams_; | 161 LocalNativeStreamMap local_media_streams_; |
160 | 162 |
161 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); | 163 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); |
162 }; | 164 }; |
163 | 165 |
| 166 } // namespace content |
| 167 |
164 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 168 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ |
OLD | NEW |