Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / renderer / media / rtc_peer_connection_handler.h
index 3944376..ec5f775 100644 (file)
@@ -5,10 +5,13 @@
 #ifndef CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_
 #define CONTENT_RENDERER_MEDIA_RTC_PEER_CONNECTION_HANDLER_H_
 
+#include <map>
+#include <string>
+
 #include "base/basictypes.h"
 #include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
 #include "content/common/content_export.h"
-#include "content/renderer/media/peer_connection_handler_base.h"
 #include "content/renderer/media/webrtc/media_stream_track_metrics.h"
 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandler.h"
 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h"
 namespace blink {
 class WebFrame;
 class WebRTCDataChannelHandler;
+class WebRTCOfferOptions;
 }
 
 namespace content {
 
+class PeerConnectionDependencyFactory;
 class PeerConnectionTracker;
+class RemoteMediaStreamImpl;
+class RTCMediaConstraints;
+class WebRtcMediaStreamAdapter;
 
 // Mockable wrapper for blink::WebRTCStatsResponse
 class CONTENT_EXPORT LocalRTCStatsResponse
-    : public NON_EXPORTED_BASE(talk_base::RefCountInterface) {
+    : public NON_EXPORTED_BASE(rtc::RefCountInterface) {
  public:
   explicit LocalRTCStatsResponse(const blink::WebRTCStatsResponse& impl)
       : impl_(impl) {
@@ -48,7 +56,7 @@ class CONTENT_EXPORT LocalRTCStatsResponse
 
 // Mockable wrapper for blink::WebRTCStatsRequest
 class CONTENT_EXPORT LocalRTCStatsRequest
-    : public NON_EXPORTED_BASE(talk_base::RefCountInterface) {
+    : public NON_EXPORTED_BASE(rtc::RefCountInterface) {
  public:
   explicit LocalRTCStatsRequest(blink::WebRTCStatsRequest impl);
   // Constructor for testing.
@@ -64,7 +72,7 @@ class CONTENT_EXPORT LocalRTCStatsRequest
 
  private:
   blink::WebRTCStatsRequest impl_;
-  talk_base::scoped_refptr<LocalRTCStatsResponse> response_;
+  rtc::scoped_refptr<LocalRTCStatsResponse> response_;
 };
 
 // RTCPeerConnectionHandler is a delegate for the RTC PeerConnection API
@@ -74,14 +82,21 @@ class CONTENT_EXPORT LocalRTCStatsRequest
 // Callbacks to the webrtc::PeerConnectionObserver implementation also occur on
 // the main render thread.
 class CONTENT_EXPORT RTCPeerConnectionHandler
-    : public PeerConnectionHandlerBase,
-      NON_EXPORTED_BASE(public blink::WebRTCPeerConnectionHandler) {
+    : NON_EXPORTED_BASE(public blink::WebRTCPeerConnectionHandler),
+      NON_EXPORTED_BASE(public webrtc::PeerConnectionObserver) {
  public:
   RTCPeerConnectionHandler(
       blink::WebRTCPeerConnectionHandlerClient* client,
-      MediaStreamDependencyFactory* dependency_factory);
+      PeerConnectionDependencyFactory* dependency_factory);
   virtual ~RTCPeerConnectionHandler();
 
+  // Destroy all existing RTCPeerConnectionHandler objects.
+  static void DestructAllHandlers();
+
+  static void ConvertOfferOptionsToConstraints(
+      const blink::WebRTCOfferOptions& options,
+      RTCMediaConstraints* output);
+
   void associateWithFrame(blink::WebFrame* frame);
 
   // Initialize method only used for unit test.
@@ -98,6 +113,10 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
   virtual void createOffer(
       const blink::WebRTCSessionDescriptionRequest& request,
       const blink::WebMediaConstraints& options) OVERRIDE;
+  virtual void createOffer(
+      const blink::WebRTCSessionDescriptionRequest& request,
+      const blink::WebRTCOfferOptions& options) OVERRIDE;
+
   virtual void createAnswer(
       const blink::WebRTCSessionDescriptionRequest& request,
       const blink::WebMediaConstraints& options) OVERRIDE;
@@ -168,6 +187,11 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
 
   PeerConnectionTracker* peer_connection_tracker();
 
+ protected:
+  webrtc::PeerConnectionInterface* native_peer_connection() {
+    return native_peer_connection_.get();
+  }
+
  private:
   webrtc::SessionDescriptionInterface* CreateNativeSessionDescription(
       const blink::WebRTCSessionDescription& description,
@@ -176,8 +200,14 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
   // |client_| is a weak pointer, and is valid until stop() has returned.
   blink::WebRTCPeerConnectionHandlerClient* client_;
 
+  // |dependency_factory_| is a raw pointer, and is valid for the lifetime of
+  // RenderThreadImpl.
+  PeerConnectionDependencyFactory* dependency_factory_;
+
   blink::WebFrame* frame_;
 
+  ScopedVector<WebRtcMediaStreamAdapter> local_streams_;
+
   PeerConnectionTracker* peer_connection_tracker_;
 
   MediaStreamTrackMetrics track_metrics_;
@@ -185,6 +215,15 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
   // Counter for a UMA stat reported at destruction time.
   int num_data_channels_created_;
 
+  // |native_peer_connection_| is the libjingle native PeerConnection object.
+  scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_;
+
+  typedef std::map<webrtc::MediaStreamInterface*,
+      content::RemoteMediaStreamImpl*> RemoteStreamMap;
+  RemoteStreamMap remote_streams_;
+  scoped_refptr<webrtc::UMAObserver> uma_observer_;
+  base::TimeTicks ice_connection_checking_start_;
+
   DISALLOW_COPY_AND_ASSIGN(RTCPeerConnectionHandler);
 };