void PlaybackWidget::slotStop()
{
    m_mediaObject->stop();
    m_stopCalled = true;
    m_currIndex  = 0;
    m_mediaObject->setCurrentSource(static_cast<QUrl>(m_urlList[m_currIndex]));
    checkSkip();
    setGUIPlay(false);
    setZeroTime();
}
void PresentationAudioWidget::slotStop()
{
    d->mediaObject->stop();
    d->stopCalled = true;
    d->currIndex  = 0;
    d->mediaObject->setMedia(d->urlList[d->currIndex]);
    checkSkip();
    setGUIPlay(false);
    setZeroTime();
}
void PresentationAudioWidget::slotNext()
{
    d->currIndex++;

    if (d->currIndex >= d->urlList.count())
    {
        if (d->sharedData->soundtrackLoop)
        {
            d->currIndex = 0;
        }
        else
        {
            d->currIndex = d->urlList.count() - 1;
            return;
        }
    }

    d->mediaObject->setMedia(d->urlList[d->currIndex]);
    d->mediaObject->play();
    setZeroTime();
}
void PlaybackWidget::slotNext()
{
    m_currIndex++;

    if ( m_currIndex >= m_urlList.count() )
    {
        if ( m_sharedData->soundtrackLoop )
        {
            m_currIndex = 0;
        }
        else
        {
            m_currIndex = m_urlList.count() - 1;
            return;
        }
    }

    setZeroTime();

    m_mediaObject->setCurrentSource(static_cast<QUrl>(m_urlList[m_currIndex]));
    m_mediaObject->play();
}
PlaybackWidget::PlaybackWidget(QWidget* parent, KUrl::List &urls, SharedContainer* sharedData)
              : QWidget(parent)
{
    setupUi(this);

    m_sharedData = sharedData;
    m_currIndex  = 0;
    m_urlList    = urls;
    m_stopCalled = false;
    m_canHide    = true;

    m_soundLabel->setPixmap(KIcon("speaker").pixmap(64, 64));

    m_prevButton->setText("");
    m_nextButton->setText("");
    m_playButton->setText("");
    m_stopButton->setText("");

    m_prevButton->setIcon(KIcon("media-skip-backward"));
    m_nextButton->setIcon(KIcon("media-skip-forward"));
    m_playButton->setIcon(KIcon("media-playback-start"));
    m_stopButton->setIcon(KIcon("media-playback-stop"));

    connect(m_prevButton, SIGNAL(clicked()),
            this, SLOT(slotPrev()));

    connect(m_nextButton, SIGNAL(clicked()),
            this, SLOT(slotNext()));

    connect(m_playButton, SIGNAL(clicked()),
            this, SLOT(slotPlay()));

    connect(m_stopButton, SIGNAL(clicked()),
            this, SLOT(slotStop()));

    if (m_urlList.empty())
    {
        setEnabled(false);
        return;
    }

    // Waiting for files to be enqueued.
    m_playButton->setEnabled(false);

    m_prevButton->setEnabled(false);

    // Phonon
    m_mediaObject = new Phonon::MediaObject(this);

    m_mediaObject->setTransitionTime(1000);

    m_mediaObject->setTickInterval(500);

    connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this, SLOT(slotMediaStateChanged(Phonon::State,Phonon::State)));

    connect(m_mediaObject, SIGNAL(finished()),
            this, SLOT(slotSongFinished()));

    connect(m_mediaObject, SIGNAL(tick(qint64)),
            this, SLOT(slotTimeUpdaterTimeout()));

    m_audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);

    Phonon::createPath(m_mediaObject, m_audioOutput);

    m_volumeSlider->setAudioOutput(m_audioOutput);

    m_volumeSlider->setOrientation(Qt::Horizontal);

    setZeroTime();

    // Loading first song
    m_mediaObject->setCurrentSource(static_cast<QUrl>(m_urlList[m_currIndex]));
}
Exemple #6
0
TransitionTimeline::TransitionTimeline(Document* document, PassOwnPtr<PlatformTiming> timing)
    : DocumentTimeline(document, timing)
{
    setZeroTime(document->animationClock().currentTime());
    document->animationClock().unfreeze();
}
/****************************************
* RecVideo
*	Obtiene los packetes y los muestra
*****************************************/
int VideoStream::RecVideo()
{
	VideoDecoder*	videoDecoder = NULL;
	VideoCodec::Type type;
	timeval 	before;
	timeval		lastFPURequest;
	DWORD		lostCount=0;
	DWORD		frameTime = (DWORD)-1;
	DWORD		lastSeq = RTPPacket::MaxExtSeqNum;
	bool		waitIntra = false;
	
	
	Log(">RecVideo\n");
	
	//Get now
	gettimeofday(&before,NULL);

	//Not sent FPU yet
	setZeroTime(&lastFPURequest);

	//Mientras tengamos que capturar
	while(receivingVideo)
	{
		//Get RTP packet
		RTPPacket* packet = rtp.GetPacket();

		//Check
		if (!packet)
			//Next
			continue;
		
		//Get extended sequence number and timestamp
		DWORD seq = packet->GetExtSeqNum();
		DWORD ts = packet->GetTimestamp();

		//Get packet data
		BYTE* buffer = packet->GetMediaData();
		DWORD size = packet->GetMediaLength();

		//Get type
		type = (VideoCodec::Type)packet->GetCodec();

		//Lost packets since last
		DWORD lost = 0;

		//If not first
		if (lastSeq!=RTPPacket::MaxExtSeqNum)
			//Calculate losts
			lost = seq-lastSeq-1;

		//Increase total lost count
		lostCount += lost;

		//Update last sequence number
		lastSeq = seq;

		//If lost some packets or still have not got an iframe
		if(lostCount || waitIntra)
		{
			//Check if we got listener and more than 1/2 second have elapsed from last request
			if (listener && getDifTime(&lastFPURequest)>minFPUPeriod)
			{
				//Debug
				Debug("-Requesting FPU lost %d\n",lostCount);
				//Reset count
				lostCount = 0;
				//Request it
				listener->onRequestFPU();
				//Request also over rtp
				rtp.RequestFPU();
				//Update time
				getUpdDifTime(&lastFPURequest);
				//Waiting for refresh
				waitIntra = true;
			}
		}

		//Check if it is a redundant packet
		if (type==VideoCodec::RED)
		{
			//Get redundant packet
			RTPRedundantPacket* red = (RTPRedundantPacket*)packet;
			//Get primary codec
			type = (VideoCodec::Type)red->GetPrimaryCodec();
			//Check it is not ULPFEC redundant packet
			if (type==VideoCodec::ULPFEC)
			{
				//Delete packet
				delete(packet);
				//Skip
				continue;
			}
			//Update primary redundant payload
			buffer = red->GetPrimaryPayloadData();
			size = red->GetPrimaryPayloadSize();
		}
		
		//Check codecs
		if ((videoDecoder==NULL) || (type!=videoDecoder->type))
		{
			//If we already got one
			if (videoDecoder!=NULL)
				//Delete it
				delete videoDecoder;

			//Create video decorder for codec
			videoDecoder = VideoCodecFactory::CreateDecoder(type);

			//Check
			if (videoDecoder==NULL)
			{
				Error("Error creando nuevo decodificador de video [%d]\n",type);
				//Delete packet
				delete(packet);
				//Next
				continue;
			}
		}

		//Check if we have lost the last packet from the previous frame by comparing both timestamps
		if (ts>frameTime)
		{
			Debug("-lost mark packet ts:%u frameTime:%u\n",ts,frameTime);
			//Try to decode what is in the buffer
			videoDecoder->DecodePacket(NULL,0,1,1);
			//Get picture
			BYTE *frame = videoDecoder->GetFrame();
			DWORD width = videoDecoder->GetWidth();
			DWORD height = videoDecoder->GetHeight();
			//Check values
			if (frame && width && height)
			{
				//Set frame size
				videoOutput->SetVideoSize(width,height);

				//Check if muted
				if (!muted)
					//Send it
					videoOutput->NextFrame(frame);
			}
		}
		
		//Update frame time
		frameTime = ts;
		
		//Decode packet
		if(!videoDecoder->DecodePacket(buffer,size,lost,packet->GetMark()))
		{
			//Check if we got listener and more than 1/2 seconds have elapsed from last request
			if (listener && getDifTime(&lastFPURequest)>minFPUPeriod)
			{
				//Debug
				Log("-Requesting FPU decoder error\n");
				//Reset count
				lostCount = 0;
				//Request it
				listener->onRequestFPU();
				//Request also over rtp
				rtp.RequestFPU();
				//Update time
				getUpdDifTime(&lastFPURequest);
				//Waiting for refresh
				waitIntra = true;
			}
		}

		//Check if it is the last packet of a frame
		if(packet->GetMark())
		{
			if (videoDecoder->IsKeyFrame())
				Debug("-Got Intra\n");
			
			//No frame time yet for next frame
			frameTime = (DWORD)-1;

			//Get picture
			BYTE *frame = videoDecoder->GetFrame();
			DWORD width = videoDecoder->GetWidth();
			DWORD height = videoDecoder->GetHeight();
			//Check values
			if (frame && width && height)
			{
				//Set frame size
				videoOutput->SetVideoSize(width,height);
				
				//Check if muted
				if (!muted)
					//Send it
					videoOutput->NextFrame(frame);
			}
			//Check if we got the waiting refresh
			if (waitIntra && videoDecoder->IsKeyFrame())
				//Do not wait anymore
				waitIntra = false;
		}
		//Delete packet
		delete(packet);
	}

	//Delete encoder
	delete videoDecoder;

	Log("<RecVideo\n");
}