diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/libmp4v2/atom_ohdr.cpp | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/external_dependencies/libmp4v2/atom_ohdr.cpp')
-rw-r--r-- | Src/external_dependencies/libmp4v2/atom_ohdr.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Src/external_dependencies/libmp4v2/atom_ohdr.cpp b/Src/external_dependencies/libmp4v2/atom_ohdr.cpp new file mode 100644 index 00000000..301090fd --- /dev/null +++ b/Src/external_dependencies/libmp4v2/atom_ohdr.cpp @@ -0,0 +1,92 @@ +/** \file atom_ohdr.cpp + + \author Danijel Kopcinovic (danijel.kopcinovic@adnecto.net) +*/ + +#include "mp4common.h" + +/*! \brief Patch class for read/write operations when string is 0-length. + + We want to use string property, but mpeg4ip doesn't support ohdr way of + encoding of string (in ohdr atom we first have 3 lengths of 3 strings and + then their string values, and it cannot be simulated with any of the + current mpeg4ip string property parameters), so we have to write our own + Read() and Write() routines. +*/ +class OhdrMP4StringProperty: public MP4StringProperty { +public: + /*! \brief Constructor. + + \param name name of the property. + \param useCountedFormat counted format flag. + \param useUnicode unicode flag. + */ + OhdrMP4StringProperty(char* name, bool useCountedFormat = false, + bool useUnicode = false): MP4StringProperty(name, useCountedFormat, + useUnicode) { + } + + /*! \brief Read property from file. + + \param pFile input, file handle. + \param index input, index to read. + */ + void Read(MP4File* pFile, u_int32_t index = 0) { + MP4Free(m_values[index]); + m_values[index] = (char*)MP4Calloc(m_fixedLength + 1); + (void)pFile->ReadBytes((u_int8_t*)m_values[index], m_fixedLength); + } + + /*! \brief Write property to file. + + \param pFile input, file handle. + \param index input, index to write. + */ + void Write(MP4File* pFile, u_int32_t index = 0) { + pFile->WriteBytes((u_int8_t*)m_values[index], m_fixedLength); + } +}; + +/*! \brief OMA DRM headers atom. + + Contained in OMA DRM key management atom. It must contain content identifier. +*/ +/*! \brief Constructor. +*/ +MP4OhdrAtom::MP4OhdrAtom(): MP4Atom("ohdr") { + AddVersionAndFlags(); + + AddProperty(new MP4Integer8Property("EncryptionMethod")); + AddProperty(new MP4Integer8Property("EncryptionPadding")); + AddProperty(new MP4Integer64Property("PlaintextLength")); + AddProperty(new MP4Integer16Property("ContentIDLength")); + AddProperty(new MP4Integer16Property("RightsIssuerURLLength")); + AddProperty(new MP4Integer16Property("TextualHeadersLength")); + AddProperty(new OhdrMP4StringProperty("ContentID")); + AddProperty(new OhdrMP4StringProperty("RightsIssuerURL")); + AddProperty(new MP4BytesProperty("TextualHeaders")); +} + +MP4OhdrAtom::~MP4OhdrAtom() { +} + +/*! \brief Read atom. +*/ +void MP4OhdrAtom::Read() { + ReadProperties(0, 8); + MP4Property* lProperty; + MP4Property* property; + lProperty = GetProperty(5); + property = GetProperty(8); + ((OhdrMP4StringProperty*)property)->SetFixedLength( + ((MP4Integer16Property*)lProperty)->GetValue()); + lProperty = GetProperty(6); + property = GetProperty(9); + ((OhdrMP4StringProperty*)property)->SetFixedLength( + ((MP4Integer16Property*)lProperty)->GetValue()); + lProperty = GetProperty(7); + property = GetProperty(10); + ((MP4BytesProperty*)property)->SetFixedSize( + ((MP4Integer16Property*)lProperty)->GetValue()); + ReadProperties(8, 3); +} |