From 6448f3765da41e61536b86bd67b53896f1a237f2 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 4 Sep 2026 11:18:49 -0400 Subject: [PATCH] MT#65420 support setting marker from packetizer Change-Id: Icbaa3b874e0afcd3bd9ca06e6c8b684ee2312542 --- daemon/codec.c | 4 ++-- lib/amr.c | 2 +- lib/codeclib.c | 4 ++-- lib/codeclib.h | 2 +- lib/g729.c | 4 ++-- t/test-amr-encode.c | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 5717196e5..b8e13d8e6 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -232,7 +232,7 @@ struct codec_ssrc_handler { uint64_t skip_pts; - bool rtp_mark:1; + bool rtp_mark; }; struct transcode_packet { seq_packet_t p; // must be first @@ -4596,7 +4596,7 @@ void packet_encoded_packetize(AVPacket *pkt, struct codec_ssrc_handler *ch, stru ilogs(transcoding, LOG_DEBUG, "Adding %i bytes to packetizer", in_pkt->size); int64_t pts, duration; int ret = pktzer->fn(in_pkt, &inout, ch->bytes_per_packet, pkt_f_data, &pts, - &duration); + &duration, &ch->rtp_mark); if (G_UNLIKELY(ret == -1 || pts == AV_NOPTS_VALUE)) { // nothing diff --git a/lib/amr.c b/lib/amr.c index a1c85de82..707a0ab4a 100644 --- a/lib/amr.c +++ b/lib/amr.c @@ -527,7 +527,7 @@ static void amr_encoder_got_packet(encoder_t *enc) { enc->avc.amr.pkt_seq++; } static int packetizer_amr_fn(AVPacket *pkt, str *output, size_t num_bytes, encoder_t *enc, - int64_t *__restrict pts, int64_t *__restrict duration) + int64_t *__restrict pts, int64_t *__restrict duration, bool *mark) { assert(pkt->size >= 1); diff --git a/lib/codeclib.c b/lib/codeclib.c index e310e9891..d04b0dd82 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -847,7 +847,7 @@ static int encoder_input_fifo(encoder_t *enc, AVFrame *frame, static int packetizer_passthrough_fn(AVPacket *pkt, str *output, size_t num_bytes, encoder_t *enc, - int64_t *__restrict pts, int64_t *__restrict duration) + int64_t *__restrict pts, int64_t *__restrict duration, bool *mark) { if (!pkt) return -1; @@ -871,7 +871,7 @@ packetizer_t packetizer_passthrough = { // returns: -1 = not enough data, nothing returned; 0 = returned a packet; // 1 = returned a packet and there's more static int packetizer_samplestream_fn(AVPacket *pkt, str *input_output, size_t num_bytes, - encoder_t *enc, int64_t *__restrict pts, int64_t *__restrict duration) + encoder_t *enc, int64_t *__restrict pts, int64_t *__restrict duration, bool *mark) { GString *buf = enc->sample_buffer; diff --git a/lib/codeclib.h b/lib/codeclib.h index d594854da..f4be4c02e 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -107,7 +107,7 @@ typedef struct dtx_method_s dtx_method_t; typedef struct codec_cc_s codec_cc_t; typedef int packetizer_f(AVPacket *, str *, size_t, encoder_t *, - int64_t *__restrict pts, int64_t *__restrict dur); + int64_t *__restrict pts, int64_t *__restrict dur, bool *mark); typedef void format_init_f(struct rtp_payload_type *); typedef bool set_enc_options_f(encoder_t *, const str *); typedef void set_dec_options_f(decoder_t *, const str *); diff --git a/lib/g729.c b/lib/g729.c index fa220d953..c37317acc 100644 --- a/lib/g729.c +++ b/lib/g729.c @@ -216,7 +216,7 @@ static void bcg729_encoder_close(encoder_t *enc) { } static int packetizer_g729_fn(AVPacket *pkt, str *input_output, size_t num_bytes, encoder_t *enc, - int64_t *__restrict pts, int64_t *__restrict duration) + int64_t *__restrict pts, int64_t *__restrict duration, bool *mark) { GString *buf = enc->sample_buffer; @@ -225,7 +225,7 @@ static int packetizer_g729_fn(AVPacket *pkt, str *input_output, size_t num_bytes // easiest case: we only want one frame. return what we got if (want_frames == 1 && pkt) - return packetizer_passthrough.fn(pkt, input_output, num_bytes, enc, pts, duration); + return packetizer_passthrough.fn(pkt, input_output, num_bytes, enc, pts, duration, mark); // any other case, we go through our buffer str output = *input_output; // remaining output buffer diff --git a/t/test-amr-encode.c b/t/test-amr-encode.c index 658d3d062..5780b3cb1 100644 --- a/t/test-amr-encode.c +++ b/t/test-amr-encode.c @@ -24,7 +24,8 @@ static int dec_cb(encoder_t *e, void *u1, void *u2) { char payload[plen]; str inout = STR_LEN(payload, plen); int64_t pts, dur; - e->def->packetizer->fn(e->avpkt, &inout, plen, e, &pts, &dur); + bool mark; + e->def->packetizer->fn(e->avpkt, &inout, plen, e, &pts, &dur, &mark); if (inout.len != *expect_len || memcmp(inout.s, *expect, *expect_len))