|
|
@ -22,76 +22,81 @@ PlayVideo::PlayVideo(QObject *parent,
|
|
|
|
void PlayVideo::play()
|
|
|
|
void PlayVideo::play()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MediaPacket *pkt;
|
|
|
|
MediaPacket *pkt;
|
|
|
|
|
|
|
|
int usl;
|
|
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vcrMutex.lock();
|
|
|
|
vcrMutex.lock();
|
|
|
|
switch (vcrFlag)
|
|
|
|
switch (vcrFlag)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case VCR_PLAY:
|
|
|
|
case VCR_PLAY:
|
|
|
|
vcrFlag = 0;
|
|
|
|
vcrFlag = 0;
|
|
|
|
vcrMutex.unlock();
|
|
|
|
vcrMutex.unlock();
|
|
|
|
if (pausedTime)
|
|
|
|
if (pausedTime)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
elapsedTime = av_gettime() - pausedTime;
|
|
|
|
elapsedTime = av_gettime() - pausedTime;
|
|
|
|
pausedTime = 0;
|
|
|
|
pausedTime = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isStopped = false;
|
|
|
|
isStopped = false;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case VCR_PAUSE:
|
|
|
|
case VCR_PAUSE:
|
|
|
|
vcrMutex.unlock();
|
|
|
|
vcrMutex.unlock();
|
|
|
|
if (!pausedTime)
|
|
|
|
if (!pausedTime)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* save amount of video played so far */
|
|
|
|
/* save amount of video played so far */
|
|
|
|
pausedTime = av_gettime() - elapsedTime;
|
|
|
|
pausedTime = av_gettime() - elapsedTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
usleep(1000 * 100);
|
|
|
|
|
|
|
|
isStopped = false;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case VCR_STOP:
|
|
|
|
|
|
|
|
vcrMutex.unlock();
|
|
|
|
|
|
|
|
if (isStopped)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
usleep(1000 * 100);
|
|
|
|
usleep(1000 * 100);
|
|
|
|
|
|
|
|
isStopped = false;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
clearVideoQ();
|
|
|
|
|
|
|
|
elapsedTime = 0;
|
|
|
|
case VCR_STOP:
|
|
|
|
pausedTime = 0;
|
|
|
|
vcrMutex.unlock();
|
|
|
|
la_seekPos = -1;
|
|
|
|
if (isStopped)
|
|
|
|
xrdpvr_seek_media(0, 0);
|
|
|
|
{
|
|
|
|
isStopped = true;
|
|
|
|
usleep(1000 * 100);
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearVideoQ();
|
|
|
|
|
|
|
|
elapsedTime = 0;
|
|
|
|
|
|
|
|
pausedTime = 0;
|
|
|
|
|
|
|
|
la_seekPos = -1;
|
|
|
|
|
|
|
|
xrdpvr_seek_media(0, 0);
|
|
|
|
|
|
|
|
isStopped = true;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
vcrMutex.unlock();
|
|
|
|
vcrMutex.unlock();
|
|
|
|
goto label1;
|
|
|
|
goto label1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
label1:
|
|
|
|
label1:
|
|
|
|
|
|
|
|
|
|
|
|
if (videoQueue->isEmpty())
|
|
|
|
if (videoQueue->isEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qDebug() << "PlayVideo::play: GOT EMPTY";
|
|
|
|
|
|
|
|
usleep(1000 * 100);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pkt = videoQueue->dequeue();
|
|
|
|
pkt = videoQueue->dequeue();
|
|
|
|
sendMutex->lock();
|
|
|
|
sendMutex->lock();
|
|
|
|
send_video_pkt(channel, stream_id, pkt->av_pkt);
|
|
|
|
send_video_pkt(channel, stream_id, pkt->av_pkt);
|
|
|
|
sendMutex->unlock();
|
|
|
|
sendMutex->unlock();
|
|
|
|
|
|
|
|
usl = pkt->delay_in_us;
|
|
|
|
|
|
|
|
if (usl < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
usl = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usl > 100 * 1000)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
usl = 100 * 1000;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
usleep(usl);
|
|
|
|
delete pkt;
|
|
|
|
delete pkt;
|
|
|
|
usleep(pkt->delay_in_us);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateMediaPos();
|
|
|
|
updateMediaPos();
|
|
|
|
|
|
|
|
|
|
|
|
if (elapsedTime == 0)
|
|
|
|
if (elapsedTime == 0)
|
|
|
|
elapsedTime = av_gettime();
|
|
|
|
elapsedTime = av_gettime();
|
|
|
|
|
|
|
|
|
|
|
|