• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 Amlogic Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _PLAYER_TYPE_H_
18 #define _PLAYER_TYPE_H_
19 
20 //#include <libavformat/avformat.h>
21 #include <stdint.h>
22 #include <stream_format.h>
23 
24 #define MSG_SIZE                    64
25 #define MAX_VIDEO_STREAMS           10
26 #define MAX_AUDIO_STREAMS           16
27 #define MAX_SUB_INTERNAL            64
28 #define MAX_SUB_EXTERNAL            24
29 #define MAX_SUB_STREAMS             (MAX_SUB_INTERNAL + MAX_SUB_EXTERNAL)
30 #define MAX_PLAYER_THREADS          32
31 
32 #define CALLBACK_INTERVAL           (300)
33 
34 //#define DEBUG_VARIABLE_DUR
35 
36 typedef enum {
37     /******************************
38     * 0x1000x:
39     * player do parse file
40     * decoder not running
41     ******************************/
42     PLAYER_INITING      = 0x10001,
43     PLAYER_TYPE_REDY  = 0x10002,
44     PLAYER_INITOK       = 0x10003,
45 
46     /******************************
47     * 0x2000x:
48     * playback status
49     * decoder is running
50     ******************************/
51     PLAYER_RUNNING      = 0x20001,
52     PLAYER_BUFFERING    = 0x20002,
53     PLAYER_PAUSE        = 0x20003,
54     PLAYER_SEARCHING    = 0x20004,
55 
56     PLAYER_SEARCHOK     = 0x20005,
57     PLAYER_START        = 0x20006,
58     PLAYER_FF_END       = 0x20007,
59     PLAYER_FB_END       = 0x20008,
60 
61     PLAYER_PLAY_NEXT    = 0x20009,
62     PLAYER_BUFFER_OK    = 0x2000a,
63     PLAYER_FOUND_SUB    = 0x2000b,
64 
65     /******************************
66     * 0x3000x:
67     * player will exit
68     ******************************/
69     PLAYER_ERR          = 0x30001, /* to Fix confliction with OHOS,  modify 'PLAYER_ERROR' as 'PLAYER_ERR' */
70     PLAYER_PLAYEND      = 0x30002,
71     PLAYER_STOPED       = 0x30003,
72     PLAYER_EXIT         = 0x30004,
73 
74     /******************************
75      * 0x4000x:
76      * divx drm
77      * decoder will exit or give
78      * a message dialog
79      * ****************************/
80     PLAYER_DIVX_AUTHORERR   =   0x40001,
81     PLAYER_DIVX_RENTAL_EXPIRED  =   0x40002,
82     PLAYER_DIVX_RENTAL_VIEW =   0x40003,
83 } player_status;
84 
85 /**
86  * This structure contains the info of streaming protocol.
87  */
88 typedef struct _tagAVStreamInfo {
89     int stream_type;
90     char * stream_lang;
91     char * stream_mime;
92     int stream_auto;
93     int stream_default;
94     int stream_forced;
95 } av_stream_info_t;
96 typedef struct {
97     int index;
98     int id;
99     int width;
100     int height;
101     int aspect_ratio_num;
102     int aspect_ratio_den;
103     int frame_rate_num;
104     int frame_rate_den;
105     int bit_rate;
106     vformat_t format;
107     int duartion;
108     unsigned int video_rotation_degree;
109 } mvideo_info_t;
110 
111 typedef enum {
112     ACOVER_NONE   = 0,
113     ACOVER_JPG    ,
114     ACOVER_PNG    ,
115 } audio_cover_type;
116 
117 typedef struct {
118     char title[512];
119     char author[512];
120     char album[512];
121     char comment[512];
122     char year[4];
123     int track;
124     char genre[32];
125     char copyright[512];
126     audio_cover_type pic;
127 } audio_tag_info;
128 
129 typedef struct {
130     int index;
131     int id;
132     int channel;
133     int sample_rate;
134     int bit_rate;
135     aformat_t aformat;
136     int duration;
137     audio_tag_info *audio_tag;
138     char language[128];
139 } maudio_info_t;
140 
141 typedef struct {
142     int index;
143     int id;
144     char internal_external; //0:internal_sub 1:external_sub
145     unsigned short width;
146     unsigned short height;
147     unsigned int sub_type;
148     char resolution;
149     long long subtitle_size;
150     char sub_language[128];
151 } msub_info_t;
152 
153 typedef struct {
154     int video_pid;
155     int audio_track_num;
156     int audio_pid[MAX_AUDIO_STREAMS]; //max audio streams is 16 per programe
157     char programe_name[64];
158 } ts_programe_detail_t;
159 
160 typedef struct {
161     int programe_num;
162     ts_programe_detail_t ts_programe_detail[MAX_VIDEO_STREAMS];
163 } ts_programe_info_t;
164 
165 typedef struct {
166     char *filename;
167     int  duration;
168     long long  file_size;
169     pfile_type type;
170     int bitrate;
171     int has_video;
172     int has_audio;
173     int has_sub;
174     int nb_streams;
175     int total_video_num;
176     int cur_video_index;
177     int total_audio_num;
178     int cur_audio_index;
179     int total_sub_num;
180     int cur_sub_index;
181     int seekable;
182     int drm_check;
183     int adif_file_flag;
184 } mstream_info_t;
185 
186 typedef struct {
187     mstream_info_t stream_info;
188     mvideo_info_t *video_info[MAX_VIDEO_STREAMS];
189     maudio_info_t *audio_info[MAX_AUDIO_STREAMS];
190     msub_info_t *sub_info[MAX_SUB_STREAMS];
191     ts_programe_info_t ts_programe_info;
192 } media_info_t;
193 
194 typedef struct player_info {
195     char *name;
196     player_status last_sta;
197     player_status status;          /*stop,pause */
198     int full_time;     /*Seconds    */
199     int full_time_ms;  /* mSeconds */
200     int current_time;  /*Seconds    */
201     int current_ms; /*ms*/
202     int last_time;
203     int error_no;
204     int64_t start_time;
205     int64_t first_time;
206     int pts_video;
207     //int pts_pcrscr;
208     unsigned int current_pts;
209     long curtime_old_time;
210     unsigned int video_error_cnt;
211     unsigned int audio_error_cnt;
212     float audio_bufferlevel; // relative value
213     float video_bufferlevel; // relative value
214     int64_t bufed_pos;
215     int bufed_time;/* Second*/
216     unsigned int drm_rental;
217     int64_t download_speed; //download speed
218     unsigned int last_pts;
219     int seek_point;
220     int seek_delay;
221 } player_info_t;
222 
223 typedef struct pid_info {
224     int num;
225     int pid[MAX_PLAYER_THREADS];
226 } pid_info_t;
227 
228 typedef struct player_file_type {
229     const char *fmt_string;
230     int video_tracks;
231     int audio_tracks;
232     int subtitle_tracks;
233     /**/
234 } player_file_type_t;
235 
236 
237 #define STATE_PRE(sta) (sta>>16)
238 #define PLAYER_THREAD_IS_INITING(sta)   (STATE_PRE(sta)==0x1)
239 #define PLAYER_THREAD_IS_RUNNING(sta)   (STATE_PRE(sta)==0x2)
240 #define PLAYER_THREAD_IS_STOPPED(sta)   (sta==PLAYER_EXIT)
241 
242 typedef int (*update_state_fun_t)(int pid, player_info_t *) ;
243 typedef int (*notify_callback)(int pid, int msg, unsigned long ext1, unsigned long ext2);
244 typedef enum {
245     PLAYER_EVENTS_PLAYER_INFO = 1,          ///<ext1=player_info*,ext2=0,same as update_statue_callback
246     PLAYER_EVENTS_STATE_CHANGED,            ///<ext1=new_state,ext2=0,
247     PLAYER_EVENTS_ERROR,                    ///<ext1=error_code,ext2=message char *
248     PLAYER_EVENTS_BUFFERING,                ///<ext1=buffered=d,d={0-100},ext2=0,
249     PLAYER_EVENTS_FILE_TYPE,                ///<ext1=player_file_type_t*,ext2=0
250     PLAYER_EVENTS_HTTP_WV,                      ///<(need use DRMExtractor),ext1=0, ext2=0
251     PLAYER_EVENTS_HWBUF_DATA_SIZE_CHANGED,      ///<(need use DRMExtractor),ext1=0, ext2=0
252     PLAYER_EVENTS_NOT_SUPPORT_SEEKABLE,     //not support seek;
253     PLAYER_EVENTS_VIDEO_SIZE_CHANGED,           ///<ext1 refers to video width,ext2 refers to video height
254     PLAYER_EVENTS_SUBTITLE_DATA,            // sub data ext1 refers to subtitledata struct
255     PLAYER_EVENTS_BLURAY_INFO,              // ext1=info id, ext2=info data
256 } player_events;
257 
258 typedef struct {
259     int vbufused;
260     int vbufsize;
261     int vdatasize;
262     int abufused;
263     int abufsize;
264     int adatasize;
265     int sbufused;
266     int sbufsize;
267     int sdatasize;
268 } hwbufstats_t;
269 
270 
271 typedef struct {
272     update_state_fun_t update_statue_callback;
273     int update_interval;
274     long callback_old_time;
275     notify_callback    notify_fn;
276 } callback_t;
277 
278 typedef struct {
279     char  *file_name;                       //file url
280     char  *headers;                         //file name's authentication information,maybe used in network streaming
281     //List  *play_list;
282     int video_index;                        //video track, no assigned, please set to -1
283     int audio_index;                        //audio track, no assigned, please set to -1
284     int sub_index;                          //subtitle track, no assigned, please set to -1
285     float t_pos;                                //start postion, use second as unit
286     int read_max_cnt;                       //read retry maxium counts, if exceed it, return error
287     int avsync_threshold;                             //for adec av sync threshold in ms
288     union {
289         struct {
290             unsigned int loop_mode: 1;      //file loop mode 0:loop 1:not loop
291             unsigned int nosound: 1;        //0:play with audio  1:play without audio
292             unsigned int novideo: 1;        //0:play with video  1:play without video
293             unsigned int hassub: 1;         //0:ignore subtitle  1:extract subtitle if have
294             unsigned int need_start: 1; /*If set need_start, we need call player_start_play to playback*/
295 #ifdef DEBUG_VARIABLE_DUR
296             unsigned int is_variable: 1;    //0:extrack duration from header 1:update duration during playback
297 #endif
298             unsigned int displast_frame : 1;//0:black out when player exit  1:keep last frame when player exit
299         };
300         int mode;                           //no use
301     };
302     callback_t callback_fn;                 //callback function
303     callback_t subdata_fn;                  // subtitle data notify function
304     void *subhd;                            // sub handle
305     int subdatasource;                      // sub data source
306     int byteiobufsize;                      //byteio buffer size used in ffmpeg
307     int loopbufsize;                        //loop buffer size used in ffmpeg
308     int enable_rw_on_pause;                 //no use
309     /*
310     data%<min && data% <max  enter buffering;
311     data% >middle exit buffering;
312     */
313     int auto_buffing_enable;                 //auto buffering switch
314     float buffing_min;                       //auto buffering low limit
315     float buffing_middle;                    //auto buffering middle limit
316     float buffing_max;                       //auto buffering high limit
317     int is_playlist;                         //no use
318     int is_type_parser;                      //is try to get file type
319     int is_livemode;                               // support timeshift for chinamobile
320     int buffing_starttime_s;            //for rest buffing_middle,buffering seconds data to start.
321     int buffing_force_delay_s;
322     int lowbuffermode_flag;
323     int lowbuffermode_limited_ms;
324     int is_ts_soft_demux;
325     int reserved [56];                  //reserved  for furthur used,some one add more ,can del reserved num
326     int SessionID;
327     int t_duration_ms;                  //duration parsed from url
328 } play_control_t;
329 
330 #define BLURAY_STREAM_PATH          1
331 #define BLURAY_STREAM_TYPE_VIDEO    'V'
332 #define BLURAY_STREAM_TYPE_AUDIO    'A'
333 #define BLURAY_STREAM_TYPE_SUB      'S'
334 
335 typedef char LANG[4];
336 typedef struct bluray_stream_info_s {
337     uint8_t type;
338     LANG lang;
339 } bluray_stream_info_t;
340 
341 typedef struct bluray_chapter_info_s {
342     uint32_t start;
343     uint32_t duration;
344 } bluray_chapter_info_t;
345 
346 typedef struct bluray_info {
347     int info;
348     char *stream_path;
349     int stream_info_num;
350     bluray_stream_info_t *stream_info;
351     int chapter_num;
352     bluray_chapter_info_t *chapter_info;
353 } bluray_info_t;
354 
355 #endif
356