1
0

mpeg4ip.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. 2000-2005. All Rights Reserved.
  17. *
  18. * Contributor(s):
  19. * Dave Mackie [email protected]
  20. * Bill May [email protected]
  21. */
  22. #ifndef __MPEG4IP_INCLUDED__
  23. #define __MPEG4IP_INCLUDED__
  24. /* project wide applicable stuff here */
  25. #ifndef _WIN32
  26. #ifdef PACKAGE_BUGREPORT
  27. #define TEMP_PACKAGE_BUGREPORT PACKAGE_BUGREPORT
  28. #define TEMP_PACKAGE_NAME PACKAGE_NAME
  29. #define TEMP_PACKAGE_STRING PACKAGE_STRING
  30. #define TEMP_PACKAGE_TARNAME PACKAGE_TARNAME
  31. #define TEMP_PACKAGE_VERSION PACKAGE_VERSION
  32. #undef PACKAGE_BUGREPORT
  33. #undef PACKAGE_NAME
  34. #undef PACKAGE_STRING
  35. #undef PACKAGE_TARNAME
  36. #undef PACKAGE_VERSION
  37. #include <mpeg4ip_config.h>
  38. #undef PACKAGE_BUGREPORT
  39. #undef PACKAGE_NAME
  40. #undef PACKAGE_STRING
  41. #undef PACKAGE_TARNAME
  42. #undef PACKAGE_VERSION
  43. #define PACKAGE_BUGREPORT TEMP_PACKAGE_BUGREPORT
  44. #define PACKAGE_NAME TEMP_PACKAGE_NAME
  45. #define PACKAGE_STRING TEMP_PACKAGE_STRING
  46. #define PACKAGE_TARNAME TEMP_PACKAGE_TARNAME
  47. #define PACKAGE_VERSION TEMP_PACKAGE_VERSION
  48. #else
  49. #include <mpeg4ip_config.h>
  50. #endif
  51. #endif
  52. // the mpeg4ip_package and mpeg4ip_version are always in this
  53. // file
  54. #include "mpeg4ip_version.h"
  55. #ifdef _WIN32
  56. #include "mpeg4ip_win32.h"
  57. #include "mpeg4ip_version.h"
  58. #include "stdint.h"
  59. #else /* UNIX */
  60. /*****************************************************************************
  61. * UNIX LIKE DEFINES BELOW THIS POINT
  62. *****************************************************************************/
  63. #ifdef sun
  64. #include <sys/feature_tests.h>
  65. #endif
  66. #ifndef _FILE_OFFSET_BITS
  67. #define _FILE_OFFSET_BITS 64
  68. #else
  69. #ifndef sun
  70. #if _FILE_OFFSET_BITS < 64
  71. #error File offset bits is already set to non-64 value
  72. #endif
  73. #endif
  74. #endif
  75. #ifndef _LARGEFILE_SOURCE
  76. #define _LARGEFILE_SOURCE
  77. #endif
  78. #include <stdio.h>
  79. #include <errno.h>
  80. #include <stdlib.h>
  81. #ifdef HAVE_INTTYPES_H
  82. #include <inttypes.h>
  83. #endif
  84. #ifdef HAVE_STDINT_H
  85. #include <stdint.h>
  86. #endif
  87. #if !defined(HAVE_INTTYPES_H) && !defined(HAVE_STDINT_H)
  88. #error "Don't have stdint.h or inttypes.h - no way to get uint8_t"
  89. #endif
  90. #include <unistd.h>
  91. #include <fcntl.h>
  92. #include <netinet/in.h>
  93. #include <sys/types.h>
  94. #include <sys/socket.h>
  95. #include <netinet/in.h>
  96. #include <arpa/inet.h>
  97. #include <syslog.h>
  98. #include <string.h>
  99. #include <ctype.h>
  100. #include <netdb.h>
  101. #include <sys/stat.h>
  102. #ifdef TIME_WITH_SYS_TIME
  103. #include <sys/time.h>
  104. #include <time.h>
  105. #else
  106. #ifdef HAVE_SYS_TIME_H
  107. #include <sys/time.h>
  108. #else
  109. #include <time.h>
  110. #endif
  111. #endif
  112. #include <sys/param.h>
  113. #ifdef __cplusplus
  114. extern "C" {
  115. #endif
  116. char *strcasestr(const char *haystack, const char *needle);
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #define OPEN_RDWR O_RDWR
  121. #define OPEN_CREAT O_CREAT
  122. #define OPEN_RDONLY O_RDONLY
  123. #define closesocket close
  124. #define IOSBINARY ios::bin
  125. #if SIZEOF_LONG == 8
  126. #define MAX_UINT64 -1LU
  127. #define D64F "ld"
  128. #define U64F "lu"
  129. #define X64F "lx"
  130. #define TO_D64(a) (a##L)
  131. #define TO_U64(a) (a##LU)
  132. #else
  133. #define MAX_UINT64 -1LLU
  134. #define D64F "lld"
  135. #define U64F "llu"
  136. #define X64F "llx"
  137. #define TO_D64(a) (a##LL)
  138. #define TO_U64(a) (a##LLU)
  139. #endif
  140. #ifdef HAVE_FPOS_T___POS
  141. #define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)((fpos).__pos)
  142. #define VAR_TO_FPOS(fpos, var) (fpos).__pos = (var)
  143. #else
  144. #define FPOS_TO_VAR(fpos, typed, var) (var) = (typed)(fpos)
  145. #define VAR_TO_FPOS(fpos, var) (fpos) = (var)
  146. #endif
  147. #define FOPEN_READ_BINARY "r"
  148. #define FOPEN_WRITE_BINARY "w"
  149. #define UINT64_TO_DOUBLE(a) ((double)(a))
  150. #endif /* define unix */
  151. /*****************************************************************************
  152. * Generic type includes used in the whole package *
  153. *****************************************************************************/
  154. #define D64 "%"D64F
  155. #define U64 "%"U64F
  156. #define X64 "%"X64F
  157. #define M_LLU TO_U64(1000)
  158. #define M_64 TO_U64(1000)
  159. #define LLU U64
  160. #include <stdarg.h>
  161. typedef void (*error_msg_func_t)(int loglevel,
  162. const char *lib,
  163. const char *fmt,
  164. va_list ap);
  165. typedef void (*lib_message_func_t)(int loglevel,
  166. const char *lib,
  167. const char *fmt,
  168. ...);
  169. #ifndef HAVE_IN_PORT_T
  170. typedef uint16_t in_port_t;
  171. #endif
  172. #ifndef HAVE_SOCKLEN_T
  173. typedef unsigned int socklen_t;
  174. #endif
  175. #ifdef sun
  176. #include <limits.h>
  177. #define u_int8_t uint8_t
  178. #define u_int16_t uint16_t
  179. #define u_int32_t uint32_t
  180. #define u_int64_t uint64_t
  181. #define __STRING(expr) #expr
  182. #endif
  183. #ifndef HAVE_STRSEP
  184. #ifdef __cplusplus
  185. extern "C" {
  186. #endif
  187. char *strsep(char **strp, const char *delim);
  188. #ifdef __cplusplus
  189. }
  190. #endif
  191. #endif
  192. #ifndef MIN
  193. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  194. #endif
  195. #ifndef MAX
  196. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  197. #endif
  198. #ifndef INADDR_NONE
  199. #define INADDR_NONE (-1)
  200. #endif
  201. #define MALLOC_STRUCTURE(a) ((a *)malloc(sizeof(a)))
  202. #define CHECK_AND_FREE(a) if ((a) != NULL) { free((void *)(a)); (a) = NULL;}
  203. #define NUM_ELEMENTS_IN_ARRAY(name) ((sizeof((name))) / (sizeof(*(name))))
  204. #define ADV_SPACE(a) {while (isspace(*(a)) && (*(a) != '\0'))(a)++;}
  205. #ifndef HAVE_GTK
  206. typedef char gchar;
  207. typedef unsigned char guchar;
  208. typedef int gint;
  209. typedef unsigned int guint;
  210. typedef long glong;
  211. typedef unsigned long gulong;
  212. typedef double gdouble;
  213. typedef int gboolean;
  214. typedef int16_t gint16;
  215. typedef uint16_t guint16;
  216. typedef int32_t gint32;
  217. typedef uint32_t guint32;
  218. typedef int64_t gint64;
  219. typedef uint64_t guint64;
  220. typedef uint8_t guint8;
  221. typedef int8_t gint8;
  222. #endif
  223. #ifndef FALSE
  224. #define FALSE 0
  225. #endif
  226. #ifndef TRUE
  227. #define TRUE 1
  228. #endif
  229. #ifndef __cplusplus
  230. #ifndef bool
  231. #if SIZEOF_BOOL == 8
  232. typedef uint64_t bool;
  233. #else
  234. #if SIZEOF_BOOL == 4
  235. typedef uint32_t bool;
  236. #else
  237. #if SIZEOF_BOOL == 2
  238. typedef uint16_t bool;
  239. #else
  240. typedef unsigned char bool;
  241. #endif
  242. #endif
  243. #endif
  244. #ifndef false
  245. #define false FALSE
  246. #endif
  247. #ifndef true
  248. #define true TRUE
  249. #endif
  250. #endif
  251. #endif
  252. #ifndef ROUND
  253. # ifdef HAVE_RINT
  254. # define ROUND(f) rint(f)
  255. # else
  256. # define ROUND(f) (int)(floor((f) + 0.5))
  257. # endif
  258. #endif
  259. #ifndef INT16_MAX
  260. # define INT16_MAX (32767)
  261. #endif
  262. #ifndef INT16_MIN
  263. # define INT16_MIN (-32767-1)
  264. #endif
  265. #ifndef UINT32_MAX
  266. # define UINT32_MAX (4294967295U)
  267. #endif
  268. #ifndef UINT64_MAX
  269. # define UINT64_MAX TO_U64(0xffffffffffffffff)
  270. #endif
  271. typedef enum audio_format_t {
  272. AUDIO_FMT_U8 = 0,
  273. AUDIO_FMT_S8,
  274. AUDIO_FMT_U16LSB,
  275. AUDIO_FMT_S16LSB,
  276. AUDIO_FMT_U16MSB,
  277. AUDIO_FMT_S16MSB,
  278. AUDIO_FMT_U16,
  279. AUDIO_FMT_S16,
  280. AUDIO_FMT_FLOAT,
  281. AUDIO_FMT_HW_AC3,
  282. } audio_format_t;
  283. #ifdef _WIN32
  284. #define MP4_FILENAME_CHAR wchar_t
  285. #else
  286. #define MP4_FILENAME_CHAR char
  287. #endif
  288. #endif /* __MPEG4IP_INCLUDED__ */