Skip to content

Commit

Permalink
fix(HLSStream): improve subtitle seek
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Feb 24, 2020
1 parent 5839fac commit 7cc6587
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions framework/demuxer/play_list/HLSStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,9 +1187,10 @@ namespace Cicada {
AF_LOGD("%s:%d stream (%d) usSeeked is %lld seek num is %d\n", __func__, __LINE__,
mPTracker->getStreamType(), usSought, num);

if (mPTracker->getStreamType() == STREAM_TYPE_SUB && mPTracker->getSegSize() == 1) {
if (mPTracker->getStreamType() == STREAM_TYPE_SUB && num == mPTracker->getCurSegNum()) {
AF_LOGW("only one subtitle seg");
reqReOpen = false;
seek_internal(num, us);
}

mSwitchNeedBreak = true;
Expand All @@ -1215,7 +1216,6 @@ namespace Cicada {
mPTracker->setCurSegNum(num);
}

// seek_internal(num, us);
mIsEOS = false;
mIsDataEOS = false;
mError = 0;
Expand Down Expand Up @@ -1260,13 +1260,6 @@ namespace Cicada {

int HLSStream::reopenSegment(uint64_t num, OpenType openType)
{
bool reqReOpen = true;

if (mPTracker->getStreamType() == STREAM_TYPE_SUB && mPTracker->getSegSize() == 1) {
AF_LOGW("only one subtitle seg");
reqReOpen = false;
}

mSwitchNeedBreak = true;
mWaitCond.notify_one();

Expand All @@ -1276,22 +1269,19 @@ namespace Cicada {

mSwitchNeedBreak = false;
clearDataFrames();
resetSource();

if (reqReOpen) {
resetSource();

if (mIsOpened_internal) {
mReopen = true;
num--;
}
if (mIsOpened_internal) {
mReopen = true;
num--;
}

if (openType == OpenType::SegNum) {
mPTracker->setCurSegNum(num);
AF_LOGD("setCurSegNum %llu\n", num);
} else if (openType == OpenType::SegPosition) {
mPTracker->setCurSegPosition(num);
AF_LOGD("setCurSegPosition %llu\n", num);
}
if (openType == OpenType::SegNum) {
mPTracker->setCurSegNum(num);
AF_LOGD("setCurSegNum %llu\n", num);
} else if (openType == OpenType::SegPosition) {
mPTracker->setCurSegPosition(num);
AF_LOGD("setCurSegPosition %llu\n", num);
}

seek_internal(num, 0);
Expand Down

0 comments on commit 7cc6587

Please sign in to comment.