[GStreamer] human readable language code for tracks
authorb.long@cablelabs.com <b.long@cablelabs.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Mar 2014 22:13:01 +0000 (22:13 +0000)
committerb.long@cablelabs.com <b.long@cablelabs.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Mar 2014 22:13:01 +0000 (22:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124514

Reviewed by Martin Robinson.

.:

* Source/autotools/FindDependencies.m4: Add gstreamer-tag-1.0.
* Source/cmake/FindGStreamer.cmake: Same.
* Source/cmake/OptionsEfl.cmake: Same.
* Source/cmake/OptionsGTK.cmake: Same.

Source/WebCore:

* PlatformEfl.cmake: Add GSTREAMER_TAG_INCLUDE_DIRS and GSTREAMER_TAG_LIBRARIES.
* PlatformGTK.cmake: Same.
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
(WebCore::TrackPrivateBaseGStreamer::getLanguageCode): Run language codes though gst_tag_get_language_code_iso_639_1() to make sure they're valid.
(WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged): Use getLanguageCode() for languages instead of just getTag().

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

ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/PlatformEfl.cmake
Source/WebCore/PlatformGTK.cmake
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h
Source/autotools/FindDependencies.m4
Source/cmake/FindGStreamer.cmake
Source/cmake/OptionsEfl.cmake
Source/cmake/OptionsGTK.cmake

index 77967cd..d4674bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-03-17  Brendan Long  <b.long@cablelabs.com>
+
+        [GStreamer] human readable language code for tracks
+        https://bugs.webkit.org/show_bug.cgi?id=124514
+
+        Reviewed by Martin Robinson.
+
+        * Source/autotools/FindDependencies.m4: Add gstreamer-tag-1.0.
+        * Source/cmake/FindGStreamer.cmake: Same.
+        * Source/cmake/OptionsEfl.cmake: Same.
+        * Source/cmake/OptionsGTK.cmake: Same.
+
 2014-03-17  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK][CMake] Credential storage is not enabled
index bac30f2..184c4f5 100644 (file)
@@ -1,3 +1,16 @@
+2014-03-17  Brendan Long  <b.long@cablelabs.com>
+
+        [GStreamer] human readable language code for tracks
+        https://bugs.webkit.org/show_bug.cgi?id=124514
+
+        Reviewed by Martin Robinson.
+
+        * PlatformEfl.cmake: Add GSTREAMER_TAG_INCLUDE_DIRS and GSTREAMER_TAG_LIBRARIES.
+        * PlatformGTK.cmake: Same.
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
+        (WebCore::TrackPrivateBaseGStreamer::getLanguageCode): Run language codes though gst_tag_get_language_code_iso_639_1() to make sure they're valid.
+        (WebCore::TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged): Use getLanguageCode() for languages instead of just getTag().
+
 2014-03-17  Ryosuke Niwa  <rniwa@webkit.org>
 
         [Mac] Rewrite WebHTMLConverter::_computedStringForNode in C++
index 717eb73..1886917 100644 (file)
@@ -280,9 +280,11 @@ endif ()
 
 if (ENABLE_VIDEO)
     list(APPEND WebCore_INCLUDE_DIRECTORIES
+        ${GSTREAMER_TAG_INCLUDE_DIRS}
         ${GSTREAMER_VIDEO_INCLUDE_DIRS}
     )
     list(APPEND WebCore_LIBRARIES
+        ${GSTREAMER_TAG_LIBRARIES}
         ${GSTREAMER_VIDEO_LIBRARIES}
     )
 endif ()
index 5e297ba..50cd5d3 100644 (file)
@@ -361,9 +361,11 @@ endif ()
 
 if (ENABLE_VIDEO)
     list(APPEND WebCore_INCLUDE_DIRECTORIES
+        ${GSTREAMER_TAG_INCLUDE_DIRS}
         ${GSTREAMER_VIDEO_INCLUDE_DIRS}
     )
     list(APPEND WebCore_LIBRARIES
+        ${GSTREAMER_TAG_LIBRARIES}
         ${GSTREAMER_VIDEO_LIBRARIES}
     )
 endif ()
index 16bd494..0ee8a7b 100644 (file)
@@ -34,7 +34,9 @@
 #include "TrackPrivateBase.h"
 #include <glib-object.h>
 #include <gst/gst.h>
+#include <gst/tag/tag.h>
 #include <wtf/gobject/GUniquePtr.h>
+#include <wtf/text/CString.h>
 
 GST_DEBUG_CATEGORY_EXTERN(webkit_media_player_debug);
 #define GST_CAT_DEFAULT webkit_media_player_debug
@@ -146,6 +148,20 @@ void TrackPrivateBaseGStreamer::notifyTrackOfActiveChanged()
     setActive(active);
 }
 
