1
0

mp4.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  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. * Alix Marchandise-Franquet [email protected]
  27. * Ximpo Group Ltd. [email protected]
  28. * Bill May [email protected]
  29. */
  30. #ifndef __MP4_INCLUDED__
  31. #define __MP4_INCLUDED__
  32. /* include system and project specific headers */
  33. #include "include/mpeg4ip.h"
  34. #include <math.h> /* to define float HUGE_VAL and/or NAN */
  35. #ifndef NAN
  36. #define NAN HUGE_VAL
  37. #endif
  38. #ifdef __cplusplus
  39. /* exploit C++ ability of default values for function parameters */
  40. #define DEFAULT(x) =x
  41. #else
  42. #define DEFAULT(x)
  43. #endif
  44. /* MP4 API types */
  45. typedef void* MP4FileHandle;
  46. typedef u_int32_t MP4TrackId;
  47. typedef u_int32_t MP4SampleId;
  48. typedef u_int32_t MP4ChunkId;
  49. typedef u_int64_t MP4Timestamp;
  50. typedef u_int64_t MP4Duration;
  51. typedef u_int32_t MP4EditId;
  52. typedef u_int64_t (*VIRTUALIO_GETFILELENGTH)(void *user); // return file length in bytes
  53. typedef int (*VIRTUALIO_SETPOSITION)(void *user, u_int64_t position); // return 0 on success
  54. typedef int (*VIRTUALIO_GETPOSITION)(void *user, u_int64_t *position); // fill position, return 0 on success
  55. typedef size_t (*VIRTUALIO_READ)(void *user, void *buffer, size_t size); // return number of bytes actually read
  56. typedef size_t (*VIRTUALIO_WRITE)(void *user, void *buffer, size_t size); // return number of bytes actually written
  57. typedef int (*VIRTUALIO_ENDOFFILE)(void *user); // return 1 if file hit EOF
  58. typedef int (*VIRTUALIO_CLOSE)(void *user); // return 0 on success
  59. typedef struct Virtual_IO
  60. {
  61. VIRTUALIO_GETFILELENGTH GetFileLength;
  62. VIRTUALIO_SETPOSITION SetPosition;
  63. VIRTUALIO_GETPOSITION GetPosition;
  64. VIRTUALIO_READ Read;
  65. VIRTUALIO_WRITE Write;
  66. VIRTUALIO_ENDOFFILE EndOfFile;
  67. VIRTUALIO_CLOSE Close;
  68. } Virtual_IO_t;
  69. /* Invalid values for API types */
  70. #define MP4_INVALID_FILE_HANDLE ((MP4FileHandle)NULL)
  71. #define MP4_INVALID_TRACK_ID ((MP4TrackId)0)
  72. #define MP4_INVALID_SAMPLE_ID ((MP4SampleId)0)
  73. #define MP4_INVALID_TIMESTAMP ((MP4Timestamp)-1)
  74. #define MP4_INVALID_DURATION ((MP4Duration)-1)
  75. #define MP4_INVALID_EDIT_ID ((MP4EditId)0)
  76. /* Macros to test for API type validity */
  77. #define MP4_IS_VALID_FILE_HANDLE(x) ((x) != MP4_INVALID_FILE_HANDLE)
  78. #define MP4_IS_VALID_TRACK_ID(x) ((x) != MP4_INVALID_TRACK_ID)
  79. #define MP4_IS_VALID_SAMPLE_ID(x) ((x) != MP4_INVALID_SAMPLE_ID)
  80. #define MP4_IS_VALID_TIMESTAMP(x) ((x) != MP4_INVALID_TIMESTAMP)
  81. #define MP4_IS_VALID_DURATION(x) ((x) != MP4_INVALID_DURATION)
  82. #define MP4_IS_VALID_EDIT_ID(x) ((x) != MP4_INVALID_EDIT_ID)
  83. /* MP4 verbosity levels - e.g. MP4SetVerbosity() */
  84. #define MP4_DETAILS_ALL 0xFFFFFFFF
  85. #define MP4_DETAILS_ERROR 0x00000001
  86. #define MP4_DETAILS_WARNING 0x00000002
  87. #define MP4_DETAILS_READ 0x00000004
  88. #define MP4_DETAILS_WRITE 0x00000008
  89. #define MP4_DETAILS_FIND 0x00000010
  90. #define MP4_DETAILS_TABLE 0x00000020
  91. #define MP4_DETAILS_SAMPLE 0x00000040
  92. #define MP4_DETAILS_HINT 0x00000080
  93. #define MP4_DETAILS_ISMA 0x00000100
  94. #define MP4_DETAILS_EDIT 0x00000200
  95. #define MP4_DETAILS_READ_ALL \
  96. (MP4_DETAILS_READ | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
  97. #define MP4_DETAILS_WRITE_ALL \
  98. (MP4_DETAILS_WRITE | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
  99. /*
  100. * MP4 Known track type names - e.g. MP4GetNumberOfTracks(type)
  101. *
  102. * Note this first group of track types should be created
  103. * via the MP4Add<Type>Track() functions, and not MP4AddTrack(type)
  104. */
  105. #define MP4_OD_TRACK_TYPE "odsm"
  106. #define MP4_SCENE_TRACK_TYPE "sdsm"
  107. #define MP4_AUDIO_TRACK_TYPE "soun"
  108. #define MP4_VIDEO_TRACK_TYPE "vide"
  109. #define MP4_HINT_TRACK_TYPE "hint"
  110. #define MP4_CNTL_TRACK_TYPE "cntl"
  111. #define MP4_TEXT_TRACK_TYPE "text"
  112. /*
  113. * This second set of track types should be created
  114. * via MP4AddSystemsTrack(type)
  115. */
  116. #define MP4_CLOCK_TRACK_TYPE "crsm"
  117. #define MP4_MPEG7_TRACK_TYPE "m7sm"
  118. #define MP4_OCI_TRACK_TYPE "ocsm"
  119. #define MP4_IPMP_TRACK_TYPE "ipsm"
  120. #define MP4_MPEGJ_TRACK_TYPE "mjsm"
  121. #define MP4_IS_VIDEO_TRACK_TYPE(type) \
  122. (!strcasecmp(type, MP4_VIDEO_TRACK_TYPE))
  123. #define MP4_IS_AUDIO_TRACK_TYPE(type) \
  124. (!strcasecmp(type, MP4_AUDIO_TRACK_TYPE))
  125. #define MP4_IS_CNTL_TRACK_TYPE(type) \
  126. (!strcasecmp(type, MP4_CNTL_TRACK_TYPE))
  127. #define MP4_IS_OD_TRACK_TYPE(type) \
  128. (!strcasecmp(type, MP4_OD_TRACK_TYPE))
  129. #define MP4_IS_SCENE_TRACK_TYPE(type) \
  130. (!strcasecmp(type, MP4_SCENE_TRACK_TYPE))
  131. #define MP4_IS_HINT_TRACK_TYPE(type) \
  132. (!strcasecmp(type, MP4_HINT_TRACK_TYPE))
  133. #define MP4_IS_SYSTEMS_TRACK_TYPE(type) \
  134. (!strcasecmp(type, MP4_CLOCK_TRACK_TYPE) \
  135. || !strcasecmp(type, MP4_MPEG7_TRACK_TYPE) \
  136. || !strcasecmp(type, MP4_OCI_TRACK_TYPE) \
  137. || !strcasecmp(type, MP4_IPMP_TRACK_TYPE) \
  138. || !strcasecmp(type, MP4_MPEGJ_TRACK_TYPE))
  139. /* MP4 Audio track types - see MP4AddAudioTrack()*/
  140. #define MP4_INVALID_AUDIO_TYPE 0x00
  141. #define MP4_MPEG1_AUDIO_TYPE 0x6B
  142. #define MP4_MPEG2_AUDIO_TYPE 0x69
  143. #define MP4_MP3_AUDIO_TYPE MP4_MPEG2_AUDIO_TYPE
  144. #define MP4_MPEG2_AAC_MAIN_AUDIO_TYPE 0x66
  145. #define MP4_MPEG2_AAC_LC_AUDIO_TYPE 0x67
  146. #define MP4_MPEG2_AAC_SSR_AUDIO_TYPE 0x68
  147. #define MP4_MPEG2_AAC_AUDIO_TYPE MP4_MPEG2_AAC_MAIN_AUDIO_TYPE
  148. #define MP4_MPEG4_AUDIO_TYPE 0x40
  149. #define MP4_PRIVATE_AUDIO_TYPE 0xC0
  150. #define MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE 0xE0 /* a private definition */
  151. #define MP4_VORBIS_AUDIO_TYPE 0xE1 /* a private definition */
  152. #define MP4_AC3_AUDIO_TYPE 0xE2 /* a private definition */
  153. #define MP4_ALAW_AUDIO_TYPE 0xE3 /* a private definition */
  154. #define MP4_ULAW_AUDIO_TYPE 0xE4 /* a private definition */
  155. #define MP4_G723_AUDIO_TYPE 0xE5 /* a private definition */
  156. #define MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE 0xE6 /* a private definition */
  157. /* MP4 MPEG-4 Audio types from 14496-3 Table 1.5.1 */
  158. #define MP4_MPEG4_INVALID_AUDIO_TYPE 0
  159. #define MP4_MPEG4_AAC_MAIN_AUDIO_TYPE 1
  160. #define MP4_MPEG4_AAC_LC_AUDIO_TYPE 2
  161. #define MP4_MPEG4_AAC_SSR_AUDIO_TYPE 3
  162. #define MP4_MPEG4_AAC_LTP_AUDIO_TYPE 4
  163. #define MP4_MPEG4_AAC_HE_AUDIO_TYPE 5
  164. #define MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE 6
  165. #define MP4_MPEG4_CELP_AUDIO_TYPE 8
  166. #define MP4_MPEG4_HVXC_AUDIO_TYPE 9
  167. #define MP4_MPEG4_TTSI_AUDIO_TYPE 12
  168. #define MP4_MPEG4_MAIN_SYNTHETIC_AUDIO_TYPE 13
  169. #define MP4_MPEG4_WAVETABLE_AUDIO_TYPE 14
  170. #define MP4_MPEG4_MIDI_AUDIO_TYPE 15
  171. #define MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE 16
  172. #define MP4_MPEG4_PARAMETRIC_STEREO 29
  173. #define MP4_MPEG4_ALS_AUDIO_TYPE 31
  174. #define MP4_MPEG4_LAYER1_AUDIO_TYPE 32
  175. #define MP4_MPEG4_LAYER2_AUDIO_TYPE 33
  176. #define MP4_MPEG4_LAYER3_AUDIO_TYPE 34
  177. #define MP4_MPEG4_SLS_AUDIO_TYPE 35
  178. /* MP4 Audio type utilities following common usage */
  179. #define MP4_IS_MP3_AUDIO_TYPE(type) \
  180. ((type) == MP4_MPEG1_AUDIO_TYPE || (type) == MP4_MPEG2_AUDIO_TYPE)
  181. #define MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
  182. (((type) >= MP4_MPEG2_AAC_MAIN_AUDIO_TYPE \
  183. && (type) <= MP4_MPEG2_AAC_SSR_AUDIO_TYPE))
  184. #define MP4_IS_MPEG4_AAC_AUDIO_TYPE(mpeg4Type) \
  185. (((mpeg4Type) >= MP4_MPEG4_AAC_MAIN_AUDIO_TYPE \
  186. && (mpeg4Type) <= MP4_MPEG4_AAC_HE_AUDIO_TYPE) \
  187. || (mpeg4Type) == MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE \
  188. || (mpeg4Type) == 17)
  189. #define MP4_IS_AAC_AUDIO_TYPE(type) \
  190. (MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
  191. || (type) == MP4_MPEG4_AUDIO_TYPE)
  192. /* MP4 Video track types - see MP4AddVideoTrack() */
  193. #define MP4_INVALID_VIDEO_TYPE 0x00
  194. #define MP4_MPEG1_VIDEO_TYPE 0x6A
  195. #define MP4_MPEG2_SIMPLE_VIDEO_TYPE 0x60
  196. #define MP4_MPEG2_MAIN_VIDEO_TYPE 0x61
  197. #define MP4_MPEG2_SNR_VIDEO_TYPE 0x62
  198. #define MP4_MPEG2_SPATIAL_VIDEO_TYPE 0x63
  199. #define MP4_MPEG2_HIGH_VIDEO_TYPE 0x64
  200. #define MP4_MPEG2_442_VIDEO_TYPE 0x65
  201. #define MP4_MPEG2_VIDEO_TYPE MP4_MPEG2_MAIN_VIDEO_TYPE
  202. #define MP4_MPEG4_VIDEO_TYPE 0x20
  203. #define MP4_JPEG_VIDEO_TYPE 0x6C
  204. #define MP4_PRIVATE_VIDEO_TYPE 0xD0
  205. #define MP4_YUV12_VIDEO_TYPE 0xF0 /* a private definition */
  206. #define MP4_H263_VIDEO_TYPE 0xF2 /* a private definition */
  207. #define MP4_H261_VIDEO_TYPE 0xF3 /* a private definition */
  208. /* MP4 Video type utilities */
  209. #define MP4_IS_MPEG1_VIDEO_TYPE(type) \
  210. ((type) == MP4_MPEG1_VIDEO_TYPE)
  211. #define MP4_IS_MPEG2_VIDEO_TYPE(type) \
  212. (((type) >= MP4_MPEG2_SIMPLE_VIDEO_TYPE \
  213. && (type) <= MP4_MPEG2_442_VIDEO_TYPE) \
  214. || MP4_IS_MPEG1_VIDEO_TYPE(type))
  215. #define MP4_IS_MPEG4_VIDEO_TYPE(type) \
  216. ((type) == MP4_MPEG4_VIDEO_TYPE)
  217. /* Mpeg4 Visual Profile Defines - ISO/IEC 14496-2:2001/Amd.2:2002(E) */
  218. #define MPEG4_SP_L1 (0x1)
  219. #define MPEG4_SP_L2 (0x2)
  220. #define MPEG4_SP_L3 (0x3)
  221. #define MPEG4_SP_L0 (0x8)
  222. #define MPEG4_SSP_L1 (0x11)
  223. #define MPEG4_SSP_L2 (0x12)
  224. #define MPEG4_CP_L1 (0x21)
  225. #define MPEG4_CP_L2 (0x22)
  226. #define MPEG4_MP_L2 (0x32)
  227. #define MPEG4_MP_L3 (0x33)
  228. #define MPEG4_MP_L4 (0x34)
  229. #define MPEG4_NBP_L2 (0x42)
  230. #define MPEG4_STP_L1 (0x51)
  231. #define MPEG4_SFAP_L1 (0x61)
  232. #define MPEG4_SFAP_L2 (0x62)
  233. #define MPEG4_SFBAP_L1 (0x63)
  234. #define MPEG4_SFBAP_L2 (0x64)
  235. #define MPEG4_BATP_L1 (0x71)
  236. #define MPEG4_BATP_L2 (0x72)
  237. #define MPEG4_HP_L1 (0x81)
  238. #define MPEG4_HP_L2 (0x82)
  239. #define MPEG4_ARTSP_L1 (0x91)
  240. #define MPEG4_ARTSP_L2 (0x92)
  241. #define MPEG4_ARTSP_L3 (0x93)
  242. #define MPEG4_ARTSP_L4 (0x94)
  243. #define MPEG4_CSP_L1 (0xa1)
  244. #define MPEG4_CSP_L2 (0xa2)
  245. #define MPEG4_CSP_L3 (0xa3)
  246. #define MPEG4_ACEP_L1 (0xb1)
  247. #define MPEG4_ACEP_L2 (0xb2)
  248. #define MPEG4_ACEP_L3 (0xb3)
  249. #define MPEG4_ACEP_L4 (0xb4)
  250. #define MPEG4_ACP_L1 (0xc1)
  251. #define MPEG4_ACP_L2 (0xc2)
  252. #define MPEG4_AST_L1 (0xd1)
  253. #define MPEG4_AST_L2 (0xd2)
  254. #define MPEG4_AST_L3 (0xd3)
  255. #define MPEG4_S_STUDIO_P_L1 (0xe1)
  256. #define MPEG4_S_STUDIO_P_L2 (0xe2)
  257. #define MPEG4_S_STUDIO_P_L3 (0xe3)
  258. #define MPEG4_S_STUDIO_P_L4 (0xe4)
  259. #define MPEG4_C_STUDIO_P_L1 (0xe5)
  260. #define MPEG4_C_STUDIO_P_L2 (0xe6)
  261. #define MPEG4_C_STUDIO_P_L3 (0xe7)
  262. #define MPEG4_C_STUDIO_P_L4 (0xe8)
  263. #define MPEG4_ASP_L0 (0xF0)
  264. #define MPEG4_ASP_L1 (0xF1)
  265. #define MPEG4_ASP_L2 (0xF2)
  266. #define MPEG4_ASP_L3 (0xF3)
  267. #define MPEG4_ASP_L4 (0xF4)
  268. #define MPEG4_ASP_L5 (0xF5)
  269. #define MPEG4_ASP_L3B (0xF7)
  270. #define MPEG4_FGSP_L0 (0xf8)
  271. #define MPEG4_FGSP_L1 (0xf9)
  272. #define MPEG4_FGSP_L2 (0xfa)
  273. #define MPEG4_FGSP_L3 (0xfb)
  274. #define MPEG4_FGSP_L4 (0xfc)
  275. #define MPEG4_FGSP_L5 (0xfd)
  276. /* chapter related definitions */
  277. #define CHAPTERTITLELEN 1023
  278. typedef struct MP4ChapterStruct {
  279. MP4Duration duration; /* duration of a chapter in milliseconds*/
  280. char title[CHAPTERTITLELEN+1]; /* title of the chapter */
  281. } MP4Chapters_t;
  282. /* milliseconds to 100 nanoseconds */
  283. #define MILLI2HUNDREDNANO 10000
  284. /* MP4 API declarations */
  285. #ifdef __cplusplus
  286. extern "C" {
  287. #endif
  288. /* file operations */
  289. #define MP4_CREATE_64BIT_DATA (0x01)
  290. #define MP4_CREATE_64BIT_TIME (0x02) // Quicktime is not compatible with this
  291. #define MP4_CREATE_64BIT (MP4_CREATE_64BIT_DATA | MP4_CREATE_64BIT_TIME)
  292. #define MP4_CREATE_EXTENSIBLE_FORMAT (0x04)
  293. MP4FileHandle MP4Create(
  294. const MP4_FILENAME_CHAR *fileName,
  295. u_int32_t verbosity DEFAULT(0),
  296. u_int32_t flags DEFAULT(0));
  297. MP4FileHandle MP4CreateEx(
  298. const MP4_FILENAME_CHAR *fileName,
  299. u_int32_t verbosity DEFAULT(0),
  300. u_int32_t flags DEFAULT(0),
  301. int add_ftyp DEFAULT(1),
  302. int add_iods DEFAULT(1),
  303. char* majorBrand DEFAULT(0),
  304. u_int32_t minorVersion DEFAULT(0),
  305. char** supportedBrands DEFAULT(0),
  306. u_int32_t supportedBrandsCount DEFAULT(0));
  307. MP4FileHandle MP4Modify(
  308. const MP4_FILENAME_CHAR *fileName,
  309. u_int32_t verbosity DEFAULT(0),
  310. u_int32_t flags DEFAULT(0));
  311. MP4FileHandle MP4Read(
  312. const MP4_FILENAME_CHAR *fileName,
  313. u_int32_t verbosity DEFAULT(0));
  314. // benski>
  315. MP4FileHandle MP4ReadEx(const MP4_FILENAME_CHAR *fileName,
  316. void *user,
  317. Virtual_IO_t *virtual_IO,
  318. u_int32_t verbosity DEFAULT(0));
  319. void MP4Close(
  320. MP4FileHandle hFile);
  321. bool MP4Optimize(
  322. const MP4_FILENAME_CHAR *existingFileName,
  323. const MP4_FILENAME_CHAR *newFileName DEFAULT(NULL),
  324. u_int32_t verbosity DEFAULT(0));
  325. bool MP4Dump(
  326. MP4FileHandle hFile,
  327. FILE* pDumpFile DEFAULT(NULL),
  328. bool dumpImplicits DEFAULT(0));
  329. #if 0
  330. char* MP4Info(
  331. MP4FileHandle hFile,
  332. MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
  333. char* MP4FileInfo(
  334. const MP4_FILENAME_CHAR* fileName,
  335. MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
  336. #endif
  337. /* file properties */
  338. /* specific file properties */
  339. u_int32_t MP4GetVerbosity(MP4FileHandle hFile);
  340. void MP4SetVerbosity(MP4FileHandle hFile, u_int32_t verbosity);
  341. MP4Duration MP4GetDuration(MP4FileHandle hFile);
  342. u_int32_t MP4GetTimeScale(MP4FileHandle hFile);
  343. bool MP4SetTimeScale(MP4FileHandle hFile, u_int32_t value);
  344. u_int8_t MP4GetODProfileLevel(MP4FileHandle hFile);
  345. bool MP4SetODProfileLevel(MP4FileHandle hFile, u_int8_t value);
  346. u_int8_t MP4GetSceneProfileLevel(MP4FileHandle hFile);
  347. bool MP4SetSceneProfileLevel(MP4FileHandle hFile, u_int8_t value);
  348. u_int8_t MP4GetVideoProfileLevel(MP4FileHandle hFile,
  349. MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
  350. void MP4SetVideoProfileLevel(MP4FileHandle hFile, u_int8_t value);
  351. u_int8_t MP4GetAudioProfileLevel(MP4FileHandle hFile);
  352. void MP4SetAudioProfileLevel(MP4FileHandle hFile, u_int8_t value);
  353. u_int8_t MP4GetGraphicsProfileLevel(MP4FileHandle hFile);
  354. bool MP4SetGraphicsProfileLevel(MP4FileHandle hFile, u_int8_t value);
  355. /* generic file properties */
  356. bool MP4HaveAtom(MP4FileHandle hFile,
  357. const char *atomName);
  358. bool MP4GetIntegerProperty(
  359. MP4FileHandle hFile,
  360. const char* propName,
  361. u_int64_t *retval );
  362. bool MP4GetFloatProperty(
  363. MP4FileHandle hFile,
  364. const char* propName,
  365. float *retvalue);
  366. bool MP4GetStringProperty(
  367. MP4FileHandle hFile,
  368. const char* propName,
  369. const char **retvalue);
  370. bool MP4GetBytesProperty(
  371. MP4FileHandle hFile,
  372. const char* propName,
  373. u_int8_t** ppValue,
  374. u_int32_t* pValueSize);
  375. bool MP4SetIntegerProperty(
  376. MP4FileHandle hFile,
  377. const char* propName,
  378. int64_t value);
  379. bool MP4SetFloatProperty(
  380. MP4FileHandle hFile,
  381. const char* propName,
  382. float value);
  383. bool MP4SetStringProperty(
  384. MP4FileHandle hFile, const char* propName, const char* value);
  385. bool MP4SetBytesProperty(
  386. MP4FileHandle hFile, const char* propName,
  387. const u_int8_t* pValue, u_int32_t valueSize);
  388. /* track operations */
  389. MP4TrackId MP4AddTrack(
  390. MP4FileHandle hFile,
  391. const char* type);
  392. MP4TrackId MP4AddSystemsTrack(
  393. MP4FileHandle hFile,
  394. const char* type);
  395. MP4TrackId MP4AddODTrack(
  396. MP4FileHandle hFile);
  397. MP4TrackId MP4AddSceneTrack(
  398. MP4FileHandle hFile);
  399. MP4TrackId MP4AddAudioTrack(
  400. MP4FileHandle hFile,
  401. u_int32_t timeScale,
  402. MP4Duration sampleDuration,
  403. u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
  404. typedef struct mp4v2_ismacryp_session_params {
  405. u_int32_t scheme_type;
  406. u_int16_t scheme_version;
  407. u_int8_t key_ind_len;
  408. u_int8_t iv_len;
  409. u_int8_t selective_enc;
  410. const char *kms_uri;
  411. } mp4v2_ismacrypParams;
  412. // API to initialize ismacryp properties to sensible defaults
  413. // if input param is null then mallocs a params struct
  414. mp4v2_ismacrypParams *MP4DefaultISMACrypParams(mp4v2_ismacrypParams *ptr);
  415. MP4TrackId MP4AddEncAudioTrack(
  416. MP4FileHandle hFile,
  417. u_int32_t timeScale,
  418. MP4Duration sampleDuration,
  419. mp4v2_ismacrypParams *icPp,
  420. u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
  421. MP4TrackId MP4AddAmrAudioTrack(
  422. MP4FileHandle hFile,
  423. u_int32_t timeScale,
  424. u_int16_t modeSet,
  425. u_int8_t modeChangePeriod,
  426. u_int8_t framesPerSample,
  427. bool isAmrWB);
  428. void MP4SetAmrVendor(
  429. MP4FileHandle hFile,
  430. MP4TrackId trackId,
  431. u_int32_t vendor);
  432. void MP4SetAmrDecoderVersion(
  433. MP4FileHandle hFile,
  434. MP4TrackId trackId,
  435. u_int8_t decoderVersion);
  436. void MP4SetAmrModeSet(MP4FileHandle hFile, MP4TrackId trakId, uint16_t modeSet);
  437. uint16_t MP4GetAmrModeSet(MP4FileHandle hFile, MP4TrackId trackId);
  438. MP4TrackId MP4AddHrefTrack(MP4FileHandle hFile,
  439. uint32_t timeScale,
  440. MP4Duration sampleDuration,
  441. const char *base_url DEFAULT(NULL));
  442. const char *MP4GetHrefTrackBaseUrl(MP4FileHandle hFile,
  443. MP4TrackId trackId);
  444. MP4TrackId MP4AddVideoTrack(
  445. MP4FileHandle hFile,
  446. u_int32_t timeScale,
  447. MP4Duration sampleDuration,
  448. u_int16_t width,
  449. u_int16_t height,
  450. u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
  451. MP4TrackId MP4AddEncVideoTrack(
  452. MP4FileHandle hFile,
  453. u_int32_t timeScale,
  454. MP4Duration sampleDuration,
  455. u_int16_t width,
  456. u_int16_t height,
  457. mp4v2_ismacrypParams *icPp,
  458. u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE),
  459. const char *oFormat DEFAULT(NULL));
  460. MP4TrackId MP4AddH264VideoTrack(
  461. MP4FileHandle hFile,
  462. u_int32_t timeScale,
  463. MP4Duration sampleDuration,
  464. u_int16_t width,
  465. u_int16_t height,
  466. uint8_t AVCProfileIndication,
  467. uint8_t profile_compat,
  468. uint8_t AVCLevelIndication,
  469. uint8_t sampleLenFieldSizeMinusOne);
  470. MP4TrackId MP4AddEncH264VideoTrack(
  471. MP4FileHandle dstFile,
  472. u_int32_t timeScale,
  473. MP4Duration sampleDuration,
  474. u_int16_t width,
  475. u_int16_t height,
  476. MP4FileHandle srcFile,
  477. MP4TrackId srcTrackId,
  478. mp4v2_ismacrypParams *icPp);
  479. void MP4AddH264SequenceParameterSet(MP4FileHandle hFile,
  480. MP4TrackId trackId,
  481. const uint8_t *pSequence,
  482. uint16_t sequenceLen);
  483. void MP4AddH264PictureParameterSet(MP4FileHandle hFile,
  484. MP4TrackId trackId,
  485. const uint8_t *pPict,
  486. uint16_t pictLen);
  487. void MP4SetH263Vendor(
  488. MP4FileHandle hFile,
  489. MP4TrackId trackId,
  490. u_int32_t vendor);
  491. void MP4SetH263DecoderVersion(
  492. MP4FileHandle hFile,
  493. MP4TrackId trackId,
  494. u_int8_t decoderVersion);
  495. void MP4SetH263Bitrates(
  496. MP4FileHandle hFile,
  497. MP4TrackId trackId,
  498. u_int32_t avgBitrate,
  499. u_int32_t maxBitrate);
  500. MP4TrackId MP4AddH263VideoTrack(
  501. MP4FileHandle hFile,
  502. u_int32_t timeScale,
  503. MP4Duration sampleDuration,
  504. u_int16_t width,
  505. u_int16_t height,
  506. u_int8_t h263Level,
  507. u_int8_t h263Profile,
  508. u_int32_t avgBitrate,
  509. u_int32_t maxBitrate);
  510. MP4TrackId MP4AddHintTrack(
  511. MP4FileHandle hFile,
  512. MP4TrackId refTrackId);
  513. MP4TrackId MP4AddTextTrack(
  514. MP4FileHandle hFile,
  515. MP4TrackId refTrackId);
  516. MP4TrackId MP4AddChapterTextTrack(
  517. MP4FileHandle hFile,
  518. MP4TrackId refTrackId,
  519. u_int32_t timescale DEFAULT(0));
  520. void MP4AddQTChapter(
  521. MP4FileHandle hFile,
  522. MP4TrackId chapterTrackId,
  523. MP4Duration chapterDuration,
  524. u_int32_t chapterNr,
  525. const char * chapterTitle DEFAULT(0));
  526. void MP4AddChapter(
  527. MP4FileHandle hFile,
  528. MP4Timestamp chapterStart,
  529. const char * chapterTitle DEFAULT(0));
  530. void MP4ConvertChapters(
  531. MP4FileHandle hFile,
  532. bool toQT DEFAULT(true));
  533. void MP4DeleteChapters(
  534. MP4FileHandle hFile,
  535. MP4TrackId chapterTrackId DEFAULT(MP4_INVALID_TRACK_ID),
  536. bool deleteQT DEFAULT(true));
  537. void MP4GetChaptersList(
  538. MP4FileHandle hFile,
  539. MP4Chapters_t ** chapterList,
  540. u_int32_t * chapterCount,
  541. bool getQT DEFAULT(true));
  542. MP4TrackId MP4CloneTrack(
  543. MP4FileHandle srcFile,
  544. MP4TrackId srcTrackId,
  545. MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
  546. MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID));
  547. MP4TrackId MP4EncAndCloneTrack(
  548. MP4FileHandle srcFile,
  549. MP4TrackId srcTrackId,
  550. mp4v2_ismacrypParams *icPp,
  551. MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
  552. MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID));
  553. MP4TrackId MP4CopyTrack(
  554. MP4FileHandle srcFile,
  555. MP4TrackId srcTrackId,
  556. MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
  557. bool applyEdits DEFAULT(false),
  558. MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID));
  559. typedef u_int32_t (*encryptFunc_t)(u_int32_t, u_int32_t, u_int8_t*, u_int32_t*, u_int8_t **);
  560. MP4TrackId MP4EncAndCopyTrack(
  561. MP4FileHandle srcFile,
  562. MP4TrackId srcTrackId,
  563. mp4v2_ismacrypParams *icPp,
  564. encryptFunc_t encfcnp,
  565. u_int32_t encfcnparam1,
  566. MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
  567. bool applyEdits DEFAULT(false),
  568. MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID));
  569. void MP4DeleteTrack(
  570. MP4FileHandle hFile,
  571. MP4TrackId trackId);
  572. u_int32_t MP4GetNumberOfTracks(
  573. MP4FileHandle hFile,
  574. const char* type DEFAULT(NULL),
  575. u_int8_t subType DEFAULT(0));
  576. MP4TrackId MP4FindTrackId(
  577. MP4FileHandle hFile,
  578. u_int16_t index,
  579. const char* type DEFAULT(NULL),
  580. u_int8_t subType DEFAULT(0));
  581. u_int16_t MP4FindTrackIndex(
  582. MP4FileHandle hFile,
  583. MP4TrackId trackId);
  584. /* track properties */
  585. /* specific track properties */
  586. bool MP4HaveTrackAtom(MP4FileHandle hFile,
  587. MP4TrackId trackId,
  588. const char *atomname);
  589. const char* MP4GetTrackType(
  590. MP4FileHandle hFile,
  591. MP4TrackId trackId);
  592. const char *MP4GetTrackMediaDataName(MP4FileHandle hFile,
  593. MP4TrackId trackId);
  594. // MP4GetTrackMediaDataOriginalFormat is to be used to get the original
  595. // MediaDataName if a track has been encrypted.
  596. bool MP4GetTrackMediaDataOriginalFormat(MP4FileHandle hFile,
  597. MP4TrackId trackId, char *originalFormat, u_int32_t buflen);
  598. MP4Duration MP4GetTrackDuration(
  599. MP4FileHandle hFile,
  600. MP4TrackId trackId);
  601. u_int32_t MP4GetTrackTimeScale(
  602. MP4FileHandle hFile,
  603. MP4TrackId trackId);
  604. void MP4SetTrackTimeScale(
  605. MP4FileHandle hFile,
  606. MP4TrackId trackId,
  607. u_int32_t value);
  608. u_int8_t MP4GetTrackAudioMpeg4Type(
  609. MP4FileHandle hFile,
  610. MP4TrackId trackId);
  611. u_int8_t MP4GetTrackEsdsObjectTypeId(
  612. MP4FileHandle hFile,
  613. MP4TrackId trackId);
  614. /* returns MP4_INVALID_DURATION if track samples do not have a fixed duration */
  615. MP4Duration MP4GetTrackFixedSampleDuration(
  616. MP4FileHandle hFile,
  617. MP4TrackId trackId);
  618. u_int32_t MP4GetTrackBitRate(
  619. MP4FileHandle hFile,
  620. MP4TrackId trackId);
  621. bool MP4GetTrackVideoMetadata(MP4FileHandle hFile,
  622. MP4TrackId trackId,
  623. uint8_t **ppConfig,
  624. uint32_t *pConfigSize);
  625. bool MP4GetTrackESConfiguration(
  626. MP4FileHandle hFile,
  627. MP4TrackId trackId,
  628. u_int8_t** ppConfig,
  629. u_int32_t* pConfigSize);
  630. bool MP4SetTrackESConfiguration(
  631. MP4FileHandle hFile,
  632. MP4TrackId trackId,
  633. const u_int8_t* pConfig,
  634. u_int32_t configSize);
  635. /* h264 information routines */
  636. bool MP4GetTrackH264ProfileLevel(MP4FileHandle hFile,
  637. MP4TrackId trackId,
  638. uint8_t *pProfile,
  639. uint8_t *pLevel);
  640. void MP4GetTrackH264SeqPictHeaders(MP4FileHandle hFile,
  641. MP4TrackId trackId,
  642. uint8_t ***pSeqHeaders,
  643. uint32_t **pSeqHeaderSize,
  644. uint8_t ***pPictHeader,
  645. uint32_t **pPictHeaderSize);
  646. bool MP4GetTrackH264LengthSize(MP4FileHandle hFile,
  647. MP4TrackId trackId,
  648. uint32_t *pLength);
  649. MP4SampleId MP4GetTrackNumberOfSamples(
  650. MP4FileHandle hFile,
  651. MP4TrackId trackId);
  652. MP4ChunkId MP4GetTrackNumberOfChunks(
  653. MP4FileHandle hFile,
  654. MP4TrackId trackId);
  655. u_int16_t MP4GetTrackVideoWidth(
  656. MP4FileHandle hFile,
  657. MP4TrackId trackId);
  658. u_int16_t MP4GetTrackVideoHeight(
  659. MP4FileHandle hFile,
  660. MP4TrackId trackId);
  661. double MP4GetTrackVideoFrameRate(
  662. MP4FileHandle hFile,
  663. MP4TrackId trackId);
  664. int MP4GetTrackAudioChannels(MP4FileHandle hFile,
  665. MP4TrackId trackId);
  666. bool MP4IsIsmaCrypMediaTrack(
  667. MP4FileHandle hFile,
  668. MP4TrackId trackId);
  669. /* generic track properties */
  670. bool MP4HaveTrackAtom(MP4FileHandle hFile,
  671. MP4TrackId trackId,
  672. const char *atomName);
  673. bool MP4GetTrackIntegerProperty(
  674. MP4FileHandle hFile,
  675. MP4TrackId trackId,
  676. const char* propName,
  677. u_int64_t *retvalue);
  678. bool MP4GetTrackFloatProperty(
  679. MP4FileHandle hFile,
  680. MP4TrackId trackId,
  681. const char* propName,
  682. float *ret_value);
  683. bool MP4GetTrackStringProperty(
  684. MP4FileHandle hFile,
  685. MP4TrackId trackId,
  686. const char* propName,
  687. const char **retvalue);
  688. bool MP4GetTrackBytesProperty(
  689. MP4FileHandle hFile,
  690. MP4TrackId trackId,
  691. const char* propName,
  692. u_int8_t** ppValue,
  693. u_int32_t* pValueSize);
  694. bool MP4SetTrackIntegerProperty(
  695. MP4FileHandle hFile,
  696. MP4TrackId trackId,
  697. const char* propName,
  698. int64_t value);
  699. bool MP4SetTrackFloatProperty(
  700. MP4FileHandle hFile,
  701. MP4TrackId trackId,
  702. const char* propName,
  703. float value);
  704. bool MP4SetTrackStringProperty(
  705. MP4FileHandle hFile,
  706. MP4TrackId trackId,
  707. const char* propName,
  708. const char* value);
  709. bool MP4SetTrackBytesProperty(
  710. MP4FileHandle hFile,
  711. MP4TrackId trackId,
  712. const char* propName,
  713. const u_int8_t* pValue,
  714. u_int32_t valueSize);
  715. /* sample operations */
  716. bool MP4ReadSample(
  717. /* input parameters */
  718. MP4FileHandle hFile,
  719. MP4TrackId trackId,
  720. MP4SampleId sampleId,
  721. /* input/output parameters */
  722. u_int8_t** ppBytes,
  723. u_int32_t* pNumBytes,
  724. /* output parameters */
  725. MP4Timestamp* pStartTime DEFAULT(NULL),
  726. MP4Duration* pDuration DEFAULT(NULL),
  727. MP4Duration* pRenderingOffset DEFAULT(NULL),
  728. bool* pIsSyncSample DEFAULT(NULL));
  729. bool MP4ReadChunk(
  730. /* input parameters */
  731. MP4FileHandle hFile,
  732. MP4TrackId trackId,
  733. MP4ChunkId sampleId,
  734. /* input/output parameters */
  735. u_int8_t** ppBytes,
  736. u_int32_t* pNumBytes,
  737. MP4Timestamp* pStartTime DEFAULT(NULL),
  738. MP4Duration* pDuration DEFAULT(NULL));
  739. /* uses (unedited) time to specify sample instead of sample id */
  740. bool MP4ReadSampleFromTime(
  741. /* input parameters */
  742. MP4FileHandle hFile,
  743. MP4TrackId trackId,
  744. MP4Timestamp when,
  745. /* input/output parameters */
  746. u_int8_t** ppBytes,
  747. u_int32_t* pNumBytes,
  748. /* output parameters */
  749. MP4Timestamp* pStartTime DEFAULT(NULL),
  750. MP4Duration* pDuration DEFAULT(NULL),
  751. MP4Duration* pRenderingOffset DEFAULT(NULL),
  752. bool* pIsSyncSample DEFAULT(NULL));
  753. bool MP4WriteSample(
  754. MP4FileHandle hFile,
  755. MP4TrackId trackId,
  756. const u_int8_t* pBytes,
  757. u_int32_t numBytes,
  758. MP4Duration duration DEFAULT(MP4_INVALID_DURATION),
  759. MP4Duration renderingOffset DEFAULT(0),
  760. bool isSyncSample DEFAULT(true));
  761. bool MP4CopySample(
  762. MP4FileHandle srcFile,
  763. MP4TrackId srcTrackId,
  764. MP4SampleId srcSampleId,
  765. MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
  766. MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
  767. MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
  768. bool MP4EncAndCopySample(
  769. MP4FileHandle srcFile,
  770. MP4TrackId srcTrackId,
  771. MP4SampleId srcSampleId,
  772. encryptFunc_t encfcnp,
  773. u_int32_t encfcnparam1,
  774. MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
  775. MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
  776. MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
  777. /* Note this function is not yet implemented */
  778. bool MP4ReferenceSample(
  779. MP4FileHandle srcFile,
  780. MP4TrackId srcTrackId,
  781. MP4SampleId srcSampleId,
  782. MP4FileHandle dstFile,
  783. MP4TrackId dstTrackId,
  784. MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
  785. u_int32_t MP4GetSampleSize(
  786. MP4FileHandle hFile,
  787. MP4TrackId trackId,
  788. MP4SampleId sampleId);
  789. u_int32_t MP4GetTrackMaxSampleSize(
  790. MP4FileHandle hFile,
  791. MP4TrackId trackId);
  792. MP4SampleId MP4GetSampleIdFromTime(
  793. MP4FileHandle hFile,
  794. MP4TrackId trackId,
  795. MP4Timestamp when,
  796. bool wantSyncSample DEFAULT(false),
  797. bool rewind DEFAULT(false));
  798. MP4ChunkId MP4GetChunkIdFromTime(
  799. MP4FileHandle hFile,
  800. MP4TrackId trackId,
  801. MP4Timestamp when);
  802. MP4Timestamp MP4GetSampleTime(
  803. MP4FileHandle hFile,
  804. MP4TrackId trackId,
  805. MP4SampleId sampleId);
  806. MP4Duration MP4GetSampleDuration(
  807. MP4FileHandle hFile,
  808. MP4TrackId trackId,
  809. MP4SampleId sampleId);
  810. MP4Duration MP4GetSampleRenderingOffset(
  811. MP4FileHandle hFile,
  812. MP4TrackId trackId,
  813. MP4SampleId sampleId);
  814. bool MP4SetSampleRenderingOffset(
  815. MP4FileHandle hFile,
  816. MP4TrackId trackId,
  817. MP4SampleId sampleId,
  818. MP4Duration renderingOffset);
  819. int8_t MP4GetSampleSync(
  820. MP4FileHandle hFile,
  821. MP4TrackId trackId,
  822. MP4SampleId sampleId);
  823. /* rtp hint track operations */
  824. bool MP4GetHintTrackRtpPayload(
  825. MP4FileHandle hFile,
  826. MP4TrackId hintTrackId,
  827. char** ppPayloadName DEFAULT(NULL),
  828. u_int8_t* pPayloadNumber DEFAULT(NULL),
  829. u_int16_t* pMaxPayloadSize DEFAULT(NULL),
  830. char **ppEncodingParams DEFAULT(NULL));
  831. #define MP4_SET_DYNAMIC_PAYLOAD 0xff
  832. bool MP4SetHintTrackRtpPayload(
  833. MP4FileHandle hFile,
  834. MP4TrackId hintTrackId,
  835. const char* pPayloadName,
  836. u_int8_t* pPayloadNumber,
  837. u_int16_t maxPayloadSize DEFAULT(0),
  838. const char *encode_params DEFAULT(NULL),
  839. bool include_rtp_map DEFAULT(true),
  840. bool include_mpeg4_esid DEFAULT(true));
  841. const char* MP4GetSessionSdp(
  842. MP4FileHandle hFile);
  843. bool MP4SetSessionSdp(
  844. MP4FileHandle hFile,
  845. const char* sdpString);
  846. bool MP4AppendSessionSdp(
  847. MP4FileHandle hFile,
  848. const char* sdpString);
  849. const char* MP4GetHintTrackSdp(
  850. MP4FileHandle hFile,
  851. MP4TrackId hintTrackId);
  852. bool MP4SetHintTrackSdp(
  853. MP4FileHandle hFile,
  854. MP4TrackId hintTrackId,
  855. const char* sdpString);
  856. bool MP4AppendHintTrackSdp(
  857. MP4FileHandle hFile,
  858. MP4TrackId hintTrackId,
  859. const char* sdpString);
  860. MP4TrackId MP4GetHintTrackReferenceTrackId(
  861. MP4FileHandle hFile,
  862. MP4TrackId hintTrackId);
  863. bool MP4ReadRtpHint(
  864. MP4FileHandle hFile,
  865. MP4TrackId hintTrackId,
  866. MP4SampleId hintSampleId,
  867. u_int16_t* pNumPackets DEFAULT(NULL));
  868. u_int16_t MP4GetRtpHintNumberOfPackets(
  869. MP4FileHandle hFile,
  870. MP4TrackId hintTrackId);
  871. int8_t MP4GetRtpPacketBFrame(
  872. MP4FileHandle hFile,
  873. MP4TrackId hintTrackId,
  874. u_int16_t packetIndex);
  875. int32_t MP4GetRtpPacketTransmitOffset(
  876. MP4FileHandle hFile,
  877. MP4TrackId hintTrackId,
  878. u_int16_t packetIndex);
  879. bool MP4ReadRtpPacket(
  880. MP4FileHandle hFile,
  881. MP4TrackId hintTrackId,
  882. u_int16_t packetIndex,
  883. u_int8_t** ppBytes,
  884. u_int32_t* pNumBytes,
  885. u_int32_t ssrc DEFAULT(0),
  886. bool includeHeader DEFAULT(true),
  887. bool includePayload DEFAULT(true));
  888. MP4Timestamp MP4GetRtpTimestampStart(
  889. MP4FileHandle hFile,
  890. MP4TrackId hintTrackId);
  891. bool MP4SetRtpTimestampStart(
  892. MP4FileHandle hFile,
  893. MP4TrackId hintTrackId,
  894. MP4Timestamp rtpStart);
  895. bool MP4AddRtpHint(
  896. MP4FileHandle hFile,
  897. MP4TrackId hintTrackId);
  898. bool MP4AddRtpVideoHint(
  899. MP4FileHandle hFile,
  900. MP4TrackId hintTrackId,
  901. bool isBframe DEFAULT(false),
  902. u_int32_t timestampOffset DEFAULT(0));
  903. bool MP4AddRtpPacket(
  904. MP4FileHandle hFile,
  905. MP4TrackId hintTrackId,
  906. bool setMbit DEFAULT(false),
  907. int32_t transmitOffset DEFAULT(0));
  908. bool MP4AddRtpImmediateData(
  909. MP4FileHandle hFile,
  910. MP4TrackId hintTrackId,
  911. const u_int8_t* pBytes,
  912. u_int32_t numBytes);
  913. bool MP4AddRtpSampleData(
  914. MP4FileHandle hFile,
  915. MP4TrackId hintTrackId,
  916. MP4SampleId sampleId,
  917. u_int32_t dataOffset,
  918. u_int32_t dataLength);
  919. bool MP4AddRtpESConfigurationPacket(
  920. MP4FileHandle hFile,
  921. MP4TrackId hintTrackId);
  922. bool MP4WriteRtpHint(
  923. MP4FileHandle hFile,
  924. MP4TrackId hintTrackId,
  925. MP4Duration duration,
  926. bool isSyncSample DEFAULT(true));
  927. /* 3GP specific utilities */
  928. bool MP4Make3GPCompliant(
  929. const MP4_FILENAME_CHAR* fileName,
  930. u_int32_t verbosity DEFAULT(0),
  931. char* majorBrand DEFAULT(0),
  932. u_int32_t minorVersion DEFAULT(0),
  933. char** supportedBrands DEFAULT(NULL),
  934. u_int32_t supportedBrandsCount DEFAULT(0),
  935. bool deleteIodsAtom DEFAULT(true));
  936. /* ISMA specific utilities */
  937. bool MP4MakeIsmaCompliant(const MP4_FILENAME_CHAR* fileName,
  938. u_int32_t verbosity DEFAULT(0),
  939. bool addIsmaComplianceSdp DEFAULT(true));
  940. char* MP4MakeIsmaSdpIod(
  941. u_int8_t videoProfile,
  942. u_int32_t videoBitrate,
  943. u_int8_t* videoConfig,
  944. u_int32_t videoConfigLength,
  945. u_int8_t audioProfile,
  946. u_int32_t audioBitrate,
  947. u_int8_t* audioConfig,
  948. u_int32_t audioConfigLength,
  949. u_int32_t verbosity DEFAULT(0));
  950. /* edit list */
  951. /* NOTE this section of functionality
  952. * has not yet been fully tested
  953. */
  954. MP4EditId MP4AddTrackEdit(
  955. MP4FileHandle hFile,
  956. MP4TrackId trackId,
  957. MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID),
  958. MP4Timestamp startTime DEFAULT(0),
  959. MP4Duration duration DEFAULT(0),
  960. bool dwell DEFAULT(false));
  961. bool MP4DeleteTrackEdit(
  962. MP4FileHandle hFile,
  963. MP4TrackId trackId,
  964. MP4EditId editId);
  965. u_int32_t MP4GetTrackNumberOfEdits(
  966. MP4FileHandle hFile,
  967. MP4TrackId trackId);
  968. MP4Timestamp MP4GetTrackEditStart(
  969. MP4FileHandle hFile,
  970. MP4TrackId trackId,
  971. MP4EditId editId);
  972. MP4Duration MP4GetTrackEditTotalDuration(
  973. MP4FileHandle hFile,
  974. MP4TrackId trackId,
  975. MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID));
  976. MP4Timestamp MP4GetTrackEditMediaStart(
  977. MP4FileHandle hFile,
  978. MP4TrackId trackId,
  979. MP4EditId editId);
  980. bool MP4SetTrackEditMediaStart(
  981. MP4FileHandle hFile,
  982. MP4TrackId trackId,
  983. MP4EditId editId,
  984. MP4Timestamp startTime);
  985. MP4Duration MP4GetTrackEditDuration(
  986. MP4FileHandle hFile,
  987. MP4TrackId trackId,
  988. MP4EditId editId);
  989. bool MP4SetTrackEditDuration(
  990. MP4FileHandle hFile,
  991. MP4TrackId trackId,
  992. MP4EditId editId,
  993. MP4Duration duration);
  994. int8_t MP4GetTrackEditDwell(
  995. MP4FileHandle hFile,
  996. MP4TrackId trackId,
  997. MP4EditId editId);
  998. bool MP4SetTrackEditDwell(
  999. MP4FileHandle hFile,
  1000. MP4TrackId trackId,
  1001. MP4EditId editId,
  1002. bool dwell);
  1003. bool MP4ReadSampleFromEditTime(
  1004. /* input parameters */
  1005. MP4FileHandle hFile,
  1006. MP4TrackId trackId,
  1007. MP4Timestamp when,
  1008. /* input/output parameters */
  1009. u_int8_t** ppBytes,
  1010. u_int32_t* pNumBytes,
  1011. /* output parameters */
  1012. MP4Timestamp* pStartTime DEFAULT(NULL),
  1013. MP4Duration* pDuration DEFAULT(NULL),
  1014. MP4Duration* pRenderingOffset DEFAULT(NULL),
  1015. bool* pIsSyncSample DEFAULT(NULL));
  1016. MP4SampleId MP4GetSampleIdFromEditTime(
  1017. MP4FileHandle hFile,
  1018. MP4TrackId trackId,
  1019. MP4Timestamp when,
  1020. MP4Timestamp* pStartTime DEFAULT(NULL),
  1021. MP4Duration* pDuration DEFAULT(NULL));
  1022. /* iTunes metadata handling */
  1023. bool MP4MetadataDelete(MP4FileHandle hFile);
  1024. bool MP4GetMetadataByIndex(MP4FileHandle hFile, u_int32_t index,
  1025. char** ppName, // need to free memory
  1026. u_int8_t** ppValue, // need to free
  1027. u_int32_t* pValueSize);
  1028. bool MP4SetMetadataName(MP4FileHandle hFile, const char* value);
  1029. bool MP4GetMetadataName(MP4FileHandle hFile, char** value);
  1030. bool MP4DeleteMetadataName(MP4FileHandle hFile);
  1031. bool MP4SetMetadataArtist(MP4FileHandle hFile, const char* value);
  1032. bool MP4GetMetadataArtist(MP4FileHandle hFile, char** value);
  1033. bool MP4DeleteMetadataArtist(MP4FileHandle hFile);
  1034. bool MP4SetMetadataRating(MP4FileHandle hFile, const char* value);
  1035. bool MP4GetMetadataRating(MP4FileHandle hFile, char** value);
  1036. bool MP4DeleteMetadataRating(MP4FileHandle hFile);
  1037. bool MP4SetMetadataWriter(MP4FileHandle hFile, const char* value);
  1038. bool MP4GetMetadataWriter(MP4FileHandle hFile, char** value);
  1039. bool MP4DeleteMetadataWriter(MP4FileHandle hFile);
  1040. bool MP4SetMetadataComment(MP4FileHandle hFile, const char* value);
  1041. bool MP4GetMetadataComment(MP4FileHandle hFile, char** value);
  1042. bool MP4DeleteMetadataComment(MP4FileHandle hFile);
  1043. bool MP4SetMetadataTool(MP4FileHandle hFile, const char* value);
  1044. bool MP4GetMetadataTool(MP4FileHandle hFile, char** value);
  1045. bool MP4DeleteMetadataTool(MP4FileHandle hFile);
  1046. bool MP4SetMetadataYear(MP4FileHandle hFile, const char* value);
  1047. bool MP4GetMetadataYear(MP4FileHandle hFile, char** value);
  1048. bool MP4DeleteMetadataYear(MP4FileHandle hFile);
  1049. bool MP4SetMetadataAlbum(MP4FileHandle hFile, const char* value);
  1050. bool MP4GetMetadataAlbum(MP4FileHandle hFile, char** value);
  1051. bool MP4DeleteMetadataAlbum(MP4FileHandle hFile);
  1052. bool MP4SetMetadataTrack(MP4FileHandle hFile,
  1053. u_int16_t track, u_int16_t totalTracks);
  1054. bool MP4GetMetadataTrack(MP4FileHandle hFile,
  1055. u_int16_t* track, u_int16_t* totalTracks);
  1056. bool MP4DeleteMetadataTrack(MP4FileHandle hFile);
  1057. bool MP4SetMetadataDisk(MP4FileHandle hFile,
  1058. u_int16_t disk, u_int16_t totalDisks);
  1059. bool MP4GetMetadataDisk(MP4FileHandle hFile,
  1060. u_int16_t* disk, u_int16_t* totalDisks);
  1061. bool MP4DeleteMetadataDisk(MP4FileHandle hFile);
  1062. bool MP4SetMetadataGenre(MP4FileHandle hFile, const char *genre);
  1063. bool MP4GetMetadataGenre(MP4FileHandle hFile, char **genre);
  1064. bool MP4DeleteMetadataGenre(MP4FileHandle hFile);
  1065. bool MP4SetMetadataGrouping(MP4FileHandle hFile, const char *grouping);
  1066. bool MP4GetMetadataGrouping(MP4FileHandle hFile, char **grouping);
  1067. bool MP4DeleteMetadataGrouping(MP4FileHandle hFile);
  1068. bool MP4SetMetadataTempo(MP4FileHandle hFile, u_int16_t tempo);
  1069. bool MP4GetMetadataTempo(MP4FileHandle hFile, u_int16_t* tempo);
  1070. bool MP4DeleteMetadataTempo(MP4FileHandle hFile);
  1071. bool MP4SetMetadataCompilation(MP4FileHandle hFile, u_int8_t cpl);
  1072. bool MP4GetMetadataCompilation(MP4FileHandle hFile, u_int8_t* cpl);
  1073. bool MP4DeleteMetadataCompilation(MP4FileHandle hFile);
  1074. bool MP4SetMetadataPartOfGaplessAlbum(MP4FileHandle hFile, uint8_t pgap);
  1075. bool MP4GetMetadataPartOfGaplessAlbum(MP4FileHandle hFile, uint8_t *pgap);
  1076. bool MP4DeleteMetadataPartOfGaplessAlbum(MP4FileHandle hFile);
  1077. bool MP4SetMetadataCoverArt(MP4FileHandle hFile, u_int8_t *coverArt, u_int32_t size, int flags);
  1078. bool MP4GetMetadataCoverArt(MP4FileHandle hFile, u_int8_t **coverArt, u_int32_t* size, int *flags, uint32_t index DEFAULT(0));
  1079. u_int32_t MP4GetMetadataCoverArtCount(MP4FileHandle hFile);
  1080. bool MP4DeleteMetadataCoverArt(MP4FileHandle hFile);
  1081. bool MP4SetMetadataAlbumArtist(MP4FileHandle hFile, const char* value);
  1082. bool MP4GetMetadataAlbumArtist(MP4FileHandle hFile, char** value);
  1083. bool MP4DeleteMetadataAlbumArtist(MP4FileHandle hFile);
  1084. bool MP4SetMetadataFreeForm(MP4FileHandle hFile, const char *name,
  1085. const u_int8_t* pValue, u_int32_t valueSize, const char *owner DEFAULT(NULL));
  1086. bool MP4GetMetadataFreeForm(MP4FileHandle hFile, const char *name,
  1087. u_int8_t** pValue, u_int32_t* valueSize, const char *owner DEFAULT(NULL));
  1088. bool MP4DeleteMetadataFreeForm(MP4FileHandle hFile, const char *name, const char *owner DEFAULT(NULL));
  1089. bool MP4Get3GPMetadata(MP4FileHandle hFile, const char *name, uint16_t **value);
  1090. bool MP4Set3GPMetadata(MP4FileHandle hFile, const char *name, const uint16_t* value);
  1091. bool MP4Get3GPMetadataInteger(MP4FileHandle hFile, const char *name, uint64_t *value);
  1092. bool MP4Set3GPMetadataInteger(MP4FileHandle hFile, const char *name, uint64_t value);
  1093. bool MP4Delete3GPMetadata(MP4FileHandle hFile, const char *name);
  1094. /* time conversion utilties */
  1095. /* predefined values for timeScale parameter below */
  1096. #define MP4_SECONDS_TIME_SCALE 1
  1097. #define MP4_MILLISECONDS_TIME_SCALE 1000
  1098. #define MP4_MICROSECONDS_TIME_SCALE 1000000
  1099. #define MP4_NANOSECONDS_TIME_SCALE 1000000000
  1100. #define MP4_SECS_TIME_SCALE MP4_SECONDS_TIME_SCALE
  1101. #define MP4_MSECS_TIME_SCALE MP4_MILLISECONDS_TIME_SCALE
  1102. #define MP4_USECS_TIME_SCALE MP4_MICROSECONDS_TIME_SCALE
  1103. #define MP4_NSECS_TIME_SCALE MP4_NANOSECONDS_TIME_SCALE
  1104. u_int64_t MP4ConvertFromMovieDuration(
  1105. MP4FileHandle hFile,
  1106. MP4Duration duration,
  1107. u_int32_t timeScale);
  1108. u_int64_t MP4ConvertFromTrackTimestamp(
  1109. MP4FileHandle hFile,
  1110. MP4TrackId trackId,
  1111. MP4Timestamp timeStamp,
  1112. u_int32_t timeScale);
  1113. MP4Timestamp MP4ConvertToTrackTimestamp(
  1114. MP4FileHandle hFile,
  1115. MP4TrackId trackId,
  1116. u_int64_t timeStamp,
  1117. u_int32_t timeScale);
  1118. u_int64_t MP4ConvertFromTrackDuration(
  1119. MP4FileHandle hFile,
  1120. MP4TrackId trackId,
  1121. MP4Duration duration,
  1122. u_int32_t timeScale);
  1123. MP4Duration MP4ConvertToTrackDuration(
  1124. MP4FileHandle hFile,
  1125. MP4TrackId trackId,
  1126. u_int64_t duration,
  1127. u_int32_t timeScale);
  1128. char* MP4BinaryToBase16(
  1129. const u_int8_t* pData,
  1130. u_int32_t dataSize);
  1131. char* MP4BinaryToBase64(
  1132. const u_int8_t* pData,
  1133. u_int32_t dataSize);
  1134. uint8_t *Base64ToBinary(const char *pData,
  1135. uint32_t decodeSize,
  1136. uint32_t *pDataSize);
  1137. void MP4Free(void *p);
  1138. char* MP4PrintAudioInfo(
  1139. MP4FileHandle mp4File,
  1140. MP4TrackId trackId);
  1141. char* MP4PrintVideoInfo(
  1142. MP4FileHandle mp4File,
  1143. MP4TrackId trackId);
  1144. #ifdef __cplusplus
  1145. }
  1146. #endif
  1147. /* undefined our utlity macro to avoid conflicts */
  1148. #undef DEFAULT
  1149. #endif /* __MP4_INCLUDED__ */