From 4e1a89c3247db72076893d3fc5ad80f4b3c04ec2 Mon Sep 17 00:00:00 2001 From: ireader Date: Sat, 21 Sep 2024 09:56:01 +0800 Subject: [PATCH] fix: amf write date --- libflv/include/flv-proto.h | 4 ++-- libflv/include/opus-head.h | 1 + libflv/source/amf0.c | 2 +- libflv/source/opus-head.c | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libflv/include/flv-proto.h b/libflv/include/flv-proto.h index fa26b1a8..dd24c806 100644 --- a/libflv/include/flv-proto.h +++ b/libflv/include/flv-proto.h @@ -20,11 +20,11 @@ #define FLV_AUDIO_AAC (10 << 4) #define FLV_AUDIO_SPEEX (11 << 4) #define FLV_AUDIO_AC3 (12 << 4) // enhanced rtmp v2 -#define FLV_AUDIO_OPUS (13 << 4) +#define FLV_AUDIO_OPUS (13 << 4) // opus-codec.org #define FLV_AUDIO_MP3_8K (14 << 4) // MP3 8 kHz #define FLV_AUDIO_DEVIDE (15 << 4) // Device-specific sound #define FLV_AUDIO_ASC (0x1000 | FLV_AUDIO_AAC) // AudioSpecificConfig(ISO-14496-3) -#define FLV_AUDIO_OPUS_HEAD (0x1100 | FLV_AUDIO_OPUS) // opus-codec.org +#define FLV_AUDIO_OPUS_HEAD (0x1100 | FLV_AUDIO_OPUS) // https://datatracker.ietf.org/doc/html/rfc7845#section-5.1 #define FLV_AUDIO_FLAC_HEAD (0x1200 | FLV_AUDIO_FLAC) // xiph.org/flac // FLV Video Type diff --git a/libflv/include/opus-head.h b/libflv/include/opus-head.h index 630ad541..faa37078 100644 --- a/libflv/include/opus-head.h +++ b/libflv/include/opus-head.h @@ -21,6 +21,7 @@ struct opus_head_t uint8_t channel_mapping[8]; }; +/// @param[out] data https://datatracker.ietf.org/doc/html/rfc7845#section-5.1 /// @return >0-ok, <=0-error int opus_head_save(const struct opus_head_t* opus, uint8_t* data, size_t bytes); /// @return >0-ok, <=0-error diff --git a/libflv/source/amf0.c b/libflv/source/amf0.c index 333cc394..6d534658 100644 --- a/libflv/source/amf0.c +++ b/libflv/source/amf0.c @@ -153,7 +153,7 @@ uint8_t* AMFWriteDate(uint8_t* ptr, const uint8_t* end, double milliseconds, int AMFWriteDouble(ptr, end, milliseconds); *ptr = AMF_DATE; // rewrite to date - return AMFWriteInt16(ptr + 8, end, timezone); + return AMFWriteInt16(ptr + 9, end, timezone); } uint8_t* AMFWriteNamedBoolean(uint8_t* ptr, const uint8_t* end, const char* name, size_t length, uint8_t value) diff --git a/libflv/source/opus-head.c b/libflv/source/opus-head.c index d1387cc9..98821beb 100644 --- a/libflv/source/opus-head.c +++ b/libflv/source/opus-head.c @@ -3,6 +3,7 @@ #include #include +// https://datatracker.ietf.org/doc/html/rfc7845#section-5.1 // http://www.opus-codec.org/docs/opus_in_isobmff.html // 4.3.2 Opus Specific Box /*