📄 mosaic_data.c
字号:
slength -= (el + 5);
APP_TRACE("all pid is 0x%x\n", component_pid);
if(el == 0)
return component_pid;
parsed_size = 0;
while(parsed_size < el)
{
if((q[0] == DVB_STREAM_IDENTIFIER_TAG) &&
(q[2] == component_tag))
{
APP_TRACE("component found 0x%x\n", component_pid);
return component_pid;
}
desc_size = q[1];
parsed_size += (desc_size + 2);
q += (desc_size + 2);
}
}
APP_TRACE("ms component missing\n");
return 0x1fff;
}
#if 0
error_t mosaic_test(void)
{
uint8_t *table;
service_t mosaic_table_service;
int32_t size, section_max_size;
uint8_t *pat_section, *pmt_section;
si_filter_t filter;
clock_t wait_time;
error_t error;
section_max_size = 1024;
mosaic_table_service.network_index = db_get_current_network_index();
si_cache_control(NIT_CACHE, SI_CACHE_STOP);
memset(filter.filter_data, 0, SI_CACHE_MAX_FILTER_SIZE);
memset(filter.filter_mask, 0, SI_CACHE_MAX_FILTER_SIZE);
filter.filter_data[0] = 0x40;
filter.filter_mask[0] = 0xf0;
si_cache_configure(NIT_CACHE, 0x10, &filter, 1);
si_cache_change_service(NIT_CACHE, &mosaic_table_service);
si_cache_control(NIT_CACHE, SI_CACHE_START);
if(si_cache_request_table(NIT_CACHE, 0x40, 0xff, &mosaic_table_service, false,
&table, &size, 10000) != SUCCESS)
{
APP_TRACE("mosaic NIT timeout\n");
return ERROR_MOSAIC_NO_SIGNAL;
}
error = ms_parse_nit (table);
si_cache_release_table(table);
if(error == ERROR_MOSAIC_NO_SIGNAL)
{
APP_TRACE("mosaic can not get valid NIT data\n");
return ERROR_MOSAIC_NO_SIGNAL;
}
mosaic_table_service.original_network_id = ms_network_data.on_id/*0x4080*/;
mosaic_table_service.transport_stream_id = ms_network_data.ts_id/*0x000A*/;
mosaic_table_service.service_id = ms_network_data.service_id/*0x29*/;
ss_connect_service(&mosaic_table_service);
wait_time = time_plus(time_now(), /*102390*/ST_GetClocksPerSecond()*5);
error = semaphore_wait_timeout(connect_ok, &wait_time);
if(error == -1)
{
APP_TRACE("mosaic service can not be connected\n");
return ERROR_MOSAIC_NO_SIGNAL;
}
APP_TRACE("connected\n");
/*parse the PAT to get the mosaic table PMT*/
pat_section = app_mem_allocate ( section_max_size );
if ( pat_section == NULL )
{
APP_TRACE("mosaic PAT empty\n");
return ERROR_MOSAIC_NO_SIGNAL;
}
if(si_cache_get_table(DVB_PAT, &mosaic_table_service,
pat_section, section_max_size ,&size) != SUCCESS)
{
APP_TRACE("mosaic can not get valid PAT data\n");
return ERROR_MOSAIC_NO_SIGNAL;
}
error = ms_parse_pat (pat_section);
app_mem_deallocate( pat_section );
APP_TRACE("***mosaic PMT PID is [%d]\n",ms_network_data.mosaic_pmt_pid);
/*parse the mosaic PMT to get the pid of the mosaic table*/
si_cache_control(PMT_CACHE, SI_CACHE_STOP);
memset(filter.filter_data, 0, SI_CACHE_MAX_FILTER_SIZE);
memset(filter.filter_mask, 0, SI_CACHE_MAX_FILTER_SIZE);
filter.filter_data[0] = 0x02;
filter.filter_mask[0] = 0xf0;
si_cache_configure(PMT_CACHE, ms_network_data.mosaic_pmt_pid, &filter, 1);
si_cache_change_service(PMT_CACHE, &mosaic_table_service);
si_cache_control(PMT_CACHE, SI_CACHE_START);
if(si_cache_request_table(PMT_CACHE, 0x02, 0xff, &mosaic_table_service, false,
&pmt_section, &size, 10000) != SUCCESS)
{
APP_TRACE("mosaic PMT timeout\n");
return ERROR_MOSAIC_NO_SIGNAL;
}
error = ms_parse_pmt(pmt_section);
si_cache_release_table(pmt_section);
APP_TRACE("***mosaic table PID is [%d]\n",ms_network_data.mosaic_table_pid);
/*receive the mosaic table and parse the data*/
table = receive_mosaic_table(&mosaic_table_service,
ms_network_data.mosaic_table_pid/*0xD2*/,
0xB4,
&size);
if(table != NULL)
{
main_parse_mosaic ( table, size);
si_cache_release_table(table);
}
return SUCCESS;
}
#endif
char* ms_parse_sdt_name(uint8_t *ms_sdt_section,
int16_t sdt_max_size,
service_t service)
{
int16_t ts_id, service_id, section_length, descriptor_loop_length;
int16_t last_section_number;
int8_t descriptor_length, service_provider_length, service_name_length;
static char svc_name[64];
language_t language;
language = sys_get_current_language();
section_length = ((ms_sdt_section[1]& 0x0F)<<8) | ms_sdt_section[2];
ts_id = (ms_sdt_section[3]<<8) | ms_sdt_section[4];
last_section_number = ms_sdt_section[7];
ms_sdt_section += 11;
/*the constant '4' is the CRC*/
section_length -= (11 + 4);
while(section_length > 0)
{
service_id = (ms_sdt_section[0]<<8) | ms_sdt_section[1];
APP_TRACE("\n mosaic current cell service_id [%d]",service_id);
descriptor_loop_length = ((ms_sdt_section[3]& 0x0F)<<8) | ms_sdt_section[4];
/*the constant '5' is the bytes num before the des-loop*/
section_length -= (descriptor_loop_length + 5);
if(service.service_id == service_id)
{
ms_sdt_section += 5;
if(language == UNRECOGNIZED_LANGUAGE)
{
APP_TRACE("\n mosaic unrecognized_language service name \n");
return NULL;
}
else if(language == CHINESE_LANGUAGE)
{
while(descriptor_loop_length > 0)
{
descriptor_length = ms_sdt_section[1];
switch(ms_sdt_section[0])
{
case SERVICE_DES: /*0x48*/
service_provider_length = ms_sdt_section[3];
service_name_length = ms_sdt_section[4 + service_provider_length];
memcpy(svc_name, (ms_sdt_section + 5 + service_provider_length), service_name_length);
svc_name[service_name_length] = '\0';
APP_TRACE("\n this cell link service name is [%s]", svc_name);
break;
default:
break;
}
ms_sdt_section += (descriptor_length + 2);
descriptor_loop_length -= (descriptor_length + 2);
}/*end of the while-loop*/
}
else if(language == ENGLISH_LANGUAGE)/*now using English*/
{
while(descriptor_loop_length > 0)
{
descriptor_length = ms_sdt_section[1];
switch(ms_sdt_section[0])
{
case MULTILINGUAL_SERVICE_NAME_DES: /*0x5D*/
ms_sdt_section += 2;
while(descriptor_length > 0)
{
service_provider_length = ms_sdt_section[3];
service_name_length = ms_sdt_section[4 + service_provider_length];
/*check the ISO_639_language_code*/
language = sys_get_language_id((char *)(ms_sdt_section));
if(language == ENGLISH_LANGUAGE)
{
memcpy(svc_name, ms_sdt_section + 5 + service_provider_length, service_name_length);
svc_name[service_name_length] = '\0';
APP_TRACE("\n this cell link service name is [%s]", svc_name);
break;
}
descriptor_length -= (5 + service_provider_length + service_name_length);
ms_sdt_section += (5 + service_provider_length + service_name_length);
}
break;
default:
break;
}
ms_sdt_section += (descriptor_length + 2);
descriptor_loop_length -= (descriptor_length + 2);
}/*end of the while-loop*/
}
}
else
{
ms_sdt_section += (descriptor_loop_length + 5);
}
}/*end of the while-loop*/
return svc_name;
}
error_t mosaic_test(void)
{
service_t mosaic_table_service;
app_linkage_t ms_linkage_data;
uint8_t *table;
int32_t size;
error_t error;
error = ss_connect_application(DVB_MOSAIC_SERVICE_TYPE);
if((error != SUCCESS) && (error != ERROR_SYS_TIMEOUT))
{
return ERROR_MOSAIC_NO_SIGNAL;
}
error = reg_read(REG_MOSAIC_SERVICE_KEY, &ms_linkage_data);
mosaic_table_service.network_index = ms_linkage_data.network_index;
mosaic_table_service.original_network_id = ms_linkage_data.original_network_id;
mosaic_table_service.transport_stream_id = ms_linkage_data.transport_stream_id;
mosaic_table_service.service_id = ms_linkage_data.service_id;
/*ms_network_data.network_index = ms_linkage_data.network_index;*/
ms_network_data.on_id = ms_linkage_data.original_network_id;
ms_network_data.ts_id = ms_linkage_data.transport_stream_id;
ms_network_data.service_id = ms_linkage_data.service_id;
/*receive the mosaic table and parse the data*/
table = receive_mosaic_table(&mosaic_table_service,
ms_linkage_data.pid/*0xD2*/,
0xB4,
&size);
if(table != NULL)
{
main_parse_mosaic ( table, size);
si_cache_release_table(table);
}
else
return ERROR_MOSAIC_NO_SIGNAL;
return SUCCESS;
}
/**add lock message box**/
error_t ms_locked_window_pre_process_handler(ui_window_t *window, void *context)
{
app_message_t *msg = (app_message_t *)context;
if(msg->event == EV_SYS_KEYBOARD)
{
switch(msg->wparam)
{
case VK_FP_MENU:
case VK_EXIT:
window->return_value = ERROR_DTV_PROG_LOCKED;
window->flags &= (~UI_WINDOW_RUNNING);
break;
case VK_FP_OK:
case VK_OK:
break;
case VK_RIGHT:
break;
default:
return ERROR_UI_MESSAGE_NOT_HANDLED;
}
return ERROR_UI_MESSAGE_HANDLED;
}
else
return ERROR_UI_MESSAGE_NOT_HANDLED;
}
error_t ms_locked_window_post_process_handler(ui_window_t *window, void *context)
{
ui_control_t *pin_control;
ui_pinbox_t *pinbox;
char reg_pin[REG_PIN_LENGTH + 1];
pin_control = window->focused_control;
pinbox = pin_control->data;
if(pinbox->ui_num_length == REG_PIN_LENGTH)
{
memset(reg_pin, 0, REG_PIN_LENGTH + 1);
if(reg_read(REG_PIN_KEY, reg_pin) == SUCCESS)
{
if(pinbox->ui_number == atoi(reg_pin))
{
/*if(ss_send_pin(reg_pin) == SUCCESS)*/
window->return_value = ERROR_DTV_PROG_UNLOCKED;
}
else
window->return_value = ERROR_DTV_ERROR_PASSWARD;
window->flags &= (~UI_WINDOW_RUNNING);
return ERROR_UI_MESSAGE_HANDLED;
}
}
return ERROR_UI_MESSAGE_NOT_HANDLED;
}
uint32_t ms_locked_message(void)
{
return ui_message_box( MESSAGEBOX_POS_X, MESSAGEBOX_POS_Y, UI_IDCANCEL,
UI_BLACK_COLOR, g_menu_small_panel_id, RES_PICTURE_PROMPT_BG_ID,
res_string(RES_STRING_PIN_AGAIN),
TIMER_ONCE, *TIMEOUT_INFINITY);
}
error_t ms_locked_window(void)
{
ui_window_t *locked_window;
ui_rect_t window_rect, bmp_rect;
char *pin_text;
error_t window_err;
ui_rect_t label_rect;
ui_rect_t label_exit_rect;
ui_rect_t pinbox_rect;
ui_control_t *pinbox_control;
ui_pinbox_t *pinbox;
hitune_ui_bitmap_t *bmp = NULL, *button_exit_bmp = NULL;
hitune_ui_bitmap_t *background_p;
ST_ErrorCode_t error;
int8_t vertical_distance = 0;
pin_text = " ";
window_rect.x = MESSAGEBOX_POS_X;
window_rect.y = MESSAGEBOX_POS_Y;
window_rect.w = MESSAGEBOX_WIDTH;
window_rect.h = MESSAGEBOX_HEIGHT;
bmp_rect = window_rect;
/*get the background data*/
background_p = hitune_ui_get_background(window_rect.x, window_rect.y, window_rect.w, window_rect.h);
locked_window = ui_window_create(UI_MAIN_MENU_WINDOW, window_rect);
if(locked_window == NULL)
{
DBG_TRACE("[DTV] locked window creat failure\n");
return ERROR_UI_CREATE_WINDOW;
}
locked_window->pre_process = ms_locked_window_pre_process_handler;
locked_window->post_process = ms_locked_window_post_process_handler;
bmp = hitune_ui_bitmap_create(RES_PICTURE_PROMPT_BG_ID);
if(background_p != NULL)
hitune_ui_bitmap_display_without_margin(bmp_rect.x, bmp_rect.y, bmp, background_p);
label_rect.w = 160;
label_rect.h = GLOBAL_FONT_WIDTH;
pinbox_rect.w = 120;
pinbox_rect.h = GLOBAL_FONT_WIDTH;
label_exit_rect.w = UI_BTN_WIDTH;
label_exit_rect.h = GLOBAL_FONT_WIDTH;
vertical_distance = ((MESSAGEBOX_HEIGHT)-(label_rect.h+10) - (pinbox_rect.h+24) - label_exit_rect.h)/2;
label_rect.x = bmp_rect.x +(bmp_rect.w -label_rect.w)/2;
label_rect.y = bmp_rect.y+vertical_distance;
hitune_ui_font_draw_text(hitune_ui_draw_get_context(),
res_string(RES_STRING_MENU_PIN_INPUT),
strlen(res_string(RES_STRING_MENU_PIN_INPUT)),
label_rect.x,
label_rect.y,
ui_black_color.Value.PaletteEntry,
hitune_ui_draw_get_font(),
2);
pinbox_rect.x = bmp_rect.x + (bmp_rect.w - pinbox_rect.w)/2;
pinbox_rect.y = label_rect.y+(label_rect.h+10);
pinbox_control = ui_pinbox_create( pinbox_rect, " ", 4,
g_pinbox_fc_id, g_pinbox_bc_id,
g_pinbox_focus_fc_id,g_pinbox_focus_bc_id);
pinbox = pinbox_control->data;
ui_window_add_control(locked_window,pinbox_control);
locked_window->focused_control = pinbox_control;
label_exit_rect.x = bmp_rect.x+(bmp_rect.w-label_exit_rect.w)/2;
label_exit_rect.y = pinbox_rect.y+pinbox_rect.h+24;
/*draw the ok and exit button*/
button_exit_bmp = hitune_ui_bitmap_create(RES_PICTURE_BTN_BG_ID);
ui_bitmap_label_display(label_exit_rect.x, label_exit_rect.y, UI_BTN_WIDTH, UI_BTN_HEIGHT, button_exit_bmp, "退出", g_menu_statusbar_bc_id);
window_err = ui_window_run(locked_window);
if(background_p != NULL)
{
hitune_ui_recover_background(background_p, window_rect.x, window_rect.y);
background_p = NULL;
}
ui_window_delete(locked_window);
if(button_exit_bmp != NULL)
hitune_ui_bitmap_delete(button_exit_bmp);
hitune_ui_bitmap_delete(bmp);
return window_err;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -