MP4(3)

πŸ“¦ version 2.1.0, in fedora 43, fedora 44

πŸ’– MP4BinaryToBase64 πŸ’–

okay bestie so this is a page from the MP4 File Format Library, and it lives in section 3 of the manual β€” that's the MP4(3) zone, the C library function corner of the man world 🫢. Lowkey the whole thing is about one tiny iconic little function that turns your crunchy binary bytes into a cute little base 64 string. Slay. Let's get into it ✨


✨ NAME ✨

MP4BinaryToBase64 β€” converts binary data to a base 64 string πŸ’…


🌸 SYNTAX 🌸

#include <mp4.h>

char* MP4BinaryToBase64(
     const u_int8_t* pData,
     u_int32_t dataSize
)

not me showing you the exact signature, character for character, because that's the whole vibe πŸ”₯


πŸŽ€ ARGUMENTS πŸŽ€

  • pData β€” the pointer to the binary data, bestie. It's the raw stuff. It's const, so don't even think about touching it πŸ™ˆ
  • dataSize β€” the size in bytes of that binary data. Yes, bytes. It's a u_int32_t. It's giving "I counted, trust me" πŸ’œ

πŸ‘‘ RETURN VALUES πŸ‘‘

  • Upon success: a null terminated string representing the data in base 64. So iconic. So well behaved.
  • Upon error: NULL. 😭 yeah. check for it. please.

🌈 DESCRIPTION 🌈

MP4BinaryToBase64 converts binary data to a base 64 string. Periodt.

The way this encoding works is it maps groups of 6 bits into the character set [A-Za-z0-9+/=]. That's the whole alphabet, no cap. And the string it hands back is sitting in malloc'd memory, so πŸ‘ the πŸ‘ caller πŸ‘ is πŸ‘ responsible πŸ‘ for πŸ‘ free'ing πŸ‘ the πŸ‘ memory. I'm serious. That's your job now. main character responsibility energy 🧚

This utility is useful for generating the SDP descriptions for some RTP payloads. ykyk πŸ¦‹

Example, because examples eat every time:

0x12, 0xAB -> "Eqs="

literally that. two lil bytes walk in, a four character base 64 string walks out. ate πŸ’…


πŸ’€ SEE ALSO πŸ’€

  • MP4(3) β€” go read the whole library page, bestie, it's the mothership πŸŽ€

and that's the page!! πŸ’– it's from Cisco Systems Inc., it's Version 0.9, and it's hanging out in the MP4(3) section of the manual. go forth and free your malloc'd strings, queen πŸ‘‘βœ¨πŸŒˆ

πŸ“¦ where this page comes from