- Main Page
- Classes
- Files

# Ap4Marlin.h

Go to the documentation of this file.

    00001 /*****************************************************************
    00002 |
    00003 |    AP4 - Marlin File Format support
    00004 |
    00005 |    Copyright 2008 Gilles Boccon-Gibod & Julien Boeuf
    00006 |
    00007 |
    00008 |    This file is part of Bento4/AP4 (MP4 Atom Processing Library).
    00009 |
    00010 |    Unless you have obtained Bento4 under a difference license,
    00011 |    this version of Bento4 is Bento4|GPL.
    00012 |    Bento4|GPL is free software; you can redistribute it and/or modify
    00013 |    it under the terms of the GNU General Public License as published by
    00014 |    the Free Software Foundation; either version 2, or (at your option)
    00015 |    any later version.
    00016 |
    00017 |    Bento4|GPL is distributed in the hope that it will be useful,
    00018 |    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019 |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00020 |    GNU General Public License for more details.
    00021 |
    00022 |    You should have received a copy of the GNU General Public License
    00023 |    along with Bento4|GPL; see the file COPYING.  If not, write to the
    00024 |    Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    00025 |    02111-1307, USA.
    00026 |
    00027 ****************************************************************/
    00028
    00029 #ifndef _AP4_MARLIN_H_
    00030 #define _AP4_MARLIN_H_
    00031
    00032 /*----------------------------------------------------------------------
    00033 |   includes
    00034 +---------------------------------------------------------------------*/
    00035 #include "Ap4Types.h"
    00036 #include "Ap4SampleEntry.h"
    00037 #include "Ap4Atom.h"
    00038 #include "Ap4AtomFactory.h"
    00039 #include "Ap4SampleDescription.h"
    00040 #include "Ap4Processor.h"
    00041 #include "Ap4Protection.h"
    00042 #include "Ap4TrefTypeAtom.h"
    00043 #include "Ap4ObjectDescriptor.h"
    00044 #include "Ap4Command.h"
    00045
    00046 /*----------------------------------------------------------------------
    00047 |   class references
    00048 +---------------------------------------------------------------------*/
    00049
    00050 /*----------------------------------------------------------------------
    00051 |   constants
    00052 +---------------------------------------------------------------------*/
    00053 const AP4_UI32 AP4_MARLIN_BRAND_MGSV       = AP4_ATOM_TYPE('M','G','S','V');
    00054 const AP4_UI16 AP4_MARLIN_IPMPS_TYPE_MGSV  = 0xA551;
    00055 const AP4_UI32 AP4_MARLIN_SCHEME_TYPE_ACBC = AP4_ATOM_TYPE('A','C','B','C');
    00056
    00057 /*----------------------------------------------------------------------
    00058 |   AP4_MarlinDecryptingProcessor
    00059 +---------------------------------------------------------------------*/
    00060 class AP4_MarlinDecryptingProcessor : public AP4_Processor
    00061 {
    00062 public:
    00063     // constructor and destructor
    00064     AP4_MarlinDecryptingProcessor(const AP4_ProtectionKeyMap* key_map = NULL,
    00065                                   AP4_BlockCipherFactory*     block_cipher_factory = NULL);
    00066     ~AP4_MarlinDecryptingProcessor();
    00067
    00068     // accessors
    00069     AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; }
    00070
    00071     // methods
    00072     virtual AP4_Result Initialize(AP4_AtomParent&   top_level,
    00073                                   AP4_ByteStream&   stream,
    00074                                   ProgressListener* listener);
    00075     virtual AP4_Processor::TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak);
    00076
    00077 private:
    00078     // types
    00079     struct SinfEntry {
    00080          SinfEntry(AP4_UI32 track_id, AP4_ContainerAtom* sinf) :
    00081              m_TrackId(track_id), m_Sinf(sinf) {}
    00082         ~SinfEntry() { delete m_Sinf; }
    00083         AP4_UI32           m_TrackId;
    00084         AP4_ContainerAtom* m_Sinf;
    00085     };
    00086
    00087     // members
    00088     AP4_BlockCipherFactory*      m_BlockCipherFactory;
    00089     AP4_ProtectionKeyMap         m_KeyMap;
    00090     AP4_List<SinfEntry>          m_SinfEntries;
    00091 };
    00092
    00093 /*----------------------------------------------------------------------
    00094 |   AP4_MarlinTrackDecrypter
    00095 +---------------------------------------------------------------------*/
    00096 class AP4_MarlinTrackDecrypter : public AP4_Processor::TrackHandler
    00097 {
    00098 public:
    00099     // class methods
    00100     static AP4_Result Create(AP4_BlockCipherFactory&    cipher_factory,
    00101                              const AP4_UI08*            key,
    00102                              AP4_MarlinTrackDecrypter*& decrypter);
    00103
    00104     // destructor
    00105     ~AP4_MarlinTrackDecrypter();
    00106
    00107     // AP4_Processor::TrackHandler methods
    00108     virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample);
    00109     virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in,
    00110                                      AP4_DataBuffer& data_out);
    00111
    00112
    00113 private:
    00114     // constructor
    00115     AP4_MarlinTrackDecrypter(AP4_StreamCipher* cipher) : m_Cipher(cipher) {}
    00116
    00117     // members
    00118     AP4_StreamCipher* m_Cipher;
    00119 };
    00120
    00121 #endif // _AP4_MARLIN_H_