Example #1
3
void AbstractAudioSource::onPipelineBusmessage (const QGst::MessagePtr& message)
{
    switch (message->type()) {
    case QGst::MessageError: {
        QGst::ErrorMessagePtr errMsg = message.staticCast<QGst::ErrorMessage>();
        qDebug() << "[AbstractContentSource::onPipelineBusmessage()] Error message:" << errMsg->debugMessage();
    }
    break;

    case QGst::MessageStateChanged: {
        QGst::StateChangedMessagePtr stateMsg = message.staticCast<QGst::StateChangedMessage>();
        QString oldState = getStateText (stateMsg->oldState());
        QString newState = getStateText (stateMsg->newState());
        qDebug() << "[AbstractContentSource::onPipelineBusmessage()] State changed from" << oldState << "to" << newState;
    }
    break;

    case QGst::MessageAsyncDone:
        qDebug() << "[AbstractContentSource::onPipelineBusmessage()] Asynchronous completion invoked.";
        break;

    case QGst::MessageAsyncStart:
        qDebug() << "[AbstractContentSource::onPipelineBusmessage()] Asynchronous start invoked.";
        break;

    case QGst::MessageStreamStatus: {
        QGst::StreamStatusMessagePtr streamStatusMessage = message.staticCast<QGst::StreamStatusMessage>();
        qWarning() << "[AbstractContentSource::onPipelineBusmessage()] " << streamStatusMessage->streamStatusObject().toString();
    }
    break;

    case QGst::MessageElement: {
        QGst::ElementMessagePtr elementMessage = message.staticCast<QGst::ElementMessage>();
        //qDebug() << "[AbstractContentSource::onPipelineBusmessage()] Element message: " << elementMessage->internalStructure()->toString();
    }
    break;

    case QGst::MessageClockProvide:
    case QGst::MessageClockLost: {
    }
    break;

    default:
        qWarning() << "[AbstractContentSource::onPipelineBusmessage()] Unexpected message:" << message->typeName();
        break;
    }
}
Example #2
1
void Sphinx::applicationMessage (const QGst::MessagePtr& p_message)
{
    QString l_msgType    = p_message->internalStructure()->name();
    QString l_hypothesis = p_message->internalStructure()->value ("hyp").toString();
    QString l_uttid      = p_message->internalStructure()->value ("uttid").toString();

    if (l_msgType == "result") {
        qDebug() << "ASR result:" << l_hypothesis << l_uttid;
        emit finished (l_hypothesis);
    }
}
Example #3
1
void EventTest::sinkMessageTest()
{
    QGst::MessagePtr msg = QGst::BufferingMessage::create(QGst::ObjectPtr(), 90);
    QGst::SinkMessageEventPtr evt = QGst::SinkMessageEvent::create("sink-message", msg);
    QVERIFY(evt->type()==QGst::EventSinkMessage);
    QCOMPARE(evt->typeName(), QString("sink-message"));

    QGst::MessagePtr msg2 = evt->message();
    QVERIFY(msg2->type() == msg->type());
    QGst::BufferingMessagePtr msg3 = msg2.dynamicCast<QGst::BufferingMessage>();
    QCOMPARE(msg3->percent(), 90);
};
Example #4
0
void RefPointerTest::messageDynamicCastTest()
{
    QGst::BinPtr bin = QGst::Bin::create();
    QGst::MessagePtr msg = QGst::ApplicationMessage::create(bin);
    QVERIFY(!msg.isNull());
    QVERIFY(!msg.dynamicCast<QGst::ApplicationMessage>().isNull());
    QVERIFY(msg.dynamicCast<QGst::EosMessage>().isNull());
}
void RefPointerTest::messageDynamicCastTest()
{
    QGst::Structure s("mystruct");
    s.setValue("frequency", 123456);
    QGst::BinPtr bin = QGst::Bin::create();
    QGst::MessagePtr msg = QGst::ApplicationMessage::create(bin, s);
    QVERIFY(!msg.isNull());
    QVERIFY(!msg.dynamicCast<QGst::ApplicationMessage>().isNull());
    QVERIFY(msg.dynamicCast<QGst::EosMessage>().isNull());
}
Example #6
0
void Player::onBusMessage(const QGst::MessagePtr & message)
{
    switch (message->type()) {
    case QGst::MessageEos: //End of stream. We reached the end of the file.
        stop();
        break;
    case QGst::MessageError: //Some error occurred.
        qCritical() << message.staticCast<QGst::ErrorMessage>()->error();
        stop();
        break;
    case QGst::MessageStateChanged: //The element in message->source() has changed state
        if (message->source() == m_pipeline) {
            handlePipelineStateChange(message.staticCast<QGst::StateChangedMessage>());
        }
        break;
    default:
        break;
    }
}
Example #7
0
void MediaSourceBase::onBusMessage(const QGst::MessagePtr &message)
{
    qDebug() << "SOURCEPIPELINE" << id << "MESSAGE" << message->type() << message->typeName();
    switch (message->type()) {
    case QGst::MessageEos:
        sourceOffline();
        emit pipelineEOS();
        break;
    case QGst::MessageError:
        qCritical() << "SOURCEPIPELINE" << id << "ERROR:" << message.staticCast<QGst::ErrorMessage>()->error() << message.staticCast<QGst::ErrorMessage>()->debugMessage();
        sourceOffline();
        emit pipelineError(message.staticCast<QGst::ErrorMessage>()->error().message(), message.staticCast<QGst::ErrorMessage>()->debugMessage());
        break;
    case QGst::MessageStateChanged:
        qDebug() << "NEWSTATE:" << message.staticCast<QGst::StateChangedMessage>()->newState();
        emit pipelineNewState(message.staticCast<QGst::StateChangedMessage>()->newState());
        break;
    default:
        break;
    }

    updateBackground();
}
Example #8
0
void GstRecorder::onBusMessage(const QGst::MessagePtr &message) {
  switch (message->type()) {
    case QGst::MessageEos:
      // got end-of-stream - stop the pipeline
      stop();
      break;
    case QGst::MessageError:
      // check if the pipeline exists before destroying it,
      // as we might get multiple error messages
      if (m_pipeline) {
        stop();
      }
      qDebug() << message.staticCast<QGst::ErrorMessage>()->error().message();
      break;
    default:
      break;
  }
}
void GStreamerPipeline::handleBusMessage( const QGst::MessagePtr &message )
{
    switch( message->type() ) {
    case( QGst::MessageEos ):
        onEos();
        break;
    case( QGst::MessageError ):
        onError( message.staticCast<QGst::ErrorMessage>() );
        break;
    case( QGst::MessageBuffering ):
        onBuffering( message.staticCast<QGst::BufferingMessage>() );
        break;
    case( QGst::MessageClockLost ):
        qDebug() << "Clock Lost!";
        mPipeline->setState( QGst::StatePaused );
        mPipeline->setState( QGst::StatePlaying );
        break;
    }
}
void QtGStreamerCaptureBackend::onBusMessage(const QGst::MessagePtr & message)
{
    switch (message->type()) {
    case QGst::MessageEos:
        //got end-of-stream - stop the pipeline
        qCDebug(LIBSOUND_LOG) << "EOS signal received, stopping pipeline";
        stopPipeline();
        break;
    case QGst::MessageError:
        //check if the pipeline exists before destroying it,
        //since we could get multiple error messages
        if (m_pipeline) {
            stopPipeline();
        }
        qCritical() << "Pipeline Error:"
                 << message.staticCast<QGst::ErrorMessage>()->error().message();
        break;
    default:
        break;
    }
}
Example #11
0
void RefPointerTest::cppWrappersTest()
{
    QGst::ElementPtr e = QGst::ElementFactory::make("playbin");
    QVERIFY(!e.isNull());

    {
        QGst::PipelinePtr pipeline = e.dynamicCast<QGst::Pipeline>();
        QVERIFY(!pipeline.isNull());
        //the C++ wrappers must be the same
        QCOMPARE(static_cast<QGlib::RefCountedObject*>(pipeline.operator->()),
                 static_cast<QGlib::RefCountedObject*>(e.operator->()));
    }

    {
        QGst::ChildProxyPtr proxy = e.dynamicCast<QGst::ChildProxy>();
        QVERIFY(!proxy.isNull());
        //the C++ wrappers must be the same
        QCOMPARE(static_cast<QGlib::RefCountedObject*>(proxy.operator->()),
                 static_cast<QGlib::RefCountedObject*>(e.operator->()));
    }

    {   //new wrap() should give the same C++ instance
        GstElement *gobj = e;
        QGst::ElementPtr e2 = QGst::ElementPtr::wrap(gobj);
        QCOMPARE(static_cast<QGlib::RefCountedObject*>(e2.operator->()),
                 static_cast<QGlib::RefCountedObject*>(e.operator->()));
    }

    {
        QGst::StreamVolumePtr sv = e.dynamicCast<QGst::StreamVolume>();
        QVERIFY(!sv.isNull());
        //now the C++ wrapper must not be the same, since Pipeline does not inherit StreamVolume
        QVERIFY(static_cast<QGlib::RefCountedObject*>(sv.operator->())
                != static_cast<QGlib::RefCountedObject*>(e.operator->()));
    }

    {
        QGst::Structure s("mystruct");
        s.setValue("days", 365);
        QGst::MessagePtr msg = QGst::ApplicationMessage::create(e, s);
        QVERIFY(!msg.isNull());
        QGst::MessagePtr msg2 = msg;
        QCOMPARE(static_cast<QGlib::RefCountedObject*>(msg.operator->()),
                 static_cast<QGlib::RefCountedObject*>(msg2.operator->()));
        QVERIFY(msg2 == msg);

        QGst::MessagePtr msg3 = QGst::MessagePtr::wrap(msg2);
        QVERIFY(static_cast<QGlib::RefCountedObject*>(msg3.operator->())
                != static_cast<QGlib::RefCountedObject*>(msg2.operator->()));
        QVERIFY(msg3 == msg2);
    }

    {
        QGst::MessagePtr msg = QGst::ElementMessage::create(e);
        QGst::MessagePtr msg2 = msg;
        QCOMPARE(static_cast<QGlib::RefCountedObject*>(msg.operator->()),
                 static_cast<QGlib::RefCountedObject*>(msg2.operator->()));
        QVERIFY(msg2 == msg);

        QGst::MessagePtr msg3 = QGst::MessagePtr::wrap(msg2);
        QVERIFY(static_cast<QGlib::RefCountedObject*>(msg3.operator->())
                != static_cast<QGlib::RefCountedObject*>(msg2.operator->()));
        QVERIFY(msg3 == msg2);
    }
}