Simplify demuxer

Call the same push_packet_to_sinks() in all cases, and make
sc_demuxer_parse() return void.
This commit is contained in:
Romain Vimont 2022-02-02 21:03:24 +01:00
parent 7dec225ceb
commit c460243ce2

View file

@ -69,7 +69,7 @@ push_packet_to_sinks(struct sc_demuxer *demuxer, const AVPacket *packet) {
return true; return true;
} }
static bool static void
sc_demuxer_parse(struct sc_demuxer *demuxer, AVPacket *packet) { sc_demuxer_parse(struct sc_demuxer *demuxer, AVPacket *packet) {
uint8_t *in_data = packet->data; uint8_t *in_data = packet->data;
int in_len = packet->size; int in_len = packet->size;
@ -89,14 +89,6 @@ sc_demuxer_parse(struct sc_demuxer *demuxer, AVPacket *packet) {
} }
packet->dts = packet->pts; packet->dts = packet->pts;
bool ok = push_packet_to_sinks(demuxer, packet);
if (!ok) {
LOGE("Could not process packet");
return false;
}
return true;
} }
static bool static bool
@ -138,25 +130,23 @@ sc_demuxer_push_packet(struct sc_demuxer *demuxer, AVPacket *packet) {
} }
} }
if (is_config) { if (!is_config) {
// config packet
bool ok = push_packet_to_sinks(demuxer, packet);
if (!ok) {
return false;
}
} else {
// data packet // data packet
bool ok = sc_demuxer_parse(demuxer, packet); sc_demuxer_parse(demuxer, packet);
}
if (demuxer->pending) { bool ok = push_packet_to_sinks(demuxer, packet);
if (!is_config && demuxer->pending) {
// the pending packet must be discarded (consumed or error) // the pending packet must be discarded (consumed or error)
av_packet_free(&demuxer->pending); av_packet_free(&demuxer->pending);
} }
if (!ok) { if (!ok) {
LOGE("Could not process packet");
return false; return false;
} }
}
return true; return true;
} }