void service_init(struct service *sv, uint16_t port, const char *key, const char *capture, const char *playback, uint32_t bitrate, void (*handler)(enum service_event event, const uint8_t uid[20], void *args), void *args) { sv->state = STATE_IDLE; sv->state_handler = handler; sv->state_args = args; sv->epfd = epoll_create1(0); assert(sv->epfd > 0); sv->timerfd = timerfd_create(CLOCK_MONOTONIC, 0); assert(sv->timerfd > 0); service_pollfd(sv, sv->timerfd, (void(*)(void*))timer_handler, sv); const int optval = 1; const struct sockaddr_in addr = { AF_INET, htons(port) }; sv->sockfd = socket(AF_INET, SOCK_DGRAM, 0); assert(sv->sockfd > 0); int res = setsockopt(sv->sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); assert(res == 0); if(bind(sv->sockfd, (struct sockaddr*)&addr, sizeof(addr)) != 0) { ERROR("Cannot bind socket"); abort(); } service_pollfd(sv, sv->sockfd, (void(*)(void*))socket_handler, sv); route_init(sv->table); sv->crypto = (struct crypto*)((void*)sv + sizeof(struct service)); crypto_init(sv->crypto, key, sv->srcid); sv->media = (struct media*)((void*)sv + sizeof(struct service) + crypto_sizeof()); media_init(sv->media, capture, playback); sv->packet_size = bitrate / 8 / 50; INFO("Media: bitrate = %u, capture = %s, playback = %s", bitrate, capture, playback); char tmp[128]; INFO("User ID is %.40s", hexify(sv->srcid, tmp, 20)); }
void LOS_init(void) { if (media_init() == 0) { mSD_status = SD_ERR_INIT; printf("ERROR: Media init failed\n"); return; } // Attach media access functions to library if (fl_attach_media(media_read, media_write) != FAT_INIT_OK) { mSD_status = SD_ERR_ATTACH; printf("ERROR: Media attach failed\n"); return; } #ifndef __LOCAL_STORE_ACCEL_MODE__ BQ_init(&LOS_queue, LOS_write_buffer, sizeof(LOS_write_buffer)); #endif LOS_tid = registerTask(LOS_proc, 0, 0, 0xFF); #ifdef FRAM_ENABLED FRAM_WR_init(); #endif // Delete File int i = 0; while ((i = fl_remove("/file.txt")) == -1); if (!i) { //printf("ERROR: Delete file failed\n"); } }
gint main (gint argc, gchar * argv[]) { media_init(); cortrol_service_init(); server_main_loop(); return 0; }
/*============================================================================== * - T_shell() * * - the shell task entry */ void T_shell () { char usr_cmd_line[_CMD_LEN_MAX]; char *start_cmd = NULL; banner(); _shell_cmd_init(); /* i, exit ... */ yaffs_init(); /* cd, ls, pwd ... */ vi_cmd_init(); /* vi */ net_init(); tetris_cmd_init(); /* tetris */ lian_cmd_init(); /* lianliankan */ date_cmd_init(); /* show and set date */ cal_cmd_init(); /* calculator expression */ gui_init(); ios_init(); media_init(); wtd_cmd_init(); #if 0 fat_cmd_init(); /* fatls */ usb_cmd_init(); /* usb.start ... */ #endif serial_puts("\n-> "); FOREVER { _get_cmd_line(usr_cmd_line); start_cmd = _del_front_space(usr_cmd_line); /* * cmd_line have no char except blank */ if (strlen(start_cmd) == 0) { serial_puts("-> "); continue; } /* * deal with cmd_line */ if (cmd_do(start_cmd) == CMD_EXIT) { serial_puts("\nAu Revoir!\n"); break; } else { serial_puts("\n-> "); } } }
gint main (gint argc, gchar * argv[]) { ui_init(); media_init(); cortrol_service_init(); gtk_main(); media_cleanup(); cortrol_service_cleanup(); return 0; }
static void plugin_init(OhmPlugin *plugin) { OHM_DEBUG_INIT(playback); client_init(plugin); media_init(plugin); pbreq_init(plugin); sm_init(plugin); dbusif_init(plugin); dresif_init(plugin); fsif_init(plugin); timestamp_init(); }
void main() { FL_FILE *file; // Initialise media media_init(); // Initialise File IO Library fiol_init(); // Attach media access functions to library if (fiol_attach_media(media_read, media_write) != FAT_INIT_OK) { printf("ERROR: Media attach failed\n"); return; } // List root directory fiol_listdirectory("/"); // Create File file = fiol_fopen("/file.bin", "w"); if (file) { // Write some data unsigned char data[] = { 1, 2, 3, 4 }; if (fiol_fwrite(data, 1, sizeof(data), file) != sizeof(data)) printf("ERROR: Write file failed\n"); } else printf("ERROR: Create file failed\n"); // Close file fiol_fclose(file); // Delete File if (fiol_remove("/file.bin") < 0) printf("ERROR: Delete file failed\n"); // List root directory fiol_listdirectory("/"); fiol_shutdown(); }
int media_access_init(int drive) { int ret; io_floppy_timeout = 0; ret = init_fdc(drive); if( ret != ERR_NO_ERROR ) return ret; #ifdef DEBUG dbg_printf("init_fdc Done\n"); #endif ret = media_init(); if( ret == ERR_NO_ERROR ) { #ifdef DEBUG dbg_printf("media_init done\n"); #endif // Initialise File IO Library fl_init(); #ifdef DEBUG dbg_printf("fl_init done\n"); #endif /* Attach media access functions to library*/ if (fl_attach_media(media_read, media_write) != FAT_INIT_OK) { return -ERR_MEDIA_ATTACH; } #ifdef DEBUG dbg_printf("fl_attach_media done\n"); #endif return ERR_NO_ERROR; } return ret; }
//----------------------------------------------------------------------------- // fl_init: Initialise library //----------------------------------------------------------------------------- int fl_init(void) { int i; // Add all file objects to free list for (i=0;i<FATFS_MAX_OPEN_FILES;i++) { _files[i].next = _free_file_list; _free_file_list = &_files[i]; } // Initialize media //if(!_filelib_init) _filelib_init = media_init(); int ret = FAT_INIT_MEDIA_ACCESS_ERROR; if(_filelib_init) { // Attach media access functions to library if ((ret = fl_attach_media(media_read, media_write)) != FAT_INIT_OK) { #ifdef FAT_PRINT FAT_PRINT("Failed to attach media. ERROR = "); FAT_PRINT_INT8(ret); FAT_PRINT("\n"); #endif return ret; } #ifdef FAT_PRINT else FAT_PRINT("Filesystem OK.\n"); #endif } return ret; }
static void file_browser_init(struct file_browser *browser, NVGcontext *vg, struct zr_user_font *font, int width, int height) { memset(browser, 0, sizeof(*browser)); media_init(&browser->media, vg); { /* gui */ browser->font = *font; browser->memory = calloc(1, MAX_COMMAND_MEMORY); memset(&browser->input, 0, sizeof(browser->input)); zr_command_queue_init_fixed(&browser->queue, browser->memory, MAX_COMMAND_MEMORY); zr_style_default(&browser->config, ZR_DEFAULT_ALL, &browser->font); zr_window_init(&browser->window, zr_rect(0,0,width,height), 0, &browser->queue, &browser->config, &browser->input); browser->ratio_dir = 0.75; browser->ratio_sel = 0.25f; } { /* load files and sub-directory list */ const char *home = getenv("HOME"); if (!home) home = getpwuid(getuid())->pw_dir; { size_t l; strncpy(browser->home, home, MAX_PATH_LEN); l = strlen(browser->home); strcpy(browser->home + l, "/"); strcpy(browser->directory, browser->home); } { size_t l; strcpy(browser->desktop, browser->home); l = strlen(browser->desktop); strcpy(browser->desktop + l, "desktop/"); } browser->files = dir_list(browser->directory, 0, &browser->file_count); browser->directories = dir_list(browser->directory, 1, &browser->dir_count); } }
// initialize USB serial void usb_init(void) { uint8_t u; u = USBCON; if ((u & (1<<USBE)) && !(u & (1<<FRZCLK))) { media_restart(); return; } HW_CONFIG(); USB_FREEZE(); // enable USB PLL_CONFIG(); // config PLL while (!(PLLCSR & (1<<PLOCK))) ; // wait for PLL lock USB_CONFIG(); // start USB clock UDCON = 0; // enable attach resistor usb_configuration = 0; usb_suspended = 0; debug_flush_timer = 0; keyboard_report_data[0] = 0; keyboard_report_data[1] = 0; keyboard_report_data[2] = 0; keyboard_report_data[3] = 0; keyboard_report_data[4] = 0; keyboard_report_data[5] = 0; keyboard_report_data[6] = 0; keyboard_report_data[7] = 0; keyboard_protocol = 1; keyboard_idle_config = 125; keyboard_idle_count = 0; keyboard_leds = 0; ms_state = MS_STATE_IDLE; media_lock_state = 0; UDINT = 0; UDIEN = (1<<EORSTE)|(1<<SOFE); //sei(); // init() in wiring.c does this media_init(); }
/** * Showtime main */ int main(int argc, char **argv) { struct timeval tv; const char *settingspath = NULL; const char *uiargs[16]; const char *argv0 = argc > 0 ? argv[0] : "showtime"; const char *forceview = NULL; int nuiargs = 0; int can_standby = 0; int can_poweroff = 0; int r; trace_level = TRACE_INFO; gettimeofday(&tv, NULL); srand(tv.tv_usec); arch_set_default_paths(argc, argv); /* We read options ourselfs since getopt() is broken on some (nintento wii) targets */ argv++; argc--; while(argc > 0) { if(!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { printf("HTS Showtime %s\n" "Copyright (C) 2007-2010 Andreas Öman\n" "\n" "Usage: %s [options] [<url>]\n" "\n" " Options:\n" " -h, --help - This help text.\n" " -d - Enable debug output.\n" " --ffmpeglog - Print ffmpeg log messages.\n" " --with-standby - Enable system standby.\n" " --with-poweroff - Enable system power-off.\n" " -s <path> - Non-default Showtime settings path.\n" " --ui <ui> - Use specified user interface.\n" " -L <ip:host> - Send log messages to remote <ip:host>.\n" " --syslog - Send log messages to syslog.\n" #if ENABLE_STDIN " --stdin - Listen on stdin for events.\n" #endif " -v <view> - Use specific view for <url>.\n" " --cache <path> - Set path for cache [%s].\n" #if ENABLE_SERDEV " --serdev - Probe service ports for devices.\n" #endif "\n" " URL is any URL-type supported by Showtime, " "e.g., \"file:///...\"\n" "\n", htsversion_full, argv0, showtime_cache_path); exit(0); argc--; argv++; } else if(!strcmp(argv[0], "-d")) { trace_level++; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--ffmpeglog")) { ffmpeglog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--syslog")) { trace_to_syslog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--stdin")) { listen_on_stdin = 1; argc -= 1; argv += 1; continue; #if ENABLE_SERDEV } else if(!strcmp(argv[0], "--serdev")) { enable_serdev = 1; argc -= 1; argv += 1; continue; #endif } else if(!strcmp(argv[0], "--with-standby")) { can_standby = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-poweroff")) { can_poweroff = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "-s") && argc > 1) { settingspath = argv[1]; argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "--ui") && argc > 1) { if(nuiargs < 16) uiargs[nuiargs++] = argv[1]; argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "-L") && argc > 1) { showtime_logtarget = argv[1]; argc -= 2; argv += 2; continue; } else if (!strcmp(argv[0], "-v") && argc > 1) { forceview = argv[1]; argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--cache") && argc > 1) { mystrset(&showtime_cache_path, argv[1]); argc -= 2; argv += 2; #ifdef __APPLE__ /* ignore -psn argument, process serial number */ } else if(!strncmp(argv[0], "-psn", 4)) { argc -= 1; argv += 1; continue; #endif } else break; } unicode_init(); /* Initialize property tree */ prop_init(); init_global_info(); /* Initiailize logging */ trace_init(); /* Callout framework */ callout_init(); /* Notification framework */ notifications_init(); /* Architecture specific init */ arch_init(); htsmsg_store_init(); /* Try to create cache path */ if(showtime_cache_path != NULL && (r = makedirs(showtime_cache_path)) != 0) { TRACE(TRACE_ERROR, "cache", "Unable to create cache path %s -- %s", showtime_cache_path, strerror(r)); showtime_cache_path = NULL; } /* Initializte blob cache */ blobcache_init(); /* Try to create settings path */ if(showtime_settings_path != NULL && (r = makedirs(showtime_settings_path)) != 0) { TRACE(TRACE_ERROR, "settings", "Unable to create settings path %s -- %s", showtime_settings_path, strerror(r)); showtime_settings_path = NULL; } /* Initialize keyring */ keyring_init(); /* Initialize settings */ settings_init(); /* Initialize libavcodec & libavformat */ av_lockmgr_register(fflockmgr); av_log_set_callback(fflog); av_register_all(); /* Freetype keymapper */ #if ENABLE_LIBFREETYPE freetype_init(); #endif /* Global keymapper */ keymapper_init(); /* Initialize media subsystem */ media_init(); /* Service handling */ service_init(); /* Initialize backend content handlers */ backend_init(); /* Initialize navigator */ nav_init(); /* Initialize audio subsystem */ audio_init(); /* Initialize bookmarks */ bookmarks_init(); /* Initialize plugin manager and load plugins */ plugins_init(); /* Internationalization */ i18n_init(); nav_open(NAV_HOME, NULL); /* Open initial page */ if(argc > 0) nav_open(argv[0], forceview); /* Various interprocess communication stuff (D-Bus on Linux, etc) */ ipc_init(); /* Service discovery. Must be after ipc_init() (d-bus and threads, etc) */ sd_init(); /* Initialize various external APIs */ api_init(); /* HTTP server and UPNP */ #if ENABLE_HTTPSERVER http_server_init(); upnp_init(); #endif /* */ runcontrol_init(can_standby, can_poweroff); TRACE(TRACE_DEBUG, "core", "Starting UI"); /* Initialize user interfaces */ ui_start(nuiargs, uiargs, argv0); finalize(); }
/** * Bootloader main entry */ int main(void) { uint8_t boot_region = 0; /* Real boot region at this time */ #ifdef DBG_USE_USART uint8_t load_region = 0; /* Real region to put loaded data */ #endif struct regions_info info; void *app_addr = NULL; uint32_t app_size = 0; enum trigger_modes trigger; bool app_valid = false; wdt_disable(WDT); sysclk_init(); board_init(); /* First turn on the led to indicate the bootloader run. */ ioport_set_pin_dir(DBG_LED_PIN, IOPORT_DIR_OUTPUT); ioport_set_pin_level(DBG_LED_PIN, DBG_LED_PIN_ON_LEVEL); dbg_init(); dbg_print("\r\n\n----------------------\r\n"); dbg_print("%s Bootloader\r\n", BOARD_NAME); dbg_print("Boot region: %x, size %dK\r\n", BOOT0_START, BOOT_SIZE / 1024); dbg_print("App region: %x, size %dK\r\n", APP0_START, (int)APP_SIZE / 1024); dbg_print(" - Code %dK + Info %dK\r\n", (int)APP_CODE_SIZE, (int)INFO_SIZE); dbg_print("----------------------\r\n"); /* bootloader initialize */ dbg_print("bl: init ...\r\n"); trigger_init(); memory_init(); media_init(file_list, MEDIA_FILE_LIST_LEN); dbg_print("bl: init done\r\n"); boot_region = _app_boot_get(); dbg_print("bl: current boot region %d\r\n", (int)boot_region); #ifdef MEM_LOCK_BOOT_REGION dbg_print("bl: lock boot region ...\r\n"); memory_lock((void *)BOOT0_START, (void *)BOOT0_END); dbg_print("bl: lock boot region done\r\n"); #endif /* load regions information * Single flash: from last page * Dual flash (remap) : from last page of last physical flash * Dual flash (mirror): from last page of boot flash */ dbg_print("bl: read regions info ...\r\n"); region_info_read((void *)INFO_ADDR(true), &info); /* Read for boot */ app_addr = (void *)(APP_START(boot_region)); app_valid = region_check_valid(app_addr, info.length[boot_region], info.signature[boot_region]); dbg_print("bl: read regions info done\r\n"); dbg_print("bl: trigger flag %s\r\n", trigger_modes_str[info.trigger]); dbg_print("bl: region\t%8d\t%8d\r\n", 0, 1); dbg_print("bl: size\t%8d\t%8d\r\n", (int)info.length[0], (int)info.length[1]); dbg_print("bl: sign\t%8x\t%8x\r\n", (unsigned)info.signature[0], (unsigned)info.signature[1]); dbg_print("bl: boot\t %c\t %c\r\n", boot_region ? ' ' : 'Y', boot_region ? 'Y' : ' '); dbg_print("bl: App @ %d, %x - data %x ...\r\n", (int)boot_region, (unsigned)app_addr, (unsigned)*(uint32_t *)app_addr); dbg_print("bl: App valid: %c\r\n", app_valid ? 'Y' : 'N'); #ifdef DBG_USE_INFO_EDIT /* InfoEdit */ _app_info_edit(&info); #endif /* bootloader trigger check */ dbg_print("bl: trigger ...\r\n"); trigger = trigger_poll(&info); dbg_print("bl: trigger mode %s\r\n", trigger_modes_str[trigger]); if (TRIGGER_BOOT == trigger) { goto main_run_app_check; } /* Now any other trigger load file to update application directly */ #ifdef DBG_USE_LED _app_led_blink(100, 1); #endif /* Update media file information */ if (info.boot_file_name[0]) { dbg_print("bl: boot file assigned, set it\r\n"); media_set_file_name(info.boot_file_name); } main_load_app: /* load new firmware */ #ifdef DBG_USE_USART load_region = boot_region; dbg_print("bl: download @ %d ...\r\n", load_region); #endif app_size = _app_load(&info, true); if (app_size == 0) { _app_led_error(); dbg_print("bl: download fail, retry\r\n"); goto main_load_app; } else { dbg_print("bl: download done, size %d\r\n", (int)app_size); } main_run_app_check: /* Is application valid */ dbg_print("bl: check app @ %d is valid\r\n", (int)info.boot_region); app_valid = region_check_valid(app_addr, info.length[info.boot_region], info.signature[info.boot_region]); if (!app_valid) { dbg_print("bl: application is not valid\r\n"); _app_led_error(); dbg_print("bl: reload firmware\r\n"); goto main_load_app; } dbg_print("bl: application is valid, run\r\n"); /* Turn off the led before jump to the app. */ _app_led_off(DBG_LED_PIN); /* cleanup */ dbg_print("bl: cleanup ...\r\n"); media_cleanup(); trigger_cleanup(); memory_cleanup(); dbg_print("bl: cleanup done\r\n"); /* load application */ dbg_print("bl: load application ...\r\n\n"); #ifdef DBG_USE_USART delay_ms(50); /* Wait USART lines idle */ dbg_cleanup(); delay_ms(50); #endif /* run application */ _app_exec(app_addr); return (int)app_addr; }
void showtime_init(void) { int r; hts_mutex_init(&gconf.state_mutex); hts_cond_init(&gconf.state_cond, &gconf.state_mutex); gconf.exit_code = 1; unicode_init(); /* Initialize property tree */ prop_init(); init_global_info(); /* Initiailize logging */ trace_init(); /* Callout framework */ callout_init(); /* Initialize htsmsg_store() */ htsmsg_store_init(); /* Notification framework */ notifications_init(); /* Initialize settings */ settings_init(); TRACE(TRACE_DEBUG, "core", "Loading resources from %s", showtime_dataroot()); /* Try to create cache path */ if(gconf.cache_path != NULL && (r = makedirs(gconf.cache_path)) != 0) { TRACE(TRACE_ERROR, "cache", "Unable to create cache path %s -- %s", gconf.cache_path, strerror(r)); gconf.cache_path = NULL; } /* Initialize sqlite3 */ db_init(); /* Initializte blob cache */ blobcache_init(); /* Try to create settings path */ if(gconf.persistent_path != NULL && (r = makedirs(gconf.persistent_path)) != 0) { TRACE(TRACE_ERROR, "settings", "Unable to create path for persistent storage %s -- %s", gconf.persistent_path, strerror(r)); gconf.persistent_path = NULL; } /* Metadata init */ metadata_init(); metadb_init(); kvstore_init(); /* Metadata decoration init */ decoration_init(); /* Initialize keyring */ keyring_init(); #if ENABLE_LIBAV /* Initialize libavcodec & libavformat */ av_lockmgr_register(fflockmgr); av_log_set_callback(fflog); av_register_all(); TRACE(TRACE_INFO, "libav", LIBAVFORMAT_IDENT", "LIBAVCODEC_IDENT", "LIBAVUTIL_IDENT); #endif /* Freetype */ #if ENABLE_LIBFREETYPE freetype_init(); rasterizer_ft_init(); #endif #if ENABLE_GLW glw_settings_init(); #endif fontstash_init(); /* Global keymapper */ keymapper_init(); /* Initialize media subsystem */ media_init(); /* Service handling */ service_init(); /* Initialize backend content handlers */ backend_init(); /* Initialize navigator */ nav_init(); /* Initialize audio subsystem */ audio_init(); /* Initialize plugin manager */ plugins_init(gconf.devplugin); /* Start software installer thread (plugins, upgrade, etc) */ hts_thread_create_detached("swinst", swthread, NULL, THREAD_PRIO_LOW); /* Internationalization */ i18n_init(); /* Video settings */ video_settings_init(); if(gconf.load_jsfile) js_load(gconf.load_jsfile); /* Various interprocess communication stuff (D-Bus on Linux, etc) */ init_group(INIT_GROUP_IPC); /* Service discovery. Must be after ipc_init() (d-bus and threads, etc) */ if(!gconf.disable_sd) sd_init(); /* Initialize various external APIs */ init_group(INIT_GROUP_API); /* HTTP server and UPNP */ #if ENABLE_HTTPSERVER http_server_init(); if(!gconf.disable_upnp) upnp_init(); #endif runcontrol_init(); }
/************************************************* Function: logic_init Description: 逻辑初始化 Input: 无 Output: 无 Return: 无 *************************************************/ void logic_init(void) { PFULL_DEVICE_NO pDevNo = NULL; PNET_PARAM pNetParam = NULL; init_auTimer(); // 初始化定时器 init_timer(); storage_init(); // 初始化存储模块 init_list_address(); // 初始化监视列表 ScreenInit(); NetworkInit(); #ifdef _JD_MODE_ jd_logic_init(); // 如有家电模块可以不启动看门狗,家电轮巡命令可以喂狗 //#else hw_start_com_dog(); // 启动串口看门狗 #endif #ifdef _DOOR_PHONE_ init_ioctrl_callback(analog_callin_io); hw_switch_digit(); // 切换到数字通路 #endif init_keypad_probe(); // 按键侦测 alarm_logic_init(); media_init(); sys_init_hint_state(); alarm_init_gui_callback((ALARMGUI_CALLBACK)af_callback_gui, (SHOW_SYSEVENHIT)show_sys_event_hint); inter_call_ini(callrequest_state_callbak, callout_state_callbak, callin_state_callbak); monitor_ini(monitor_list_state_callbak, monitor_state_callbak); rtsp_ini(rtsp_list_state_callbak, rtsp_state_callbak); other_func_callbak_ini(); net_set_recivedata_func(SSC_INFO, msg_distribute, msg_responsion); net_set_recivedata_func(SSC_ALARM, alarm_distribute, alarm_responsion); net_set_recivedata_func(SSC_INTERPHONE, inter_distribute, inter_responsion); net_set_recivedata_func(SSC_PUBLIC, public_distribute, public_responsion); net_set_recivedata_func(SSC_VIDEOMONITORING, rtsp_distribute, rtsp_responsion); net_set_recivedata_func(SSC_IPDOORPHONE, netdoor_distribute, netdoor_responsion); #ifdef _JD_MODE_ net_set_recivedata_func(SSC_EHOME, jd_net_distribute, jd_net_responsion); #endif pDevNo = storage_get_devparam(); pNetParam = storage_get_netparam(); net_start_comm(pDevNo, pNetParam); net_send_cmd_packet(NULL, 0, INADDR_BROADCAST, NETCMD_UDP_PORT); init_reboot_timer(); // 定时重启设置 #ifdef _USE_NEW_CENTER_ logic_reg_center_ini(); // 新上位机注册保持 #endif #ifdef _NEW_SELF_IPC_ init_ipc_state(); // add by chenbh 2016-03-09 初始化家居监视列表在线状态值 #endif #ifdef _IP_MODULE_ init_ipmodule(); // IP模块绑定 保持 #endif #ifdef _RTSP_REG_KEEP_ init_rtsp_timer(); // 室内主机需要向流媒体服务器保持 #endif #ifdef _YUYUE_MODE_ init_yuyue_timer(); // 预约模块定时器 #endif // 请求时间同步 uint32 center = storage_get_center_ip(); set_nethead(G_CENTER_DEVNO, PRIRY_DEFAULT); net_direct_send(CMD_REQ_SYN_TIME, NULL, 0, center, NETCMD_UDP_PORT); // 测试校验数据是否正确 check_sysconfig_ifcorrect(); dprintf("devno: %s \n", pDevNo->DeviceNoStr); }
void main_init(void) { char errbuf[512]; hts_mutex_init(&gconf.state_mutex); hts_cond_init(&gconf.state_cond, &gconf.state_mutex); gconf.exit_code = 1; asyncio_init_early(); init_group(INIT_GROUP_NET); unicode_init(); /* Initialize property tree */ prop_init(); init_global_info(); /* Initiailize logging */ trace_init(); /* Callout framework */ callout_init(); prop_init_late(); /* Initialize htsmsg_store() */ htsmsg_store_init(); /* Notification framework */ notifications_init(); /* Initialize settings */ settings_init(); TRACE(TRACE_DEBUG, "core", "Loading resources from %s", app_dataroot()); TRACE(TRACE_DEBUG, "core", "Cache path: %s", gconf.cache_path); /* Try to create cache path */ if(gconf.cache_path != NULL && fa_makedirs(gconf.cache_path, errbuf, sizeof(errbuf))) { TRACE(TRACE_ERROR, "core", "Unable to create cache path %s -- %s", gconf.cache_path, errbuf); gconf.cache_path = NULL; } /* Initialize sqlite3 */ #if ENABLE_SQLITE db_init(); #endif /* Initializte blob cache */ blobcache_init(); TRACE(TRACE_DEBUG, "core", "Persistent path: %s", gconf.persistent_path); /* Try to create settings path */ if(gconf.persistent_path != NULL && fa_makedirs(gconf.persistent_path, errbuf, sizeof(errbuf))) { TRACE(TRACE_ERROR, "core", "Unable to create path for persistent storage %s -- %s", gconf.persistent_path, errbuf); gconf.persistent_path = NULL; } /* Per-item key/value store */ kvstore_init(); /* Metadata init */ #if ENABLE_METADATA metadata_init(); metadb_init(); decoration_init(); #endif subtitles_init(); /* Initialize keyring */ keyring_init(); #if ENABLE_LIBAV /* Initialize libavcodec & libavformat */ av_lockmgr_register(fflockmgr); av_log_set_callback(fflog); av_register_all(); TRACE(TRACE_INFO, "libav", LIBAVFORMAT_IDENT", "LIBAVCODEC_IDENT", "LIBAVUTIL_IDENT" cpuflags:0x%x", av_get_cpu_flags()); #endif init_group(INIT_GROUP_GRAPHICS); #if ENABLE_GLW glw_settings_init(); #endif /* Global keymapper */ keymapper_init(); /* Initialize media subsystem */ media_init(); /* Service handling */ service_init(); /* Initialize backend content handlers */ backend_init(); /* Initialize navigator */ nav_init(); /* Initialize audio subsystem */ audio_init(); /* Initialize plugin manager */ plugins_init(gconf.devplugins); /* Start software installer thread (plugins, upgrade, etc) */ hts_thread_create_detached("swinst", swthread, NULL, THREAD_PRIO_BGTASK); /* Internationalization */ i18n_init(); /* Video settings */ video_settings_init(); /* Various interprocess communication stuff (D-Bus on Linux, etc) */ init_group(INIT_GROUP_IPC); /* Service discovery. Must be after ipc_init() (d-bus and threads, etc) */ if(!gconf.disable_sd) sd_init(); /* Initialize various external APIs */ init_group(INIT_GROUP_API); /* Asynchronous IO (Used by HTTP server, etc) */ asyncio_start(); runcontrol_init(); TRACE(TRACE_DEBUG, "SYSTEM", "Hashed device ID: %s", gconf.device_id); if(gconf.device_type[0]) TRACE(TRACE_DEBUG, "SYSTEM", "Device type: %s", gconf.device_type); }