runav.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. #ifndef __RUNAV_H__
  2. #define __RUNAV_H__
  3. #define LIBRUNAV_VERSION_MAJOR 1
  4. #define LIBRUNAV_VERSION_MINOR 0
  5. #define LIBRUNAV_VERSION_MICRO 0
  6. #include <stdint.h>
  7. #include "types.h"
  8. #ifdef CONFIG_USE_PROPRIETARY_MHEG5
  9. #include "aes_key.h"
  10. #endif
  11. #define RUNAV_OPTION_REWIND (1<<0)
  12. #define RUNAV_OPTION_VERBOSE (1<<1)
  13. #define RUNAV_OPTION_LOWMEM_OFF (1<<2)
  14. //#define RUNAV_OPTION_DEBUG_MODE1 (1<<3)
  15. #define RUNAV_OPTION_DIRECIO_DISABLE (1<<3)
  16. #define RUNAV_OPTION_DEBUG_MODE2 (1<<4)
  17. #define RUNAV_OPTION_DEBUG_MODE3 (1<<5)
  18. #define RUNAV_VIDEO_DISABLE (1<<6)
  19. #define RUNAV_AUDIO_DISABLE (1<<7)
  20. #define RUNAV_OPTION_RCD_FORMAT (1<<8)
  21. #define RUNAV_PVR_TIMESHIFT (1<<9)
  22. #define RUNAV_DROP_CACHE_DISABLE (1<<10)
  23. #define RUNAV_OPTION_CIPLUS (1<<11)
  24. #define RUNAV_MIRACAST (1<<12)
  25. #define RUNAV_ZMCAST (1<<13)
  26. #define RUNAV_ZICAST (1<<14)
  27. #define RUNAV_DLNA (1<<15)
  28. #define RUNAV_AIRPLAY (1<<16)
  29. #define RUNAV_DLNA_RANGEBYTE_SEEKABLE (1<<17)
  30. #define RUNAV_AIRPLAY_STREAMING (1<<18)
  31. #define REPEAT_AB_ENABLE ((avinfo.repeatAB_flags & SET_A_POINT)&&(avinfo.repeatAB_flags & SET_B_POINT))
  32. #define MAX_PROG_NAME 128
  33. #ifdef CONFIG_SUPPORT_MIRACAST
  34. #define MIRACAST_DROP_ERRORFRAME 0
  35. #define MIRACAST_DELAY_HANDLE 1
  36. #define MIRACAST_DEBUG_INFO 0
  37. #endif
  38. enum
  39. {
  40. RUNAV_STREAM_TYPE_UNKNOWN = -1,
  41. RUNAV_STREAM_TYPE_VIDEO,
  42. RUNAV_STREAM_TYPE_AUDIO,
  43. RUNAV_STREAM_TYPE_DATA,
  44. RUNAV_STREAM_TYPE_SUBTITLE,
  45. RUNAV_STREAM_TYPE_ATTACHMENT,
  46. RUNAV_STREAM_TYPE_NB,
  47. //RUNAV_EVENT_UPDATE_STREAM_INFO,
  48. };
  49. enum
  50. {
  51. RUNAV_AUDIO_FORMAL,
  52. RUNAV_AUDIO_CE,
  53. RUNAV_AUDIO_HI,
  54. RUNAV_AUDIO_VI,
  55. RUNAV_AUDIO_MIXED_VI,
  56. };
  57. typedef enum _TS_SUB_TYPE
  58. {
  59. TS_SUBTITLE_NON,
  60. TS_SUBTITLE_SUB,
  61. TS_SUBTITLE_TTX,
  62. TS_SUBTITLE_PGS
  63. }TS_SUB_TYPE;
  64. typedef struct
  65. {
  66. int subtitling_type;
  67. int composition_page_id;
  68. int ancillary_page_id;
  69. } runav_ts_sub_info_t;
  70. typedef struct
  71. {
  72. int teletext_type;
  73. int teletext_magazine_number;
  74. int teletext_page_number;
  75. } runav_tt_sub_info_t;
  76. typedef struct
  77. {
  78. TS_SUB_TYPE sub_type;
  79. union{
  80. runav_ts_sub_info_t sub;
  81. runav_tt_sub_info_t ttx;
  82. }info;
  83. }runav_sub_info;
  84. typedef struct
  85. {
  86. int track;
  87. int prog_id;
  88. int index;
  89. int id;
  90. int type;
  91. int errflags;
  92. int flags;
  93. int unsupport;
  94. int sample_rate;
  95. int channels;
  96. char lang[4];
  97. char codec_name[32];
  98. char prog_name[MAX_PROG_NAME];
  99. int pid;
  100. int has_tt_data;
  101. int component_tag;
  102. runav_sub_info sub_info;
  103. } runav_stream_t;
  104. typedef struct
  105. {
  106. char country_code[4];
  107. int rating;
  108. int64_t update_pts;
  109. } runav_rating_info_t;
  110. typedef struct
  111. {
  112. /* current program */
  113. int prog_id;
  114. int track_video;
  115. int track_audio;
  116. int track_subtitle;
  117. /* all streams */
  118. int nb_streams;
  119. int nb_sub_total; //should equal nb_dvb_sub+nb_dvb_ttx
  120. int nb_dvb_sub;
  121. int nb_dvb_ttx;
  122. runav_stream_t *streams;
  123. /*for subtitle*/
  124. void * subtitle_info_list;
  125. } runav_stream_info_t;
  126. enum
  127. {
  128. RUNAV_EVENT_EOF,
  129. RUNAV_EVENT_VIDEO_UNSUPPORT,
  130. RUNAV_EVENT_AUDIO_UNSUPPORT,
  131. RUNAV_EVENT_INPROCESS,
  132. RUNAV_EVENT_FINISH,
  133. RUNAV_EVENT_HEAD_OF_FILE,
  134. RUNAV_EVENT_AUDIO_SUPPORT,
  135. RUNAV_EVENT_UNKNOWN_FORMAT,
  136. RUNAV_EVENT_STREAM_INFO,
  137. RUNAV_EVENT_UPDATE_STREAM_INFO,
  138. RUNAV_EVENT_FILE_NOT_EXIST,
  139. RUNAV_EVENT_OOM,
  140. RUNAV_EVENT_SEEK_COMPLETE,
  141. RUNAV_EVENT_SEEK_FAIL,
  142. RUNAV_EVENT_NEXT_PROG,
  143. RUNAV_EVENT_BUFFERING_START,
  144. RUNAV_EVENT_BUFFERING_END,
  145. RUNAV_EVENT_RATING_UPDATE,
  146. RUNAV_EVENT_NO_AUDIO,
  147. RUNAV_EVENT_UPDATE_TIME,
  148. RUNAV_EVENT_RESUME_PLAY,
  149. RUNAV_EVENT_PVR_NEXT_FILE,
  150. #ifdef CONFIG_SUPPORT_DIVXDRM
  151. RUNAV_EVENT_DIVXDRM_RENTAL_EXPIRED,
  152. RUNAV_EVENT_DIVXDRM_RENTAL_VIEW,
  153. RUNAV_EVENT_DIVXDRM_NOT_AUTHORIZED,
  154. RUNAV_EVENT_DIVXDRM_WRONG_VERSION,
  155. #endif
  156. RUNAV_EVENT_RATING_UPDATE2, //without thread, use in runav_init
  157. #ifdef CONFIG_SUPPORT_DASH
  158. RUNAV_EVENT_DASH_CHANGESTREAM,
  159. #endif
  160. RUNAV_EVENT_POOR_NETWORK,
  161. RUNAV_EVENT_SET_PLAYLIST_RELOAD_TIME,
  162. //RUNAV_EVENT_SEEK_START,
  163. };
  164. enum
  165. {
  166. RUNAV_SEEK_CUR,
  167. RUNAV_SEEK_SET,
  168. RUNAV_SEEK_REPEATAB
  169. };
  170. typedef void (*event_handler_t)(int event_id, void *arg);
  171. typedef char* (*get_conti_filename_t)(int b_next_file);
  172. typedef struct
  173. {
  174. long long duration; /* seconds */
  175. char codec_video[32];
  176. char codec_audio[32];
  177. char lang_audio[4];
  178. char format[32];
  179. int width;
  180. int height;
  181. int sample_rate;
  182. int channels;
  183. int bit_rate;
  184. int frame_rate; //in x_100
  185. int nb_programs;
  186. int prog_id;
  187. int is_progressive; //only valid for mpeg12, avc and avs recently
  188. int has_tt_data;
  189. } media_info_t;
  190. #ifdef CONFIG_SUPPORT_DIVXDRM
  191. //Activation Status
  192. enum
  193. {
  194. DRMSTATUS_IsActived,
  195. DRMSTATUS_NeverRegistered,
  196. DRMSTATUS_NotActived,
  197. };
  198. typedef struct
  199. {
  200. int count;
  201. int limit;
  202. } rental_info;
  203. // Divx DRM function
  204. // return value: Activation Status
  205. int DivxDRM_GetActivationStatus(void);
  206. // parameter: DeRegistrationCode: 11 byte array
  207. // return value: 0 success, -1 failed
  208. int DivxDRM_Deactivate(char *DeRegistrationCode);
  209. // parameter: RegistrationCode: 11 byte array
  210. // return value: 0 success, -1 failed
  211. int DivxDrm_GetRegistrationCode(char *RegistrationCode);
  212. #endif
  213. /*
  214. * init operation
  215. *
  216. * @parameter: fname
  217. * @parameter: opt
  218. * @parameter: event handler
  219. * return -1 if any error
  220. */
  221. int runav_init(const char *fname, unsigned int opt, event_handler_t callback);
  222. int runav_init1(const char *fname, unsigned int opt, event_handler_t callback, get_conti_filename_t get_cont_filename);
  223. int runav_init_fpos(const char *fname, unsigned int opt, event_handler_t callback, int64_t fpos);
  224. /*
  225. * get init status
  226. */
  227. int runav_get_init_status(void);
  228. /*
  229. * exit operation
  230. */
  231. int runav_exit(void);
  232. /*
  233. * playblack operations
  234. */
  235. void runav_play(void);
  236. void runav_play_begin_settings(void);
  237. void runav_pause(void);
  238. void runav_stop(void);
  239. void runav_step(int num);
  240. void runav_step_example(int num);
  241. void runav_set_blackscreen(int enable);
  242. /*
  243. * seek operation
  244. * return -1 if any error
  245. */
  246. int runav_seek(double offset, int whence);
  247. int runav_fast_forward(int num);
  248. int runav_fast_backward(int num);
  249. int runav_audio_fast_forward(int num);
  250. int runav_audio_fast_backward(int num);
  251. unsigned int runav_TS_relative_seek(double offset, int whence);
  252. int runav_cur_fname(char* fname);
  253. void runav_set_head_pos(int64_t pos);
  254. void runav_set_filesize(int64_t size);
  255. int runav_slow_play(int num);
  256. int runav_fast_play(int num);
  257. /*
  258. * read/write option settings
  259. */
  260. unsigned int runav_getopt(void);
  261. void runav_setopt(unsigned int opt);
  262. //int64_t runav_getCurPos();
  263. int64_t runav_timeshift_set_eof(int eof_enable);
  264. void runav_timeshift_to_livedtv(unsigned char enable);
  265. void runav_set_duration(int set_duration , int max_record_time);
  266. /* Gets the current time in microseconds. */
  267. int runav_gettime(unsigned int *current_time);
  268. int runav_getCurrentTime(unsigned int *current_time);
  269. int runav_getstc(unsigned int *current_time);
  270. /* Get Info after runav_init() */
  271. void runav_getinfo(media_info_t *info);
  272. void runav_getcnt(int *cnt_vframe, int *cnt_aframe);
  273. int64_t runav_get_fpos();
  274. /* Set video/audio/subtitle stream index */
  275. int runav_stream_setidx(int type, int index);
  276. int runav_stream_setall(int vstrea_index, int astream_index, int sstream_index);
  277. void* runav_getstream(int stream_index);
  278. int runav_setidx_by_component_tag(int type, int component_tag);
  279. void runav_set_ad_enable(int enable);
  280. void runav_set_ad_index(int main_index, int ad_inedx);
  281. int runav_next_prog(int offset);
  282. int runav_prog(int prog_id);
  283. void runav_set_def_prog(int prog_id);
  284. #ifdef CONFIG_SUPPORT_DASH
  285. int runav_switch_dash_stream_idx(int type, int stream_index);
  286. #endif
  287. /* runav callback functions -- subtitle */
  288. void runav_set_monflg(int flg);
  289. enum
  290. {
  291. RUNAV_STATE_IDLE,
  292. RUNAV_STATE_PLAY,
  293. RUNAV_STATE_PAUSE,
  294. RUNAV_STATE_FF,
  295. RUNAV_STATE_FB
  296. };
  297. enum
  298. {
  299. NONE = 0,
  300. SET_A_POINT,
  301. SET_B_POINT
  302. };
  303. typedef struct
  304. {
  305. void* (*init)(const char * fname, void * stream_info);
  306. int (*exit)();
  307. int (*set_data)(int index, char *data, int size, UINT64 pts, UINT64 Audio_pts, UINT64 Video_pts,int duration, UINT64 convergence_duration);
  308. int (*subt_on)(int id, char magNo, char pageNo);
  309. int (*subt_off)();
  310. int (*change_state)(int new_state);
  311. } runav_subtitle_funs_t;
  312. typedef enum
  313. {
  314. type_none, //nothing exist?
  315. type_asf,
  316. type_ogg,
  317. type_flac,
  318. type_mp3,
  319. type_mp3_id3v2
  320. } metadata_type_e;
  321. typedef struct
  322. {
  323. UINT64 pic_offset;
  324. UINT32 pic_size;
  325. } metadata_pic_info;
  326. typedef struct
  327. {
  328. int s[100]; //second
  329. char song[100][50]; //50 isn't limited
  330. } LYRICS;
  331. typedef struct _ID3_TAG
  332. {
  333. char* data;
  334. char encodeType;
  335. }ID3_TAG, *pID3_TAG;
  336. typedef struct
  337. {
  338. metadata_type_e info_type;
  339. ID3_TAG title;
  340. ID3_TAG artist;
  341. ID3_TAG album;
  342. ID3_TAG genre;
  343. ID3_TAG year;
  344. ID3_TAG track;
  345. LYRICS *l;
  346. metadata_pic_info pic_info;
  347. } runav_metadata_info_t;
  348. extern runav_subtitle_funs_t * runav_subtitle_funs_ptr;
  349. int runav_subtitle_on(int id);
  350. int runav_subtitle_off();
  351. void runav_setfrate(int input_frate);
  352. unsigned int runav_getfrate();
  353. void runav_setbyterate_timeshift(long Byterate, int normal_play);
  354. void runav_find_audio_duration();
  355. void send_event(int event_id, void *arg);
  356. void runav_setOutputWindow(int XStart, int YStart, int XEnd, int YEnd, char FullScreen);
  357. int runav_set_repeatAB(unsigned int set_time, int flagAB);
  358. void runav_reset_repeatAB();
  359. int runav_status_repeatAB();
  360. int runav_checkNormalScreen();
  361. int runav_get_id3metadata_info(runav_metadata_info_t* pID3Info);
  362. int runav_get_id3pic_data(char* buf, UINT32 bufsize, UINT64 offset);
  363. void runav_stream_info_allocate(void);
  364. #ifdef CONFIG_USE_PROPRIETARY_MHEG5
  365. void runav_set_aes_key(aes_key_t *aes_key);
  366. #else
  367. void runav_set_aes_key(unsigned char* odd, unsigned char* even, unsigned char* civ);
  368. #endif
  369. #ifdef CONFIG_SUPPORT_MIRACAST
  370. void runav_miracast_setfrate(int frate);
  371. void runav_miracast_set_audiotype(int audio_type);
  372. void runav_set_play();
  373. unsigned long runav_is_miracast();
  374. #endif
  375. void runav_get_status(unsigned char *p_init, unsigned char *p_exit);
  376. int runav_find_first_pts(void);
  377. #ifdef CONFIG_SUPPORT_NEW_AIRPLAY
  378. //for airplay youtube
  379. void runav_locking_YT_m3u8_file(void);
  380. void runav_unlocking_YT_m3u8_file(void);
  381. #endif
  382. #endif