⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 236478 in webkit


Ignore:
Timestamp:
Sep 25, 2018, 2:59:35 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Implement MediaStreamTrack Content Hints
​https://bugs.webkit.org/show_bug.cgi?id=189262
<rdar://problem/44101773>

Patch by YUHAN WU <​yuhan_wu@apple.com> on 2018-09-25
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

  • web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint-expected.txt:

Source/WebCore:

contentHint is a new attribute which is stored in MediaStreamTrackPrivate.
​https://w3c.github.io/mst-content-hint/

Covered by tests:
LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint.html
LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/idlharness.window.html

  • Modules/mediastream/MediaStreamTrack.cpp:

(WebCore::MediaStreamTrack::contentHint const):
(WebCore::MediaStreamTrack::setContentHint):

  • Modules/mediastream/MediaStreamTrack.h:
  • Modules/mediastream/MediaStreamTrack.idl:
  • platform/mediastream/MediaStreamTrackPrivate.cpp:

(WebCore::MediaStreamTrackPrivate::setContentHint):
(WebCore::MediaStreamTrackPrivate::clone):

  • platform/mediastream/MediaStreamTrackPrivate.h:

(WebCore::MediaStreamTrackPrivate::contentHint):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r236467 r236478  
     12018-09-25  YUHAN WU  <yuhan_wu@apple.com>
     2
     3        Implement MediaStreamTrack Content Hints
     4        https://bugs.webkit.org/show_bug.cgi?id=189262
     5        <rdar://problem/44101773>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        * web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint-expected.txt:
     10
    1112018-09-25  YUHAN WU  <yuhan_wu@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint-expected.txt

    r236367 r236478  
    11
    2 FAIL Tracks have empty default content hint assert_equals: expected (undefined) undefined but got (string) ""
     2PASS Tracks have empty default content hint
    33PASS Accepts valid audio contentHints
    4 FAIL Audio tracks ignore invalid/video contentHints assert_equals: Audio tracks should ignore video-only contentHints. expected "speech" but got "motion"
     4PASS Audio tracks ignore invalid/video contentHints
    55PASS Accepts valid video contentHints
    6 FAIL Video tracks ignore invalid/audio contentHints assert_equals: Video tracks should ignore audio-only contentHints. expected "motion" but got "speech"
    7 FAIL Cloned video tracks have separate contentHints assert_equals: expected (string) "motion" but got (undefined) undefined
    8 FAIL Cloned audio tracks have separate contentHints assert_equals: expected (string) "speech" but got (undefined) undefined
     6PASS Video tracks ignore invalid/audio contentHints
     7FAIL Cloned video tracks have separate contentHints assert_equals: expected "motion" but got ""
     8PASS Cloned audio tracks have separate contentHints
    99
  • trunk/Source/WebCore/ChangeLog

    r236474 r236478  
     12018-09-25  YUHAN WU  <yuhan_wu@apple.com>
     2
     3        Implement MediaStreamTrack Content Hints
     4        https://bugs.webkit.org/show_bug.cgi?id=189262
     5        <rdar://problem/44101773>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        contentHint is a new attribute which is stored in MediaStreamTrackPrivate.
     10        https://w3c.github.io/mst-content-hint/
     11
     12        Covered by tests:
     13        LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint.html
     14        LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/idlharness.window.html
     15
     16        * Modules/mediastream/MediaStreamTrack.cpp:
     17        (WebCore::MediaStreamTrack::contentHint const):
     18        (WebCore::MediaStreamTrack::setContentHint):
     19        * Modules/mediastream/MediaStreamTrack.h:
     20        * Modules/mediastream/MediaStreamTrack.idl:
     21        * platform/mediastream/MediaStreamTrackPrivate.cpp:
     22        (WebCore::MediaStreamTrackPrivate::setContentHint):
     23        (WebCore::MediaStreamTrackPrivate::clone):
     24        * platform/mediastream/MediaStreamTrackPrivate.h:
     25        (WebCore::MediaStreamTrackPrivate::contentHint):
     26
    1272018-09-25  Alex Christensen  <achristensen@webkit.org>
    228
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp

    r234995 r236478  
    9393}
    9494
     95const AtomicString& MediaStreamTrack::contentHint() const
     96{
     97    static NeverDestroyed<const AtomicString> speechHint("speech", AtomicString::ConstructFromLiteral);
     98    static NeverDestroyed<const AtomicString> musicHint("music", AtomicString::ConstructFromLiteral);
     99    static NeverDestroyed<const AtomicString> detailHint("detail", AtomicString::ConstructFromLiteral);
     100    static NeverDestroyed<const AtomicString> textHint("text", AtomicString::ConstructFromLiteral);
     101    static NeverDestroyed<const AtomicString> motionHint("motion", AtomicString::ConstructFromLiteral);
     102
     103    switch (m_private->contentHint()) {
     104    case MediaStreamTrackPrivate::HintValue::Empty:
     105        return emptyAtom();
     106    case MediaStreamTrackPrivate::HintValue::Speech:
     107        return speechHint;
     108    case MediaStreamTrackPrivate::HintValue::Music:
     109        return musicHint;
     110    case MediaStreamTrackPrivate::HintValue::Motion:
     111        return motionHint;
     112    case MediaStreamTrackPrivate::HintValue::Detail:
     113        return detailHint;
     114    case MediaStreamTrackPrivate::HintValue::Text:
     115        return textHint;
     116    default:
     117        return emptyAtom();
     118    }
     119}
     120
     121void MediaStreamTrack::setContentHint(const String& hintValue)
     122{
     123    MediaStreamTrackPrivate::HintValue value;
     124    if (m_private->type() == RealtimeMediaSource::Type::Audio) {
     125        if (hintValue == "")
     126            value = MediaStreamTrackPrivate::HintValue::Empty;
     127        else if (hintValue == "speech")
     128            value = MediaStreamTrackPrivate::HintValue::Speech;
     129        else if (hintValue == "music")
     130            value = MediaStreamTrackPrivate::HintValue::Music;
     131        else
     132            return;
     133    } else {
     134        if (hintValue == "")
     135            value = MediaStreamTrackPrivate::HintValue::Empty;
     136        else if (hintValue == "detail")
     137            value = MediaStreamTrackPrivate::HintValue::Detail;
     138        else if (hintValue == "motion")
     139            value = MediaStreamTrackPrivate::HintValue::Motion;
     140        else if (hintValue == "text")
     141            value = MediaStreamTrackPrivate::HintValue::Text;
     142        else
     143            return;
     144    }
     145    m_private->setContentHint(value);
     146}
     147
    95148bool MediaStreamTrack::enabled() const
    96149{
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h

    r232754 r236478  
    7070    const String& label() const;
    7171
     72
     73    const AtomicString& contentHint() const;
     74    void setContentHint(const String&);
     75       
    7276    bool enabled() const;
    7377    void setEnabled(bool);
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl

    r232754 r236478  
    3838    readonly attribute DOMString label;
    3939    attribute boolean enabled;
     40    attribute DOMString contentHint;
    4041    readonly attribute boolean muted;
    4142    attribute EventHandler onmute;
  • trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp

    r234334 r236478  
    9797}
    9898
     99void MediaStreamTrackPrivate::setContentHint(HintValue hintValue)
     100{
     101    m_contentHint = hintValue;
     102}
     103   
    99104bool MediaStreamTrackPrivate::muted() const
    100105{
    … …  
    143148    clonedMediaStreamTrackPrivate->m_isEnabled = this->m_isEnabled;
    144149    clonedMediaStreamTrackPrivate->m_isEnded = this->m_isEnded;
     150    clonedMediaStreamTrackPrivate->m_contentHint = this->m_contentHint;
    145151    clonedMediaStreamTrackPrivate->updateReadyState();
    146152
  • trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h

    r234334 r236478  
    6767    bool ended() const { return m_isEnded; }
    6868
     69    enum class HintValue { Empty, Speech, Music, Motion, Detail, Text };
     70    HintValue contentHint() const { return m_contentHint; }
     71    void setContentHint(HintValue);
     72   
    6973    void startProducingData() { m_source->start(); }
    7074    void stopProducingData() { m_source->stop(); }
    … …  
    130134    bool m_isEnded { false };
    131135    bool m_haveProducedData { false };
     136    HintValue m_contentHint { HintValue::Empty };
    132137    RefPtr<WebAudioSourceProvider> m_audioSourceProvider;
    133138};
Note: See TracChangeset for help on using the changeset viewer.