duck_hfb.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. #ifndef _duck_hfb_h
  2. #define _duck_hfb_h
  3. /******************************************************************************\
  4. <table BGCOLOR=#FFC0C0 border=1 WIDTH=100% ><tr><td><b>
  5. duck_hfb.h </b></td><td><b> TrueMotion include file for buffering/streaming libraries </b>
  6. </td></tr><tr><td>&nbsp</td><td> Version: 6.0.0
  7. </td></tr><tr><td>&nbsp</td><td> Updated: $Date: 2010/07/23 19:10:44 $
  8. </td></tr><tr><td>&nbsp</td><td> Copyright (c) 1994-98, The Duck Corp. All rights reserved.
  9. </td></tr>
  10. </table>
  11. ******************************************************************************/
  12. #define lHFB_ HFB_
  13. #define libFunc
  14. #if defined(__cplusplus)
  15. extern "C" {
  16. #endif
  17. #include "duck_bmp.h"
  18. #include "duck_wav.h"
  19. #include <string.h> /* for size_t */
  20. typedef enum dukDirect { /* direction to move within stream */
  21. DUK_BACKWARD=-1, /* move backward from current position */
  22. DUK_ABSOLUTE=0, /* move to an absolute position */
  23. DUK_FORWARD=1, /* move forward from current position */
  24. DUK_RESET=2 /* reset stream according to file position */
  25. } hfbDirection;
  26. typedef enum HFB_FileType { /* type of file opened */
  27. DUK_NULFILE = 0, /* not a TrueMotion "S" A/V file */
  28. DUK_DUKFILE = 1, /* TrueMotion "S" duk file */
  29. DUK_AVIFILE = -1, /* TrueMotion "S" Video for Windows AVI compatible file */
  30. DUK_QTFILE = 3 /* TrueMotion "S" Quicktime MOV compatible file */
  31. } hfbFileType;
  32. typedef enum HFB_StreamType {/* stream types */
  33. DUK_UNDEFINED = 0, /* indeterminate or uninitialized stream */
  34. DUK_AUDSTREAM = 1, /* audio stream */
  35. DUK_VIDSTREAM = 2, /* video stream */
  36. DUK_TXTSTREAM = 3 /* text stream */
  37. } hfbStreamType;
  38. typedef enum HFB_Modes { /* HFB buffering modes */
  39. HFBMODE_NORMAL = 0, /* normal play once mode */
  40. HFBMODE_FORWARDLOOP = 1, /* forward looping mode (loop back to start) */
  41. HFBMODE_REVERSE = 2, /* reverse play once mode (not yet implemented)*/
  42. HFBMODE_REVERSELOOP = 4, /* reverse looping mode (not yet implemented)*/
  43. HFBMODE_QUEUE = 8, /* file queue mode (not yet implemented)*/
  44. HFBMODE_FLYINDEX = 16, /* HFB does not have to read the AVI index to play the movie */ /* FWG 6-23-99 */
  45. HFBMODE_ASYNC = 32, /* HFB is in asnyc mode. Needed for first read and index stuff */ /* FWG 7-7-99 */
  46. HFBMODE_ASYNC_FLYINDEX = 64, /* Asnyc & Fly-Index mode. */ /* FWG 7-7-99 */
  47. HFBMODE_PSEUDO_ASYNC = 128 /* */
  48. } hfbBufferMode;
  49. typedef enum BUFFERSTATUS {
  50. HFB_BUSY = 0,
  51. HFB_COMPLETE
  52. } hfbBufferStatus;
  53. typedef enum PRELOADSPEC {
  54. HFB_FULL = -2,
  55. HFB_THREEQUARTERS = -1,
  56. HFB_NONE = 0
  57. } hfbPreloadSpec;
  58. #define HFB_USE_DEFAULT 0L
  59. #define HFB_RESET_COUNT -1L
  60. #define HFB_IGNORE_COUNT -2L
  61. #define HFB_DATA_READ 0x01
  62. #define HFB_DATA_RELEASED 0x02
  63. #define HFB_DATA_KEYFRAME 0x08
  64. typedef struct tHFB_STREAM_INFO{
  65. hfbStreamType streamType;
  66. int streamNum;
  67. int lSampleRate;
  68. int lStart;
  69. int lLength;
  70. char szName[24];
  71. union {
  72. DKWAVEFORM WaveformInfo;
  73. DKBITMAP BitmapInfo;
  74. DKBITMAP_old depricatedBitmapInfo; /* please don't use this */
  75. } a;
  76. DK_BITMAPINFOHEADER bmih; /* should be part of union or replace DKBITMAP ... but due to healthy paranoia add here ... */
  77. } HFB_STREAM_INFO, MFP_STREAM_INFO;
  78. typedef struct tHFB_FILE_INFO{
  79. int lFileSize;
  80. int lNumStreams;
  81. char sName[96];
  82. int lNumFrames;
  83. } HFB_FILE_INFO, MFP_FILE_INFO;
  84. typedef struct tHFBFile *HFB_FILE_HANDLE;
  85. typedef struct tHFBStream *HFB_STREAM_HANDLE;
  86. typedef struct tHFBBuffer *HFB_BUFFER_HANDLE;
  87. typedef int HFB_DATA_HANDLE;
  88. #define DCK_DEFAULT_READSIZE 0
  89. #define DCK_DEFAULT_BUFFSIZE 0
  90. /* main HFB initialization and exit routines */
  91. /*@
  92. @Name HFB_Init
  93. @Description Allocate and initialize required data structures.If all three parameters are -1,
  94. HFB will dynamically allocate objects as needed.
  95. @Return value 0 if success or negative return code.
  96. @*/
  97. libFunc int HFB_Init(
  98. int maxOpenFiles, /* maximum of concurently open file objects. */
  99. int maxOpenStreams, /* maximum of concurently open streams. */
  100. int maxOpenBuffers /* maximum of concurently open buffer objects. */
  101. );
  102. /*@
  103. @Name HFB_Exit
  104. @Description free any allocated strcutures, close all files, etc.
  105. @Return value none.
  106. @*/
  107. libFunc void HFB_Exit(void);
  108. /*@
  109. @Name HFB_SeekToIndex
  110. @Description Seek to the index in the AVI file
  111. @Return Value returns 0 on success.
  112. @*/
  113. libFunc int HFB_SeekToIndex(HFB_FILE_HANDLE FileHandle);
  114. /*@
  115. @!Name HFB_BeginLoadIndex
  116. @Description
  117. @Return value
  118. @*/
  119. libFunc int HFB_BeginLoadIndex(
  120. HFB_BUFFER_HANDLE dckPtr, /* */
  121. int size /* */
  122. );
  123. /*@
  124. @!Name HFB_FinishLoadIndex
  125. @Description
  126. @Return value
  127. @*/
  128. libFunc int HFB_FinishLoadIndex(
  129. HFB_BUFFER_HANDLE dckPtr, /* */
  130. void *data, /* */
  131. int size /* */
  132. );
  133. /*@
  134. @!Name HFB_ParseBigIndex
  135. @Description
  136. @Return value
  137. @*/
  138. libFunc int HFB_ParseBigIndex(
  139. HFB_BUFFER_HANDLE dckPtr,
  140. void *data,
  141. int size
  142. );
  143. /*@
  144. @Name HFB_OpenFile
  145. @Description open specified file, parse its header(s) and load the index
  146. @Return value handle to HFB file object.
  147. @*/
  148. libFunc HFB_FILE_HANDLE HFB_OpenFile(
  149. const char *fileName, /* file to be opened. */
  150. HFB_BUFFER_HANDLE bufferHandle, /* handle to a pre-existing HFB buffer. */
  151. unsigned int userData /* user data. */
  152. );
  153. /* the following three functions, findfile, parsefile and loadindex,
  154. are encapsulated by openfile, they are provided as a convenience
  155. for use on systems with asynchronous i/o */
  156. #if 0 // Changed to a static funtion MEW 11-6-03
  157. /*@
  158. @Name HFB_FindFile
  159. @Description This function implements a portion of the functionality performed by HFB_OpenFile.
  160. @Return value Handle to a HFB file object.
  161. @*/
  162. libFunc HFB_FILE_HANDLE HFB_FindFile(
  163. const char *fileName, /* name of file to open */
  164. unsigned int userData /* user data */
  165. );
  166. #endif
  167. /*@
  168. @Name HFB_ParseFile
  169. @Description After a file has been found, and at least a single sector is buffered, it's header can be
  170. parsedfor the information necessary to describe what the file contains. The combination of loading functions must
  171. appear in this order HFB_FindFile, HFB_ParseFile, HFBLoadIndex.
  172. @Return value none.
  173. @*/
  174. libFunc int HFB_ParseFile(
  175. HFB_FILE_HANDLE fileHandle, /* handle to an HFB file object. */
  176. HFB_BUFFER_HANDLE bufferHandle /* handle to an HFB buffer object. */
  177. );
  178. /*@
  179. @Name HFB_LoadIndex
  180. @Description Load a TrueMotion file's index into the specified buffer object.
  181. Must be used in this order ... HFB_FindFile, HFB_ParseFile, HFB_LoadIndex.
  182. @Return value 0 if successful, -1 if error
  183. @*/
  184. libFunc int HFB_LoadIndex(
  185. HFB_FILE_HANDLE fileHandle, /* handle to HFB file object. */
  186. HFB_BUFFER_HANDLE bufferHandle /* handle to HFFB buffer object. */
  187. );
  188. /*@
  189. @Name HFB_CloseFile
  190. @Description Close a TrueMotion file (AVI) and release file structures.
  191. @Return value None.
  192. @*/
  193. libFunc void HFB_CloseFile(
  194. HFB_FILE_HANDLE fHnd /* handle to an HFB file object. */
  195. );
  196. /*@
  197. @Name HFB_GetFileInfo
  198. @Description Used to read information about an opened TrueMotion File (AVI).
  199. @Return value a pointer to an HFB_FILE_INFO structure describing the indicated file.
  200. @*/
  201. libFunc HFB_FILE_INFO *HFB_GetFileInfo(
  202. HFB_FILE_HANDLE fileHandle /* handle to an HFB file object. */
  203. );
  204. /*@
  205. @Name HFB_CreateBuffer
  206. @Description Create High-speed File Buffer.
  207. @Return value Handle to an HFB Buffer object, or null if no buffer objects available.
  208. @*/
  209. libFunc HFB_BUFFER_HANDLE HFB_CreateBuffer(
  210. int sizeOfBuffer, /* size in bytes of buffer to allocate. */
  211. int reserved /* reserved - must bbe zero. */
  212. );
  213. /*@
  214. @Name HFB_InitBuffer
  215. @Description After creating a buffer and opening a file, an application mst initialize the buffer with data.
  216. @Return value Zero if successful, non-zero if not successful.
  217. @*/
  218. libFunc int HFB_InitBuffer(
  219. HFB_BUFFER_HANDLE bufferHandle, /* handle to HFB buffer object. */
  220. HFB_FILE_HANDLE fileToLoad, /* handle to HFB file object */
  221. int startFrame, /* frame at which to being playback , normally 0. */
  222. int initialReadSize /* amount of buffer to preload with data (specified in bytes). -1 means 3/4 buffer. -2 fill entire buffer */
  223. );
  224. /*@
  225. @Name HFB_FillBuffer
  226. @Description read additional data from a file into space invalidated by HFB_ReleaseStreamingData calls
  227. or any empty buffer space available. For best results call this function once per frame with the elapsedFrames set to DUCK_IGNORE_COUNT.
  228. The function will use the elapsedFrame parameter in conjunction with internal computed values to determine the amount to read from the file
  229. in order to avoid waiting for data to become availabble.
  230. @Return value Number of bytes actually read from the disk file into the buffer or a negative error code.
  231. @*/
  232. libFunc int HFB_FillBuffer(
  233. HFB_BUFFER_HANDLE bufferHandle, /* handle to a buffer objects */
  234. int maxToRead, /* maximum number of bytes to read during this call */
  235. int elapsedFrames /* number of frames elapsed since start of play */
  236. );
  237. /*@
  238. @Name HFB_DestroyBuffer
  239. @Description Free memory used by buffer and release buffer object.
  240. @Return value none.
  241. @*/
  242. libFunc void HFB_DestroyBuffer(
  243. HFB_BUFFER_HANDLE bufferHandle /* handle to an HFB buffer object */
  244. );
  245. /*@
  246. @!Name HFB_ResetStreams
  247. @Description
  248. @Return value
  249. @*/
  250. libFunc void HFB_ResetStreams(
  251. HFB_BUFFER_HANDLE bufferHandle /* */
  252. );
  253. /*@
  254. @Name HFB_SetBufferMode
  255. @Description Sets the mode for the specified bufffer. Buffer mode defaults to HFBMODE_NORMAL unless this function is called.
  256. @Return value
  257. @*/
  258. libFunc int HFB_SetBufferMode(
  259. HFB_BUFFER_HANDLE buffer, /* handle to HFB buffer object. */
  260. hfbBufferMode mode /* mode. */
  261. );
  262. /*@
  263. @!Name HFB_GetBufferPerCentFull
  264. @Description
  265. @Return value
  266. @*/
  267. libFunc int HFB_GetBufferPerCentFull(
  268. HFB_BUFFER_HANDLE buffer /* */
  269. );
  270. /*@
  271. @!Name HFB_GetmovieSize
  272. @Description
  273. @Return value
  274. @*/
  275. libFunc int HFB_GetmovieSize(
  276. HFB_BUFFER_HANDLE buffer /* */
  277. );
  278. /*@
  279. @!Name HFB_GetBufferSpace
  280. @Description
  281. @Return value
  282. @*/
  283. libFunc int HFB_GetBufferSpace(
  284. HFB_BUFFER_HANDLE buffer /* */
  285. );
  286. /*@
  287. @Name HFB_GetBufferStatus
  288. @Description Use this to detemine if a buffer has reached an end of file.
  289. @Return value 0 - buffer OK. 1 - Buffer reached end of file.
  290. @*/
  291. libFunc hfbBufferStatus HFB_GetBufferStatus(
  292. HFB_BUFFER_HANDLE buffer /* handle to an HFB buffer object. */
  293. );
  294. /*@
  295. @!Name HFB_ConditionBuffer
  296. @Description
  297. @Return value
  298. @*/
  299. libFunc int HFB_ConditionBuffer(
  300. HFB_BUFFER_HANDLE bufferHandle, /* */
  301. int bufferSize, /* */
  302. int reserved /* */
  303. );
  304. #define HFB_ResetBuffer HFB_ConditionBuffer
  305. /*@
  306. @Name HFB_GetStream
  307. @Description get a stream reference handle by name, number, or type.
  308. @Return value handle to a stream object.
  309. @*/
  310. libFunc HFB_STREAM_HANDLE HFB_GetStream(
  311. HFB_FILE_HANDLE fileHandle, /* handle to HFB file object. */
  312. const char *StreamNameOrNull, /* C string containing the name of a stream within the specified file. Null to ignore. */
  313. int streamNumber, /* an absolute stream number or the nth occuring stream of the specified file. */
  314. unsigned int streamType /* the type of stream to be opened. */
  315. );
  316. /*@
  317. @Name HFB_ReleaseStream
  318. @Description relinquish reference to stream object so it may return to the pool.
  319. @Return value none.
  320. @*/
  321. libFunc void HFB_ReleaseStream(
  322. HFB_STREAM_HANDLE streamHandle /* handle to an HFB stream object. */
  323. );
  324. /*@
  325. @Name HFB_GetStreamInfo
  326. @Description get a pointer to stream info struct
  327. @Return value pointer to a struct containing the stream info.
  328. @*/
  329. libFunc HFB_STREAM_INFO* HFB_GetStreamInfo(
  330. HFB_STREAM_HANDLE streamHandle /* handle to an HFB stream object */
  331. );
  332. #define HFB_GetStreamLength(strmh) HFB_GetStreamInfo(strmh)->lLength
  333. #define HFB_GetStreamName(strmh) HFB_GetStreamInfo(strmh)->szName
  334. /*@
  335. @Name HFB_GetStreamingData
  336. @Description Get pointer to buffered record and length. Normally this will be balanced by a call to HFB_ReleaseStreamingData, unless
  337. the entire file fits within the HFB buffer. The operation does not move compressed data.
  338. @Return value >= 0 handle to compressed block; -1 request out of range ; -2 block exists but is not in the buffer ...
  339. usually caused by unrleased block of buffer starvation ; -4 block has been release from use.
  340. @*/
  341. libFunc HFB_DATA_HANDLE HFB_GetStreamingData(
  342. HFB_STREAM_HANDLE streamHandle, /* handle to an HFB stream object. */
  343. void **ptrToPtr, /* pointer to pointer to compressed data. */
  344. int *ptrToLength, /* pointer to length of data in bytes. */
  345. hfbDirection directionToMove, /* direction in which to read records. */
  346. int framesToMove /* the number of reqested records. */
  347. );
  348. /*@
  349. @Name HFB_ReleaseStreamingData
  350. @Description release buffer space occupied by record
  351. @Return value none.
  352. @*/
  353. libFunc void HFB_ReleaseStreamingData(
  354. HFB_BUFFER_HANDLE bufferHandle, /* handle to HFB buffer object. */
  355. HFB_DATA_HANDLE recordToRelease /* index of data record to release. */
  356. );
  357. /*@
  358. @Name HFB_ReadData
  359. @Description read data directly from a file into a supplied buffer,
  360. limit is set by initial value of *ptrToLength
  361. @Return value 0 on success, or negative error code.
  362. @*/
  363. libFunc int HFB_ReadData(
  364. HFB_STREAM_HANDLE streamHandle, /* handle to HFB stream object. */
  365. void *data, /* pointer to where data should be copied. Used by duck_read. */
  366. int *maxLength, /* pointer to max data size, will be over-written with actual count of bytes read. */
  367. hfbDirection directionToMove, /* direction in which the seek should move. */
  368. int count /* the number of datarecords to move before reading. Absolute referencse begin at 0. */
  369. );
  370. libFunc int HFB_ReadDataBlocking(
  371. HFB_STREAM_HANDLE streamHandle, /* handle to HFB stream object. */
  372. void *data, /* pointer to where data should be copied. Used by duck_read. */
  373. int *maxLength, /* pointer to max data size, will be over-written with actual count of bytes read. */
  374. hfbDirection directionToMove, /* direction in which the seek should move. */
  375. int count /* the number of datarecords to move before reading. Absolute referencse begin at 0. */
  376. );
  377. /*@
  378. @!Name HFB_FramestoNextKeyFrame
  379. @Description
  380. @Return value
  381. @*/
  382. libFunc int HFB_FramestoNextKeyFrame(
  383. HFB_STREAM_HANDLE streamHandle, /* */
  384. int recordHandle, /* */
  385. int *numberOfRecordsSpanned /* */
  386. );
  387. /*@
  388. @!Name HFB_FrameToChunk
  389. @Description
  390. @Return value
  391. @*/
  392. libFunc int HFB_FrameToChunk(
  393. HFB_STREAM_HANDLE streamHandle, /* */
  394. int frameNumber /* */
  395. );
  396. /*@
  397. @Name HFB_PreviousKeyFrame
  398. @Description Get the frameNumber of the keyframe at or prior to the specified frameNumber
  399. @Return value
  400. @*/
  401. libFunc int HFB_PreviousKeyFrame(
  402. HFB_STREAM_HANDLE streamHandle, /* */
  403. int frameNumber /* */
  404. );
  405. typedef enum FTYPE {
  406. HFB_FRAMENUM = 0,
  407. HFB_INDEXNUM = 1
  408. } hfbFrameNumber;
  409. /*@
  410. @Name HFB_GetIndexFlags
  411. @Description get the HFB index flags for the specified record/frame
  412. @Return value >= 0 data block flags for data block specifid; -1 frameNum is out of index range ; -2 frameNum is out of frame range.
  413. @*/
  414. libFunc int HFB_GetIndexFlags(
  415. HFB_STREAM_HANDLE , /* handle to HFB stream object. */
  416. hfbFrameNumber frameNumberType, /* one of HFB_FRAMENUM, HFB_INDEXNUM */
  417. int recordHandleOrFrameNumber /* record handle or frame number. */
  418. );
  419. /*@
  420. @Name HFB_AddIndexFlags
  421. @Description add the HFB index flags for the specified record/frame
  422. @Return value 0 if unsuccessful; 1 if successful;
  423. @*/
  424. libFunc int HFB_AddIndexFlags(
  425. HFB_STREAM_HANDLE , /* handle to HFB stream object. */
  426. hfbFrameNumber frameNumberType, /* one of HFB_FRAMENUM, HFB_INDEXNUM */
  427. int recordHandleOrFrameNumber, /* record handle or frame number. */
  428. int flags /* flags to add */
  429. );
  430. /*@
  431. @Name HFB_GetDataPosition
  432. @Description get current data position. video - frameNumber, audio - sampleCount.
  433. This is useful for resolving differences between streams when starting from a position other than the beginning of the file.
  434. @Return value Longword starting position of the data record within the stream, expressed in audio samples for audio streams and frames for video streams.
  435. @*/
  436. libFunc int HFB_GetDataPosition(
  437. HFB_STREAM_HANDLE streamHandle, /* handle to HFB stream object. */
  438. HFB_DATA_HANDLE dataIndex /* index to a data record within a stream. Use -1 to find position of first available record in the buffered stream */
  439. );
  440. /*@
  441. @Name HFB_GetAudioInfo
  442. @Description Get information about audio stream.
  443. @Return value pointer to a DKWAVEFORM structure describing the audio information contained in the stream.
  444. @*/
  445. libFunc DKWAVEFORM *HFB_GetAudioInfo(
  446. HFB_STREAM_HANDLE aStream, /* handle to HFB stream object */
  447. int *NumChannels, /* pointer to number of channels in the audio stream. */
  448. int *SamplesPerSec, /* pointer to samples per second in the audio stream. */
  449. int *BytesPerSec, /* pointer to bytes per second in the audio stream. */
  450. int *wFormat /* pointer to the format tag value for the audio stream. */
  451. );
  452. /*@
  453. @!Name HFB_GetInitialFrames
  454. @Description /* get the amount of audio skew expressed in records
  455. @Return value
  456. @*/
  457. libFunc int HFB_GetInitialFrames(
  458. HFB_STREAM_HANDLE videoStream, /* handle to video stream */
  459. HFB_STREAM_HANDLE audioStream /* handle to audio stream */
  460. );
  461. /*@
  462. @Name HFB_GetSamplesPerFrame
  463. @Description get the number of audio frames elapsed during a single video frame
  464. @Return value The number of audio samples from the audio stream occurring within a single frame interval of video.
  465. @*/
  466. libFunc int HFB_GetSamplesPerFrame(
  467. HFB_STREAM_HANDLE videoStream, /* handle to an HFB video stream */
  468. HFB_STREAM_HANDLE audioStream /* handle to an HFB audio stream */
  469. );
  470. /*@
  471. @Name HFB_GetFrameRates
  472. @Description get video frame rate and calculated audio skew (in audio samples)
  473. @Return value
  474. @*/
  475. libFunc void HFB_GetFrameRates(
  476. HFB_STREAM_HANDLE videoStream, /* handle to an HFB video stream */
  477. HFB_STREAM_HANDLE audioStream, /* handle to an HFB audio stream */
  478. int *ptrToIntegerFrameRate, /* pointer to receive frame rate of dominant stream. */
  479. int *ptrToEstimatedAudioSampleSkew /* pointer to number of audio samples appearing before the first video frame in file. */
  480. );
  481. /*@
  482. @Name HFB_GetDRMData
  483. @Description get the DRMX data chunk
  484. @Return value
  485. @*/
  486. libFunc int HFB_GetDRMData(
  487. HFB_FILE_HANDLE dckPtr, /* */
  488. unsigned int* pOutEncFourCC, /* */
  489. int* pOutLength, /* */
  490. unsigned char** ppOutData /* */
  491. );
  492. /*@
  493. @!Name HFB_GetStreamParentBuffer
  494. @Description functions to retrieve parent buffer and file of a given stream
  495. @Return value
  496. @*/
  497. libFunc HFB_BUFFER_HANDLE HFB_GetStreamParentBuffer(
  498. HFB_STREAM_HANDLE streamHandle /* */
  499. );
  500. /*@
  501. @!Name HFB_GetStreamParentFile
  502. @Description
  503. @Return value
  504. @*/
  505. libFunc HFB_FILE_HANDLE HFB_GetStreamParentFile(
  506. HFB_STREAM_HANDLE streamHandle /* */
  507. );
  508. /*@
  509. @!Name HFB_GetStreamParentFileHandle
  510. @Description function to retrieve parent file handle of a given stream
  511. @Return value
  512. @*/
  513. libFunc int HFB_GetStreamParentFileHandle(
  514. HFB_STREAM_HANDLE streamhandle /* */
  515. ); /* FWG 6-23-99 */
  516. /*@
  517. @Name HFB_SetMaxFrameSize
  518. @Description Tell HFB maximum frame size in bytes.
  519. ****** DO NOT GIVE WRONG NUMBER****** This might cause
  520. HFB to crash. Only used in Fly-Index mode.
  521. @Return Value T.B.D.
  522. @*/
  523. libFunc int HFB_SetMaxFrameSize(
  524. HFB_BUFFER_HANDLE Buffer, /* handle to an HFB Buffer */
  525. int maxFrameSize /* maximum frame size */
  526. ); /* FWG 7-7-99 */
  527. libFunc hfbBufferMode HFB_GetBufferMode(HFB_BUFFER_HANDLE); /* FWG 7-8-99 */
  528. /* used to precisely calculate rational frame rates
  529. for a specific stream */
  530. libFunc void HFB_GetStreamRateAndScale(
  531. HFB_STREAM_HANDLE xStream, /* stream handle */
  532. int *rate, /* rate - of rate and scale. */
  533. int *scale /* scale - of rate and scale. */
  534. );
  535. /*@
  536. @Name HFB_GetStreamFCCs
  537. @Description get stream type and handler fourCC codes,
  538. @Return Value returns type (not handler)
  539. @*/
  540. libFunc unsigned int HFB_GetStreamFCCs(
  541. HFB_STREAM_HANDLE xStream, /* handle to compressed stream */
  542. unsigned int *type, /* pointer to stream type */
  543. unsigned int *handler /* pointer to fourCC code */
  544. );
  545. /*@
  546. @Name HFB_NextKeyFrame
  547. @Description returns the index of the next keyframe, looking forward from StartChunk.
  548. byteRate is the projected byterate up to that keyframe.
  549. @Return Value returns the index of the next keyframe
  550. @*/
  551. int HFB_NextKeyFrame(
  552. HFB_STREAM_HANDLE sPtr, /* stream handle */
  553. int StartChunk, /* look forward from here. */
  554. int *byteRate /* */
  555. );
  556. /*
  557. @Name HFB_isVideoKeyFrame
  558. @Description checks if a video frame is a key frame (in logarithmic time)
  559. @Return Value returns 1 if key frame, 0 if not, -1 on error
  560. @Note: only works for the first video stream*/
  561. int HFB_isVideoKeyFrame(
  562. HFB_BUFFER_HANDLE dckPtr, /* buffer handle */
  563. int frameNum /* video frame to check */
  564. );
  565. int HFB_ProjectBitRate(HFB_STREAM_HANDLE sPtr, int StartChunk, int *numFrames );
  566. // returns the byterate for the next *numFrames , given a starting chunkIndex
  567. // numFrames is a pointer since the actual amount looked ahead may be adjusted
  568. // as you get to the end of the stream
  569. /* Determine the stream to which we can switch that has the highest precedence */
  570. /* (defined by order in the array), but is below the ceiling specified by the caller */
  571. /* Note: We can only switch to another stream if its next frame is a keyframe. */
  572. /* Note: If no streams are below the ceiling, we will attempt to switch to the */
  573. /* lowest bitrate stream on a keyframe. */
  574. int HFB_SelectBestFitStream(
  575. HFB_STREAM_HANDLE* streamArray, // array of streams to consider
  576. int numberOfStreamsInArray, // number of streams in the array
  577. int currentStream, // array index matching currently used stream
  578. int desiredProjectionSpan, // distance in frames ahead to project
  579. int bitRateCeiling); // we're looking for a stream under this bitrate
  580. /* get streamSampleSize, <= 0 means variable */
  581. libFunc int HFB_GetStreamSampleSize(HFB_STREAM_HANDLE xStream);
  582. /*@
  583. @!Name HFB_WhatsAhead
  584. @Description
  585. @Return value
  586. @*/
  587. libFunc int HFB_WhatsAhead(
  588. HFB_STREAM_HANDLE sPtr, /* */
  589. int StartChunk, /* */
  590. int *horizon /* */
  591. );
  592. /* windows 95 dll system abstraction functions */
  593. libFunc void HFB_Setmalloc(
  594. void *(*mallocFuncPtr)(unsigned int size)
  595. );
  596. libFunc void HFB_Setcalloc(
  597. void *(*callocFuncPtr)(unsigned int size, unsigned int number)
  598. );
  599. libFunc void HFB_Setfree(
  600. void (*freeFuncPtr)(void *)
  601. );
  602. libFunc void HFB_Setopen(
  603. int (*openFuncPtr)(const char *, int,...)
  604. );
  605. libFunc void HFB_Setclose(
  606. int (*closeFuncPtr)(int)
  607. );
  608. libFunc void HFB_Setread(
  609. int (*readFuncPtr)(int,void *, unsigned int)
  610. );
  611. libFunc void HFB_Setseek(
  612. int (*seekFuncPtr)(int,int,int)
  613. );
  614. /*@
  615. @Name HFB_GetStreamArray
  616. @Description HFB_GetStreamArray
  617. will return an array of all streams in a file
  618. that are of the given type. If the given type is DUK_UNDEFINED,
  619. all streams will be included in the array, regardless of type.
  620. This function will also report back the size of the array (ie: the number
  621. of matching streams) through the numberOfStreams pointer.
  622. @Return value The array of stream handles
  623. @*/
  624. HFB_STREAM_HANDLE* HFB_GetStreamArray(
  625. HFB_FILE_HANDLE FileHandle, /* the file we will be looking in for our streams */
  626. unsigned int StreamType, /* the type of stream we are looking for */
  627. unsigned int* numberOfStreams /* a pointer to the number of matching streams */
  628. );
  629. /*@
  630. @Name HFB_ReleaseStreamArray
  631. @Description HFB_ReleaseStreamArray will deallocate an array of streams which
  632. was previously allocated by a call to HFB_GetStreamArray().
  633. @Return Value
  634. @*/
  635. void HFB_ReleaseStreamArray(
  636. HFB_STREAM_HANDLE* StreamArray, /* the array of streams we want to release */
  637. unsigned int numberOfStreams /* number of streams in the array */
  638. );
  639. /*@
  640. @Name HFB_GetLastError
  641. @Description HFB_GetLastError will return the last error that occured
  642. @Return Value 0 if successful, -1 if unsuccessful
  643. @*/
  644. int HFB_GetLastError(
  645. HFB_BUFFER_HANDLE bfHnd, /* pointer to the buffer handle */
  646. int* lastErrorCode, /* will return negative value for HFB error,
  647. positive value for SAL error */
  648. char errorString[], /* will return error string */
  649. size_t maxLen /* max size of error string */
  650. );
  651. typedef enum HFB_ERR_t {
  652. HFB_ERR_MIN = -7,
  653. HFB_ERROR_LOADING_INDEX = -6,
  654. HFB_ERROR_PARSING_FILE = -5,
  655. HFB_PARTIALREAD = -4,
  656. HFB_ENDOFSTREAM = -3,
  657. HFB_NOTREADY = -2,
  658. HFB_ERROR = -1,
  659. HFB_OK = 0
  660. } HFB_ERR;
  661. typedef struct HFB_ERR_DECODE_temp
  662. {
  663. HFB_ERR code;
  664. char* decode;
  665. } HFB_ERR_DECODE_t;
  666. #if defined(__cplusplus)
  667. }
  668. #endif
  669. #undef libFunc
  670. #endif