Changeset 83561 in webkit


Ignore:
Timestamp:
Apr 12, 2011 12:52:58 AM (13 years ago)
Author:
Philippe Normand
Message:

2011-04-07 Philippe Normand <pnormand@igalia.com>

Reviewed by Martin Robinson.

[GStreamer] report playback statistics
https://bugs.webkit.org/show_bug.cgi?id=58033

Provide media playback statistics using fpsdisplaysink and
position queries.

  • manual-tests/video-statistics.html: Added.
  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::decodedFrameCount): (WebCore::MediaPlayerPrivateGStreamer::droppedFrameCount): (WebCore::MediaPlayerPrivateGStreamer::audioDecodedByteCount): (WebCore::MediaPlayerPrivateGStreamer::videoDecodedByteCount): (WebCore::MediaPlayerPrivateGStreamer::updateAudioSink): (WebCore::MediaPlayerPrivateGStreamer::updateStates): (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
Location:
trunk/Source/WebCore
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83560 r83561  
     12011-04-07  Philippe Normand  <pnormand@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GStreamer] report playback statistics
     6        https://bugs.webkit.org/show_bug.cgi?id=58033
     7
     8        Provide media playback statistics using fpsdisplaysink and
     9        position queries.
     10
     11        * manual-tests/video-statistics.html: Added.
     12        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     13        (WebCore::MediaPlayerPrivateGStreamer::decodedFrameCount):
     14        (WebCore::MediaPlayerPrivateGStreamer::droppedFrameCount):
     15        (WebCore::MediaPlayerPrivateGStreamer::audioDecodedByteCount):
     16        (WebCore::MediaPlayerPrivateGStreamer::videoDecodedByteCount):
     17        (WebCore::MediaPlayerPrivateGStreamer::updateAudioSink):
     18        (WebCore::MediaPlayerPrivateGStreamer::updateStates):
     19        (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
     20        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
     21
    1222011-04-11  Philippe Normand  <pnormand@igalia.com>
    223
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r83560 r83561  
    350350    , m_audioTagsTimerHandler(0)
    351351    , m_videoTagsTimerHandler(0)
     352    , m_webkitAudioSink(0)
    352353{
    353354    if (doGstInit())
     
    959960}
    960961
     962unsigned MediaPlayerPrivateGStreamer::decodedFrameCount() const
     963{
     964    guint64 decodedFrames = 0;
     965    if (m_fpsSink)
     966        g_object_get(m_fpsSink, "frames-rendered", &decodedFrames, NULL);
     967    return static_cast<unsigned>(decodedFrames);
     968}
     969
     970unsigned MediaPlayerPrivateGStreamer::droppedFrameCount() const
     971{
     972    guint64 framesDropped = 0;
     973    if (m_fpsSink)
     974        g_object_get(m_fpsSink, "frames-dropped", &framesDropped, NULL);
     975    return static_cast<unsigned>(framesDropped);
     976}
     977
     978unsigned MediaPlayerPrivateGStreamer::audioDecodedByteCount() const
     979{
     980    GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES);
     981    gint64 position = 0;
     982
     983    if (m_webkitAudioSink && gst_element_query(m_webkitAudioSink, query))
     984        gst_query_parse_position(query, 0, &position);
     985
     986    gst_query_unref(query);
     987    return static_cast<unsigned>(position);
     988}
     989
     990unsigned MediaPlayerPrivateGStreamer::videoDecodedByteCount() const
     991{
     992    GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES);
     993    gint64 position = 0;
     994
     995    if (gst_element_query(m_webkitVideoSink, query))
     996        gst_query_parse_position(query, 0, &position);
     997
     998    gst_query_unref(query);
     999    return static_cast<unsigned>(position);
     1000}
     1001
     1002void MediaPlayerPrivateGStreamer::updateAudioSink()
     1003{
     1004    if (!m_playBin)
     1005        return;
     1006
     1007    GOwnPtr<GstElement> element;
     1008
     1009    g_object_get(m_playBin, "audio-sink", &element.outPtr(), NULL);
     1010    gst_object_replace(reinterpret_cast<GstObject**>(&m_webkitAudioSink),
     1011                       reinterpret_cast<GstObject*>(element.get()));
     1012}
     1013
    9611014void MediaPlayerPrivateGStreamer::cancelLoad()
    9621015{
     
    10181071        // needed.
    10191072        if (state == GST_STATE_PAUSED) {
     1073            if (!m_webkitAudioSink)
     1074                updateAudioSink();
    10201075            if (m_buffering && m_bufferingPercentage == 100) {
    10211076                m_buffering = false;
     
    16201675    gst_object_unref(GST_OBJECT(sinkPad));
    16211676
    1622     WTFLogChannel* channel = getChannelFromName("Media");
    1623     if (channel->state == WTFLogChannelOn) {
    1624         m_fpsSink = gst_element_factory_make("fpsdisplaysink", "sink");
    1625         if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_fpsSink), "video-sink")) {
    1626             g_object_set(m_fpsSink, "video-sink", m_webkitVideoSink, NULL);
    1627             gst_bin_add(GST_BIN(m_videoSinkBin), m_fpsSink);
     1677    m_fpsSink = gst_element_factory_make("fpsdisplaysink", "sink");
     1678
     1679    if (m_fpsSink) {
     1680        // The verbose property has been added in -bad 0.10.22. Making
     1681        // this whole code depend on it because we don't want
     1682        // fpsdiplaysink to spit data on stdout.
     1683        GstElementFactory* factory = GST_ELEMENT_FACTORY(GST_ELEMENT_GET_CLASS(m_fpsSink)->elementfactory);
     1684        if (gst_plugin_feature_check_version(GST_PLUGIN_FEATURE(factory), 0, 10, 22)) {
     1685            g_object_set(m_fpsSink, "silent", TRUE , NULL);
     1686
     1687            // Turn off text overlay unless logging is enabled.
     1688            WTFLogChannel* channel = getChannelFromName("Media");
     1689            if (channel->state != WTFLogChannelOn)
     1690                g_object_set(m_fpsSink, "text-overlay", FALSE , NULL);
     1691
     1692            if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_fpsSink), "video-sink")) {
     1693                g_object_set(m_fpsSink, "video-sink", m_webkitVideoSink, NULL);
     1694                gst_bin_add(GST_BIN(m_videoSinkBin), m_fpsSink);
    16281695#if GST_CHECK_VERSION(0, 10, 30)
    1629             // Faster elements linking, if possible.
    1630             gst_element_link_pads_full(queue, "src", m_fpsSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
     1696                // Faster elements linking, if possible.
     1697                gst_element_link_pads_full(queue, "src", m_fpsSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
    16311698#else
    1632             gst_element_link(queue, m_fpsSink);
     1699                gst_element_link(queue, m_fpsSink);
    16331700#endif
    1634         } else {
     1701            } else
     1702                m_fpsSink = 0;
     1703        } else
    16351704            m_fpsSink = 0;
    1636             gst_bin_add(GST_BIN(m_videoSinkBin), m_webkitVideoSink);
    1637 #if GST_CHECK_VERSION(0, 10, 30)
    1638             // Faster elements linking, if possible.
    1639             gst_element_link_pads_full(queue, "src", m_webkitVideoSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
    1640 #else
    1641             gst_element_link(queue, m_webkitVideoSink);
    1642 #endif
    1643             LOG_VERBOSE(Media, "Can't display FPS statistics, you need gst-plugins-bad >= 0.10.18");
    1644         }
    1645     } else {
     1705    }
     1706
     1707    if (!m_fpsSink) {
    16461708        gst_bin_add(GST_BIN(m_videoSinkBin), m_webkitVideoSink);
    16471709#if GST_CHECK_VERSION(0, 10, 30)
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r81228 r83561  
    136136            void notifyPlayerOfAudioTags();
    137137
     138            unsigned decodedFrameCount() const;
     139            unsigned droppedFrameCount() const;
     140            unsigned audioDecodedByteCount() const;
     141            unsigned videoDecodedByteCount() const;
     142
    138143        private:
    139144            MediaPlayerPrivateGStreamer(MediaPlayer*);
     
    145150            static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
    146151            static bool isAvailable();
     152
     153            void updateAudioSink();
    147154
    148155            void cacheDuration();
     
    194201            guint m_audioTagsTimerHandler;
    195202            guint m_videoTagsTimerHandler;
     203            GstElement* m_webkitAudioSink;
    196204    };
    197205}
Note: See TracChangeset for help on using the changeset viewer.