All pastes #1607001 Raw Edit

Unnamed

public text v1 · immutable
#1607001 ·published 2009-10-09 12:48 UTC
rendered paste body
diff --git a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
index 65c64b4..212e54f 100644
--- a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
+++ b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
@@ -52,6 +52,9 @@ using namespace std;
 
 namespace WebCore {
 
+GST_DEBUG_CATEGORY_STATIC(webkit_media_debug);
+#define GST_CAT_DEFAULT webkit_media_debug
+
 gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpointer data)
 {
     if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
@@ -59,7 +62,7 @@ gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpoin
         GOwnPtr<gchar> debug;
 
         gst_message_parse_error(message, &err.outPtr(), &debug.outPtr());
-        LOG_VERBOSE(Media, "Error: %d, %s", err->code,  err->message);
+        GST_INFO("Error: %d, %s", err->code,  err->message);
 
         MediaPlayer::NetworkState error = MediaPlayer::Empty;
         if (err->domain == GST_CORE_ERROR || err->domain == GST_LIBRARY_ERROR)
@@ -79,7 +82,7 @@ gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpoin
 gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data)
 {
     if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS) {
-        LOG_VERBOSE(Media, "End of Stream");
+        GST_INFO("End of Stream");
         MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data);
         mp->didEnd();
     }
@@ -100,7 +103,7 @@ gboolean mediaPlayerPrivateBufferingCallback(GstBus* bus, GstMessage* message, g
     if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_BUFFERING) {
         gint percent = 0;
         gst_message_parse_buffering(message, &percent);
-        LOG_VERBOSE(Media, "Buffering %d", percent);
+        GST_INFO("Buffering %d", percent);
     }
     return true;
 }
@@ -117,8 +120,10 @@ MediaPlayerPrivateInterface* MediaPlayerPrivate::create(MediaPlayer* player)
 
 void MediaPlayerPrivate::registerMediaEngine(MediaEngineRegistrar registrar)
 {
-    if (isAvailable())
+    if (isAvailable()) {
+        GST_DEBUG_CATEGORY_INIT(webkit_media_debug, "webkit", 0, "player");
         registrar(create, getSupportedTypes, supportsType);
+    }
 }
 
 static bool gstInitialized = false;
