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_PEER_CONNECTION_HANDLER_BASE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_ |
6 #define CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_ | 6 #define CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "third_party/libjingle/source/talk/app/webrtc/mediastream.h" | 14 #include "third_party/libjingle/source/talk/app/webrtc/mediastream.h" |
15 #include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h" | 15 #include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" |
17 | 17 |
18 class MediaStreamDependencyFactory; | 18 class MediaStreamDependencyFactory; |
19 class MediaStreamImpl; | |
20 | 19 |
21 // PeerConnectionHandlerBase is the base class of a delegate for the | 20 // PeerConnectionHandlerBase is the base class of a delegate for the |
22 // PeerConnection (JSEP or ROAP) API messages going between WebKit and native | 21 // PeerConnection (JSEP or ROAP) API messages going between WebKit and native |
23 // PeerConnection in libjingle. ROAP PeerConnection will be removed soon. | 22 // PeerConnection in libjingle. ROAP PeerConnection will be removed soon. |
24 class CONTENT_EXPORT PeerConnectionHandlerBase | 23 class CONTENT_EXPORT PeerConnectionHandlerBase |
25 : NON_EXPORTED_BASE(public webrtc::PeerConnectionObserver) { | 24 : NON_EXPORTED_BASE(public webrtc::PeerConnectionObserver) { |
26 public: | 25 public: |
27 PeerConnectionHandlerBase( | 26 PeerConnectionHandlerBase( |
28 MediaStreamImpl* msi, | |
29 MediaStreamDependencyFactory* dependency_factory); | 27 MediaStreamDependencyFactory* dependency_factory); |
30 | 28 |
31 webrtc::MediaStreamInterface* GetRemoteMediaStream( | |
32 const WebKit::WebMediaStreamDescriptor& stream); | |
33 | |
34 void SetRemoteVideoRenderer(const std::string& source_id, | |
35 webrtc::VideoRendererWrapperInterface* renderer); | |
36 | |
37 protected: | 29 protected: |
38 virtual ~PeerConnectionHandlerBase(); | 30 virtual ~PeerConnectionHandlerBase(); |
39 | 31 |
40 void AddStream(const WebKit::WebMediaStreamDescriptor& stream); | 32 void AddStream(const WebKit::WebMediaStreamDescriptor& stream); |
41 void RemoveStream(const WebKit::WebMediaStreamDescriptor& stream); | 33 void RemoveStream(const WebKit::WebMediaStreamDescriptor& stream); |
42 WebKit::WebMediaStreamDescriptor CreateWebKitStreamDescriptor( | 34 WebKit::WebMediaStreamDescriptor CreateWebKitStreamDescriptor( |
43 webrtc::MediaStreamInterface* stream); | 35 webrtc::MediaStreamInterface* stream); |
44 // Returns a VideoTrack given the |source_id| | |
45 webrtc::VideoTrackInterface* FindRemoteVideoTrack( | |
46 const std::string& source_id); | |
47 | |
48 // media_stream_impl_ is a raw pointer, and is valid for the lifetime of this | |
49 // class. Calls to it must be done on the render thread. | |
50 MediaStreamImpl* media_stream_impl_; | |
51 | 36 |
52 // dependency_factory_ is a raw pointer, and is valid for the lifetime of | 37 // dependency_factory_ is a raw pointer, and is valid for the lifetime of |
53 // MediaStreamImpl. | 38 // MediaStreamImpl. |
54 MediaStreamDependencyFactory* dependency_factory_; | 39 MediaStreamDependencyFactory* dependency_factory_; |
55 | 40 |
56 // native_peer_connection_ is the native PeerConnection object, | 41 // native_peer_connection_ is the native PeerConnection object, |
57 // it handles the ICE processing and media engine. | 42 // it handles the ICE processing and media engine. |
58 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> | 43 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> |
59 native_peer_connection_; | 44 native_peer_connection_; |
60 | 45 |
61 typedef std::map<webrtc::MediaStreamInterface*, | 46 typedef std::map<webrtc::MediaStreamInterface*, |
62 WebKit::WebMediaStreamDescriptor> RemoteStreamMap; | 47 WebKit::WebMediaStreamDescriptor> RemoteStreamMap; |
63 RemoteStreamMap remote_streams_; | 48 RemoteStreamMap remote_streams_; |
64 | 49 |
65 // Native PeerConnection only supports 1:1 mapping between MediaStream and | |
66 // video tag/renderer, so we restrict to this too. The key in | |
67 // VideoRendererMap is the track label. | |
68 typedef talk_base::scoped_refptr<webrtc::VideoRendererWrapperInterface> | |
69 VideoRendererPtr; | |
70 | |
71 typedef std::map<std::string, VideoRendererPtr> VideoRendererMap; | |
72 VideoRendererMap video_renderers_; | |
73 | |
74 // The message loop we are created on and on which to make calls to WebKit. | 50 // The message loop we are created on and on which to make calls to WebKit. |
75 // This should be the render thread message loop. | 51 // This should be the render thread message loop. |
76 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 52 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
77 | 53 |
78 DISALLOW_COPY_AND_ASSIGN(PeerConnectionHandlerBase); | 54 DISALLOW_COPY_AND_ASSIGN(PeerConnectionHandlerBase); |
79 }; | 55 }; |
80 | 56 |
81 #endif // CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_ | 57 #endif // CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_BASE_H_ |
OLD | NEW |