| 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_RTC_PEER_CONNECTION_HANDLER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_ | 6 #define CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/renderer/media/peer_connection_handler_base.h" | 11 #include "content/renderer/media/peer_connection_handler_base.h" |
| 12 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h" | 12 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h" |
| 13 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h" | 13 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h" |
| 14 #include "third_party/WebKit/public/platform/WebRTCStatsResponse.h" | 14 #include "third_party/WebKit/public/platform/WebRTCStatsResponse.h" |
| 15 | 15 |
| 16 namespace WebKit { | 16 namespace blink { |
| 17 class WebFrame; | 17 class WebFrame; |
| 18 class WebRTCDataChannelHandler; | 18 class WebRTCDataChannelHandler; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 class PeerConnectionTracker; | 23 class PeerConnectionTracker; |
| 24 | 24 |
| 25 // Mockable wrapper for WebKit::WebRTCStatsResponse | 25 // Mockable wrapper for blink::WebRTCStatsResponse |
| 26 class CONTENT_EXPORT LocalRTCStatsResponse | 26 class CONTENT_EXPORT LocalRTCStatsResponse |
| 27 : public NON_EXPORTED_BASE(talk_base::RefCountInterface) { | 27 : public NON_EXPORTED_BASE(talk_base::RefCountInterface) { |
| 28 public: | 28 public: |
| 29 explicit LocalRTCStatsResponse(const WebKit::WebRTCStatsResponse& impl) | 29 explicit LocalRTCStatsResponse(const blink::WebRTCStatsResponse& impl) |
| 30 : impl_(impl) { | 30 : impl_(impl) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual WebKit::WebRTCStatsResponse webKitStatsResponse() const; | 33 virtual blink::WebRTCStatsResponse webKitStatsResponse() const; |
| 34 virtual size_t addReport(WebKit::WebString type, WebKit::WebString id, | 34 virtual size_t addReport(blink::WebString type, blink::WebString id, |
| 35 double timestamp); | 35 double timestamp); |
| 36 virtual void addStatistic(size_t report, | 36 virtual void addStatistic(size_t report, |
| 37 WebKit::WebString name, WebKit::WebString value); | 37 blink::WebString name, blink::WebString value); |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 virtual ~LocalRTCStatsResponse() {} | 40 virtual ~LocalRTCStatsResponse() {} |
| 41 // Constructor for creating mocks. | 41 // Constructor for creating mocks. |
| 42 LocalRTCStatsResponse() {} | 42 LocalRTCStatsResponse() {} |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 WebKit::WebRTCStatsResponse impl_; | 45 blink::WebRTCStatsResponse impl_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 // Mockable wrapper for WebKit::WebRTCStatsRequest | 48 // Mockable wrapper for blink::WebRTCStatsRequest |
| 49 class CONTENT_EXPORT LocalRTCStatsRequest | 49 class CONTENT_EXPORT LocalRTCStatsRequest |
| 50 : public NON_EXPORTED_BASE(talk_base::RefCountInterface) { | 50 : public NON_EXPORTED_BASE(talk_base::RefCountInterface) { |
| 51 public: | 51 public: |
| 52 explicit LocalRTCStatsRequest(WebKit::WebRTCStatsRequest impl); | 52 explicit LocalRTCStatsRequest(blink::WebRTCStatsRequest impl); |
| 53 // Constructor for testing. | 53 // Constructor for testing. |
| 54 LocalRTCStatsRequest(); | 54 LocalRTCStatsRequest(); |
| 55 | 55 |
| 56 virtual bool hasSelector() const; | 56 virtual bool hasSelector() const; |
| 57 virtual WebKit::WebMediaStreamTrack component() const; | 57 virtual blink::WebMediaStreamTrack component() const; |
| 58 virtual void requestSucceeded(const LocalRTCStatsResponse* response); | 58 virtual void requestSucceeded(const LocalRTCStatsResponse* response); |
| 59 virtual scoped_refptr<LocalRTCStatsResponse> createResponse(); | 59 virtual scoped_refptr<LocalRTCStatsResponse> createResponse(); |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 virtual ~LocalRTCStatsRequest(); | 62 virtual ~LocalRTCStatsRequest(); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 WebKit::WebRTCStatsRequest impl_; | 65 blink::WebRTCStatsRequest impl_; |
| 66 talk_base::scoped_refptr<LocalRTCStatsResponse> response_; | 66 talk_base::scoped_refptr<LocalRTCStatsResponse> response_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // RTCPeerConnectionHandler is a delegate for the RTC PeerConnection API | 69 // RTCPeerConnectionHandler is a delegate for the RTC PeerConnection API |
| 70 // messages going between WebKit and native PeerConnection in libjingle. It's | 70 // messages going between WebKit and native PeerConnection in libjingle. It's |
| 71 // owned by WebKit. | 71 // owned by WebKit. |
| 72 // WebKit calls all of these methods on the main render thread. | 72 // WebKit calls all of these methods on the main render thread. |
| 73 // Callbacks to the webrtc::PeerConnectionObserver implementation also occur on | 73 // Callbacks to the webrtc::PeerConnectionObserver implementation also occur on |
| 74 // the main render thread. | 74 // the main render thread. |
| 75 class CONTENT_EXPORT RTCPeerConnectionHandler | 75 class CONTENT_EXPORT RTCPeerConnectionHandler |
| 76 : public PeerConnectionHandlerBase, | 76 : public PeerConnectionHandlerBase, |
| 77 NON_EXPORTED_BASE(public WebKit::WebRTCPeerConnectionHandler) { | 77 NON_EXPORTED_BASE(public blink::WebRTCPeerConnectionHandler) { |
| 78 public: | 78 public: |
| 79 RTCPeerConnectionHandler( | 79 RTCPeerConnectionHandler( |
| 80 WebKit::WebRTCPeerConnectionHandlerClient* client, | 80 blink::WebRTCPeerConnectionHandlerClient* client, |
| 81 MediaStreamDependencyFactory* dependency_factory); | 81 MediaStreamDependencyFactory* dependency_factory); |
| 82 virtual ~RTCPeerConnectionHandler(); | 82 virtual ~RTCPeerConnectionHandler(); |
| 83 | 83 |
| 84 void associateWithFrame(WebKit::WebFrame* frame); | 84 void associateWithFrame(blink::WebFrame* frame); |
| 85 | 85 |
| 86 // Initialize method only used for unit test. | 86 // Initialize method only used for unit test. |
| 87 bool InitializeForTest( | 87 bool InitializeForTest( |
| 88 const WebKit::WebRTCConfiguration& server_configuration, | 88 const blink::WebRTCConfiguration& server_configuration, |
| 89 const WebKit::WebMediaConstraints& options, | 89 const blink::WebMediaConstraints& options, |
| 90 PeerConnectionTracker* peer_connection_tracker); | 90 PeerConnectionTracker* peer_connection_tracker); |
| 91 | 91 |
| 92 // WebKit::WebRTCPeerConnectionHandler implementation | 92 // blink::WebRTCPeerConnectionHandler implementation |
| 93 virtual bool initialize( | 93 virtual bool initialize( |
| 94 const WebKit::WebRTCConfiguration& server_configuration, | 94 const blink::WebRTCConfiguration& server_configuration, |
| 95 const WebKit::WebMediaConstraints& options) OVERRIDE; | 95 const blink::WebMediaConstraints& options) OVERRIDE; |
| 96 | 96 |
| 97 virtual void createOffer( | 97 virtual void createOffer( |
| 98 const WebKit::WebRTCSessionDescriptionRequest& request, | 98 const blink::WebRTCSessionDescriptionRequest& request, |
| 99 const WebKit::WebMediaConstraints& options) OVERRIDE; | 99 const blink::WebMediaConstraints& options) OVERRIDE; |
| 100 virtual void createAnswer( | 100 virtual void createAnswer( |
| 101 const WebKit::WebRTCSessionDescriptionRequest& request, | 101 const blink::WebRTCSessionDescriptionRequest& request, |
| 102 const WebKit::WebMediaConstraints& options) OVERRIDE; | 102 const blink::WebMediaConstraints& options) OVERRIDE; |
| 103 | 103 |
| 104 virtual void setLocalDescription( | 104 virtual void setLocalDescription( |
| 105 const WebKit::WebRTCVoidRequest& request, | 105 const blink::WebRTCVoidRequest& request, |
| 106 const WebKit::WebRTCSessionDescription& description) OVERRIDE; | 106 const blink::WebRTCSessionDescription& description) OVERRIDE; |
| 107 virtual void setRemoteDescription( | 107 virtual void setRemoteDescription( |
| 108 const WebKit::WebRTCVoidRequest& request, | 108 const blink::WebRTCVoidRequest& request, |
| 109 const WebKit::WebRTCSessionDescription& description) OVERRIDE; | 109 const blink::WebRTCSessionDescription& description) OVERRIDE; |
| 110 | 110 |
| 111 virtual WebKit::WebRTCSessionDescription localDescription() | 111 virtual blink::WebRTCSessionDescription localDescription() |
| 112 OVERRIDE; | 112 OVERRIDE; |
| 113 virtual WebKit::WebRTCSessionDescription remoteDescription() | 113 virtual blink::WebRTCSessionDescription remoteDescription() |
| 114 OVERRIDE; | 114 OVERRIDE; |
| 115 virtual bool updateICE( | 115 virtual bool updateICE( |
| 116 const WebKit::WebRTCConfiguration& server_configuration, | 116 const blink::WebRTCConfiguration& server_configuration, |
| 117 const WebKit::WebMediaConstraints& options) OVERRIDE; | 117 const blink::WebMediaConstraints& options) OVERRIDE; |
| 118 virtual bool addICECandidate( | 118 virtual bool addICECandidate( |
| 119 const WebKit::WebRTCICECandidate& candidate) OVERRIDE; | 119 const blink::WebRTCICECandidate& candidate) OVERRIDE; |
| 120 | 120 |
| 121 virtual bool addStream( | 121 virtual bool addStream( |
| 122 const WebKit::WebMediaStream& stream, | 122 const blink::WebMediaStream& stream, |
| 123 const WebKit::WebMediaConstraints& options) OVERRIDE; | 123 const blink::WebMediaConstraints& options) OVERRIDE; |
| 124 virtual void removeStream( | 124 virtual void removeStream( |
| 125 const WebKit::WebMediaStream& stream) OVERRIDE; | 125 const blink::WebMediaStream& stream) OVERRIDE; |
| 126 virtual void getStats( | 126 virtual void getStats( |
| 127 const WebKit::WebRTCStatsRequest& request) OVERRIDE; | 127 const blink::WebRTCStatsRequest& request) OVERRIDE; |
| 128 virtual WebKit::WebRTCDataChannelHandler* createDataChannel( | 128 virtual blink::WebRTCDataChannelHandler* createDataChannel( |
| 129 const WebKit::WebString& label, | 129 const blink::WebString& label, |
| 130 const WebKit::WebRTCDataChannelInit& init) OVERRIDE; | 130 const blink::WebRTCDataChannelInit& init) OVERRIDE; |
| 131 virtual WebKit::WebRTCDTMFSenderHandler* createDTMFSender( | 131 virtual blink::WebRTCDTMFSenderHandler* createDTMFSender( |
| 132 const WebKit::WebMediaStreamTrack& track) OVERRIDE; | 132 const blink::WebMediaStreamTrack& track) OVERRIDE; |
| 133 virtual void stop() OVERRIDE; | 133 virtual void stop() OVERRIDE; |
| 134 | 134 |
| 135 // webrtc::PeerConnectionObserver implementation | 135 // webrtc::PeerConnectionObserver implementation |
| 136 virtual void OnError() OVERRIDE; | 136 virtual void OnError() OVERRIDE; |
| 137 // Triggered when the SignalingState changed. | 137 // Triggered when the SignalingState changed. |
| 138 virtual void OnSignalingChange( | 138 virtual void OnSignalingChange( |
| 139 webrtc::PeerConnectionInterface::SignalingState new_state) OVERRIDE; | 139 webrtc::PeerConnectionInterface::SignalingState new_state) OVERRIDE; |
| 140 virtual void OnAddStream(webrtc::MediaStreamInterface* stream) OVERRIDE; | 140 virtual void OnAddStream(webrtc::MediaStreamInterface* stream) OVERRIDE; |
| 141 virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream) OVERRIDE; | 141 virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream) OVERRIDE; |
| 142 virtual void OnIceCandidate( | 142 virtual void OnIceCandidate( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 155 virtual void getStats(LocalRTCStatsRequest* request); | 155 virtual void getStats(LocalRTCStatsRequest* request); |
| 156 | 156 |
| 157 // Calls GetStats on |native_peer_connection_|. | 157 // Calls GetStats on |native_peer_connection_|. |
| 158 void GetStats(webrtc::StatsObserver* observer, | 158 void GetStats(webrtc::StatsObserver* observer, |
| 159 webrtc::MediaStreamTrackInterface* track); | 159 webrtc::MediaStreamTrackInterface* track); |
| 160 | 160 |
| 161 PeerConnectionTracker* peer_connection_tracker(); | 161 PeerConnectionTracker* peer_connection_tracker(); |
| 162 | 162 |
| 163 private: | 163 private: |
| 164 webrtc::SessionDescriptionInterface* CreateNativeSessionDescription( | 164 webrtc::SessionDescriptionInterface* CreateNativeSessionDescription( |
| 165 const WebKit::WebRTCSessionDescription& description, | 165 const blink::WebRTCSessionDescription& description, |
| 166 webrtc::SdpParseError* error); | 166 webrtc::SdpParseError* error); |
| 167 | 167 |
| 168 // |client_| is a weak pointer, and is valid until stop() has returned. | 168 // |client_| is a weak pointer, and is valid until stop() has returned. |
| 169 WebKit::WebRTCPeerConnectionHandlerClient* client_; | 169 blink::WebRTCPeerConnectionHandlerClient* client_; |
| 170 | 170 |
| 171 WebKit::WebFrame* frame_; | 171 blink::WebFrame* frame_; |
| 172 | 172 |
| 173 PeerConnectionTracker* peer_connection_tracker_; | 173 PeerConnectionTracker* peer_connection_tracker_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(RTCPeerConnectionHandler); | 175 DISALLOW_COPY_AND_ASSIGN(RTCPeerConnectionHandler); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace content | 178 } // namespace content |
| 179 | 179 |
| 180 #endif // CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_ | 180 #endif // CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_ |
| OLD | NEW |