Skip to content

Commit

Permalink
fix(media_packet_queue): fix get key frame logic
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Feb 18, 2020
1 parent 46b5bd5 commit 3318748
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mediaPlayer/media_packet_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace Cicada {
for (auto r_iter = mQueue.rbegin(); r_iter != mQueue.rend(); ++r_iter) {
IAFPacket *packet = (*r_iter).get();

if (packet && packet->getInfo().flags) {
if (packet && (packet->getInfo().flags & AF_PKT_FLAG_KEY)) {
lastPos = packet->getInfo().timePosition;
return lastPos;
}
Expand All @@ -72,6 +72,7 @@ namespace Cicada {

return mQueue.back()->getInfo().pts;
}

int64_t MediaPacketQueue::GetLastTimePos()
{
ADD_LOCK;
Expand All @@ -82,6 +83,7 @@ namespace Cicada {

return mQueue.back()->getInfo().timePosition;
}

int64_t MediaPacketQueue::GetKeyPTSBefore(int64_t pts)
{
ADD_LOCK;
Expand All @@ -90,7 +92,7 @@ namespace Cicada {
for (auto r_iter = mQueue.rbegin(); r_iter != mQueue.rend(); ++r_iter) {
IAFPacket *packet = (*r_iter).get();

if (packet && packet->getInfo().flags && packet->getInfo().pts <= pts) {
if (packet && (packet->getInfo().flags & AF_PKT_FLAG_KEY) && packet->getInfo().pts <= pts) {
lastKeyPts = packet->getInfo().pts;
return lastKeyPts;
}
Expand All @@ -107,7 +109,7 @@ namespace Cicada {
for (auto r_iter = mQueue.rbegin(); r_iter != mQueue.rend(); ++r_iter) {
IAFPacket *packet = (*r_iter).get();

if (packet && packet->getInfo().flags && packet->getInfo().timePosition <= pts) {
if (packet && (packet->getInfo().flags & AF_PKT_FLAG_KEY) && packet->getInfo().timePosition <= pts) {
lastKeyPos = packet->getInfo().timePosition;
return lastKeyPos;
}
Expand Down Expand Up @@ -185,6 +187,7 @@ namespace Cicada {

return mDuration;
}

int64_t MediaPacketQueue::ClearPacketBeforePTS(int64_t pts)
{
ADD_LOCK;
Expand All @@ -203,6 +206,7 @@ namespace Cicada {

return dropCount;
}

int64_t MediaPacketQueue::ClearPacketBeforeTimePos(int64_t pts)
{
ADD_LOCK;
Expand Down

0 comments on commit 3318748

Please sign in to comment.