atoms.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /*
  2. * The contents of this file are subject to the Mozilla Public
  3. * License Version 1.1 (the "License"); you may not use this file
  4. * except in compliance with the License. You may obtain a copy of
  5. * the License at http://www.mozilla.org/MPL/
  6. *
  7. * Software distributed under the License is distributed on an "AS
  8. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9. * implied. See the License for the specific language governing
  10. * rights and limitations under the License.
  11. *
  12. * The Original Code is MPEG4IP.
  13. *
  14. * The Initial Developer of the Original Code is Cisco Systems Inc.
  15. * Portions created by Cisco Systems Inc. are
  16. * Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved.
  17. *
  18. * 3GPP features implementation is based on 3GPP's TS26.234-v5.60,
  19. * and was contributed by Ximpo Group Ltd.
  20. *
  21. * Portions created by Ximpo Group Ltd. are
  22. * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. * Dave Mackie [email protected]
  26. * Ximpo Group Ltd. [email protected]
  27. * Bill May [email protected]
  28. */
  29. #ifndef __MP4_ATOMS_INCLUDED__
  30. #define __MP4_ATOMS_INCLUDED__
  31. // declare all the atom subclasses
  32. // i.e. spare us atom_xxxx.h for all the atoms
  33. //
  34. // The majority of atoms just need their own constructor declared
  35. // Some atoms have a few special needs
  36. // A small minority of atoms need lots of special handling
  37. class MP4RootAtom : public MP4Atom {
  38. public:
  39. MP4RootAtom();
  40. void BeginWrite(bool use64 = false);
  41. void Write();
  42. void FinishWrite(bool use64 = false);
  43. void BeginOptimalWrite();
  44. void FinishOptimalWrite();
  45. protected:
  46. u_int32_t GetLastMdatIndex();
  47. void WriteAtomType(const char* type, bool onlyOne);
  48. };
  49. /***********************************************************************
  50. * Common atom classes - standard for anything that just contains atoms
  51. * and non-maleable properties, treftype and url
  52. ***********************************************************************/
  53. class MP4StandardAtom : public MP4Atom {
  54. public:
  55. MP4StandardAtom(const char *name);
  56. };
  57. class MP4TrefTypeAtom : public MP4Atom {
  58. public:
  59. MP4TrefTypeAtom(const char* type);
  60. void Read();
  61. };
  62. class MP4UrlAtom : public MP4Atom {
  63. public:
  64. MP4UrlAtom(const char *type="url ");
  65. void Read();
  66. void Write();
  67. };
  68. /***********************************************************************
  69. * Sound and Video atoms - use the generic atoms when possible
  70. * (MP4SoundAtom and MP4VideoAtom)
  71. ***********************************************************************/
  72. class MP4SoundAtom : public MP4Atom {
  73. public:
  74. MP4SoundAtom(const char *atomid);
  75. void Generate();
  76. void Read();
  77. protected:
  78. void AddProperties(u_int8_t version);
  79. };
  80. class MP4VideoAtom : public MP4Atom {
  81. public:
  82. MP4VideoAtom(const char *atomid);
  83. void Generate();
  84. };
  85. class MP4AmrAtom : public MP4Atom {
  86. public:
  87. MP4AmrAtom(const char *type);
  88. void Generate();
  89. };
  90. // H.264 atoms
  91. class MP4Avc1Atom : public MP4Atom {
  92. public:
  93. MP4Avc1Atom();
  94. void Generate();
  95. };
  96. class MP4AvcCAtom : public MP4Atom {
  97. public:
  98. MP4AvcCAtom();
  99. void Generate();
  100. void Clone(MP4AvcCAtom *dstAtom);
  101. };
  102. class MP4D263Atom : public MP4Atom {
  103. public:
  104. MP4D263Atom();
  105. void Generate();
  106. void Write();
  107. };
  108. class MP4DamrAtom : public MP4Atom {
  109. public:
  110. MP4DamrAtom();
  111. void Generate();
  112. };
  113. class MP4EncaAtom : public MP4Atom {
  114. public:
  115. MP4EncaAtom();
  116. void Generate();
  117. };
  118. class MP4EncvAtom : public MP4Atom {
  119. public:
  120. MP4EncvAtom();
  121. void Generate();
  122. };
  123. class MP4Mp4aAtom : public MP4Atom {
  124. public:
  125. MP4Mp4aAtom();
  126. void Generate();
  127. };
  128. class MP4Mp4sAtom : public MP4Atom {
  129. public:
  130. MP4Mp4sAtom();
  131. void Generate();
  132. };
  133. class MP4Mp4vAtom : public MP4Atom {
  134. public:
  135. MP4Mp4vAtom();
  136. void Generate();
  137. };
  138. class MP4S263Atom : public MP4Atom {
  139. public:
  140. MP4S263Atom();
  141. void Generate();
  142. };
  143. /************************************************************************
  144. * Specialized Atoms
  145. ************************************************************************/
  146. class MP4DataAtom : public MP4Atom {
  147. public:
  148. MP4DataAtom();
  149. void Read();
  150. };
  151. class MP4DrefAtom : public MP4Atom {
  152. public:
  153. MP4DrefAtom();
  154. void Read();
  155. };
  156. class MP4ElstAtom : public MP4Atom {
  157. public:
  158. MP4ElstAtom();
  159. void Generate();
  160. void Read();
  161. protected:
  162. void AddProperties(u_int8_t version);
  163. };
  164. class MP4FreeAtom : public MP4Atom {
  165. public:
  166. MP4FreeAtom();
  167. void Read();
  168. void Write();
  169. };
  170. class MP4FtypAtom : public MP4Atom {
  171. public:
  172. MP4FtypAtom();
  173. void Generate();
  174. void Read();
  175. };
  176. class MP4GminAtom : public MP4Atom {
  177. public:
  178. MP4GminAtom();
  179. void Generate();
  180. };
  181. class MP4HdlrAtom : public MP4Atom {
  182. public:
  183. MP4HdlrAtom();
  184. void Read();
  185. };
  186. class MP4HinfAtom : public MP4Atom {
  187. public:
  188. MP4HinfAtom();
  189. void Generate();
  190. };
  191. class MP4HntiAtom : public MP4Atom {
  192. public:
  193. MP4HntiAtom();
  194. void Read();
  195. };
  196. class MP4MdatAtom : public MP4Atom {
  197. public:
  198. MP4MdatAtom();
  199. void Read();
  200. void Write();
  201. };
  202. class MP4MdhdAtom : public MP4Atom {
  203. public:
  204. MP4MdhdAtom();
  205. void Generate();
  206. void Read();
  207. protected:
  208. void AddProperties(u_int8_t version);
  209. };
  210. class MP4Meta1Atom : public MP4Atom {
  211. public:
  212. MP4Meta1Atom(const char *name);
  213. void Read();
  214. };
  215. class MP4Meta2Atom : public MP4Atom {
  216. public:
  217. MP4Meta2Atom(const char *name);
  218. void Read();
  219. };
  220. class MP4Meta3Atom : public MP4Atom {
  221. public:
  222. MP4Meta3Atom(const char *name);
  223. void Read();
  224. };
  225. class MP4Meta4Atom : public MP4Atom {
  226. public:
  227. MP4Meta4Atom(const char *name);
  228. void Read();
  229. };
  230. class MP4MvhdAtom : public MP4Atom {
  231. public:
  232. MP4MvhdAtom();
  233. void Generate();
  234. void Read();
  235. protected:
  236. void AddProperties(u_int8_t version);
  237. };
  238. class MP4OhdrAtom : public MP4Atom {
  239. public:
  240. MP4OhdrAtom();
  241. ~MP4OhdrAtom();
  242. void Read();
  243. };
  244. class MP4RtpAtom : public MP4Atom {
  245. public:
  246. MP4RtpAtom();
  247. void Generate();
  248. void Read();
  249. void Write();
  250. protected:
  251. void AddPropertiesStsdType();
  252. void AddPropertiesHntiType();
  253. void GenerateStsdType();
  254. void GenerateHntiType();
  255. void ReadStsdType();
  256. void ReadHntiType();
  257. void WriteHntiType();
  258. };
  259. class MP4SdpAtom : public MP4Atom {
  260. public:
  261. MP4SdpAtom();
  262. void Read();
  263. void Write();
  264. };
  265. class MP4SmiAtom : public MP4Atom {
  266. public:
  267. MP4SmiAtom(void);
  268. void Read();
  269. };
  270. class MP4StblAtom : public MP4Atom {
  271. public:
  272. MP4StblAtom();
  273. void Generate();
  274. };
  275. class MP4StdpAtom : public MP4Atom {
  276. public:
  277. MP4StdpAtom();
  278. void Read();
  279. };
  280. class MP4StscAtom : public MP4Atom {
  281. public:
  282. MP4StscAtom();
  283. void Read();
  284. };
  285. class MP4StsdAtom : public MP4Atom {
  286. public:
  287. MP4StsdAtom();
  288. void Read();
  289. };
  290. class MP4StszAtom : public MP4Atom {
  291. public:
  292. MP4StszAtom();
  293. void Read();
  294. void Write();
  295. };
  296. class MP4Stz2Atom : public MP4Atom {
  297. public:
  298. MP4Stz2Atom();
  299. void Read();
  300. };
  301. class MP4TextAtom : public MP4Atom {
  302. public:
  303. MP4TextAtom();
  304. void Generate();
  305. protected:
  306. void AddPropertiesStsdType();
  307. void AddPropertiesGmhdType();
  308. void GenerateStsdType();
  309. void GenerateGmhdType();
  310. };
  311. class MP4TfhdAtom : public MP4Atom {
  312. public:
  313. MP4TfhdAtom();
  314. void Read();
  315. protected:
  316. void AddProperties(u_int32_t flags);
  317. };
  318. class MP4TkhdAtom : public MP4Atom {
  319. public:
  320. MP4TkhdAtom();
  321. void Generate();
  322. void Read();
  323. protected:
  324. void AddProperties(u_int8_t version);
  325. };
  326. class MP4TrunAtom : public MP4Atom {
  327. public:
  328. MP4TrunAtom();
  329. void Read();
  330. protected:
  331. void AddProperties(u_int32_t flags);
  332. };
  333. class MP4UdtaAtom : public MP4Atom {
  334. public:
  335. MP4UdtaAtom();
  336. void Read();
  337. };
  338. class MP4UrnAtom : public MP4Atom {
  339. public:
  340. MP4UrnAtom();
  341. void Read();
  342. };
  343. class MP4VmhdAtom : public MP4Atom {
  344. public:
  345. MP4VmhdAtom();
  346. void Generate();
  347. };
  348. class MP4HrefAtom : public MP4Atom {
  349. public:
  350. MP4HrefAtom();
  351. void Generate(void);
  352. };
  353. class MP4ChplAtom : public MP4Atom {
  354. public:
  355. MP4ChplAtom();
  356. void Generate(void);
  357. };
  358. #endif /* __MP4_ATOMS_INCLUDED__ */