| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 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/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/public/renderer/render_view_observer.h" | 19 #include "content/public/renderer/render_view_observer.h" |
| 20 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" | 20 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |
| 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaRequest.h
" |
| 21 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 24 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" | |
| 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamDescr
iptor.h" | |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaRequest.h
" | |
| 25 #include "webkit/media/media_stream_client.h" | 25 #include "webkit/media/media_stream_client.h" |
| 26 | 26 |
| 27 namespace base{ | 27 namespace base{ |
| 28 class MessageLoopProxy; | 28 class MessageLoopProxy; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace webkit_media { | 31 namespace webkit_media { |
| 32 class MediaStreamAudioRenderer; | 32 class MediaStreamAudioRenderer; |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Stops a local MediaStream by notifying the MediaStreamDispatcher that the | 111 // Stops a local MediaStream by notifying the MediaStreamDispatcher that the |
| 112 // stream no longer may be used. | 112 // stream no longer may be used. |
| 113 void OnLocalMediaStreamStop(const std::string& label); | 113 void OnLocalMediaStreamStop(const std::string& label); |
| 114 | 114 |
| 115 // Callback function triggered when all native (libjingle) versions of the | 115 // Callback function triggered when all native (libjingle) versions of the |
| 116 // underlying media sources have been created and started. | 116 // underlying media sources have been created and started. |
| 117 // |description| is a raw pointer to the description in | 117 // |description| is a raw pointer to the description in |
| 118 // UserMediaRequests::description for which the underlying sources have been | 118 // UserMediaRequests::description for which the underlying sources have been |
| 119 // created. | 119 // created. |
| 120 void OnCreateNativeSourcesComplete( | 120 void OnCreateNativeSourcesComplete( |
| 121 WebKit::WebMediaStreamDescriptor* description, | 121 WebKit::WebMediaStream* description, |
| 122 bool request_succeeded); | 122 bool request_succeeded); |
| 123 | 123 |
| 124 // This function is virtual for test purposes. A test can override this to | 124 // This function is virtual for test purposes. A test can override this to |
| 125 // test requesting local media streams. The function notifies WebKit that the | 125 // test requesting local media streams. The function notifies WebKit that the |
| 126 // |request| have completed and generated the MediaStream |stream|. | 126 // |request| have completed and generated the MediaStream |stream|. |
| 127 virtual void CompleteGetUserMediaRequest( | 127 virtual void CompleteGetUserMediaRequest( |
| 128 const WebKit::WebMediaStreamDescriptor& stream, | 128 const WebKit::WebMediaStream& stream, |
| 129 WebKit::WebUserMediaRequest* request_info, | 129 WebKit::WebUserMediaRequest* request_info, |
| 130 bool request_succeeded); | 130 bool request_succeeded); |
| 131 | 131 |
| 132 // Returns the WebKit representation of a MediaStream given an URL. | 132 // Returns the WebKit representation of a MediaStream given an URL. |
| 133 // This is virtual for test purposes. | 133 // This is virtual for test purposes. |
| 134 virtual WebKit::WebMediaStreamDescriptor GetMediaStream(const GURL& url); | 134 virtual WebKit::WebMediaStream GetMediaStream(const GURL& url); |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 // Structure for storing information about a WebKit request to create a | 137 // Structure for storing information about a WebKit request to create a |
| 138 // MediaStream. | 138 // MediaStream. |
| 139 struct UserMediaRequestInfo { | 139 struct UserMediaRequestInfo { |
| 140 UserMediaRequestInfo() | 140 UserMediaRequestInfo() |
| 141 : request_id(0), generated(false), frame(NULL), request() { | 141 : request_id(0), generated(false), frame(NULL), request() { |
| 142 } | 142 } |
| 143 UserMediaRequestInfo(int request_id, | 143 UserMediaRequestInfo(int request_id, |
| 144 WebKit::WebFrame* frame, | 144 WebKit::WebFrame* frame, |
| 145 const WebKit::WebUserMediaRequest& request) | 145 const WebKit::WebUserMediaRequest& request) |
| 146 : request_id(request_id), generated(false), frame(frame), | 146 : request_id(request_id), generated(false), frame(frame), |
| 147 request(request) { | 147 request(request) { |
| 148 } | 148 } |
| 149 int request_id; | 149 int request_id; |
| 150 // True if MediaStreamDispatcher has generated the stream, see | 150 // True if MediaStreamDispatcher has generated the stream, see |
| 151 // OnStreamGenerated. | 151 // OnStreamGenerated. |
| 152 bool generated; | 152 bool generated; |
| 153 WebKit::WebFrame* frame; // WebFrame that requested the MediaStream. | 153 WebKit::WebFrame* frame; // WebFrame that requested the MediaStream. |
| 154 WebKit::WebMediaStreamDescriptor descriptor; | 154 WebKit::WebMediaStream descriptor; |
| 155 WebKit::WebUserMediaRequest request; | 155 WebKit::WebUserMediaRequest request; |
| 156 }; | 156 }; |
| 157 typedef ScopedVector<UserMediaRequestInfo> UserMediaRequests; | 157 typedef ScopedVector<UserMediaRequestInfo> UserMediaRequests; |
| 158 | 158 |
| 159 UserMediaRequestInfo* FindUserMediaRequestInfo(int request_id); | 159 UserMediaRequestInfo* FindUserMediaRequestInfo(int request_id); |
| 160 UserMediaRequestInfo* FindUserMediaRequestInfo( | 160 UserMediaRequestInfo* FindUserMediaRequestInfo( |
| 161 WebKit::WebMediaStreamDescriptor* descriptor); | 161 WebKit::WebMediaStream* descriptor); |
| 162 UserMediaRequestInfo* FindUserMediaRequestInfo( | 162 UserMediaRequestInfo* FindUserMediaRequestInfo( |
| 163 const WebKit::WebUserMediaRequest& request); | 163 const WebKit::WebUserMediaRequest& request); |
| 164 UserMediaRequestInfo* FindUserMediaRequestInfo(const std::string& label); | 164 UserMediaRequestInfo* FindUserMediaRequestInfo(const std::string& label); |
| 165 void DeleteUserMediaRequestInfo(UserMediaRequestInfo* request); | 165 void DeleteUserMediaRequestInfo(UserMediaRequestInfo* request); |
| 166 | 166 |
| 167 scoped_refptr<webkit_media::VideoFrameProvider> | 167 scoped_refptr<webkit_media::VideoFrameProvider> |
| 168 CreateVideoFrameProvider( | 168 CreateVideoFrameProvider( |
| 169 webrtc::MediaStreamInterface* stream, | 169 webrtc::MediaStreamInterface* stream, |
| 170 const base::Closure& error_cb, | 170 const base::Closure& error_cb, |
| 171 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb); | 171 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 188 scoped_refptr<VideoCaptureImplManager> vc_manager_; | 188 scoped_refptr<VideoCaptureImplManager> vc_manager_; |
| 189 | 189 |
| 190 UserMediaRequests user_media_requests_; | 190 UserMediaRequests user_media_requests_; |
| 191 | 191 |
| 192 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); | 192 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 } // namespace content | 195 } // namespace content |
| 196 | 196 |
| 197 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 197 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ |
| OLD | NEW |