Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
|
Henrik Grunell
2014/09/02 06:47:53
// Copyright 2014 The Chromium Authors. All rights
| |
| 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_USER_MEDIA_CLIENT_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_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_frame_observer.h" | 19 #include "content/public/renderer/render_frame_observer.h" |
| 20 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" | 20 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |
| 21 #include "content/renderer/media/media_stream_source.h" | 21 #include "content/renderer/media/media_stream_source.h" |
| 22 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 22 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 23 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 23 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 24 #include "third_party/WebKit/public/platform/WebVector.h" | 24 #include "third_party/WebKit/public/platform/WebVector.h" |
| 25 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" | 25 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" |
| 26 #include "third_party/WebKit/public/web/WebUserMediaClient.h" | 26 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |
| 27 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 27 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |
| 28 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 28 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 class PeerConnectionDependencyFactory; | 31 class PeerConnectionDependencyFactory; |
| 32 class MediaStreamDispatcher; | 32 class MediaStreamDispatcher; |
| 33 class MediaStreamVideoSource; | 33 class MediaStreamVideoSource; |
| 34 class VideoCapturerDelegate; | 34 class VideoCapturerDelegate; |
| 35 | 35 |
| 36 // MediaStreamImpl is a delegate for the Media Stream GetUserMedia API. | 36 // UserMediaClientImpl is a delegate for the Media Stream GetUserMedia API. |
| 37 // It ties together WebKit and MediaStreamManager | 37 // It ties together WebKit and MediaStreamManager |
| 38 // (via MediaStreamDispatcher and MediaStreamDispatcherHost) | 38 // (via MediaStreamDispatcher and MediaStreamDispatcherHost) |
| 39 // in the browser process. It must be created, called and destroyed on the | 39 // in the browser process. It must be created, called and destroyed on the |
| 40 // render thread. | 40 // render thread. |
| 41 class CONTENT_EXPORT MediaStreamImpl | 41 class CONTENT_EXPORT UserMediaClientImpl |
| 42 : public RenderFrameObserver, | 42 : public RenderFrameObserver, |
| 43 NON_EXPORTED_BASE(public blink::WebUserMediaClient), | 43 NON_EXPORTED_BASE(public blink::WebUserMediaClient), |
| 44 public MediaStreamDispatcherEventHandler, | 44 public MediaStreamDispatcherEventHandler, |
| 45 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 45 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 46 public: | 46 public: |
| 47 // |render_frame| and |dependency_factory| must outlive this instance. | 47 // |render_frame| and |dependency_factory| must outlive this instance. |
| 48 MediaStreamImpl( | 48 UserMediaClientImpl( |
| 49 RenderFrame* render_frame, | 49 RenderFrame* render_frame, |
| 50 PeerConnectionDependencyFactory* dependency_factory, | 50 PeerConnectionDependencyFactory* dependency_factory, |
| 51 scoped_ptr<MediaStreamDispatcher> media_stream_dispatcher); | 51 scoped_ptr<MediaStreamDispatcher> media_stream_dispatcher); |
| 52 virtual ~MediaStreamImpl(); | 52 virtual ~UserMediaClientImpl(); |
| 53 | 53 |
| 54 MediaStreamDispatcher* media_stream_dispatcher() const { | 54 MediaStreamDispatcher* media_stream_dispatcher() const { |
| 55 return media_stream_dispatcher_.get(); | 55 return media_stream_dispatcher_.get(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // blink::WebUserMediaClient implementation | 58 // blink::WebUserMediaClient implementation |
| 59 virtual void requestUserMedia( | 59 virtual void requestUserMedia( |
| 60 const blink::WebUserMediaRequest& user_media_request); | 60 const blink::WebUserMediaRequest& user_media_request); |
| 61 virtual void cancelUserMediaRequest( | 61 virtual void cancelUserMediaRequest( |
| 62 const blink::WebUserMediaRequest& user_media_request); | 62 const blink::WebUserMediaRequest& user_media_request); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 | 223 |
| 224 void StopLocalSource(const blink::WebMediaStreamSource& source, | 224 void StopLocalSource(const blink::WebMediaStreamSource& source, |
| 225 bool notify_dispatcher); | 225 bool notify_dispatcher); |
| 226 | 226 |
| 227 // Weak ref to a PeerConnectionDependencyFactory, owned by the RenderThread. | 227 // Weak ref to a PeerConnectionDependencyFactory, owned by the RenderThread. |
| 228 // It's valid for the lifetime of RenderThread. | 228 // It's valid for the lifetime of RenderThread. |
| 229 // TODO(xians): Remove this dependency once audio do not need it for local | 229 // TODO(xians): Remove this dependency once audio do not need it for local |
| 230 // audio. | 230 // audio. |
| 231 PeerConnectionDependencyFactory* const dependency_factory_; | 231 PeerConnectionDependencyFactory* const dependency_factory_; |
| 232 | 232 |
| 233 // MediaStreamImpl owns MediaStreamDispatcher instead of RenderFrameImpl | 233 // UserMediaClientImpl owns MediaStreamDispatcher instead of RenderFrameImpl |
| 234 // (or RenderFrameObserver) to ensure tear-down occurs in the right order. | 234 // (or RenderFrameObserver) to ensure tear-down occurs in the right order. |
| 235 const scoped_ptr<MediaStreamDispatcher> media_stream_dispatcher_; | 235 const scoped_ptr<MediaStreamDispatcher> media_stream_dispatcher_; |
| 236 | 236 |
| 237 LocalStreamSources local_sources_; | 237 LocalStreamSources local_sources_; |
| 238 | 238 |
| 239 UserMediaRequests user_media_requests_; | 239 UserMediaRequests user_media_requests_; |
| 240 | 240 |
| 241 // Requests to enumerate media devices. | 241 // Requests to enumerate media devices. |
| 242 MediaDevicesRequests media_devices_requests_; | 242 MediaDevicesRequests media_devices_requests_; |
| 243 | 243 |
| 244 // Note: This member must be the last to ensure all outstanding weak pointers | 244 // Note: This member must be the last to ensure all outstanding weak pointers |
| 245 // are invalidated first. | 245 // are invalidated first. |
| 246 base::WeakPtrFactory<MediaStreamImpl> weak_factory_; | 246 base::WeakPtrFactory<UserMediaClientImpl> weak_factory_; |
| 247 | 247 |
| 248 DISALLOW_COPY_AND_ASSIGN(MediaStreamImpl); | 248 DISALLOW_COPY_AND_ASSIGN(UserMediaClientImpl); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 } // namespace content | 251 } // namespace content |
| 252 | 252 |
| 253 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_IMPL_H_ | 253 #endif // CONTENT_RENDERER_MEDIA_USER_MEDIA_CLIENT_IMPL_H_ |
| OLD | NEW |