mtv_comm.h
12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2007
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* mtv_comm.h
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
*
*
* removed!
* removed!
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef _MTV_COMM_H
#define _MTV_COMM_H
#ifndef _MED_GLOBAL_H
#include "med_global.h"
#endif
#ifndef _MTV_ERROR_H
#include "mtv_error.h"
#endif
#ifndef _MTV_CUSTOM_H
#include "mtv_custom.h"
#endif
#include "app_ltlcom.h"
#include "kal_public_api.h"
#include "kal_general_types.h"
#include "stack_config.h"
#include "mpl_common.h"
/* common constants */
#define MTV_CONTROL_MOD MOD_MED
#define MTV_TRANSPORT_MOD MOD_MED
#if defined(__MED_MTV_MOD__)
#define MTV_BACKGROUND_MOD MOD_MTV
#else
/* ATV did not have background mod */
#define MTV_BACKGROUND_MOD MOD_MED
#endif
#define MTV_ASYNC_IO_MOD MOD_MED_V
#define MTV_ESG_MOD MOD_ESG
#define MTV_SETTING_PATH L"z:\\@mtv\\"
/* helper macros */
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#endif
#ifndef UNUSED
#define UNUSED(p) ((void)(p))
#endif
#define OFFSET_OF(s,m) ((int)&(((s*)0)->m))
#define PTHIS(p, parent, member) (parent*)(((int)p) - OFFSET_OF(parent,member))
#define TS_PACKET_BYTES 188
#define LEN_ADTS_HEADER 7
#define ENDIAN_FLIP(v) ( ((v) << 24) + (((v) & 0x0000ff00) << 8) + (((v) & 0x00ff0000) >> 8) + (((v) & 0xff000000) >> 24) )
#define MAKE_FOURCC(a,b,c,d) (((kal_uint32)a)|(((kal_uint32)b)<<8)|(((kal_uint32)c)<<16)|(((kal_uint32)d)<<24))
#define FOURCC_CHARS(fcc) *((char*)&fcc), *(((char*)&fcc) + 1), *(((char*)&fcc) + 2), *(((char*)&fcc) + 3)
#define CONSTRUCT_LOCAL_PARAM(st, name) \
st* name = (st*) construct_local_para(sizeof(st), TD_CTRL)
/* debugging support */
#define NOT_REACHED(msg) ASSERT(0)
#define NOT_IMPLEMENTED(msg) ASSERT(0)
#define SHOULD_NOT_HAPPEN(msg) ASSERT(0)
//#define _MTV_SLA_LOGGING
#if defined(_MTV_SLA_LOGGING) && defined(__MTK_TARGET__)
#define SLA_BEGIN(job) SLA_CustomLogging(job, SA_start)
#define SLA_END(job) SLA_CustomLogging(job, SA_stop)
#define SLA_LABEL(job) SLA_CustomLogging(job, SA_label)
#else
#define SLA_BEGIN(job) do {} while (0)
#define SLA_END(job) do {} while (0)
#define SLA_LABEL(job) do {} while (0)
#endif
//#define _MTV_DEBUG
#if defined(_MTV_DEBUG)
#define mtv_prompt_trace kal_prompt_trace
#else
#define mtv_prompt_trace 1 ? (void) 0 : kal_prompt_trace
#endif
//#define _MTV_ZAPPING_DEBUG
#if defined(_MTV_ZAPPING_DEBUG)
#define mtv_zapping_trace kal_prompt_trace
#else
#define mtv_zapping_trace 1 ? (void) 0 : kal_prompt_trace
#endif
#define mtv_error_from_fs(fs_error) (fs_error < 0 ? (MTV_IO_E_BASE + (fs_error)) : MTV_S_OK)
#define MTV_TRACE_TIME(msg) mtv_prompt_trace(MOD_MED, "[MTV][TIMING]" msg)
/* common structures */
/**
* Flags that can be tagged on a packet.
*/
typedef enum
{
MTV_PACKET_FROM_CL_TDMB_DEMUX = 0x0001, /**< this packet is from CyberLink's demux */
MTV_PACKET_WITH_ADTS_HEADER = 0X0002, /**< this packet contains ADTS header */
MTV_PACKET_WITH_H264_START_CODE = 0X0004, /**< this packet contains H.264 start code */
MTV_PACKET_WITH_RANDOM_ACCESS_POINT = 0x0008, /**< this packet contains random access point of elementary stream */
MTV_PACKET_IS_CONCEALMENT = 0x0010, /**< this packet is an audio/video concealment */
MTV_PACKET_AGGREGATION = 0x0020, /**< this packet contains multiple parts which are prefixed by 16-bit uint size information */
MTV_PACKET_RECEIVER_SHOULD_FREE = 0x0040, /**< indicates that the receiver of this packet should free the buffer */
MTV_PACKET_IS_LAST_PACKET = 0x0080,
MTV_PACKET_WITH_FEC = 0x0100
} mtv_packet_flag_t;
/**
* Generic data packet that is used to pass any data with timestamp.
*/
typedef struct
{
kal_uint8* data; /**< data pointer */
kal_uint32 size; /**< data size in bytes */
kal_uint32 timestamp; /**< the timestamp */
kal_uint32 flags; /**< flags to indicate some special packets. @see mtv_packet_flag_t */
} mtv_packet_t;
/**
* Frequency band.
*/
typedef enum
{
MTV_FREQ_INVALID_BAND,
MTV_FREQ_KOREA_BAND,
MTV_FREQ_BAND_III,
MTV_FREQ_L_BAND,
MTV_FREQ_CANADA_BAND,
MTV_FREQ_CHINESE_BAND,
MTV_FREQ_BAND_II,
MTV_FREQ_BAND_IF,
/* from Analog TV */
MTV_FREQ_ATV_BEGIN,
MTV_FREQ_AFGHANISTAN = MTV_FREQ_ATV_BEGIN,
MTV_FREQ_ARGENTINA,
MTV_FREQ_AUSTRALIA,
MTV_FREQ_BRAZIL,
MTV_FREQ_BURMA,
MTV_FREQ_CAMBODIA,
MTV_FREQ_CANADA,
MTV_FREQ_CHILE,
MTV_FREQ_CHINA,
MTV_FREQ_CHINA_HONGKONG,
MTV_FREQ_CHINA_SHENZHEN,
MTV_FREQ_EUROPE_EASTERN,
MTV_FREQ_EUROPE_WESTERN,
MTV_FREQ_FRANCE,
MTV_FREQ_FRENCH_COLONIE,
MTV_FREQ_INDIA,
MTV_FREQ_INDONESIA,
MTV_FREQ_IRAN,
MTV_FREQ_ITALY,
MTV_FREQ_JAPAN,
MTV_FREQ_KOREA,
MTV_FREQ_LAOS,
MTV_FREQ_MALAYSIA,
MTV_FREQ_MEXICO,
MTV_FREQ_NEWZEALAND,
MTV_FREQ_PAKISTAN,
MTV_FREQ_PARAGUAY,
MTV_FREQ_PHILIPPINES,
MTV_FREQ_PORTUGAL,
MTV_FREQ_RUSSIA,
MTV_FREQ_SINGAPORE,
MTV_FREQ_SOUTHAFRICA,
MTV_FREQ_SPAIN,
MTV_FREQ_TAIWAN,
MTV_FREQ_THAILAND,
MTV_FREQ_TURKEY,
MTV_FREQ_UNITED_ARAB_EMIRATES,
MTV_FREQ_UNITED_KINGDOM,
MTV_FREQ_USA,
MTV_FREQ_URUGUAY,
MTV_FREQ_VENEZUELA,
MTV_FREQ_VIETNAM,
MTV_FREQ_IRELAND,
MTV_FREQ_MOROCCO,
MTV_FREQ_ATV_END = MTV_FREQ_MOROCCO,
MTV_FREQ_ANY_BAND /**< a special value to indicate any supported band */
} mtv_freq_band_t;
/* utility functions */
extern kal_wchar* mtv_filename_dup(const kal_wchar* from);
extern kal_wchar* mtv_generate_new_filename(const kal_wchar* dir, const kal_wchar* basename, const kal_wchar* extname);
extern kal_wchar* mtv_str_dup(const kal_wchar* from, kal_uint32 max_len, kal_uint32 usage);
extern kal_wchar* mtv_alloc_filename(void);
typedef kal_bool (*mtv_process_file_callback)(void* param, const kal_wchar* filename);
extern kal_uint32 mtv_process_files(const kal_wchar* dir, const kal_wchar* pattern, mtv_process_file_callback process_file, void* callback_param);
extern kal_int32 mtv_get_service_dump_drive(void);
extern const kal_wchar* mtv_get_setting_dir(void);
extern kal_uint32 mtv_copy_str_with_escape_keyword(kal_wchar* str_dst, kal_wchar* str_src, const kal_wchar* invalid_chars, kal_wchar keyword);
/**
* To execute specified callback in the context of specified module.
*/
extern void mtv_call_async(module_type src_mod_id, void (*proc)(void* param), void* param);
/**
* Check whether ther is any pending MTV request messages.
*/
extern kal_bool mtv_check_pending_requests(void);
/* external memory allocation */
extern void* mtv_alloc_ext_mem_impl(kal_int32 size, kal_uint32 fourcc, char* file_p, long line_p);
extern void* mtv_alloc_ext_mem_cache_impl(kal_int32 size, kal_uint32 fourcc, char* file_p, long line_p);
#define mtv_alloc_ext_mem(size, fourcc) mtv_alloc_ext_mem_impl(size, fourcc, __FILE__, __LINE__)
#define mtv_alloc_ext_mem_cache(size, fourcc) mtv_alloc_ext_mem_cache_impl(size, fourcc, __FILE__, __LINE__)
extern void mtv_free_ext_mem_impl(void** p, char* file_p, long line_p);
#define mtv_free_ext_mem(pointer) mtv_free_ext_mem_impl(pointer, __FILE__, __LINE__)
/* timer service: to decouple MTV implementation and platform-depedent timer mechanism */
typedef void (*mtv_timer_callback_t)(void* param);
extern void mtv_start_transport_timer(kal_uint32 init_time, mtv_timer_callback_t callback, void* param);
extern void mtv_stop_transport_timer(void);
extern void mtv_start_timeshift_timer(kal_uint32 init_time, mtv_timer_callback_t callback, void* param);
extern void mtv_stop_timeshift_timer(void);
extern mtv_result_t mpl_media_error_to_mtv_result(media_error_t ret);
/* global EM switches */
extern kal_bool g_mtv_dump_service;
extern kal_bool g_mtv_show_demod_status;
extern kal_bool g_mtv_atv_sim;
extern kal_bool g_mtv_atv_default_chlist;
extern kal_uint32 g_mtv_demod_sim;
extern kal_uint32 g_mtv_fair_reception_threshold;
extern kal_bool g_mtv_dump_esg_xml_file;
extern void mtv_atv_set_channel_scan_mode(kal_bool enable);
extern kal_bool mtv_atv_get_channel_scan_mode(void);
/* CAS: */
extern kal_bool g_mtv_em_set_cat;
extern kal_bool g_mtv_mts_command;
extern kal_uint32 g_mtv_em_emm_service_id;
extern kal_uint32 g_mtv_em_ecm_data_type;
extern kal_uint32 g_mtv_em_emm_data_type;
/* MSVC-specific */
#if defined(_MSC_VER)
#pragma warning(disable:4514 4127)
#endif
#endif /* _MTV_COMM_H */