📄 vlm.c
字号:
Unescape (ppsz_command[i_command], ppsz_command[i_command]); i_command++; psz_cmd = psz_temp; } } /* * And then Interpret it */ if( i_command == 0 ) { p_message = vlm_MessageNew( "", NULL ); goto success; } if( !strcmp(ppsz_command[0], "new") ) { int i_type; /* Check the number of arguments */ if( i_command < 3 ) goto syntax_error; /* Get type */ if( !strcmp(ppsz_command[2], "vod") ) { i_type = VOD_TYPE; } else if( !strcmp(ppsz_command[2], "broadcast") ) { i_type = BROADCAST_TYPE; } else if( !strcmp(ppsz_command[2], "schedule") ) { i_type = SCHEDULE_TYPE; } else { p_message = vlm_MessageNew( "new", "%s: Choose between vod, " "broadcast or schedule", ppsz_command[1] ); goto error; } /* Check for forbidden media names */ if( !strcmp(ppsz_command[1], "all") || !strcmp(ppsz_command[1], "media") || !strcmp(ppsz_command[1], "schedule") ) { p_message = vlm_MessageNew( "new", "\"all\", \"media\" and " "\"schedule\" are reserved names" ); goto error; } /* Check the name is not already in use */ if( vlm_ScheduleSearch( p_vlm, ppsz_command[1] ) || vlm_MediaSearch( p_vlm, ppsz_command[1] ) ) { p_message = vlm_MessageNew( "new", "%s: Name already in use", ppsz_command[1] ); goto error; } /* Schedule */ if( i_type == SCHEDULE_TYPE ) { vlm_schedule_t *p_schedule; p_schedule = vlm_ScheduleNew( p_vlm, ppsz_command[1] ); if( !p_schedule ) { p_message = vlm_MessageNew( "new", "could not create schedule" ); goto error; } } /* Media */ else { vlm_media_t *p_media; p_media = vlm_MediaNew( p_vlm, ppsz_command[1], i_type ); if( !p_media ) { p_message = vlm_MessageNew( "new", "could not create media" ); goto error; } } if( i_command <= 3 ) { p_message = vlm_MessageNew( "new", NULL ); goto success; } /* Properties will be dealt with later on */ } else if( !strcmp(ppsz_command[0], "setup") ) { if( i_command < 2 ) goto syntax_error; /* Properties will be dealt with later on */ } else if( !strcmp(ppsz_command[0], "del") ) { vlm_media_t *p_media; vlm_schedule_t *p_schedule; if( i_command < 2 ) goto syntax_error; p_media = vlm_MediaSearch( p_vlm, ppsz_command[1] ); p_schedule = vlm_ScheduleSearch( p_vlm, ppsz_command[1] ); if( p_schedule != NULL ) { vlm_ScheduleDelete( p_vlm, p_schedule, NULL ); } else if( p_media != NULL ) { vlm_MediaDelete( p_vlm, p_media, NULL ); } else if( !strcmp(ppsz_command[1], "media") ) { while( p_vlm->i_media ) vlm_MediaDelete( p_vlm, p_vlm->media[0], NULL ); } else if( !strcmp(ppsz_command[1], "schedule") ) { while( p_vlm->i_schedule ) vlm_ScheduleDelete( p_vlm, p_vlm->schedule[0], NULL ); } else if( !strcmp(ppsz_command[1], "all") ) { while( p_vlm->i_media ) vlm_MediaDelete( p_vlm, p_vlm->media[0], NULL ); while( p_vlm->i_schedule ) vlm_ScheduleDelete( p_vlm, p_vlm->schedule[0], NULL ); } else { p_message = vlm_MessageNew( "del", "%s: media unknown", ppsz_command[1] ); goto error; } p_message = vlm_MessageNew( "del", NULL ); goto success; } else if( !strcmp(ppsz_command[0], "show") ) { vlm_media_t *p_media; vlm_schedule_t *p_schedule; if( i_command == 1 ) { p_message = vlm_Show( p_vlm, NULL, NULL, NULL ); goto success; } else if( i_command > 2 ) goto syntax_error; p_media = vlm_MediaSearch( p_vlm, ppsz_command[1] ); p_schedule = vlm_ScheduleSearch( p_vlm, ppsz_command[1] ); if( p_schedule != NULL ) { p_message = vlm_Show( p_vlm, NULL, p_schedule, NULL ); } else if( p_media != NULL ) { p_message = vlm_Show( p_vlm, p_media, NULL, NULL ); } else { p_message = vlm_Show( p_vlm, NULL, NULL, ppsz_command[1] ); } goto success; } else if( !strcmp(ppsz_command[0], "help") ) { if( i_command != 1 ) goto syntax_error; p_message = vlm_Help( p_vlm, NULL ); goto success; } else if( !strcmp(ppsz_command[0], "control") ) { vlm_media_t *p_media; if( i_command < 3 ) goto syntax_error; if( !(p_media = vlm_MediaSearch( p_vlm, ppsz_command[1] ) ) ) { p_message = vlm_MessageNew( "control", "%s: media unknown", ppsz_command[1] ); goto error; } else { char *psz_command, *psz_arg = 0, *psz_instance = 0; int i_index = 2; if( strcmp( ppsz_command[2], "play" ) && strcmp( ppsz_command[2], "stop" ) && strcmp( ppsz_command[2], "pause" ) && strcmp( ppsz_command[2], "seek" ) ) { i_index++; psz_instance = ppsz_command[2]; if( i_command < 4 ) goto syntax_error; if( strcmp( ppsz_command[3], "play" ) && strcmp( ppsz_command[3], "stop" ) && strcmp( ppsz_command[3], "pause" ) && strcmp( ppsz_command[3], "seek" ) ) goto syntax_error; } psz_command = ppsz_command[i_index]; if( i_command >= i_index + 2 ) psz_arg = ppsz_command[i_index + 1]; vlm_MediaControl( p_vlm, p_media, psz_instance, psz_command, psz_arg ); p_message = vlm_MessageNew( "control", NULL ); goto success; } } else if( !strcmp(ppsz_command[0], "save") ) { if( i_command != 2 ) goto syntax_error; if( vlm_Save( p_vlm, ppsz_command[1] ) ) { p_message = vlm_MessageNew( "save", "Unable to save to file" ); goto error; } else { p_message = vlm_MessageNew( "save", NULL ); goto success; } } else if( !strcmp(ppsz_command[0], "export" ) ) { char *psz_buf; if( i_command != 1 ) goto syntax_error; p_message = vlm_MessageNew( "export", psz_buf = Save( p_vlm ) ); free( psz_buf ); goto success; } else if( !strcmp(ppsz_command[0], "load") ) { if( i_command != 2 ) goto syntax_error; switch( vlm_Load( p_vlm, ppsz_command[1] ) ) { case 0: p_message = vlm_MessageNew( "load", NULL ); goto success; case 2: p_message = vlm_MessageNew( "load", "Read file error" ); goto error; case 3: p_message = vlm_MessageNew( "load", "Error while loading file" ); goto error; default: p_message = vlm_MessageNew( "load", "Unable to load from file" ); goto error; } } else { p_message = vlm_MessageNew( ppsz_command[0], "Unknown command" ); goto error; } /* Common code between "new" and "setup" */ if( !strcmp(ppsz_command[0], "new") || !strcmp(ppsz_command[0], "setup") ) { int i_command_start = strcmp(ppsz_command[0], "new") ? 2 : 3; vlm_media_t *p_media; vlm_schedule_t *p_schedule; if( i_command < i_command_start ) goto syntax_error; p_media = vlm_MediaSearch( p_vlm, ppsz_command[1] ); p_schedule = vlm_ScheduleSearch( p_vlm, ppsz_command[1] ); if( !p_media && !p_schedule ) { p_message = vlm_MessageNew( ppsz_command[0], "%s unknown", ppsz_command[1] ); goto error; } if( p_schedule != NULL ) { for( i = i_command_start ; i < i_command ; i++ ) { if( !strcmp( ppsz_command[i], "enabled" ) || !strcmp( ppsz_command[i], "disabled" ) ) { vlm_ScheduleSetup( p_schedule, ppsz_command[i], NULL ); } /* Beware: everything behind append is considered as * command line */ else if( !strcmp( ppsz_command[i], "append" ) ) { if( ++i >= i_command ) break; for( j = i + 1; j < i_command; j++ ) { ppsz_command[i] = realloc( ppsz_command[i], strlen(ppsz_command[i]) + strlen(ppsz_command[j]) + 1 + 1 ); strcat( ppsz_command[i], " " ); strcat( ppsz_command[i], ppsz_command[j] ); } vlm_ScheduleSetup( p_schedule, ppsz_command[i - 1], ppsz_command[i] ); break; } else { if( i + 1 >= i_command && !strcmp(ppsz_command[0], "new") ) { vlm_ScheduleDelete( p_vlm, p_schedule, NULL ); p_message = vlm_MessageNew( ppsz_command[0], "Wrong properties syntax" ); goto error; } else if( i + 1 >= i_command ) { p_message = vlm_MessageNew( ppsz_command[0], "Wrong properties syntax" ); goto error; } vlm_ScheduleSetup( p_schedule, ppsz_command[i], ppsz_command[i+1] ); i++; } } } else if( p_media != NULL ) { for( i = i_command_start ; i < i_command ; i++ ) { if( !strcmp( ppsz_command[i], "enabled" ) || !strcmp( ppsz_command[i], "disabled" ) ) { vlm_MediaSetup( p_vlm, p_media, ppsz_command[i], NULL ); } else if( i + 1 >= i_command && !strcmp( ppsz_command[i], "mux") ) { if( p_media->i_type != VOD_TYPE ) { p_message = vlm_MessageNew( ppsz_command[0], "mux only available for broadcast" ); } else { vlm_MediaSetup( p_vlm, p_media, ppsz_command[i], ppsz_command[i+1] ); i++; } } else if( !strcmp( ppsz_command[i], "loop" ) || !strcmp( ppsz_command[i], "unloop" ) ) { if( p_media->i_type != BROADCAST_TYPE ) { p_message = vlm_MessageNew( ppsz_command[0], "loop only available for broadcast" ); } else { vlm_MediaSetup( p_vlm, p_media, ppsz_command[i], NULL ); } } else { if( ( (i + 1) >= i_command ) && !strcmp(ppsz_command[0], "new") ) { vlm_MediaDelete( p_vlm, p_media, NULL ); p_message = vlm_MessageNew( ppsz_command[0], "Wrong properties syntax" ); goto error; } else if( (i + 1) >= i_command ) { p_message = vlm_MessageNew( ppsz_command[0], "Wrong properties syntax" ); goto error; } vlm_MediaSetup( p_vlm, p_media, ppsz_command[i], ppsz_command[i+1] ); i++; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -