Changeset 144748 in webkit


Ignore:
Timestamp:
Mar 5, 2013 3:34:38 AM (11 years ago)
Author:
tommyw@google.com
Message:

MediaStream API: Add the getStreamById method on RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=111311

Reviewed by Adam Barth.

Source/Platform:

Added an initial initialize method which doesn't take an id;
the id will be generated for you.

  • chromium/public/WebMediaStream.h:

(WebMediaStream):

Source/WebCore:

Adding the missing method on RTCPeerConnection defined here:
http://dev.w3.org/2011/webrtc/editor/webrtc.html#widl-RTCPeerConnection-getStreamById-MediaStream-DOMString-streamId

Existing tests have been extended to cover patch.

  • Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::getStreamById):
(WebCore):

  • Modules/mediastream/RTCPeerConnection.h:

(RTCPeerConnection):

  • Modules/mediastream/RTCPeerConnection.idl:
  • platform/chromium/support/WebMediaStream.cpp:

(WebKit::WebMediaStream::initialize):
(WebKit):

  • platform/mediastream/MediaStreamSource.cpp:

(WebCore::MediaStreamSource::setReadyState):

Tools:

Changing mocks to be more realistic.

  • DumpRenderTree/chromium/TestRunner/src/MockWebRTCPeerConnectionHandler.cpp:

(WebTestRunner::MockWebRTCPeerConnectionHandler::addStream):
(WebTestRunner::MockWebRTCPeerConnectionHandler::removeStream):

  • DumpRenderTree/chromium/TestRunner/src/WebUserMediaClientMock.cpp:

(WebTestRunner::WebUserMediaClientMock::requestUserMedia):

