[Bug 727003] New: Memory Leak in QtGstreamer

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Mon Mar 24 21:44:49 PDT 2014


https://bugzilla.gnome.org/show_bug.cgi?id=727003
  GStreamer | qt-gstreamer | 0.10.0

           Summary: Memory Leak in QtGstreamer
    Classification: Platform
           Product: GStreamer
           Version: 0.10.0
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: critical
          Priority: Normal
         Component: qt-gstreamer
        AssignedTo: gstreamer-bugs at lists.freedesktop.org
        ReportedBy: monalisabarik29 at gmail.com
         QAContact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---


I am using QTGstreamer in my application to play media files of .webm & .flv
formats. The movies of length 5-10 secs play in a loop continuously.
I have observed huge memory leak while playing these small movies. Instead if I
play a long (approx 1 hour) movie, the leak is almost negligible.
Please suggest some solution.
Below is the source code

[MAIN.CPP]

    #include "mediaapp.h"
    #include <QtGui/QApplication>
    #include <QGst/init.h>

    int main (int argc, char *argv [] )
    {
    QApplication app ( argc, argv );
    QGst :: init ( &argc, &argv );

    MediaApp media;
    media .show();
    media .openFile ("file://XYZ.webm");
    return app .exec();
    }


[MEDIAAPP.H]

    #ifndef MEDIAAPP_H_
    #define MEDIAAPP_H_

    #include <QtGui/QWidget>
    #include <QtGui/QStyle>
    #include <QtCore/QTimer>

    class Player;
    class QBoxLayout;
    class QTimer;

    class MediaApp : public QWidget
    {
    Q_OBJECT
    public:
    MediaApp(QWidget *parent = 0);
    ~MediaApp();
    void openFile(const QString & fileName);



    private Q_SLOTS:
    void onStateChanged();

    private:
    void createUI(QBoxLayout *appLayout);
    Player *m_player;
    };



[MEDIAAPP.CPP]

    #include "mediaapp.h"
    #include "player.h"
    #include <QtGui/QBoxLayout>

    MediaApp::MediaApp (QWidget *parent)
    : QWidget (parent)
    {
    //create the player
    m_player = new Player (this);
    connect (m_player, SIGNAL ( stateChanged() ), this, SLOT( onStateChanged()
) );

    //create the UI
    QVBoxLayout *appLayout = new QVBoxLayout;
    appLayout ->setContentsMargins (0, 0, 0, 0);
    appLayout ->addWidget (m_player);

    setLayout (appLayout);
    setWindowFlags (Qt::FramelessWindowHint);/* enable this for frameless
window */
    }

    MediaApp::~MediaApp()
    {
    delete m_player;
    }

    void MediaApp::openFile(const QString & fileName)
    {
    m_player->stop();
    m_player->setUri(fileName);
    m_player->play();
    }



[PLAYER.H]

    #ifndef PLAYER_H_
    #define PLAYER_H_

    #include <QtCore/QTimer>
    #include <QtCore/QTime>
    #include <QGst/Pipeline>
    #include <QGst/Ui/VideoWidget>

    class Player : public QGst :: Ui :: VideoWidget
    {
    Q_OBJECT
    public:
    Player(QWidget *parent = 0);
    ~Player();

    void setUri(const QString & uri);
    QGst :: State state() const;

    public Q_SLOTS:
    void play();

    Q_SIGNALS:
    void positionChanged();
    void stateChanged();

    private:
    void onBusMessage(const QGst :: MessagePtr & message);
    void handlePipelineStateChange(const QGst :: StateChangedMessagePtr & scm);

    QGst :: PipelinePtr m_pipeline;
    QTimer m_positionTimer;
    };

    #endif /* PLAYER_H_ */



[PLAYER.CPP]

    #include "player.h"
    #include <QtCore/QDir>
    #include <QtCore/QUrl>
    #include <QGlib/Connect>
    #include <QGlib/Error>
    #include <QGst/Pipeline>
    #include <QGst/ElementFactory>
    #include <QGst/Bus>
    #include <QGst/Message>
    #include <QGst/Query>
    #include <QGst/ClockTime>
    #include <QGst/Event>
    #include <QGst/StreamVolume>

    Player::Player(QWidget *parent)
    : QGst :: Ui :: VideoWidget(parent)
    {
    //this timer is used to tell the ui to change its position slider & label
    //every 100 ms, but only when the pipeline is playing
    // connect ( &m_positionTimer, SIGNAL ( timeout () ), this, SIGNAL (
positionChanged () ) );
    }

    Player :: ~Player ()
    {
    if (m_pipeline) {
    m_pipeline ->setState (QGst :: StateNull );
    stopPipelineWatch ();
    }
    }

    void Player :: setUri (const QString & uri)
    {
    QString realUri = uri;
    //if uri is not a real uri, assume it is a file path
    if (realUri.indexOf("://") < 0) {
    realUri = QUrl :: fromLocalFile (realUri) .toEncoded();
    }


    if ( !m_pipeline )
    {
    m_pipeline = QGst :: ElementFactory :: make ("playbin2") .dynamicCast
<QGst::Pipeline>();
    if (m_pipeline)
    {
    //let the video widget watch the pipeline for new video sinks
    watchPipeline (m_pipeline);
    //watch the bus for messages
    QGst :: BusPtr bus = m_pipeline ->bus();
    bus ->addSignalWatch();
    QGlib :: connect (bus, "message", this, &Player :: onBusMessage);
    }
    else
    {
    qCritical() << "Failed to create the pipeline";
    }
    }

    if (m_pipeline)
    {
    m_pipeline- >setProperty ("uri", realUri);
    }
    }


    QGst :: State Player :: state() const
    {
    return m_pipeline ? m_pipeline->currentState() : QGst :: StateNull;
    }

    void Player :: play()
    {
    if (m_pipeline)
    {
    m_pipeline ->setState(QGst :: StatePlaying);
    }
    }

    void Player::onBusMessage(const QGst::MessagePtr & message)
    {
    switch ( message->type()) {
    case QGst :: MessageEos : //End of stream. We reached the end of the file.
    {
    if (m_pipeline)
    {
    m_pipeline->setState(QGst::StateNull);
    m_pipeline->setState(QGst::StatePlaying);
    }
    }
    break;
    default:
    break;
    }
    }

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list