Skip to content

Commit

Permalink
fix(SuperMediaPlayer): update duration on ReadPacket
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai authored and I-m-SuperMan committed Feb 10, 2020
1 parent 38d3d85 commit 871c3a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ namespace Cicada {
} else if (theKey == "description") {
mSet.mOptions.set(theKey, value, options::REPLACE);
return 0;
} else if (theKey == "enableVRC") {
} else if (theKey == "enableVRC") {
mSet.bEnableVRC = (atoi(value) != 0);
}

Expand Down Expand Up @@ -580,7 +580,7 @@ namespace Cicada {
snprintf(value, MAX_OPT_VALUE_LENGTH, "%" PRId64 "", size);
} else if (theKey == "description") {
snprintf(value, MAX_OPT_VALUE_LENGTH, "%s", mSet.mOptions.get("description").c_str());
} else if ( theKey == "renderFps") {
} else if (theKey == "renderFps") {
float renderFps = GetVideoRenderFps();
snprintf(value, MAX_OPT_VALUE_LENGTH, "%f", renderFps);
}
Expand Down Expand Up @@ -2358,6 +2358,12 @@ namespace Cicada {

int id = GEN_STREAM_INDEX(pFrame->getInfo().streamIndex);

if (mDuration < 0) {
unique_ptr<streamMeta> pMeta;
mDemuxerService->GetStreamMeta(pMeta, pFrame->getInfo().streamIndex, false);
mDuration = ((Stream_meta *) (pMeta.get()))->duration;
}

if (id < mStreamInfoQueue.size()
&& mStreamInfoQueue[id]->type == ST_TYPE_VIDEO
&& mMainStreamId != -1 && id != mMainStreamId) {
Expand Down Expand Up @@ -2416,7 +2422,7 @@ namespace Cicada {
delete mVideoParser;
mVideoParser = nullptr;
} else {
mVideoParserTimes ++;
mVideoParserTimes++;

if (mVideoParserTimes > 10) {
mVideoInterlaced = InterlacedType_NO;
Expand Down Expand Up @@ -3102,7 +3108,7 @@ namespace Cicada {
mVideoWidth = 0;
mVideoHeight = 0;
mVideoRotation = 0;
mDuration = 0;
mDuration = INT64_MIN;
mBufferPosition = 0;
mSeekPos = INT64_MIN;
mPlayedVideoPts = INT64_MIN;
Expand Down Expand Up @@ -3979,7 +3985,7 @@ namespace Cicada {
{
while (!mVideoFrameQue.empty()) {
int64_t pts = mVideoFrameQue.front()->getInfo().pts;
ProcessVideoRenderedMsg(pts, af_getsteady_ms(), nullptr);
ProcessVideoRenderedMsg(pts, af_getsteady_ms(), nullptr);
mVideoFrameQue.pop();
}

Expand Down
2 changes: 1 addition & 1 deletion mediaPlayer/SuperMediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ namespace Cicada {
int mVideoWidth{0};
int mVideoHeight{0};
int mVideoRotation{0};
int64_t mDuration{0};
int64_t mDuration{INT64_MIN};
int64_t mBufferPosition{0};
PlayerStatus mOldPlayStatus{PLAYER_IDLE};
PlayerStatus mPlayStatus{PLAYER_IDLE};
Expand Down

0 comments on commit 871c3a6

Please sign in to comment.