//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
HRESULT DSFilterRenderStreamDSMediaSample::DoRenderSample(IMediaSample *pMediaSample)
{
    NWStreamBlockDSMediaSample* streamBlock = NEW NWStreamBlockDSMediaSample();
    streamBlock->init();
        
    // Copy the contents of the mediasample to the streamblock
    CheckPointer(pMediaSample,E_POINTER);
    streamBlock->setMediaSample(pMediaSample);

    // Set the time
    REFERENCE_TIME timeStart(0);
    REFERENCE_TIME timeEnd(0);
    if ( pMediaSample->GetTime(&timeStart,&timeEnd) == S_OK )
    {
        u64 time = timeStart;
        streamBlock->setTime(time);
    }
    else
    {
        ASSERT(false);
    }

    // Add the streamblock to the stream
    mStream->writeBlock(streamBlock);

    return NOERROR;
}
示例#2
0
//建立信号与槽
void Widget::initConnect()
{

    connect(ui->addTravelerButton, SIGNAL(clicked()), this, SLOT(addTravelerButtonClicked()));
    QObject::connect(ui->TravelerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(travelerChanged()));

    QObject::connect(ui->ThroughCityCheckBox, SIGNAL(toggled(bool)), this, SLOT(activeThroughCity()));
    QObject::connect(ui->city0cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity0()));
    QObject::connect(ui->city1cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity1()));
    QObject::connect(ui->city2cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity2()));
    QObject::connect(ui->city3cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity3()));
    QObject::connect(ui->city4cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity4()));
    QObject::connect(ui->city5cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity5()));
    QObject::connect(ui->city6cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity6()));
    QObject::connect(ui->city7cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity7()));
    QObject::connect(ui->city8cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity8()));
    QObject::connect(ui->city9cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity9()));
    QObject::connect(ui->city10cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity10()));
    QObject::connect(ui->city11cbox, SIGNAL(toggled(bool)), this, SLOT(setThroungCity11()));

    QObject::connect(ui->StartButton, SIGNAL(clicked()), this, SLOT(startButtonClicked()));
    QObject::connect(ui->StrategyComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(enOrDisAbleDeadline(int)));

    QObject::connect(mstimer, SIGNAL(timeout()), this, SLOT(displaySpentTime()));
    QObject::connect(ui->StartButton, SIGNAL(clicked()), this, SLOT(timeStart()));
    QObject::connect(this, SIGNAL(DoStartTimer()), mstimer, SLOT(start()));

}
示例#3
0
microseconds timeCurrentMicroseconds()
{
   timeStart(); //if not already initialized...

   microseconds out;
   QueryPerformanceCounter((LARGE_INTEGER*)&out);
   out -= g_startTime;
   return (out * 1000000) / g_clockFreq;
}
示例#4
0
// time stop must be >= time start
void MainWindow::on_timeStart_timeChanged(const QTime &time) {
    ui->timeStop->setMinimumTime(time);

    QTime timeStart(ui->timeStart->time());
    qint64 ms(QTimeToMS(timeStart));

    qDebug() << ms;

    player->play();
    player->setPosition(ms);
    player->pause();
}
void TcpSocketThread::newDataToRead() {

    QTime timeStart( QTime::currentTime() );

    try {

        // Die zu verarbeitenden Daten, welche vom Client zum Server gesendet wurden...
        QByteArray clientData;

        logDebug("New Data to read available.");

        // Wurde schon bestimmt, wie viele Bytes vom Client erwarten zu sind?
        if (_socketBlockSize == 0) {

            logDebug("Try to detect the size of the incoming data...");

            // Wurden schon genug Daten empfangen, um die zu erwartenden Block zu bestimmen?
            if (_socket.bytesAvailable() <= sizeof(quint32) ) {
                // Wir müssen auf mehr Daten des Clients warten...
                logDebug("Not enough data arrived. I wait for more data...");
                return;
            }

            // Anzahl erwartende Bytes:
            QDataStream dataStream(&_socket);
            dataStream >> _socketBlockSize;
            logDebug( QString("Size of incoming data detected. Size are %1 bits").arg(QString::number(_socketBlockSize)) );
        }

        // Wurden vom Client bereits alle Daten empfangen???
        if (_socket.bytesAvailable() != _socketBlockSize) {

            logDebug("Not all data packages from the client arrived (%1 from %2 bytes) Wait for more data...",
                     QString::number(_socket.bytesAvailable()), QString::number(_socketBlockSize) );

            return;
        }
        else {

            logDebug("All data from the client arrived. Start parsing the data...");
            clientData = _socket.read(_socketBlockSize);

        }

        QDataStream dataStreamRead(&clientData, QIODevice::ReadWrite);

        /**
          * Alle Daten vom Client empfangen, jetzt folgt die Bearbeitung der
          * empfangenen Daten
          */

        logDebug("Start extract the incoming datas...");

        // Art des Befehls:
        // 0 -> TcpCommand group/command
        // 1 -> timeout reseter
        quint8 tcpType;
        UtilDataStream::read(dataStreamRead, tcpType);
        switch (tcpType) {
            case 0:

                /**
                  * Tcp Command:
                  */
            {
                // Kommunikations- ID:
                quint16 commId;
                UtilDataStream::read(dataStreamRead, commId);

                // Gruppenname, in welcher sich diese Aktion befindet.
                QByteArray group;
                UtilDataStream::read(dataStreamRead, group);

                // Name der auszuführenden Aktion
                QByteArray action;
                UtilDataStream::read(dataStreamRead, action);


                logNotice("Try to find action %1/%2...", group, action);

                std::auto_ptr<TcpAbstractCommand> command( TcpCommandFactories::instance()->createCommand(group, action) );
                // Wurde 0 zurückgegeben, so existiert der Befehl nicht...
                if (command.get() == 0) {
                    logError("Could not run tcp command '%1/%2'. Action does not exists!", group, action);
                    close();
                    return;
                }

                command->setCommId(commId);
                command->setSocket(&_socket);
                command->setUserAccount(&_user);
                command->setDataStreamRead(&dataStreamRead);

                /**
                  * Überprüfen, ob Befehl ausgeführt werden darf...
                  */
                TcpAbstractCommand::TCP_RESPONSE_TYPE answerType = TcpAbstractCommand::NORMAL_RESPONSE;
                // Hat User die Berechtigungen, diesen Befehl auszuführen??
                if (! UtilUsers::canRunTcpCommand(_user.getColumn("id").toInt(), group, action)  ) {

                    /**
                      * Benutzer hat nicht entsprechende Berechtigungen, um diesen Befehl auszuführen:
                      */

                    logError("User has not enough permissions to run the tcp action %1/%2", group, action);
                    answerType = TcpAbstractCommand::TCP_PERMISSION_ERROR;
                }
                else {

                    // Befehl ausführen:
                    logDebug("Run action %1/%2...", group, action);
                    QVariant execReturn = command->exec();

                    logDebug("Run postExec().");
                    command->postExec( execReturn );
                }

                logDebug("Tramsit data over the tcp socket to the client...");
                command->writeDataStream(answerType);
                logDebug("Datastream transmitted success!...");

                break;
            }
            case 1:
            {
                /**
                  * Timeout Reseter:
                  */

                logDebug("Reset socket timeout.");

                // wir schreiben den Client die Zahl "15253" zurück...
                QByteArray dataStreamWriteArray;
                QDataStream dataStreamWrite(&dataStreamWriteArray, QIODevice::WriteOnly);
                quint16 answer = 15253;
                dataStreamWrite << (quint32) sizeof(quint16);
                dataStreamWrite << answer;
                _socket.write(dataStreamWriteArray);
                _socket.flush();

                break;
            }
        default:
                logError("Unknown tcpType. Bye!");
                close();
                return;
        }

	logError("Tcp transction time: " + QString::number(timeStart.msecsTo(QTime::currentTime())) + "ms");

        _timeoutTimer->stop();
        _timeoutTimer->start(SOCKET_TIMEOUT);

    }