@@ -189,7 +194,7 @@ MediaPlayerPrivate::~MediaPlayerPrivate()
 
 void MediaPlayerPrivate::load(const String& url)
 {
-    LOG_VERBOSE(Media, "Load %s", url.utf8().data());
+    GST_INFO("Load %s", url.utf8().data());
     if (m_networkState != MediaPlayer::Loading) {
         m_networkState = MediaPlayer::Loading;
         m_player->networkStateChanged();
@@ -205,13 +210,13 @@ void MediaPlayerPrivate::load(const String& url)
 
 void MediaPlayerPrivate::play()
 {
-    LOG_VERBOSE(Media, "Play");
+    GST_INFO("Play");
     gst_element_set_state(m_playBin, GST_STATE_PLAYING);
 }
 
 void MediaPlayerPrivate::pause()
 {
-    LOG_VERBOSE(Media, "Pause");
+    GST_INFO("Pause");
     gst_element_set_state(m_playBin, GST_STATE_PAUSED);
 }
 
@@ -226,24 +231,17 @@ float MediaPlayerPrivate::duration() const
     GstFormat timeFormat = GST_FORMAT_TIME;
     gint64 timeLength = 0;
 
-#if !GST_CHECK_VERSION(0, 10, 23)
-    // We try to get the duration, but we do not trust the
-    // return value of the query function only; the problem we are
-    // trying to work-around here is that pipelines in stream mode may
-    // not be able to figure out the duration, but still return true!
-    // See https://bugs.webkit.org/show_bug.cgi?id=24639 which has been
-    // fixed in gst-plugins-base 0.10.23
-    if (!gst_element_query_duration(m_playBin, &timeFormat, &timeLength) || timeLength <= 0) {
-#else
-    if (!gst_element_query_duration(m_playBin, &timeFormat, &timeLength)) {
-#endif
-        LOG_VERBOSE(Media, "Time duration query failed.");
+    if (!gst_element_query_duration(m_playBin, &timeFormat, &timeLength) ||
+        timeFormat != GST_FORMAT_TIME ||
+        timeLength == GST_CLOCK_TIME_NONE) {
+
+        GST_INFO("Time duration query failed.");
         return numeric_limits<float>::infinity();
     }
 
-    LOG_VERBOSE(Media, "Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(timeLength));
+    GST_INFO("Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(timeLength));
 
-    return (float) (timeLength / 1000000000.0);
+    return (float) ((guint64) timeLength / 1000000000.0);
     // FIXME: handle 3.14.9.5 properly
 }
 
@@ -259,7 +257,7 @@ float MediaPlayerPrivate::currentTime() const
 
     GstQuery* query = gst_query_new_position(GST_FORMAT_TIME);
     if (!gst_element_query(m_playBin, query)) {
-        LOG_VERBOSE(Media, "Position query failed...");
+        GST_INFO("Position query failed...");
         gst_query_unref(query);
         return ret;
     }
@@ -267,7 +265,7 @@ float MediaPlayerPrivate::currentTime() const
     gint64 position;
     gst_query_parse_position(query, 0, &position);
     ret = (float) (position / 1000000000.0);
-    LOG_VERBOSE(Media, "Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position));
+    GST_INFO("Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position));
 
     gst_query_unref(query);
 
@@ -287,13 +285,13 @@ void MediaPlayerPrivate::seek(float time)
     if (m_errorOccured)
         return;
 
-    LOG_VERBOSE(Media, "Seek: %" GST_TIME_FORMAT, GST_TIME_ARGS(sec));
+    GST_INFO("Seek: %" GST_TIME_FORMAT, GST_TIME_ARGS(sec));
     if (!gst_element_seek( m_playBin, m_rate,
             GST_FORMAT_TIME,
             (GstSeekFlags)(GST_SEEK_FLAG_FLUSH),
             GST_SEEK_TYPE_SET, sec,
             GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
-        LOG_VERBOSE(Media, "Seek to %f failed", time);
+        GST_INFO("Seek to %f failed", time);
     else
         m_seeking = true;
 }
@@ -377,7 +375,7 @@ bool MediaPlayerPrivate::hasAudio() const
 void MediaPlayerPrivate::setVolume(float volume)
 {
     m_volume = volume;
-    LOG_VERBOSE(Media, "Volume to %f", volume);
+    GST_INFO("Volume to %f", volume);
 
     if (!m_playBin)
         return;
@@ -404,7 +402,7 @@ void MediaPlayerPrivate::setRate(float rate)
         return;
 
     m_rate = rate;
-    LOG_VERBOSE(Media, "Set Rate to %f", rate);
+    GST_INFO("Set Rate to %f", rate);
     seek(currentTime());
 }
 
@@ -439,7 +437,7 @@ float MediaPlayerPrivate::maxTimeSeekable() const
         return 0.0;
 
     // TODO
-    LOG_VERBOSE(Media, "maxTimeSeekable");
+    GST_INFO("maxTimeSeekable");
     if (m_isStreaming)
         return numeric_limits<float>::infinity();
     // infinite duration means live stream
@@ -452,7 +450,7 @@ float MediaPlayerPrivate::maxTimeLoaded() const
         return 0.0;
 
     // TODO
-    LOG_VERBOSE(Media, "maxTimeLoaded");
+    GST_INFO("maxTimeLoaded");
     notImplemented();
     return duration();
 }
@@ -460,7 +458,7 @@ float MediaPlayerPrivate::maxTimeLoaded() const
 unsigned MediaPlayerPrivate::bytesLoaded() const
 {
     notImplemented();
-    LOG_VERBOSE(Media, "bytesLoaded");
+    GST_INFO("bytesLoaded");
     /*if (!m_playBin)
         return 0;
     float dur = duration();
@@ -473,13 +471,13 @@ unsigned MediaPlayerPrivate::bytesLoaded() const
 
 bool MediaPlayerPrivate::totalBytesKnown() const
 {
-    LOG_VERBOSE(Media, "totalBytesKnown");
+    GST_INFO("totalBytesKnown");
     return totalBytes() > 0;
 }
 
 unsigned MediaPlayerPrivate::totalBytes() const
 {
-    LOG_VERBOSE(Media, "totalBytes");
+    GST_INFO("totalBytes");
     if (!m_source)
         return 0;
 
@@ -521,7 +519,7 @@ void MediaPlayerPrivate::updateStates()
     bool shouldUpdateAfterSeek = false;
     switch (ret) {
     case GST_STATE_CHANGE_SUCCESS:
-        LOG_VERBOSE(Media, "State: %s, pending: %s",
+        GST_INFO("State: %s, pending: %s",
             gst_element_state_get_name(state),
             gst_element_state_get_name(pending));
 
@@ -544,22 +542,22 @@ void MediaPlayerPrivate::updateStates()
 
         g_object_get(m_playBin, "source", &m_source, NULL);
         if (!m_source)
-            LOG_VERBOSE(Media, "m_source is 0");
+            GST_INFO("m_source is 0");
         break;
     case GST_STATE_CHANGE_ASYNC:
-        LOG_VERBOSE(Media, "Async: State: %s, pending: %s",
+        GST_INFO("Async: State: %s, pending: %s",
             gst_element_state_get_name(state),
             gst_element_state_get_name(pending));
         // Change in progress
         return;
     case GST_STATE_CHANGE_FAILURE:
-        LOG_VERBOSE(Media, "Failure: State: %s, pending: %s",
+        GST_INFO("Failure: State: %s, pending: %s",
             gst_element_state_get_name(state),
             gst_element_state_get_name(pending));
         // Change failed
         return;
     case GST_STATE_CHANGE_NO_PREROLL:
-        LOG_VERBOSE(Media, "No preroll: State: %s, pending: %s",
+        GST_INFO("No preroll: State: %s, pending: %s",
             gst_element_state_get_name(state),
             gst_element_state_get_name(pending));
 
@@ -571,7 +569,7 @@ void MediaPlayerPrivate::updateStates()
         m_networkState = MediaPlayer::Loading;
         break;
     default:
-        LOG_VERBOSE(Media, "Else : %d", ret);
+        GST_INFO("Else : %d", ret);
         break;
     }
 
@@ -582,12 +580,12 @@ void MediaPlayerPrivate::updateStates()
         timeChanged();
 
     if (m_networkState != oldNetworkState) {
-        LOG_VERBOSE(Media, "Network State Changed from %u to %u",
+        GST_INFO("Network State Changed from %u to %u",
             oldNetworkState, m_networkState);
         m_player->networkStateChanged();
     }
     if (m_readyState != oldReadyState) {
-        LOG_VERBOSE(Media, "Ready State Changed from %u to %u",
+        GST_INFO("Ready State Changed from %u to %u",
             oldReadyState, m_readyState);
         m_player->readyStateChanged();
     }