Ejemplo n.º 1
0
void Usage::addJitter(ClientUser *cu) {
	QMutexLocker qml(& cu->qmTiming);
	if (! cu->qlTiming.isEmpty()) {
		qdsReport << QByteArray::fromHex(cu->qsHash.toUtf8());
		qdsReport << cu->qlTiming;
	}
}
Ejemplo n.º 2
0
void ZLibrary::run(ZLApplication* aApp)
{
    if (ZLLanguageUtil::isRTLLanguage(ZLibrary::Language())) {
        qApp->setLayoutDirection(Qt::RightToLeft);
    }

    QString qml(QString::fromStdString(BaseDirectory + BOOKS_QML_FILE));
    HDEBUG("qml file" << qPrintable(qml));

    QQuickView* view = SailfishApp::createView();
    QQmlContext* root = view->rootContext();
    QSize screenSize(view->screen()->size());
    booksPPI =
#if defined(__i386__)
        (screenSize == QSize(1536,2048)) ? 330 : 300;
#elif defined(__arm__)
        (screenSize == QSize(540,960)) ? 245 : 290;
#else
#  error Unexpected architechture
#endif
    HDEBUG("screen" << screenSize << booksPPI << "dpi");
    root->setContextProperty("PointsPerInch", booksPPI);
    root->setContextProperty("MaximumHintCount", 1);

    view->setTitle(qtTrId("books-app-name"));
    view->setSource(QUrl::fromLocalFile(qml));
    view->show();
    HDEBUG("started");
    qApp->exec();
    HDEBUG("exiting...");
}
Ejemplo n.º 3
0
void ALSAInit::destroy() {
	QMutexLocker qml(&qmALSA);
	if (pairALSA)
		delete pairALSA;
	if (paorALSA)
		delete paorALSA;
	if (cards)
		delete cards;
}
Ejemplo n.º 4
0
void AudioOutputSpeech::addFrameToBuffer(const QByteArray &qbaPacket, unsigned int iSeq) {
	QMutexLocker lock(&qmJitter);

	if (qbaPacket.size() < 2)
		return;

	PacketDataStream pds(qbaPacket);

	pds.next();

	int frames = 0;
	unsigned int header = 0;
	do {
		header = static_cast<unsigned char>(pds.next());
		frames++;
		pds.skip(header & 0x7f);
	} while ((header & 0x80) && pds.isValid());

	if (pds.isValid()) {
		JitterBufferPacket jbp;
		jbp.data = const_cast<char *>(qbaPacket.constData());
		jbp.len = qbaPacket.size();
		jbp.span = iFrameSize * frames;
		jbp.timestamp = iFrameSize * iSeq;

#ifdef REPORT_JITTER
		if (g.s.bUsage && (umtType != MessageHandler::UDPVoiceSpeex) && p && ! p->qsHash.isEmpty() && (p->qlTiming.count() < 3000)) {
			QMutexLocker qml(& p->qmTiming);

			ClientUser::JitterRecord jr;
			jr.iSequence = iSeq;
			jr.iFrames = frames;
			jr.uiElapsed = p->tTiming.restart();

			if (! p->qlTiming.isEmpty()) {
				jr.iFrames -= p->iFrames;
				jr.iSequence -= p->iSequence + p->iFrames;
			}
			p->iFrames = frames;
			p->iSequence = iSeq;

			p->qlTiming.append(jr);
		}
#endif

		jitter_buffer_put(jbJitter, &jbp);
	}
}
Ejemplo n.º 5
0
void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
                                    QString        sNT,
                                    QString        sUDN )
{
    QString sUSN;

    if ( sUDN.length() > 0)
        sUSN = sUDN + "::" + sNT;
    else
        sUSN = sNT;

    QString sData = QString ( "Server: %1\r\n"
                              "NTS: %3\r\n"
                              "NT: %4\r\n"
                              "USN: %5\r\n"
                              "CACHE-CONTROL: max-age=%6\r\n"
                              "Content-Length: 0\r\n\r\n" )
                            .arg( HttpServer::GetServerVersion() )
                            .arg( GetNTSString()    )
                            .arg( sNT          )
                            .arg( sUSN         )
                            .arg( m_nMaxAge    );

    LOG(VB_UPNP, LOG_INFO,
        QString("UPnpNotifyTask::SendNotifyMsg : %1:%2 : %3 : %4")
            .arg(pSocket->address().toString()) .arg(pSocket->port())
            .arg(sNT) .arg(sUSN));

    QMutexLocker qml(&m_mutex); // for addressList

    // -------------------------------------------------------------------
    // Refresh IP Address List in case of changes
    // -------------------------------------------------------------------

    QList<QHostAddress> addressList = UPnp::g_IPAddrList;

    for ( QList<QHostAddress>::Iterator it  = addressList.begin();
                                        it != addressList.end();
                                        ++it )
    {
        if ((*it).toString().isEmpty())
        {
            LOG(VB_GENERAL, LOG_ERR,
                "UPnpNotifyTask::SendNotifyMsg - NULL in address list");
            continue;
        }

        QHostAddress ip = *it;
        // Descope the Link Local address. The scope is only valid
        // on the server sending the announcement, not the clients
        // that receive it
        ip.setScopeId(QString());

        QString ipaddress = ip.toString();

        // If this looks like an IPv6 address, then enclose it in []'s
        if (ipaddress.contains(":"))
            ipaddress = "[" + ipaddress + "]";

        QString sHeader = QString("NOTIFY * HTTP/1.1\r\n"
                                  "HOST: %1:%2\r\n"    
                                  "LOCATION: http://%3:%4/getDeviceDesc\r\n")
                    .arg(pSocket->address().toString()) .arg(pSocket->port())
                    .arg(ipaddress) .arg(m_nServicePort);

        QString  sPacket  = sHeader + sData;
        QByteArray scPacket = sPacket.toUtf8();

        // ---------------------------------------------------------------
        // Send Packet to Socket (Send same packet twice)
        // ---------------------------------------------------------------

        pSocket->writeBlock( scPacket, scPacket.length(),
                             pSocket->address(), pSocket->port() );
        std::this_thread::sleep_for(std::chrono::milliseconds(random() % 250));
        pSocket->writeBlock( scPacket, scPacket.length(),
                             pSocket->address(), pSocket->port() );
    }
}
Ejemplo n.º 6
0
void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
                                    QString        sNT,
                                    QString        sUDN )
{
    QString sUSN;

    if ( sUDN.length() > 0)
        sUSN = sUDN + "::" + sNT;
    else
        sUSN = sNT;

    QString sData = QString ( "Server: %1, UPnP/1.0, MythTV %2\r\n"
                              "NTS: %3\r\n"
                              "NT: %4\r\n"
                              "USN: %5\r\n"
                              "CACHE-CONTROL: max-age=%6\r\n"
                              "Content-Length: 0\r\n\r\n" )
                            .arg( HttpServer::g_sPlatform )
                            .arg( MYTH_BINARY_VERSION )
                            .arg( GetNTSString()    )
                            .arg( sNT          )
                            .arg( sUSN         )
                            .arg( m_nMaxAge    );

//    VERBOSE(VB_UPNP, QString("UPnpNotifyTask::SendNotifyMsg : %1 : %2 : %3")
//                        .arg( pSocket->address().toString() )
//                        .arg( sNT  )
//                        .arg( sUSN ));

    {
    QMutexLocker qml(&m_mutex); // for addressList

    // ----------------------------------------------------------------------
    // Refresh IP Address List in case of changes
    // ----------------------------------------------------------------------

    QStringList addressList = UPnp::g_IPAddrList;

    for ( QStringList::Iterator it  = addressList.begin(); 
                                it != addressList.end(); 
                              ++it ) 
    {
        if ((*it).isEmpty())
        {
            VERBOSE(VB_GENERAL,
                    "UPnpNotifyTask::SendNotifyMsg - NULL in m_addressList");
            continue;
        }

        QString sHeader = QString( "NOTIFY * HTTP/1.1\r\n"
                                   "HOST: %1:%2\r\n"    
                                   "LOCATION: http://%3:%4/getDeviceDesc\r\n" )
                             .arg( SSDP_GROUP ) // pSocket->address().toString() )
                             .arg( SSDP_PORT )  // pSocket->port() )
                             .arg( *it )
                             .arg( m_nServicePort);

        QString  sPacket  = sHeader + sData;
        QByteArray scPacket = sPacket.toUtf8();

        // ------------------------------------------------------------------
        // Send Packet to Socket (Send same packet twice)
        // ------------------------------------------------------------------

        pSocket->writeBlock( scPacket, scPacket.length(), pSocket->address(), pSocket->port() );
        usleep( rand() % 250000 );
        pSocket->writeBlock( scPacket, scPacket.length(), pSocket->address(), pSocket->port() );
    }
    }

}
Ejemplo n.º 7
0
void UPnpNotifyTask::SendNotifyMsg( MSocketDevice *pSocket,
                                    QString        sNT,
                                    QString        sUDN )
{
    QString sUSN;

    if ( sUDN.length() > 0)
        sUSN = sUDN + "::" + sNT;
    else
        sUSN = sNT;

    QString sData = QString ( "Server: %1, UPnP/1.0, MythTV %2\r\n"
                              "NTS: %3\r\n"
                              "NT: %4\r\n"
                              "USN: %5\r\n"
                              "CACHE-CONTROL: max-age=%6\r\n"
                              "Content-Length: 0\r\n\r\n" )
                            .arg( HttpServer::GetPlatform() )
                            .arg( MYTH_BINARY_VERSION )
                            .arg( GetNTSString()    )
                            .arg( sNT          )
                            .arg( sUSN         )
                            .arg( m_nMaxAge    );

    LOG(VB_UPNP, LOG_INFO,
        QString("UPnpNotifyTask::SendNotifyMsg : %1:%2 : %3 : %4")
            .arg(pSocket->address().toString()) .arg(pSocket->port())
            .arg(sNT) .arg(sUSN));

    QMutexLocker qml(&m_mutex); // for addressList

    // -------------------------------------------------------------------
    // Refresh IP Address List in case of changes
    // -------------------------------------------------------------------

    QStringList addressList = UPnp::g_IPAddrList;

    for ( QStringList::Iterator it  = addressList.begin(); 
                                it != addressList.end(); 
                              ++it ) 
    {
        if ((*it).isEmpty())
        {
            LOG(VB_GENERAL, LOG_ERR,
                "UPnpNotifyTask::SendNotifyMsg - NULL in address list");
            continue;
        }

        QString ipaddress = *it;

        // If this looks like an IPv6 address, then enclose it in []'s
        if (ipaddress.contains(":"))
            ipaddress = "[" + ipaddress + "]";

        QString sHeader = QString("NOTIFY * HTTP/1.1\r\n"
                                  "HOST: %1:%2\r\n"    
                                  "LOCATION: http://%3:%4/getDeviceDesc\r\n")
                    .arg(pSocket->address().toString()) .arg(pSocket->port())
                    .arg(ipaddress) .arg(m_nServicePort);

        QString  sPacket  = sHeader + sData;
        QByteArray scPacket = sPacket.toUtf8();

        // ---------------------------------------------------------------
        // Send Packet to Socket (Send same packet twice)
        // ---------------------------------------------------------------

        pSocket->writeBlock( scPacket, scPacket.length(),
                             pSocket->address(), pSocket->port() );
        usleep( rand() % 250000 );
        pSocket->writeBlock( scPacket, scPacket.length(),
                             pSocket->address(), pSocket->port() );
    }
}