LayoutTests:

  • fast/mediastream/MediaStream-add-remove-tracks.html:
  • fast/mediastream/RTCPeerConnection-AddRemoveStream-expected.txt:
  • fast/mediastream/RTCPeerConnection-AddRemoveStream.html:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r144747 r144748  
     12013-03-05  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Add the getStreamById method on RTCPeerConnection
     4        https://bugs.webkit.org/show_bug.cgi?id=111311
     5
     6        Reviewed by Adam Barth.
     7
     8        * fast/mediastream/MediaStream-add-remove-tracks.html:
     9        * fast/mediastream/RTCPeerConnection-AddRemoveStream-expected.txt:
     10        * fast/mediastream/RTCPeerConnection-AddRemoveStream.html:
     11
    1122013-03-05  Antoine Quint  <graouts@apple.com>
    213
  • trunk/LayoutTests/fast/mediastream/MediaStream-add-remove-tracks.html

    r144610 r144748  
    8484    // (re-)add tracks
    8585    tryAddTrack(stream1, audioTrack);
    86     tryAddTrack(stream1, videoTrack);   
     86    tryAddTrack(stream1, videoTrack);
    8787
    8888    // verify added tracks
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-AddRemoveStream-expected.txt

    r141871 r144748  
    66PASS Got a stream.
    77PASS Got another stream.
     8PASS stream.id === stream2.id is false
    89PASS onAddStream was called.
     10PASS pc.getStreamById(stream.id) is stream
     11PASS pc.getStreamById(stream2.id) is null
    912PASS pc.getLocalStreams().length is 1
    1013PASS pc.getLocalStreams().length is 1
  • trunk/LayoutTests/fast/mediastream/RTCPeerConnection-AddRemoveStream.html

    r141871 r144748  
    2626}
    2727
    28 function onErroneousRemoveStream() {
    29     testFailed('onErroneousRemoveStream was called.');
     28function onErroneousNegotiationNeeded() {
     29    testFailed('onErroneousNegotiationNeeded was called.');
    3030    finishJSTest();
    3131}
     
    3939}
    4040
    41 function onErroneousAddStream() {
    42     testFailed('onErroneousAddStream was called.');
    43     finishJSTest();
    44 }
    45 
    4641function onAddStream(event) {
    4742    testPassed('onAddStream was called.');
    4843
    49     pc.onaddstream = onErroneousAddStream;
     44    shouldBe('pc.getStreamById(stream.id)', 'stream');
     45    shouldBe('pc.getStreamById(stream2.id)', 'null');
     46
     47    pc.onnegotiationneeded = onErroneousNegotiationNeeded;
    5048    pc.addStream(stream);
    5149    shouldBe('pc.getLocalStreams().length', '1');
    52 
    53     pc.onremovestream = onErroneousRemoveStream;
    5450    pc.removeStream(stream2);
    5551    shouldBe('pc.getLocalStreams().length', '1');
    5652
    57     pc.onremovestream = onRemoveStream;
     53    pc.onnegotiationneeded = onRemoveStream;
    5854    pc.removeStream(stream);
    5955}
     
    6359    stream2 = s;
    6460
     61    shouldBeFalse("stream.id === stream2.id");
     62
    6563    pc = new webkitRTCPeerConnection(null, null);
    66 
    67     pc.onaddstream = onAddStream;
     64    pc.onnegotiationneeded = onAddStream;
    6865    pc.addStream(stream);
    6966}
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r144736 r144748  
    44134413# These test are failing since r144519
    44144414webkit.org/b/109769 [ Mac ] fast/events/touch/gesture/touch-gesture-noscroll-body-yhidden.html [ Failure ]
    4415 webkit.org/b/109769 [ Mac ] fast/events/touch/gesture/touch-gesture-noscroll-body-propagated.html [ Failure ]
    4416 
    4417 # New crashing test since r144610
    4418 webkit.org/b/111410 [ Debug ] fast/mediastream/MediaStream-add-remove-tracks.html [ Crash ]
     4415webkit.org/b/109769 [ Mac ] fast/events/touch/gesture/touch-gesture-noscroll-body-propagated.html [ Failure ]
  • trunk/Source/Platform/ChangeLog

    r144720 r144748  
     12013-03-05  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Add the getStreamById method on RTCPeerConnection
     4        https://bugs.webkit.org/show_bug.cgi?id=111311
     5
     6        Reviewed by Adam Barth.
     7
     8        Added an initial initialize method which doesn't take an id;
     9        the id will be generated for you.
     10
     11        * chromium/public/WebMediaStream.h:
     12        (WebMediaStream):
     13
    1142013-03-04  Chris Rogers  <crogers@google.com>
    215
  • trunk/Source/Platform/chromium/public/WebMediaStream.h

    r142773 r144748  
    6363    WEBKIT_EXPORT void initialize(const WebString& label, const WebVector<WebMediaStreamSource>& audioSources, const WebVector<WebMediaStreamSource>& videoSources);
    6464
     65    WEBKIT_EXPORT void initialize(const WebVector<WebMediaStreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks);
    6566    WEBKIT_EXPORT void initialize(const WebString& label, const WebVector<WebMediaStreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks);
    6667
  • trunk/Source/WebCore/ChangeLog

    r144747 r144748  
     12013-03-05  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Add the getStreamById method on RTCPeerConnection
     4        https://bugs.webkit.org/show_bug.cgi?id=111311
     5
     6        Reviewed by Adam Barth.
     7
     8        Adding the missing method on RTCPeerConnection defined here:
     9        http://dev.w3.org/2011/webrtc/editor/webrtc.html#widl-RTCPeerConnection-getStreamById-MediaStream-DOMString-streamId
     10
     11        Existing tests have been extended to cover patch.
     12
     13        * Modules/mediastream/RTCPeerConnection.cpp:
     14        (WebCore::RTCPeerConnection::getStreamById):
     15        (WebCore):
     16        * Modules/mediastream/RTCPeerConnection.h:
     17        (RTCPeerConnection):
     18        * Modules/mediastream/RTCPeerConnection.idl:
     19        * platform/chromium/support/WebMediaStream.cpp:
     20        (WebKit::WebMediaStream::initialize):
     21        (WebKit):
     22        * platform/mediastream/MediaStreamSource.cpp:
     23        (WebCore::MediaStreamSource::setReadyState):
     24
    1252013-03-05  Antoine Quint  <graouts@apple.com>
    226
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r144568 r144748  
    432432}
    433433
     434MediaStream* RTCPeerConnection::getStreamById(const String& streamId)
     435{
     436    for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_localStreams.end(); ++iter) {
     437        if ((*iter)->id() == streamId)
     438            return iter->get();
     439    }
     440
     441    for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_remoteStreams.end(); ++iter) {
     442        if ((*iter)->id() == streamId)
     443            return iter->get();
     444    }
     445
     446    return 0;
     447}
     448
    434449void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, PassRefPtr<MediaStreamTrack> selector)
    435450{
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h

    r141984 r144748  
    9090    MediaStreamVector getRemoteStreams() const;
    9191
     92    MediaStream* getStreamById(const String& streamId);
     93
    9294    void addStream(PassRefPtr<MediaStream>, const Dictionary& mediaConstraints, ExceptionCode&);
    9395
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl

    r141984 r144748  
    6969    sequence<MediaStream> getLocalStreams();
    7070    sequence<MediaStream> getRemoteStreams();
     71    MediaStream getStreamById(DOMString streamId);
    7172
    7273    [StrictTypeChecking] void addStream(in MediaStream stream, in [Optional] Dictionary mediaConstraints)
  • trunk/Source/WebCore/platform/chromium/support/WebMediaStream.cpp

    r142773 r144748  
    3232#include "MediaStreamDescriptor.h"
    3333#include "MediaStreamSource.h"
     34#include "UUID.h"
    3435#include <public/WebMediaStreamSource.h>
    3536#include <public/WebMediaStreamTrack.h>
     
    143144}
    144145
     146void WebMediaStream::initialize(const WebVector<WebMediaStreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks)
     147{
     148    initialize(createCanonicalUUIDString(), audioTracks, videoTracks);
     149}
     150
    145151void WebMediaStream::initialize(const WebString& label, const WebVector<WebMediaStreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks)
    146152{
  • trunk/Source/WebCore/platform/mediastream/MediaStreamSource.cpp

    r138895 r144748  
    5454void MediaStreamSource::setReadyState(ReadyState readyState)
    5555{
    56     ASSERT(m_readyState != ReadyStateEnded);
    57     if (m_readyState != readyState) {
     56    if (m_readyState != ReadyStateEnded && m_readyState != readyState) {
    5857        m_readyState = readyState;
    5958        for (Vector<Observer*>::iterator i = m_observers.begin(); i != m_observers.end(); ++i)
  • trunk/Tools/ChangeLog

    r144739 r144748  
     12013-03-05  Tommy Widenflycht  <tommyw@google.com>
     2
     3        MediaStream API: Add the getStreamById method on RTCPeerConnection
     4        https://bugs.webkit.org/show_bug.cgi?id=111311
     5
     6        Reviewed by Adam Barth.
     7
     8        Changing mocks to be more realistic.
     9
     10        * DumpRenderTree/chromium/TestRunner/src/MockWebRTCPeerConnectionHandler.cpp:
     11        (WebTestRunner::MockWebRTCPeerConnectionHandler::addStream):
     12        (WebTestRunner::MockWebRTCPeerConnectionHandler::removeStream):
     13        * DumpRenderTree/chromium/TestRunner/src/WebUserMediaClientMock.cpp:
     14        (WebTestRunner::WebUserMediaClientMock::requestUserMedia):
     15
    1162013-03-05  Jochen Eisinger  <jochen@chromium.org>
    217
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/MockWebRTCPeerConnectionHandler.cpp

    r142790 r144748  
    256256bool MockWebRTCPeerConnectionHandler::addStream(const WebMediaStream& stream, const WebMediaConstraints&)
    257257{
    258     m_streamCount += 1;
    259     m_client->didAddRemoteStream(stream);
     258    ++m_streamCount;
    260259    m_client->negotiationNeeded();
    261260    return true;
     
    264263void MockWebRTCPeerConnectionHandler::removeStream(const WebMediaStream& stream)
    265264{
    266     m_streamCount -= 1;
    267     m_client->didRemoveRemoteStream(stream);
     265    --m_streamCount;
    268266    m_client->negotiationNeeded();
    269267}
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebUserMediaClientMock.cpp

    r142790 r144748  
    122122
    123123    WebMediaStream stream;
    124     stream.initialize("foobar", audioTracks, videoTracks);
     124    stream.initialize(audioTracks, videoTracks);
    125125
    126126    stream.setExtraData(new MockExtraData());
Note: See TracChangeset for help on using the changeset viewer.