ffmpeg: exporting RTP header extension via packet side data
Exports RTP header extension as base64 encoded side data of type AV_PKT_DATA_STRINGS_METADATA.
--- ffmpeg-4.2.7/libavformat/rtpdec.c 2022-05-13 23:07:14.000000000 +0000
+++ ffmpeg-4.2.7-patched/libavformat/rtpdec.c 2024-12-28 12:40:26.348880247 +0000
@@ -23,6 +23,7 @@
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/time.h"
+#include "libavutil/base64.h"
#include "avformat.h"
#include "network.h"
@@ -630,6 +631,7 @@
unsigned int ssrc;
int payload_type, seq, flags = 0;
int ext, csrc;
+ uint8_t *rtp_ext;
AVStream *st;
uint32_t timestamp;
int rv = 0;
@@ -704,6 +706,16 @@
// now perform timestamp things....
finalize_packet(s, pkt, timestamp);
+ if (ext) {
+ rtp_ext = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, 8 + AV_BASE64_SIZE(ext));
+
+ if (rtp_ext) {
+ memset(rtp_ext, 0, 8 + AV_BASE64_SIZE(ext));
+ memcpy(rtp_ext, "rtp_ext", 8);
+ av_base64_encode(rtp_ext + 8, AV_BASE64_SIZE(ext), buf - ext, ext);
+ }
+ }
+
return rv;
}