MediaStream API: Adding the onstatechange callback to PeerConnection
authortommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 09:52:17 +0000 (09:52 +0000)
committertommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Feb 2012 09:52:17 +0000 (09:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77954

When readyState changes a callback should be triggered.

Reviewed by Adam Barth.

Tests for the Media Stream API will be provided by the bug 56587, pending enough landed code.

* dom/EventNames.h:
(WebCore):
* mediastream/PeerConnection.cpp:
(WebCore::PeerConnection::changeReadyState):
* mediastream/PeerConnection.h:
(PeerConnection):
(WebCore::PeerConnection::didChangeState):
* mediastream/PeerConnection.idl:
* platform/mediastream/PeerConnectionHandlerClient.h:
(PeerConnectionHandlerClient):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107054 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/EventNames.h
Source/WebCore/mediastream/PeerConnection.cpp
Source/WebCore/mediastream/PeerConnection.h
Source/WebCore/mediastream/PeerConnection.idl
Source/WebCore/platform/mediastream/PeerConnectionHandlerClient.h

index cc3fa78..767f376 100644 (file)
@@ -1,3 +1,25 @@
+2012-02-08  Tommy Widenflycht  <tommyw@google.com>
+
+        MediaStream API: Adding the onstatechange callback to PeerConnection
+        https://bugs.webkit.org/show_bug.cgi?id=77954
+
+        When readyState changes a callback should be triggered.
+
+        Reviewed by Adam Barth.
+
+        Tests for the Media Stream API will be provided by the bug 56587, pending enough landed code.
+
+        * dom/EventNames.h:
+        (WebCore):
+        * mediastream/PeerConnection.cpp:
+        (WebCore::PeerConnection::changeReadyState):
+        * mediastream/PeerConnection.h:
+        (PeerConnection):
+        (WebCore::PeerConnection::didChangeState):
+        * mediastream/PeerConnection.idl:
+        * platform/mediastream/PeerConnectionHandlerClient.h:
+        (PeerConnectionHandlerClient):
+
 2012-02-08  Kentaro Hara  <haraken@chromium.org>
 
         Rename [DelegatingPutFunction] IDL to [CustomNamedSetter] IDL
index 6464d8c..a616f74 100644 (file)
@@ -194,6 +194,7 @@ namespace WebCore {
     macro(connecting) \
     macro(addstream) \
     macro(removestream) \
+    macro(statechange) \
     \
     macro(show) \
     \
index bb493d7..1194482 100644 (file)
@@ -367,6 +367,8 @@ void PeerConnection::changeReadyState(ReadyState readyState)
     case CLOSED:
         break;
     }
+
+    dispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
 }
 
 } // namespace WebCore
index d29d162..fd2f2fb 100644 (file)
@@ -58,14 +58,6 @@ public:
 
     void processSignalingMessage(const String& message, ExceptionCode&);
 
-    // Name and values of the enum must match the corressponding constants in the .idl file.
-    enum ReadyState {
-        NEW = 0,
-        NEGOTIATING = 1,
-        ACTIVE = 2,
-        CLOSED = 3
-    };
-
     ReadyState readyState() const;
 
     void send(const String& text, ExceptionCode&);
@@ -78,6 +70,7 @@ public:
     DEFINE_ATTRIBUTE_EVENT_LISTENER(connecting);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(open);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
+    DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(addstream);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(removestream);
 
@@ -87,6 +80,7 @@ public:
     virtual void didReceiveDataStreamMessage(const char* data, size_t length);
     virtual void didAddRemoteStream(PassRefPtr<MediaStreamDescriptor>);
     virtual void didRemoveRemoteStream(MediaStreamDescriptor*);
+    virtual void didChangeState(ReadyState state) { changeReadyState(state); }
 
     // EventTarget
     virtual const AtomicString& interfaceName() const;
index 59d35e3..afaebd7 100644 (file)
@@ -58,6 +58,7 @@ module p2p {
         attribute EventListener onconnecting;
         attribute EventListener onopen;
         attribute EventListener onmessage;
+        attribute EventListener onstatechange;
         attribute EventListener onaddstream;
         attribute EventListener onremovestream;
 
index 7d77b5f..e67ef3a 100644 (file)
@@ -42,6 +42,14 @@ class MediaStreamDescriptor;
 
 class PeerConnectionHandlerClient {
 public:
+    // Name and values of the enum must match the corressponding constants in the PeerConnection.idl file.
+    enum ReadyState {
+        NEW = 0,
+        NEGOTIATING = 1,
+        ACTIVE = 2,
+        CLOSED = 3
+    };
+
     virtual ~PeerConnectionHandlerClient() { }
 
     virtual void didCompleteICEProcessing() = 0;
@@ -49,6 +57,7 @@ public:
     virtual void didReceiveDataStreamMessage(const char* data, size_t length) = 0;
     virtual void didAddRemoteStream(PassRefPtr<MediaStreamDescriptor>) = 0;
     virtual void didRemoveRemoteStream(MediaStreamDescriptor*) = 0;
+    virtual void didChangeState(ReadyState) = 0;
 };
 
 } // namespace WebCore