Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (236477 => 236478)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-09-25 21:59:35 UTC (rev 236478)
@@ -1,5 +1,15 @@
2018-09-25 YUHAN WU <yuhan...@apple.com>
+ Implement MediaStreamTrack Content Hints
+ https://bugs.webkit.org/show_bug.cgi?id=189262
+ <rdar://problem/44101773>
+
+ Reviewed by Youenn Fablet.
+
+ * web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint-expected.txt:
+
+2018-09-25 YUHAN WU <yuhan...@apple.com>
+
Import WPT content hint tests
https://bugs.webkit.org/show_bug.cgi?id=189854
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint-expected.txt (236477 => 236478)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint-expected.txt 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mst-content-hint/MediaStreamTrack-contentHint-expected.txt 2018-09-25 21:59:35 UTC (rev 236478)
@@ -1,9 +1,9 @@
-FAIL Tracks have empty default content hint assert_equals: expected (undefined) undefined but got (string) ""
+PASS Tracks have empty default content hint
PASS Accepts valid audio contentHints
-FAIL Audio tracks ignore invalid/video contentHints assert_equals: Audio tracks should ignore video-only contentHints. expected "speech" but got "motion"
+PASS Audio tracks ignore invalid/video contentHints
PASS Accepts valid video contentHints
-FAIL Video tracks ignore invalid/audio contentHints assert_equals: Video tracks should ignore audio-only contentHints. expected "motion" but got "speech"
-FAIL Cloned video tracks have separate contentHints assert_equals: expected (string) "motion" but got (undefined) undefined
-FAIL Cloned audio tracks have separate contentHints assert_equals: expected (string) "speech" but got (undefined) undefined
+PASS Video tracks ignore invalid/audio contentHints
+FAIL Cloned video tracks have separate contentHints assert_equals: expected "motion" but got ""
+PASS Cloned audio tracks have separate contentHints
Modified: trunk/Source/WebCore/ChangeLog (236477 => 236478)
--- trunk/Source/WebCore/ChangeLog 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/Source/WebCore/ChangeLog 2018-09-25 21:59:35 UTC (rev 236478)
@@ -1,3 +1,29 @@
+2018-09-25 YUHAN WU <yuhan...@apple.com>
+
+ Implement MediaStreamTrack Content Hints
+ https://bugs.webkit.org/show_bug.cgi?id=189262
+ <rdar://problem/44101773>
+
+ Reviewed by Youenn Fablet.
+
+ 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):
+
2018-09-25 Alex Christensen <achristen...@webkit.org>
Allow for suffixes to com.apple.WebKit.WebContent
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (236477 => 236478)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2018-09-25 21:59:35 UTC (rev 236478)
@@ -92,6 +92,59 @@
return m_private->label();
}
+const AtomicString& MediaStreamTrack::contentHint() const
+{
+ static NeverDestroyed<const AtomicString> speechHint("speech", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<const AtomicString> musicHint("music", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<const AtomicString> detailHint("detail", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<const AtomicString> textHint("text", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<const AtomicString> motionHint("motion", AtomicString::ConstructFromLiteral);
+
+ switch (m_private->contentHint()) {
+ case MediaStreamTrackPrivate::HintValue::Empty:
+ return emptyAtom();
+ case MediaStreamTrackPrivate::HintValue::Speech:
+ return speechHint;
+ case MediaStreamTrackPrivate::HintValue::Music:
+ return musicHint;
+ case MediaStreamTrackPrivate::HintValue::Motion:
+ return motionHint;
+ case MediaStreamTrackPrivate::HintValue::Detail:
+ return detailHint;
+ case MediaStreamTrackPrivate::HintValue::Text:
+ return textHint;
+ default:
+ return emptyAtom();
+ }
+}
+
+void MediaStreamTrack::setContentHint(const String& hintValue)
+{
+ MediaStreamTrackPrivate::HintValue value;
+ if (m_private->type() == RealtimeMediaSource::Type::Audio) {
+ if (hintValue == "")
+ value = MediaStreamTrackPrivate::HintValue::Empty;
+ else if (hintValue == "speech")
+ value = MediaStreamTrackPrivate::HintValue::Speech;
+ else if (hintValue == "music")
+ value = MediaStreamTrackPrivate::HintValue::Music;
+ else
+ return;
+ } else {
+ if (hintValue == "")
+ value = MediaStreamTrackPrivate::HintValue::Empty;
+ else if (hintValue == "detail")
+ value = MediaStreamTrackPrivate::HintValue::Detail;
+ else if (hintValue == "motion")
+ value = MediaStreamTrackPrivate::HintValue::Motion;
+ else if (hintValue == "text")
+ value = MediaStreamTrackPrivate::HintValue::Text;
+ else
+ return;
+ }
+ m_private->setContentHint(value);
+}
+
bool MediaStreamTrack::enabled() const
{
return m_private->enabled();
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (236477 => 236478)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2018-09-25 21:59:35 UTC (rev 236478)
@@ -69,6 +69,10 @@
WEBCORE_EXPORT const String& id() const;
const String& label() const;
+
+ const AtomicString& contentHint() const;
+ void setContentHint(const String&);
+
bool enabled() const;
void setEnabled(bool);
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl (236477 => 236478)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.idl 2018-09-25 21:59:35 UTC (rev 236478)
@@ -37,6 +37,7 @@
readonly attribute DOMString id;
readonly attribute DOMString label;
attribute boolean enabled;
+ attribute DOMString contentHint;
readonly attribute boolean muted;
attribute EventHandler onmute;
attribute EventHandler onunmute;
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp (236477 => 236478)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp 2018-09-25 21:59:35 UTC (rev 236478)
@@ -96,6 +96,11 @@
return m_source->name();
}
+void MediaStreamTrackPrivate::setContentHint(HintValue hintValue)
+{
+ m_contentHint = hintValue;
+}
+
bool MediaStreamTrackPrivate::muted() const
{
return m_source->muted();
@@ -142,6 +147,7 @@
auto clonedMediaStreamTrackPrivate = create(m_source.copyRef());
clonedMediaStreamTrackPrivate->m_isEnabled = this->m_isEnabled;
clonedMediaStreamTrackPrivate->m_isEnded = this->m_isEnded;
+ clonedMediaStreamTrackPrivate->m_contentHint = this->m_contentHint;
clonedMediaStreamTrackPrivate->updateReadyState();
return clonedMediaStreamTrackPrivate;
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h (236477 => 236478)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h 2018-09-25 21:57:42 UTC (rev 236477)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h 2018-09-25 21:59:35 UTC (rev 236478)
@@ -66,6 +66,10 @@
bool ended() const { return m_isEnded; }
+ enum class HintValue { Empty, Speech, Music, Motion, Detail, Text };
+ HintValue contentHint() const { return m_contentHint; }
+ void setContentHint(HintValue);
+
void startProducingData() { m_source->start(); }
void stopProducingData() { m_source->stop(); }
bool isProducingData() { return m_source->isProducingData(); }
@@ -129,6 +133,7 @@
bool m_isEnabled { true };
bool m_isEnded { false };
bool m_haveProducedData { false };
+ HintValue m_contentHint { HintValue::Empty };
RefPtr<WebAudioSourceProvider> m_audioSourceProvider;
};