libeplayer3: fix backward mode

Origin commit data
------------------
Branch: master
Commit: b770330731
Author: martii <m4rtii@gmx.de>
Date: 2014-04-18 (Fri, 18 Apr 2014)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
martii
2014-04-18 16:09:54 +02:00
parent 2b2a43de82
commit 1a60f50ef3
2 changed files with 19 additions and 28 deletions

View File

@@ -82,8 +82,9 @@ bool Input::Play()
{
hasPlayThreadStarted = 1;
int64_t showtime = 0, bofcount = 0;
int64_t showtime = 0;
bool restart_audio_resampling = false;
bool bof = false;
int warnAudioWrite = 0;
int warnVideoWrite = 0;
@@ -103,19 +104,19 @@ bool Input::Play()
if (avfc->iformat->flags & AVFMT_TS_DISCONT) {
if (avfc->bit_rate) {
seek_target_flag = AVSEEK_FLAG_BYTE;
seek_target = avio_tell(avfc->pb) + seek_avts_rel * avfc->bit_rate / ( 8 * AV_TIME_BASE);
seek_target = avio_tell(avfc->pb) + av_rescale(seek_avts_rel, avfc->bit_rate, 8 * AV_TIME_BASE);
}
} else {
int64_t pts;
if(player->output.GetPts(pts))
seek_target = (pts * AV_TIME_BASE) / 90000 + seek_avts_rel;
seek_target = av_rescale(pts, AV_TIME_BASE, 90000ll) + seek_avts_rel;
}
seek_avts_rel = 0;
} else if (seek_avts_abs != INT64_MIN) {
if (avfc->iformat->flags & AVFMT_TS_DISCONT) {
if (avfc->bit_rate) {
seek_target_flag = AVSEEK_FLAG_BYTE;
seek_target = seek_avts_abs * avfc->bit_rate / (8 * AV_TIME_BASE);
seek_target = av_rescale(seek_avts_abs, avfc->bit_rate, 8 * AV_TIME_BASE);
}
} else {
seek_target = seek_avts_abs;
@@ -124,27 +125,16 @@ bool Input::Play()
} else if (player->isBackWard && av_gettime() >= showtime) {
player->output.ClearVideo();
if (bofcount == 1) {
if (bof) {
showtime = av_gettime();
usleep(100000);
continue;
}
if (avfc->iformat->flags & AVFMT_TS_DISCONT) {
off_t pos = avio_tell(avfc->pb);
if (pos > 0 && avfc->bit_rate) {
seek_target_flag = AVSEEK_FLAG_BYTE;
seek_target = pos + player->Speed * avfc->bit_rate * AV_TIME_BASE;
}
} else {
int64_t pts;
if(player->output.GetPts(pts))
seek_target = (pts * AV_TIME_BASE) / 90000 + seek_avts_rel;
}
seek_avts_rel = player->Speed * AV_TIME_BASE;
showtime = av_gettime() + 300000; //jump back every 300ms
continue;
} else {
bofcount = 0;
bof = false;
}
if (seek_target > INT64_MIN) {
@@ -154,7 +144,8 @@ bool Input::Play()
res = avformat_seek_file(avfc, -1, INT64_MIN, seek_target, INT64_MAX, seek_target_flag);
if (res < 0 && player->isBackWard)
bofcount = 1;
bof = true;
seek_target = INT64_MIN;
restart_audio_resampling = true;

View File

@@ -79,7 +79,7 @@ bool Output::Open()
if (videofd < 0)
return false;
dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL);
ioctl(videofd, VIDEO_CLEAR_BUFFER, NULL);
dioctl(videofd, VIDEO_SELECT_SOURCE, (void *) VIDEO_SOURCE_MEMORY);
dioctl(videofd, VIDEO_SET_STREAMTYPE, (void *) STREAM_TYPE_PROGRAM);
dioctl(videofd, VIDEO_SET_SPEED, DVB_SPEED_NORMAL_PLAY);
@@ -93,7 +93,7 @@ bool Output::Open()
return false;
}
dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL);
ioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL);
dioctl(audiofd, AUDIO_SELECT_SOURCE, (void *) AUDIO_SOURCE_MEMORY);
dioctl(audiofd, AUDIO_SET_STREAMTYPE, (void *) STREAM_TYPE_PROGRAM);
@@ -225,10 +225,10 @@ bool Output::Flush()
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
if (videofd > -1 && dioctl(videofd, VIDEO_FLUSH, NULL))
if (videofd > -1 && ioctl(videofd, VIDEO_FLUSH, NULL))
ret = false;
if (audiofd > -1 && dioctl(audiofd, AUDIO_FLUSH, NULL))
if (audiofd > -1 && ioctl(audiofd, AUDIO_FLUSH, NULL))
ret = false;
return ret;
@@ -255,13 +255,13 @@ bool Output::AVSync(bool b)
bool Output::ClearAudio()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> a_lock(audioMutex);
return audiofd > -1 && !dioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL);
return audiofd > -1 && !ioctl(audiofd, AUDIO_CLEAR_BUFFER, NULL);
}
bool Output::ClearVideo()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> v_lock(videoMutex);
return videofd > -1 && !dioctl(videofd, VIDEO_CLEAR_BUFFER, NULL);
return videofd > -1 && !ioctl(videofd, VIDEO_CLEAR_BUFFER, NULL);
}
bool Output::Clear()
@@ -274,8 +274,8 @@ bool Output::Clear()
bool Output::GetPts(int64_t &pts)
{
pts = 0;
return ((videofd > -1 && !dioctl(videofd, VIDEO_GET_PTS, (void *) &pts)) ||
(audiofd > -1 && !dioctl(audiofd, AUDIO_GET_PTS, (void *) &pts)));
return ((videofd > -1 && !ioctl(videofd, VIDEO_GET_PTS, (void *) &pts)) ||
(audiofd > -1 && !ioctl(audiofd, AUDIO_GET_PTS, (void *) &pts)));
}
bool Output::GetFrameCount(int64_t &framecount)