Changeset 156554 in webkit


Ignore:
Timestamp:
Sep 27, 2013 10:40:55 AM (11 years ago)
Author:
eric.carlson@apple.com
Message:

[MediaStream API] update SourceInfo object to match spec
https://bugs.webkit.org/show_bug.cgi?id=121941

Reviewed by Dean Jackson.

Source/WebCore:

No new tests, existing test updated.

  • Modules/mediastream/SourceInfo.cpp:

(WebCore::SourceInfo::kind): Get rid of "none".

  • Modules/mediastream/SourceInfo.h:

(WebCore::SourceInfo::sourceId): Renamed from "id".

  • Modules/mediastream/SourceInfo.idl:
  • platform/mediastream/MediaStreamTrackSourcesRequestClient.h:

(WebCore::TrackSourceInfo::create):
(WebCore::TrackSourceInfo::kind):
(WebCore::TrackSourceInfo::TrackSourceInfo):

  • platform/mock/MockMediaStreamCenter.cpp:

(WebCore::MockMediaStreamCenter::getMediaStreamTrackSources): "facing" isn't a part of sourceInfo.

Return a non-NULL ID because a source must always have one.

LayoutTests:

  • fast/mediastream/MediaStreamTrack-getSources-expected.txt:
  • fast/mediastream/MediaStreamTrack-getSources.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r156553 r156554  
     12013-09-27  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [MediaStream API] update SourceInfo object to match spec
     4        https://bugs.webkit.org/show_bug.cgi?id=121941
     5
     6        Reviewed by Dean Jackson.
     7
     8        * fast/mediastream/MediaStreamTrack-getSources-expected.txt:
     9        * fast/mediastream/MediaStreamTrack-getSources.html:
     10
    1112013-09-26  Dean Jackson  <dino@apple.com>
    212
  • trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSources-expected.txt

    r155992 r156554  
    44
    55
     6
     7*** calling MediaStreamTrack.getSources() ***
    68PASS MediaStreamTrack.getSources(gotSources1); did not throw exception.
    7 PASS gotSources1 was called.
    8 PASS sources.length > 0 is true
    9 PASS gotStream was called.
     9PASS callback called.
     10sources1[0].sourceId = "Mock_audio_device_ID"
     11sources1[0].label = "Mock audio device"
     12sources1[0].kind = "audio"
     13sources1[1].sourceId = "Mock_video_device_ID"
     14sources1[1].label = "Mock video device"
     15sources1[1].kind = "video"
     16
     17*** calling navigator.webkitGetUserMedia() ***
     18PASS navigator.webkitGetUserMedia(constraints, callback, error) did not throw exception.
     19PASS callback called.
     20
     21*** calling MediaStreamTrack.getSources() ***
    1022PASS MediaStreamTrack.getSources(gotSources2); did not throw exception.
    11 PASS gotSources2 was called.
    12 PASS sources.length > 0 is true
    13 PASS sources[0].id === previousId is true
    14 PASS sources[0].label.length > 0 is true
     23PASS callback called.
     24PASS sources2.length == sources1.length is true
     25PASS sources2[0].sourceId === sources1[0].sourceId is true
     26PASS sources2[0].label === sources1[0].label is true
     27PASS sources2[0].kind === sources1[0].kind is true
     28PASS sources2[1].sourceId === sources1[1].sourceId is true
     29PASS sources2[1].label === sources1[1].label is true
     30PASS sources2[1].kind === sources1[1].kind is true
    1531PASS successfullyParsed is true
    1632
  • trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSources.html

    r155992 r156554  
    1010            description("Tests MediaStreamTrack::getSources.");
    1111
    12             var sources = null;
    13             var previousId;
     12            var sources1 = null;
     13            var sources2 = null;
    1414            var timer = null;
    1515
     
    2626            }
    2727
    28             function getUserMedia(constraints, callback)
     28            function getUserMedia(_constraints, _callback)
    2929            {
    3030                try {
    3131                    primeTimeout("Timeout waiting for webkitGetUserMedia()");
    32                     navigator.webkitGetUserMedia(constraints, callback, error);
     32                    constraints = _constraints;
     33                    callback = _callback;
     34                debug("<br>*** calling navigator.webkitGetUserMedia() ***");
     35                    shouldNotThrow("navigator.webkitGetUserMedia(constraints, callback, error)");
    3336                } catch (e) {
    3437                    testFailed('webkitGetUserMedia threw exception :' + e);
     
    3740            }
    3841
    39             function gotSources2(s)
     42            function gotSources2(sources)
    4043            {
    41                 testPassed('gotSources2 was called.');
    42                 sources = s;
    43                 shouldBeTrue('sources.length > 0');
    44                 shouldBeTrue('sources[0].id === previousId');
    45                 shouldBeTrue('sources[0].label.length > 0');
     44                testPassed('callback called.');
     45                sources2 = sources;
     46                shouldBeTrue('sources2.length == sources1.length');
     47                for (i = 0; i < sources2.length; ++i) {
     48                    shouldBeTrue("sources2[" + i + "].sourceId === sources1[" + i + "].sourceId");
     49                    shouldBeTrue("sources2[" + i + "].label === sources1[" + i + "].label");
     50                    shouldBeTrue("sources2[" + i + "].kind === sources1[" + i + "].kind");
     51                }
    4652
    4753                finishTest();
    4854            }
    4955
    50             function gotStream(s)
     56            function gotStream(stream)
    5157            {
    52                 testPassed('gotStream was called.');
     58                testPassed('callback called.');
     59                primeTimeout("Timeout waiting for MediaStreamTrack.getSources()");
    5360
    54                 primeTimeout("Timeout waiting for MediaStreamTrack.getSources()");
     61                debug("<br>*** calling MediaStreamTrack.getSources() ***");
    5562                shouldNotThrow('MediaStreamTrack.getSources(gotSources2);');
    5663            }
    5764
    58             function gotSources1(s)
     65            function gotSources1(sources)
    5966            {
    60                 testPassed('gotSources1 was called.');
    61                 sources = s;
    62                 shouldBeTrue('sources.length > 0');
    63                 previousId = sources[0].id;
     67                testPassed('callback called.');
     68                sources1 = sources;
     69                for (i = 0; i < sources1.length; ++i) {
     70                    debug("sources1[" + i + "].sourceId = \"" + sources1[i].sourceId + "\"");
     71                    debug("sources1[" + i + "].label = \"" + sources1[i].label + "\"");
     72                    debug("sources1[" + i + "].kind = \"" + sources1[i].kind + "\"");
     73                }
    6474
    6575                getUserMedia({audio:true, video:true}, gotStream);
     
    7383
    7484            primeTimeout("Timeout waiting for MediaStreamTrack.getSources()");
     85            debug("<br>*** calling MediaStreamTrack.getSources() ***");
    7586            shouldNotThrow('MediaStreamTrack.getSources(gotSources1);');
    7687
  • trunk/Source/WebCore/ChangeLog

    r156553 r156554  
     12013-09-27  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [MediaStream API] update SourceInfo object to match spec
     4        https://bugs.webkit.org/show_bug.cgi?id=121941
     5
     6        Reviewed by Dean Jackson.
     7
     8        No new tests, existing test updated.
     9
     10        * Modules/mediastream/SourceInfo.cpp:
     11        (WebCore::SourceInfo::kind): Get rid of "none".
     12        * Modules/mediastream/SourceInfo.h:
     13        (WebCore::SourceInfo::sourceId): Renamed from "id".
     14        * Modules/mediastream/SourceInfo.idl:
     15
     16        * platform/mediastream/MediaStreamTrackSourcesRequestClient.h:
     17        (WebCore::TrackSourceInfo::create):
     18        (WebCore::TrackSourceInfo::kind):
     19        (WebCore::TrackSourceInfo::TrackSourceInfo):
     20
     21        * platform/mock/MockMediaStreamCenter.cpp:
     22        (WebCore::MockMediaStreamCenter::getMediaStreamTrackSources): "facing" isn't a part of sourceInfo.
     23            Return a non-NULL ID because a source must always have one.
     24
    1252013-09-26  Dean Jackson  <dino@apple.com>
    226
  • trunk/Source/WebCore/Modules/mediastream/SourceInfo.cpp

    r155992 r156554  
    4646const AtomicString& SourceInfo::kind() const
    4747{
    48     static NeverDestroyed<AtomicString> none("none", AtomicString::ConstructFromLiteral);
    4948    static NeverDestroyed<AtomicString> audioKind("audio", AtomicString::ConstructFromLiteral);
    5049    static NeverDestroyed<AtomicString> videoKind("video", AtomicString::ConstructFromLiteral);
     
    5554    case TrackSourceInfo::Video:
    5655        return videoKind;
    57     case TrackSourceInfo::None:
    58         return none;
    59     }
    60 
    61     ASSERT_NOT_REACHED();
    62     return emptyAtom;
    63 }
    64 
    65 const AtomicString& SourceInfo::facing() const
    66 {
    67     static NeverDestroyed<AtomicString> userFacing("user", AtomicString::ConstructFromLiteral);
    68     static NeverDestroyed<AtomicString> environmentFacing("environment", AtomicString::ConstructFromLiteral);
    69     static NeverDestroyed<AtomicString> leftFacing("left", AtomicString::ConstructFromLiteral);
    70     static NeverDestroyed<AtomicString> rightFacing("right", AtomicString::ConstructFromLiteral);
    71 
    72     switch (m_trackSourceInfo->facing()) {
    73     case TrackSourceInfo::None:
    74         return emptyAtom;
    75     case TrackSourceInfo::User:
    76         return userFacing;
    77     case TrackSourceInfo::Environment:
    78         return environmentFacing;
    79     case TrackSourceInfo::Left:
    80         return leftFacing;
    81     case TrackSourceInfo::Right:
    82         return rightFacing;
    8356    }
    8457
  • trunk/Source/WebCore/Modules/mediastream/SourceInfo.h

    r155992 r156554  
    4343    static PassRefPtr<SourceInfo> create(PassRefPtr<TrackSourceInfo>);
    4444
    45     const AtomicString& id() const { return m_trackSourceInfo->id(); }
     45    const AtomicString& sourceId() const { return m_trackSourceInfo->id(); }
    4646    const AtomicString& label() const { return m_trackSourceInfo->label(); }
    4747    const AtomicString& kind() const;
    48     const AtomicString& facing() const;
    4948
    5049private:
  • trunk/Source/WebCore/Modules/mediastream/SourceInfo.idl

    r155992 r156554  
    2929    Conditional=MEDIA_STREAM,
    3030] interface SourceInfo {
    31     readonly attribute DOMString id;
     31    readonly attribute DOMString sourceId;
    3232    readonly attribute DOMString kind;
    3333    readonly attribute DOMString label;
    34     readonly attribute DOMString facing;
    3534};
  • trunk/Source/WebCore/platform/mediastream/MediaStreamTrackSourcesRequestClient.h

    r155992 r156554  
    3737class TrackSourceInfo : public RefCounted<TrackSourceInfo> {
    3838public:
    39     enum SourceKind { NoSource, Audio, Video };
    40     enum VideoFacingMode { None, User, Environment, Left, Right };
     39    enum SourceKind { Audio, Video };
    4140
    42     static PassRefPtr<TrackSourceInfo> create(const AtomicString& id, SourceKind kind, const AtomicString& label, VideoFacingMode facing)
     41    static PassRefPtr<TrackSourceInfo> create(const AtomicString& id, SourceKind kind, const AtomicString& label)
    4342    {
    44         return adoptRef(new TrackSourceInfo(id, kind, label, facing));
     43        return adoptRef(new TrackSourceInfo(id, kind, label));
    4544    }
    4645
     
    4847    const AtomicString& label() const { return m_label; }
    4948    SourceKind kind() const { return m_kind; }
    50     VideoFacingMode facing() const { return m_facing; }
    5149
    5250private:
    53     TrackSourceInfo(const AtomicString& id, SourceKind kind, const AtomicString& label, VideoFacingMode facing)
     51    TrackSourceInfo(const AtomicString& id, SourceKind kind, const AtomicString& label)
    5452        : m_id(id)
    5553        , m_kind(kind)
    5654        , m_label(label)
    57         , m_facing(facing)
    5855    {
    5956    }
     
    6259    SourceKind m_kind;
    6360    AtomicString m_label;
    64     VideoFacingMode m_facing;
    6561};
    6662
  • trunk/Source/WebCore/platform/mock/MockMediaStreamCenter.cpp

    r156522 r156554  
    156156    Vector<RefPtr<TrackSourceInfo>> sources(2);
    157157
    158     sources[0] = TrackSourceInfo::create(emptyString(), TrackSourceInfo::Audio, "Mock audio device", TrackSourceInfo::None);
    159     sources[1] = TrackSourceInfo::create(emptyString(), TrackSourceInfo::Video, "Mock video device", TrackSourceInfo::Environment);
     158    sources[0] = TrackSourceInfo::create("Mock_audio_device_ID", TrackSourceInfo::Audio, "Mock audio device");
     159    sources[1] = TrackSourceInfo::create("Mock_video_device_ID", TrackSourceInfo::Video, "Mock video device");
    160160
    161161    requestClient->didCompleteRequest(sources);
Note: See TracChangeset for help on using the changeset viewer.