| 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_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_H_ | 6 #define CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <string> | 8 #include <string> |
| 10 | 9 |
| 11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 13 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/message_loop_proxy.h" | |
| 16 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 17 #include "third_party/libjingle/source/talk/app/webrtc/mediastream.h" | 14 #include "content/renderer/media/peer_connection_handler_base.h" |
| 18 #include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h" | |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandler.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandler.h" |
| 20 | 16 |
| 21 class MediaStreamDependencyFactory; | 17 // PeerConnectionHandler is a delegate for the ROAP PeerConnection API messages |
| 22 class MediaStreamImpl; | 18 // going between WebKit and native PeerConnection in libjingle. It's owned by |
| 23 | 19 // WebKit. ROAP PeerConnection will be removed soon. |
| 24 // PeerConnectionHandler is a delegate for the PeerConnection API messages going | |
| 25 // between WebKit and native PeerConnection in libjingle. It's owned by | |
| 26 // WebKit. | |
| 27 class CONTENT_EXPORT PeerConnectionHandler | 20 class CONTENT_EXPORT PeerConnectionHandler |
| 28 : NON_EXPORTED_BASE(public WebKit::WebPeerConnectionHandler), | 21 : public PeerConnectionHandlerBase, |
| 29 NON_EXPORTED_BASE(public webrtc::PeerConnectionObserver) { | 22 NON_EXPORTED_BASE(public WebKit::WebPeerConnectionHandler) { |
| 30 public: | 23 public: |
| 31 PeerConnectionHandler( | 24 PeerConnectionHandler( |
| 32 WebKit::WebPeerConnectionHandlerClient* client, | 25 WebKit::WebPeerConnectionHandlerClient* client, |
| 33 MediaStreamImpl* msi, | 26 MediaStreamImpl* msi, |
| 34 MediaStreamDependencyFactory* dependency_factory); | 27 MediaStreamDependencyFactory* dependency_factory); |
| 35 virtual ~PeerConnectionHandler(); | 28 virtual ~PeerConnectionHandler(); |
| 36 | 29 |
| 37 // Set the video renderer for the specified stream. | |
| 38 virtual void SetVideoRenderer( | |
| 39 const std::string& stream_label, | |
| 40 webrtc::VideoRendererWrapperInterface* renderer); | |
| 41 | |
| 42 // WebKit::WebPeerConnectionHandler implementation | 30 // WebKit::WebPeerConnectionHandler implementation |
| 43 virtual void initialize( | 31 virtual void initialize( |
| 44 const WebKit::WebString& server_configuration, | 32 const WebKit::WebString& server_configuration, |
| 45 const WebKit::WebString& username) OVERRIDE; | 33 const WebKit::WebString& username) OVERRIDE; |
| 46 virtual void produceInitialOffer( | 34 virtual void produceInitialOffer( |
| 47 const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& | 35 const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& |
| 48 pending_add_streams) OVERRIDE; | 36 pending_add_streams) OVERRIDE; |
| 49 virtual void handleInitialOffer(const WebKit::WebString& sdp) OVERRIDE; | 37 virtual void handleInitialOffer(const WebKit::WebString& sdp) OVERRIDE; |
| 50 virtual void processSDP(const WebKit::WebString& sdp) OVERRIDE; | 38 virtual void processSDP(const WebKit::WebString& sdp) OVERRIDE; |
| 51 virtual void processPendingStreams( | 39 virtual void processPendingStreams( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 virtual void OnStateChange(StateType state_changed) OVERRIDE; | 52 virtual void OnStateChange(StateType state_changed) OVERRIDE; |
| 65 virtual void OnAddStream(webrtc::MediaStreamInterface* stream) OVERRIDE; | 53 virtual void OnAddStream(webrtc::MediaStreamInterface* stream) OVERRIDE; |
| 66 virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream) OVERRIDE; | 54 virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream) OVERRIDE; |
| 67 virtual void OnIceCandidate( | 55 virtual void OnIceCandidate( |
| 68 const webrtc::IceCandidateInterface* candidate) OVERRIDE; | 56 const webrtc::IceCandidateInterface* candidate) OVERRIDE; |
| 69 virtual void OnIceComplete() OVERRIDE; | 57 virtual void OnIceComplete() OVERRIDE; |
| 70 | 58 |
| 71 private: | 59 private: |
| 72 FRIEND_TEST_ALL_PREFIXES(PeerConnectionHandlerTest, Basic); | 60 FRIEND_TEST_ALL_PREFIXES(PeerConnectionHandlerTest, Basic); |
| 73 | 61 |
| 74 void AddStreams( | |
| 75 const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& streams); | |
| 76 void RemoveStreams( | |
| 77 const WebKit::WebVector<WebKit::WebMediaStreamDescriptor>& streams); | |
| 78 void OnAddStreamCallback(webrtc::MediaStreamInterface* stream); | 62 void OnAddStreamCallback(webrtc::MediaStreamInterface* stream); |
| 79 void OnRemoveStreamCallback(webrtc::MediaStreamInterface* stream); | 63 void OnRemoveStreamCallback(webrtc::MediaStreamInterface* stream); |
| 80 WebKit::WebMediaStreamDescriptor CreateWebKitStreamDescriptor( | |
| 81 webrtc::MediaStreamInterface* stream); | |
| 82 | 64 |
| 83 // client_ is a weak pointer, and is valid until stop() has returned. | 65 // client_ is a weak pointer, and is valid until stop() has returned. |
| 84 WebKit::WebPeerConnectionHandlerClient* client_; | 66 WebKit::WebPeerConnectionHandlerClient* client_; |
| 85 | 67 |
| 86 // media_stream_impl_ is a weak pointer, and is valid for the lifetime of this | |
| 87 // class. Calls to it must be done on the render thread. | |
| 88 MediaStreamImpl* media_stream_impl_; | |
| 89 | |
| 90 // dependency_factory_ is a weak pointer, and is valid for the lifetime of | |
| 91 // MediaStreamImpl. | |
| 92 MediaStreamDependencyFactory* dependency_factory_; | |
| 93 | |
| 94 // native_peer_connection_ is the native PeerConnection object, | |
| 95 // it handles the ICE processing and media engine. | |
| 96 talk_base::scoped_refptr<webrtc::PeerConnectionInterface> | |
| 97 native_peer_connection_; | |
| 98 | |
| 99 typedef std::map<webrtc::MediaStreamInterface*, | |
| 100 WebKit::WebMediaStreamDescriptor> RemoteStreamMap; | |
| 101 RemoteStreamMap remote_streams_; | |
| 102 | |
| 103 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | |
| 104 | |
| 105 DISALLOW_COPY_AND_ASSIGN(PeerConnectionHandler); | 68 DISALLOW_COPY_AND_ASSIGN(PeerConnectionHandler); |
| 106 }; | 69 }; |
| 107 | 70 |
| 108 #endif // CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_H_ | 71 #endif // CONTENT_RENDERER_MEDIA_PEER_CONNECTION_HANDLER_H_ |
| OLD | NEW |