Important: Please read the Qt Code of Conduct -

NULL pointer Exception in mfstream.cpp with QMediaPlayer and QTCPSocket

  • I try to implement a client for live stream video over TCP.

    To display the video I tried use the QMediaPlayer class (displaying video files works well). To recieve the videostream I use the QTCPSocket class.
    Connection to Server works well too. After establishing connection, the server started to stream - seems to work well too.
    On the client site (my QT client) i receive the connected signal.
    In the "connected" slot, I have the following code:

    player->setMedia(0, m_client->m_socket);

    After "play()" I received an exception.

    Debugging showed me the following:
    In mfstream.cpp, the methods "BeginRead" was called - filled the member variable "m_currentReadResult".
    after some other method calls, "EndRead" was called - the variable m_currentReadResult was set to NULL again.
    A little bit later "bool QAbstractSocketPrivate::canReadNotification()" was called with "emit q->readyRead();"

    -> void MFStream::handleReadyRead()

    void MFStream::doRead()
    bool readDone = true;
    IUnknown *pUnk = NULL;
    HRESULT hr = m_currentReadResult->GetObject(&pUnk);

    But now "m_currentReadResult is still "NULL" -> exception.

    I don't know if there is a bug in the QT library or is it not recommended to use a QTcpSocket object (= QIODevice) together with

    *QMediaPlayer->setMedia(0, QTcpSocket)

    Can somebody help me?

Log in to reply