Skip to content

Commit

Permalink
fix(ActiveDecoder): drop the CORRUPT packet
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Jan 19, 2020
1 parent 03e3a9d commit d40fc47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion framework/base/media/AVAFPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ void AVAFPacket::copyInfo()
mInfo.pts = mpkt->pts;
mInfo.dts = mpkt->dts;
// TODO: redefine the flags
mInfo.flags = mpkt->flags;
mInfo.flags = 0;
if (mpkt->flags & AV_PKT_FLAG_KEY)
mInfo.flags |= AF_PKT_FLAG_KEY;
if (mpkt->flags & AV_PKT_FLAG_CORRUPT)
mInfo.flags |= AF_PKT_FLAG_CORRUPT;

mInfo.streamIndex = mpkt->stream_index;
mInfo.timePosition = INT64_MIN;
mInfo.pos = mpkt->pos;
Expand Down
3 changes: 2 additions & 1 deletion framework/base/media/IAFPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ struct AFRational {

AFRational &operator=(AVRational rational);
};

#define AF_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
#define AF_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
class CICADA_CPLUS_EXTERN IAFPacket {
public:
struct packetInfo {
Expand Down
4 changes: 3 additions & 1 deletion framework/codec/ActiveDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ bool ActiveDecoder::needDrop(IAFPacket *packet)
if (packet == nullptr) {
return false;
}
if (packet->getInfo().flags & AF_PKT_FLAG_CORRUPT)
return true;

if (bNeedKeyFrame) { // need a key frame, when first start or after seek
if (packet->getInfo().flags == 0) { // drop the frame that not a key frame
if ((packet->getInfo().flags & AF_PKT_FLAG_KEY) == 0) { // drop the frame that not a key frame
// TODO: return error?
AF_LOGW("wait a key frame\n");
return true;
Expand Down

0 comments on commit d40fc47

Please sign in to comment.