+bool TrackPrivateBaseGStreamer::getLanguageCode(GstTagList* tags, String& value)
+{
+    String language;
+    if (getTag(tags, GST_TAG_LANGUAGE_CODE, language)) {
+        language = gst_tag_get_language_code_iso_639_1(language.utf8().data());
+        INFO_MEDIA_MESSAGE("Converted track %d's language code to %s.", m_index, language.utf8().data());
+        if (language != value) {
+            value = language;
+            return true;
+        }
+    }
+    return false;
+}
+
 bool TrackPrivateBaseGStreamer::getTag(GstTagList* tags, const gchar* tagName, String& value)
 {
     GUniqueOutPtr<gchar> tagValue;
@@ -164,6 +180,9 @@ void TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged()
         return;
 
     TrackPrivateBaseClient* client = m_owner->client();
+    if (!client)
+        return;
+
     GRefPtr<GstTagList> tags;
     {
         MutexLocker lock(m_tagMutex);
@@ -172,10 +191,10 @@ void TrackPrivateBaseGStreamer::notifyTrackOfTagsChanged()
     if (!tags)
         return;
 
-    if (getTag(tags.get(), GST_TAG_TITLE, m_label) && client)
+    if (getTag(tags.get(), GST_TAG_TITLE, m_label))
         client->labelChanged(m_owner, m_label);
 
-    if (getTag(tags.get(), GST_TAG_LANGUAGE_CODE, m_language) && client)
+    if (getLanguageCode(tags.get(), m_language))
         client->languageChanged(m_owner, m_language);
 }
 
index 1e3b8c8..c81ed9a 100644 (file)
@@ -63,6 +63,7 @@ protected:
     GRefPtr<GstPad> m_pad;
 
 private:
+    bool getLanguageCode(GstTagList* tags, String& value);
     bool getTag(GstTagList* tags, const gchar* tagName, String& value);
 
     TrackPrivateBase* m_owner;
index 0287603..6447ee3 100644 (file)
@@ -431,6 +431,7 @@ if test "$enable_video" = "yes" || test "$enable_web_audio" = "yes"; then
         gstreamer-fft-1.0,
         gstreamer-base-1.0,
         gstreamer-pbutils-1.0,
+        gstreamer-tag-1.0,
         gstreamer-video-1.0])
     AC_SUBST([GSTREAMER_CFLAGS])
     AC_SUBST([GSTREAMER_LIBS])
index e994b91..5f3f65b 100644 (file)
@@ -20,6 +20,7 @@
 #  gstreamer-audio:      GSTREAMER_AUDIO_INCLUDE_DIRS and GSTREAMER_AUDIO_LIBRARIES
 #  gstreamer-fft:        GSTREAMER_FFT_INCLUDE_DIRS and GSTREAMER_FFT_LIBRARIES
 #  gstreamer-pbutils:    GSTREAMER_PBUTILS_INCLUDE_DIRS and GSTREAMER_PBUTILS_LIBRARIES
+#  gstreamer-tag:        GSTREAMER_TAG_INCLUDE_DIRS and GSTREAMER_TAG_LIBRARIES
 #  gstreamer-video:      GSTREAMER_VIDEO_INCLUDE_DIRS and GSTREAMER_VIDEO_LIBRARIES
 #
 # Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
@@ -105,6 +106,7 @@ FIND_GSTREAMER_COMPONENT(GSTREAMER_APP gstreamer-app-1.0 gst/app/gstappsink.h gs
 FIND_GSTREAMER_COMPONENT(GSTREAMER_AUDIO gstreamer-audio-1.0 gst/audio/audio.h gstaudio-1.0)
 FIND_GSTREAMER_COMPONENT(GSTREAMER_FFT gstreamer-fft-1.0 gst/fft/gstfft.h gstfft-1.0)
 FIND_GSTREAMER_COMPONENT(GSTREAMER_PBUTILS gstreamer-pbutils-1.0 gst/pbutils/pbutils.h gstpbutils-1.0)
+FIND_GSTREAMER_COMPONENT(GSTREAMER_TAG gstreamer-tag-1.0 gst/tag/tag.h gsttag-1.0)
 FIND_GSTREAMER_COMPONENT(GSTREAMER_VIDEO gstreamer-video-1.0 gst/video/video.h gstvideo-1.0)
 
 # ------------------------------------------------
@@ -136,6 +138,8 @@ mark_as_advanced(
     GSTREAMER_LIBRARIES
     GSTREAMER_PBUTILS_INCLUDE_DIRS
     GSTREAMER_PBUTILS_LIBRARIES
+    GSTREAMER_TAG_INCLUDE_DIRS
+    GSTREAMER_TAG_LIBRARIES
     GSTREAMER_VIDEO_INCLUDE_DIRS
     GSTREAMER_VIDEO_LIBRARIES
 )
index 947b095..0b61d07 100644 (file)
@@ -179,7 +179,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
     add_definitions(-DWTF_USE_GSTREAMER=1)
 
     if (ENABLE_VIDEO)
-        list(APPEND GSTREAMER_COMPONENTS video)
+        list(APPEND GSTREAMER_COMPONENTS video tag)
     endif ()
 
     if (ENABLE_WEB_AUDIO)
index 83ed02a..dd1fc5e 100644 (file)
@@ -150,11 +150,18 @@ add_definitions(-DUSER_AGENT_GTK_MINOR_VERSION=30)
 add_definitions(-DWEBKITGTK_API_VERSION_STRING="${WEBKITGTK_API_VERSION}")
 
 if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
+    set(GSTREAMER_COMPONENTS app pbutils)
     add_definitions(-DWTF_USE_GSTREAMER)
-endif ()
+    if (ENABLE_VIDEO)
+        list(APPEND GSTREAMER_COMPONENTS video tag)
+    endif ()
+
+    if (ENABLE_WEB_AUDIO)
+        list(APPEND GSTREAMER_COMPONENTS audio fft)
+        add_definitions(-DWTF_USE_WEBAUDIO_GSTREAMER)
+    endif ()
 
-if (ENABLE_WEB_AUDIO)
-    add_definitions(-DWTF_USE_WEBAUDIO_GSTREAMER)
+    find_package(GStreamer 1.0.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
 endif ()
 
 # FIXME: These need to be configurable.
@@ -179,7 +186,6 @@ find_package(ZLIB REQUIRED)
 find_package(Xt REQUIRED)
 find_package(ATK REQUIRED)
 find_package(WebP REQUIRED)
-find_package(GStreamer 1.0.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
 find_package(ATSPI 2.5.3)
 find_package(GObjectIntrospection)