tv.c

来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 1,059 行 · 第 1/3 页

C
1,059
字号
	    case AF_FORMAT_MPEG2:	    case AF_FORMAT_AC3:	    default:		mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnsupportedAudioType,		    af_fmt2str(audio_format, buf, 128), audio_format);		goto no_audio;	}		sh_audio = new_sh_audio(demuxer, 0);	funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,                    &sh_audio->samplerate);	funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE,                    &sh_audio->samplesize);	funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,                    &sh_audio->channels);	sh_audio->format = sh_audio_format;	sh_audio->sample_format = audio_format;	sh_audio->i_bps = sh_audio->o_bps =	    sh_audio->samplerate * sh_audio->samplesize * 	    sh_audio->channels;	// emulate WF for win32 codecs:	sh_audio->wf = malloc(sizeof(WAVEFORMATEX));	sh_audio->wf->wFormatTag = sh_audio->format;	sh_audio->wf->nChannels = sh_audio->channels;	sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8;	sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;	sh_audio->wf->nBlockAlign = sh_audio->samplesize * sh_audio->channels;	sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;	mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_TV_AudioFormat,          sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,          sh_audio->wf->nSamplesPerSec);	demuxer->audio->sh = sh_audio;	sh_audio->ds = demuxer->audio;	demuxer->audio->id = 0;    }no_audio:    if(!(funcs->start(tvh->priv))){	// start failed :(	tv_uninit(tvh);	return NULL;    }    /* set color eq */    tv_set_color_options(tvh, TV_COLOR_BRIGHTNESS, tvh->tv_param->brightness);    tv_set_color_options(tvh, TV_COLOR_HUE, tvh->tv_param->hue);    tv_set_color_options(tvh, TV_COLOR_SATURATION, tvh->tv_param->saturation);    tv_set_color_options(tvh, TV_COLOR_CONTRAST, tvh->tv_param->contrast);    if(tvh->tv_param->gain!=-1)        if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)            mp_msg(MSGT_TV,MSGL_WARN,"Unable to set gain control!\n");    funcs->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);    return demuxer;}static void demux_close_tv(demuxer_t *demuxer){    tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv);    if (!tvh) return;    tvh->functions->uninit(tvh->priv);    demuxer->priv=NULL;}/* utilities for mplayer (not mencoder!!) */int tv_set_color_options(tvi_handle_t *tvh, int opt, int value){    tvi_functions_t *funcs = tvh->functions;    switch(opt)    {	case TV_COLOR_BRIGHTNESS:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);	case TV_COLOR_HUE:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);	case TV_COLOR_SATURATION:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);	case TV_COLOR_CONTRAST:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);	default:	    mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnknownColorOption, opt);    }        return(TVI_CONTROL_UNKNOWN);}int tv_get_color_options(tvi_handle_t *tvh, int opt, int* value){    tvi_functions_t *funcs = tvh->functions;    switch(opt)    {	case TV_COLOR_BRIGHTNESS:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_BRIGHTNESS, value);	case TV_COLOR_HUE:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HUE, value);	case TV_COLOR_SATURATION:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_SATURATION, value);	case TV_COLOR_CONTRAST:	    return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_CONTRAST, value);	default:	    mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnknownColorOption, opt);    }        return(TVI_CONTROL_UNKNOWN);}int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq){    if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)    {	tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);	mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency,	    *freq, (float)*freq/16);    }    return(1);}int tv_set_freq(tvi_handle_t *tvh, unsigned long freq){    if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)    {//	unsigned long freq = atof(tvh->tv_param->freq)*16;        /* set freq in MHz */	tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);	tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);	mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency,	    freq, (float)freq/16);    }    tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);    return(1);}int tv_get_signal(tvi_handle_t *tvh){    int signal=0;    if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE ||        tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_SIGNAL, &signal)!=TVI_CONTROL_TRUE)        return 0;    return signal;}/***************************************************************** * \brief tune current frequency by step_interval value * \parameter step_interval increment value in 1/16 MHz * \note frequency is rounded to 1/16 MHz value * \return 1 * */int tv_step_freq(tvi_handle_t* tvh, float step_interval){    unsigned long frequency;    tvh->tv_param->scan=0;    tv_get_freq(tvh,&frequency);    frequency+=step_interval;    return tv_set_freq(tvh,frequency);}int tv_step_channel_real(tvi_handle_t *tvh, int direction){    struct CHANLIST cl;    tvh->tv_param->scan=0;    if (direction == TV_CHANNEL_LOWER)    {	if (tvh->channel-1 >= 0)	{	    strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);	    cl = tvh->chanlist_s[--tvh->channel];	    mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,		cl.name, (float)cl.freq/1000);	    tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));	}	    }    if (direction == TV_CHANNEL_HIGHER)    {	if (tvh->channel+1 < chanlists[tvh->chanlist].count)	{	    strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);	    cl = tvh->chanlist_s[++tvh->channel];	    mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,		cl.name, (float)cl.freq/1000);	    tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));	}	    }    return(1);}int tv_step_channel(tvi_handle_t *tvh, int direction) {	tvh->tv_param->scan=0;	if (tv_channel_list) {		if (direction == TV_CHANNEL_HIGHER) {			tv_channel_last = tv_channel_current;			if (tv_channel_current->next)				tv_channel_current = tv_channel_current->next;			else				tv_channel_current = tv_channel_list;				tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));				mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,			tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);		}		if (direction == TV_CHANNEL_LOWER) {			tv_channel_last = tv_channel_current;			if (tv_channel_current->prev)				tv_channel_current = tv_channel_current->prev;			else				while (tv_channel_current->next)					tv_channel_current = tv_channel_current->next;				tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));				mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,			tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);		}	} else tv_step_channel_real(tvh, direction);	return(1);}int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {	int i;	struct CHANLIST cl;        tvh->tv_param->scan=0;        strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);	for (i = 0; i < chanlists[tvh->chanlist].count; i++)	{	    cl = tvh->chanlist_s[i];//	    printf("count%d: name: %s, freq: %d\n",//		i, cl.name, cl.freq);	    if (!strcasecmp(cl.name, channel))	    {		tvh->channel = i;		mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,		    cl.name, (float)cl.freq/1000);		tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));		break;	    }	}	return(1);}int tv_set_channel(tvi_handle_t *tvh, char *channel) {	int i, channel_int;	tvh->tv_param->scan=0;	if (tv_channel_list) {		tv_channel_last = tv_channel_current;		channel_int = atoi(channel);		tv_channel_current = tv_channel_list;		for (i = 1; i < channel_int; i++)			if (tv_channel_current->next)				tv_channel_current = tv_channel_current->next;		mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,				tv_channel_current->name, (float)tv_channel_current->freq/1000);		tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));	} else tv_set_channel_real(tvh, channel);	return(1);}int tv_last_channel(tvi_handle_t *tvh) {	tvh->tv_param->scan=0;	if (tv_channel_list) {		tv_channels_t *tmp;		tmp = tv_channel_last;		tv_channel_last = tv_channel_current;		tv_channel_current = tmp;		mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,				tv_channel_current->name, (float)tv_channel_current->freq/1000);		tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));	} else {		int i;		struct CHANLIST cl;		for (i = 0; i < chanlists[tvh->chanlist].count; i++)		{		    cl = tvh->chanlist_s[i];		    if (!strcasecmp(cl.name, tv_channel_last_real))		    {			strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);			tvh->channel = i;			mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,			    cl.name, (float)cl.freq/1000);			tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));			break;		    }		}	}	return(1);}int tv_step_norm(tvi_handle_t *tvh){  tvh->norm++;  if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,                              &tvh->norm) != TVI_CONTROL_TRUE) {    tvh->norm = 0;    if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,                                &tvh->norm) != TVI_CONTROL_TRUE) {      mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);      return 0;    }  }    tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);    return(1);}int tv_step_chanlist(tvi_handle_t *tvh){    return(1);}int tv_set_norm(tvi_handle_t *tvh, char* norm){    tvh->norm = norm_from_string(tvh, norm);    mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedNorm, tvh->tv_param->norm);    if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {	mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);	return 0;    }    tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);    return(1);}demuxer_desc_t demuxer_desc_tv = {  "Tv card demuxer",  "tv",  "TV",  "Alex Beregszaszi, Charles R. Henrich",  "?",  DEMUXER_TYPE_TV,  0, // no autodetect  NULL,  demux_tv_fill_buffer,  demux_open_tv,  demux_close_tv,  NULL,  NULL};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?