static void build_flv_meta_data(obs_output_t context, uint8_t **output, size_t *size) { obs_encoder_t vencoder = obs_output_get_video_encoder(context); obs_encoder_t aencoder = obs_output_get_audio_encoder(context); video_t video = obs_encoder_video(vencoder); audio_t audio = obs_encoder_audio(aencoder); char buf[4096]; char *enc = buf; char *end = enc+sizeof(buf); enc_str(&enc, end, "onMetaData"); *enc++ = AMF_ECMA_ARRAY; enc = AMF_EncodeInt32(enc, end, 14); enc_num_val(&enc, end, "duration", 0.0); enc_num_val(&enc, end, "fileSize", 0.0); enc_num_val(&enc, end, "width", (double)video_output_width(video)); enc_num_val(&enc, end, "height", (double)video_output_height(video)); enc_str_val(&enc, end, "videocodecid", "avc1"); enc_num_val(&enc, end, "videodatarate", encoder_bitrate(vencoder)); enc_num_val(&enc, end, "framerate", video_output_framerate(video)); enc_str_val(&enc, end, "audiocodecid", "mp4a"); enc_num_val(&enc, end, "audiodatarate", encoder_bitrate(aencoder)); enc_num_val(&enc, end, "audiosamplerate", (double)audio_output_samplerate(audio)); enc_num_val(&enc, end, "audiosamplesize", 16.0); enc_num_val(&enc, end, "audiochannels", (double)audio_output_channels(audio)); enc_bool_val(&enc, end, "stereo", audio_output_channels(audio) == 2); enc_str_val(&enc, end, "encoder", MODULE_NAME); *enc++ = 0; *enc++ = 0; *enc++ = AMF_OBJECT_END; *size = enc-buf; *output = bmemdup(buf, *size); }
// used for various testing static int rctest_main(int argc, char *argv[]) { int on; if (argc < 2) { _dprintf("test what?\n"); } else if (strcmp(argv[1], "rc_service")==0) { notify_rc(argv[2]); } else if(strcmp(argv[1], "get_phy_status")==0) { int mask; mask = atoi(argv[2]); TRACE_PT("debug for phy_status %x\n", get_phy_status(mask)); } else if(strcmp(argv[1], "get_phy_speed")==0) { int mask; mask = atoi(argv[2]); TRACE_PT("debug for phy_speed %x\n", get_phy_speed(mask)); } else if(strcmp(argv[1], "set_phy_ctrl")==0) { int mask, ctrl; mask = atoi(argv[2]); ctrl = atoi(argv[3]); TRACE_PT("debug for phy_speed %x\n", set_phy_ctrl(mask, ctrl)); } else if(strcmp(argv[1], "handle_notifications")==0) { handle_notifications(); } else if(strcmp(argv[1], "check_action")==0) { _dprintf("check: %d\n", check_action()); } else if(strcmp(argv[1], "nvramhex")==0) { int i; char *nv; nv = nvram_safe_get(argv[2]); _dprintf("nvram %s(%d): ", nv, strlen(nv)); for(i=0;i<strlen(nv);i++) { _dprintf(" %x", (unsigned char)*(nv+i)); } _dprintf("\n"); } else { on = atoi(argv[2]); _dprintf("%s %d\n", argv[1], on); if (strcmp(argv[1], "vlan") == 0) { if(on) start_vlan(); else stop_vlan(); } else if (strcmp(argv[1], "lan") == 0) { if(on) start_lan(); else stop_lan(); } else if (strcmp(argv[1], "wl") == 0) { if(on) { start_wl(); lanaccess_wl(); } } else if (strcmp(argv[1], "wan") == 0) { if(on) start_wan(); else stop_wan(); } else if (strcmp(argv[1], "wan_port") == 0) { if(on) start_wan_port(); else stop_wan_port(); } else if (strcmp(argv[1], "firewall") == 0) { //if(on) start_firewall(); //else stop_firewall(); } else if (strcmp(argv[1], "watchdog") == 0) { if(on) start_watchdog(); else stop_watchdog(); } #if ! (defined(RTCONFIG_QCA) || defined(RTCONFIG_RALINK)) else if (strcmp(argv[1], "watchdog02") == 0) { if(on) start_watchdog02(); else stop_watchdog02(); } #endif /* ! (RTCONFIG_QCA || RTCONFIG_RALINK) */ else if (strcmp(argv[1], "sw_devled") == 0) { if(on) start_sw_devled(); else stop_sw_devled(); } #ifdef RTCONFIG_FANCTRL else if (strcmp(argv[1], "phy_tempsense") == 0) { if(on) start_phy_tempsense(); else stop_phy_tempsense(); } #endif #ifdef RTCONFIG_BCMWL6 #ifdef RTCONFIG_PROXYSTA else if (strcmp(argv[1], "psta_monitor") == 0) { if(on) start_psta_monitor(); else stop_psta_monitor(); } #endif #endif #ifdef RTCONFIG_IPERF else if (strcmp(argv[1], "monitor") == 0) { if(on) start_monitor(); else stop_monitor(); } #endif else if (strcmp(argv[1], "qos") == 0) {//qos test if(on){ #ifdef RTCONFIG_RALINK if (module_loaded("hw_nat")) { modprobe_r("hw_nat"); sleep(1); #if 0 f_write_string("/proc/sys/net/ipv4/conf/default/force_igmp_version", "0", 0, 0); f_write_string("/proc/sys/net/ipv4/conf/all/force_igmp_version", "0", 0, 0); #endif } #endif add_iQosRules(get_wan_ifname(wan_primary_ifunit())); #ifdef RTCONFIG_BWDPI if(nvram_get_int("qos_type") == 1) { start_dpi_engine_service(); // force to rebuild firewall to avoid some loopback issue if (nvram_match("fw_nat_loopback", "2")) start_firewall(wan_primary_ifunit(), 0); } else #endif start_iQos(); } else { #ifdef RTCONFIG_RALINK if (nvram_get_int("hwnat") && /* TODO: consider RTCONFIG_DUALWAN case */ // !nvram_match("wan0_proto", "l2tp") && // !nvram_match("wan0_proto", "pptp") && // !(nvram_get_int("fw_pt_l2tp") || nvram_get_int("fw_pt_ipsec") && // (nvram_match("wl0_radio", "0") || nvram_get_int("wl0_mrate_x")) && // (nvram_match("wl1_radio", "0") || nvram_get_int("wl1_mrate_x")) && !module_loaded("hw_nat")) { #if 0 f_write_string("/proc/sys/net/ipv4/conf/default/force_igmp_version", "2", 0, 0); f_write_string("/proc/sys/net/ipv4/conf/all/force_igmp_version", "2", 0, 0); #endif #if defined(RTN14U) || defined(RTAC52U) || defined(RTAC51U) || defined(RTN11P) || defined(RTN300) || defined(RTN54U) || defined(RTAC1200HP) || defined(RTN56UB1) || defined(RTAC54U) || defined(RTN56UB2) if (!(!nvram_match("switch_wantag", "none")&&!nvram_match("switch_wantag", ""))) #endif { modprobe("hw_nat"); sleep(1); } } #endif #ifdef RTCONFIG_BWDPI if(nvram_get_int("qos_type") == 1){ stop_dpi_engine_service(1); } else #endif stop_iQos(); del_iQosRules(); } } #ifdef RTCONFIG_WEBDAV else if (strcmp(argv[1], "webdav") == 0) { if(on) start_webdav(); } #endif #ifdef RTCONFIG_TUNNEL else if (strcmp(argv[1], "mastiff") == 0) { if(on) start_mastiff(); } #endif else if (strcmp(argv[1], "gpiow") == 0) { if(argc>=4) set_gpio(atoi(argv[2]), atoi(argv[3])); } else if (strcmp(argv[1], "gpior") == 0) { printf("%d\n", get_gpio(atoi(argv[2]))); } else if (strcmp(argv[1], "gpiod") == 0) { if(argc>=4) gpio_dir(atoi(argv[2]), atoi(argv[3])); } else if (strcmp(argv[1], "init_switch") == 0) { init_switch(); } else if (strcmp(argv[1], "set_action") == 0) { set_action(on); } else if (strcmp(argv[1], "pwr_usb") == 0) { set_pwr_usb(atoi(argv[2])); _dprintf("done.\n"); } else if (strcmp(argv[1], "enc_chk") == 0) { unsigned char enc_buf[ENC_WORDS_LEN]; unsigned char dec_buf[DATA_WORDS_LEN + 1]; _dprintf("get enc str:[%s]\n", enc_str(argv[2], (char *) enc_buf)); _dprintf("get dec str:[%s]\n", dec_str((char *) enc_buf, (char *) dec_buf)); _dprintf("done(%d)\n", strcmp(argv[2], (const char *) dec_buf)); } #ifdef RTCONFIG_BCMFA else if (strcmp(argv[1], "fa_rev") == 0) { _dprintf("(%d) done.\n", get_fa_rev()); } else if (strcmp(argv[1], "fa_dump") == 0) { _dprintf("(%d) done.\n", get_fa_dump()); } #endif else { printf("what?\n"); } } return 0; }
static bool build_flv_meta_data(obs_output_t *context, uint8_t **output, size_t *size, size_t a_idx) { obs_encoder_t *vencoder = obs_output_get_video_encoder(context); obs_encoder_t *aencoder = obs_output_get_audio_encoder(context, a_idx); video_t *video = obs_encoder_video(vencoder); audio_t *audio = obs_encoder_audio(aencoder); char buf[4096]; char *enc = buf; char *end = enc+sizeof(buf); struct dstr encoder_name = {0}; if (a_idx > 0 && !aencoder) return false; enc_str(&enc, end, "onMetaData"); *enc++ = AMF_ECMA_ARRAY; enc = AMF_EncodeInt32(enc, end, a_idx == 0 ? 14 : 9); enc_num_val(&enc, end, "duration", 0.0); enc_num_val(&enc, end, "fileSize", 0.0); if (a_idx == 0) { enc_num_val(&enc, end, "width", (double)obs_encoder_get_width(vencoder)); enc_num_val(&enc, end, "height", (double)obs_encoder_get_height(vencoder)); enc_str_val(&enc, end, "videocodecid", "avc1"); enc_num_val(&enc, end, "videodatarate", encoder_bitrate(vencoder)); enc_num_val(&enc, end, "framerate", video_output_get_frame_rate(video)); } enc_str_val(&enc, end, "audiocodecid", "mp4a"); enc_num_val(&enc, end, "audiodatarate", encoder_bitrate(aencoder)); enc_num_val(&enc, end, "audiosamplerate", (double)obs_encoder_get_sample_rate(aencoder)); enc_num_val(&enc, end, "audiosamplesize", 16.0); enc_num_val(&enc, end, "audiochannels", (double)audio_output_get_channels(audio)); enc_bool_val(&enc, end, "stereo", audio_output_get_channels(audio) == 2); enc_bool_val(&enc, end, "2.1", audio_output_get_channels(audio) == 3); enc_bool_val(&enc, end, "3.1", audio_output_get_channels(audio) == 4); enc_bool_val(&enc, end, "4.0", audio_output_get_channels(audio) == 4); enc_bool_val(&enc, end, "4.1", audio_output_get_channels(audio) == 5); enc_bool_val(&enc, end, "5.1", audio_output_get_channels(audio) == 6); enc_bool_val(&enc, end, "7.1", audio_output_get_channels(audio) == 8); dstr_printf(&encoder_name, "%s (libobs version ", MODULE_NAME); #ifdef HAVE_OBSCONFIG_H dstr_cat(&encoder_name, OBS_VERSION); #else dstr_catf(&encoder_name, "%d.%d.%d", LIBOBS_API_MAJOR_VER, LIBOBS_API_MINOR_VER, LIBOBS_API_PATCH_VER); #endif dstr_cat(&encoder_name, ")"); enc_str_val(&enc, end, "encoder", encoder_name.array); dstr_free(&encoder_name); *enc++ = 0; *enc++ = 0; *enc++ = AMF_OBJECT_END; *size = enc-buf; *output = bmemdup(buf, *size); return true; }