📄 avinput.c
字号:
/********************************************** * Dawn Light Player * * avinput.c * * Created by kf701 * 18:13:59 02/25/08 CST * * $Id: avinput.c 168 2008-03-21 02:50:01Z kf701 $ **********************************************/#include "avformat.h"#include "avutil.h"#include "avinput.h"#include "avoutput.h"#include "global.h"static avin_t *first_avin = NULL;static avin_t *gl_avin = NULL;#define REGISTER_AVIN(X, x) \ if(ENABLE_AVIN_##X) \ { \ extern avin_t avin_##x; \ register_avin(&avin_##x); \ }void register_avin( avin_t *in ){ avin_t **p; p = &first_avin; while ( *p != NULL ) p = &(*p)->next; *p = in; in->next = NULL;}avin_t *get_avin_by_name( const char *name ){ avin_t *p; p = first_avin; while ( p ) { if ( strcmp(name,p->name) == 0 ) return p; p = p->next; } return NULL;}void avin_register_all(void){ REGISTER_AVIN(NULL, null); REGISTER_AVIN(FILE, file); REGISTER_AVIN(HA1, ha1); REGISTER_AVIN(HA2, ha2);}queue_t *video_packet_queue = NULL;queue_t *audio_packet_queue = NULL;int av_input_init(void){ av_log(NULL, AV_LOG_INFO, "*************INIT INPUT**************\n"); video_packet_queue = dlp_queue_new(); if ( NULL == video_packet_queue) { av_log(NULL,AV_LOG_INFO,"video packet queue init ERROR\n"); dlp_exit(-1); } av_log(NULL,AV_LOG_INFO,"video packet queue init OK\n"); audio_packet_queue = dlp_queue_new(); if ( NULL == audio_packet_queue) { av_log(NULL,AV_LOG_INFO,"audio packet queue init ERROR\n"); dlp_exit(-1); } av_log(NULL,AV_LOG_INFO,"audio packet queue init OK\n"); avin_register_all(); gl_avin = get_avin_by_name(dlpctxp->avin); if ( NULL == gl_avin ) { av_log(NULL, AV_LOG_ERROR, "%s input NOT FOUND\n", dlpctxp->avin); dlp_exit(-1); } av_log(NULL, AV_LOG_INFO, "call %s avin_init now\n", gl_avin->name); if ( gl_avin->avin_init() < 0 ) { av_log(NULL, AV_LOG_ERROR, "ERROR init AV input\n"); dlp_exit(-1); } av_log(NULL, AV_LOG_INFO, "*************INIT INPUT**************\n"); return 0;}int av_input_uninit(void){ if ( video_packet_queue ) { dlp_queue_free(video_packet_queue, (free_func)av_destruct_packet); video_packet_queue = NULL; } if ( audio_packet_queue ) { dlp_queue_free(audio_packet_queue, (free_func)av_destruct_packet); audio_packet_queue = NULL; } if ( gl_avin ) { av_log(NULL, AV_LOG_INFO, "call %s avin_uninit now\n", gl_avin->name); gl_avin->avin_uninit(); } return 0;}static void *av_input_thread(void *arg){ gl_avin->avin_main(); return 0;}void create_avinput_thread(void *arg){ pthread_t threadid; if ( pthread_create(&threadid, NULL, av_input_thread, NULL) ) av_log(NULL, AV_LOG_INFO, "av input thread start error\n"); av_log(NULL, AV_LOG_INFO, "av input thread start\n");}/*----------------------------------------------------------------------------- * User Interface functions *-----------------------------------------------------------------------------*/int dlp_pause_play(void){ dlpctxp->paused = !dlpctxp->paused; if ( dlpctxp->paused ) dlp_pause_ao(); else dlp_resume_ao(); return 0;}int dlp_seek(int seek){ return gl_avin->avin_control(AVIN_CTRL_SEEK, &seek);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -