Ap4IsmaCryp.h
Go to the documentation of this file.00001 /***************************************************************** 00002 | 00003 | AP4 - ISMA E&A support 00004 | 00005 | Copyright 2002-2008 Axiomatic Systems, LLC 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_ISMACRYP_H_ 00030 #define _AP4_ISMACRYP_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 00043 /*---------------------------------------------------------------------- 00044 | class references 00045 +---------------------------------------------------------------------*/ 00046 class AP4_CtrStreamCipher; 00047 class AP4_IsfmAtom; 00048 00049 /*---------------------------------------------------------------------- 00050 | constants 00051 +---------------------------------------------------------------------*/ 00052 const AP4_UI32 AP4_PROTECTION_SCHEME_TYPE_IAEC = AP4_ATOM_TYPE('i','A','E','C'); 00053 00054 /*---------------------------------------------------------------------- 00055 | AP4_IsmaCipher 00056 +---------------------------------------------------------------------*/ 00057 class AP4_IsmaCipher : public AP4_SampleDecrypter 00058 { 00059 public: 00060 // factory 00061 static AP4_Result CreateSampleDecrypter(AP4_ProtectedSampleDescription* sample_description, 00062 const AP4_UI08* key, 00063 AP4_Size key_size, 00064 AP4_BlockCipherFactory* block_cipher_factory, 00065 AP4_IsmaCipher*& decrypter); 00066 00067 // constructor and destructor 00068 AP4_IsmaCipher(AP4_BlockCipher* block_cipher, 00069 const AP4_UI08* salt, 00070 AP4_UI08 iv_length, 00071 AP4_UI08 key_indicator_length, 00072 bool selective_encryption); 00073 ~AP4_IsmaCipher(); 00074 AP4_Result EncryptSampleData(AP4_DataBuffer& data_in, 00075 AP4_DataBuffer& data_out, 00076 AP4_UI32 offset); 00077 AP4_Result DecryptSampleData(AP4_DataBuffer& data_in, 00078 AP4_DataBuffer& data_out, 00079 const AP4_UI08* iv = NULL); 00080 AP4_Size GetDecryptedSampleSize(AP4_Sample& sample); 00081 AP4_CtrStreamCipher* GetCipher() { return m_Cipher; } 00082 AP4_UI08 GetIvLength() { return m_IvLength; } 00083 AP4_UI08 GetKeyIndicatorLength() { return m_KeyIndicatorLength; } 00084 bool GetSelectiveEncryption(){ return m_SelectiveEncryption;} 00085 00086 private: 00087 // members 00088 AP4_CtrStreamCipher* m_Cipher; 00089 AP4_UI08 m_IvLength; 00090 AP4_UI08 m_KeyIndicatorLength; 00091 bool m_SelectiveEncryption; 00092 }; 00093 00094 /*---------------------------------------------------------------------- 00095 | AP4_IsmaTrackDecrypter 00096 +---------------------------------------------------------------------*/ 00097 class AP4_IsmaTrackDecrypter : public AP4_Processor::TrackHandler { 00098 public: 00099 // construction 00100 static AP4_Result Create(const AP4_UI08* key, 00101 AP4_Size key_size, 00102 AP4_ProtectedSampleDescription* sample_description, 00103 AP4_SampleEntry* sample_entry, 00104 AP4_BlockCipherFactory* block_cipher_factory, 00105 AP4_IsmaTrackDecrypter*& decrypter); 00106 00107 virtual ~AP4_IsmaTrackDecrypter(); 00108 00109 // methods 00110 virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample); 00111 virtual AP4_Result ProcessTrack(); 00112 virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in, 00113 AP4_DataBuffer& data_out); 00114 00115 private: 00116 // constructor 00117 AP4_IsmaTrackDecrypter(AP4_IsmaCipher* cipher, 00118 AP4_SampleEntry* sample_entry, 00119 AP4_UI32 original_format); 00120 00121 // members 00122 AP4_IsmaCipher* m_Cipher; 00123 AP4_SampleEntry* m_SampleEntry; 00124 AP4_UI32 m_OriginalFormat; 00125 }; 00126 00127 /*---------------------------------------------------------------------- 00128 | AP4_IsmaEncryptingProcessor 00129 +---------------------------------------------------------------------*/ 00130 class AP4_IsmaEncryptingProcessor : public AP4_Processor 00131 { 00132 public: 00133 // constructors and destructor 00134 AP4_IsmaEncryptingProcessor(const char* kms_uri, 00135 AP4_BlockCipherFactory* block_cipher_factory = NULL); 00136 00137 // accessors 00138 AP4_ProtectionKeyMap& GetKeyMap() { return m_KeyMap; } 00139 00140 // methods 00141 virtual AP4_Processor::TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak); 00142 00143 private: 00144 // members 00145 AP4_ProtectionKeyMap m_KeyMap; 00146 AP4_String m_KmsUri; 00147 AP4_BlockCipherFactory* m_BlockCipherFactory; 00148 }; 00149 00150 #endif // _AP4_ISMACRYP_H_
Generated on Thu May 13 16:36:32 2010 for Bento4 MP4 SDK by
