[Mplayer-cvslog] CVS: main/libmpdemux tv.c,1.11,1.12

Alex Beregszaszi alex at mplayer.dev.hu
Fri Nov 16 22:53:09 CET 2001


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv9908

Modified Files:
	tv.c 
Log Message:
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching

Index: tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- tv.c	16 Nov 2001 21:30:10 -0000	1.11
+++ tv.c	16 Nov 2001 21:53:07 -0000	1.12
@@ -9,6 +9,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 
 #include "config.h"
 
@@ -30,7 +31,7 @@
 
 /* some default values */
 char *tv_param_freq = NULL;
-char *tv_param_channel = "0";
+char *tv_param_channel = "26"; /* hungarian national tv channel 1 */
 char *tv_param_norm = "pal";
 char *tv_param_device = NULL;
 char *tv_param_driver = "dummy";
@@ -52,6 +53,7 @@
     int seq = tvh->seq++;
     demux_packet_t* dp;
     int len;
+    sh_video_t *sh_video = demux->video->sh;
 
     mp_dbg(MSGT_DEMUX, MSGL_DBG2, "demux_tv_fill_buffer(sequence:%d) called!\n", seq);
 
@@ -65,7 +67,7 @@
 
     dp=new_demux_packet(len);
     tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len);
-    dp->pts=seq/25.0; //(float)pts/90000.0f;
+    dp->pts=seq/sh_video->fps; //(float)pts/90000.0f;
     //dp->pos=pos;
     //dp->flags=flags;
     // append packet to DS stream:
@@ -90,97 +92,113 @@
 
 int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
 {
-}
-
-int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
-{
-    sh_video_t *sh_video = NULL;
-    sh_audio_t *sh_audio = NULL;
     tvi_functions_t *funcs = tvh->functions;
-    
+    int picture_format = 0;
+
     if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
     {
 	mp_msg(MSGT_TV, MSGL_ERR, "Error: no video input present!\n");
 	return;
     }
-    
-    sh_video = new_sh_video(demuxer, 0);
 
     if (!strcasecmp(tv_param_outfmt, "yv12"))
-	sh_video->format = IMGFMT_YV12;
+	picture_format = IMGFMT_YV12;
     else if (!strcasecmp(tv_param_outfmt, "uyvy"))
-	sh_video->format = IMGFMT_UYVY;
+	picture_format = IMGFMT_UYVY;
     else if (!strcasecmp(tv_param_outfmt, "rgb32"))
-	sh_video->format = IMGFMT_RGB32;
+	picture_format = IMGFMT_RGB32;
     else if (!strcasecmp(tv_param_outfmt, "rgb24"))
-	sh_video->format = IMGFMT_RGB24;
+	picture_format = IMGFMT_RGB24;
     else if (!strcasecmp(tv_param_outfmt, "rgb16"))
-	sh_video->format = IMGFMT_RGB16;
+	picture_format = IMGFMT_RGB16;
     else if (!strcasecmp(tv_param_outfmt, "rgb15"))
-	sh_video->format = IMGFMT_RGB15;
+	picture_format = IMGFMT_RGB15;
     else
     {
 	mp_msg(MSGT_TV, MSGL_ERR, "Unknown format given: %s\n", tv_param_outfmt);
 	mp_msg(MSGT_TV, MSGL_INFO, "Using default: Planar YV12\n");
-	sh_video->format = IMGFMT_YV12;
+	picture_format = IMGFMT_YV12;
     }
-    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &sh_video->format);
-
-    /* get IMGFMT_ */
-    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format);
-//    if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format))
-	sh_video->format = 0x0;
-
-    /* set FPS and FRAMETIME */
-    if(!sh_video->fps)
-    {
-	if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &sh_video->fps) != TVI_CONTROL_TRUE)
-	    sh_video->fps = 24.0f;
-    }
-    sh_video->frametime = 1.0f/sh_video->fps;
+    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &picture_format);
 
     /* set width */
     if (tv_param_width != -1)
     {
 	if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tv_param_width) == TVI_CONTROL_TRUE)
-	{
 	    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tv_param_width);
-	    sh_video->disp_w = tv_param_width;
-	}
 	else
 	{
 	    mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested width: %d\n", tv_param_width);
-	    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
-	    tv_param_width = sh_video->disp_w;
+	    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tv_param_width);
 	}    
     }
-    else
-	funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
 
     /* set height */
     if (tv_param_height != -1)
     {
 	if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tv_param_height) == TVI_CONTROL_TRUE)
-	{
 	    funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tv_param_height);
-	    sh_video->disp_h = tv_param_height;
-	}
 	else
 	{
 	    mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested height: %d\n", tv_param_height);
-	    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
-	    tv_param_height = sh_video->disp_h;
+	    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tv_param_height);
 	}    
     }
-    else
-	funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
+
+    /* set some params got from cmdline */
+    funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input);
+
+    /* we need to set frequency */
+    if (tv_param_freq && (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE))
+    {
+	unsigned long freq = atof(tv_param_freq)*16;
+
+        /* set freq in MHz */
+	funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
+
+	funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
+	mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n",
+	    freq, (float)freq/16);
+    }
+    
+    /* also start device! */
+    return(funcs->start(tvh->priv));	
+}
+
+int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh)
+{
+    sh_video_t *sh_video = NULL;
+    sh_audio_t *sh_audio = NULL;
+    tvi_functions_t *funcs = tvh->functions;
+    
+    sh_video = new_sh_video(demuxer, 0);
+
+    /* get IMAGE FORMAT */
+    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format);
+//    if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format))
+	sh_video->format = 0x0;
+
+    /* set FPS and FRAMETIME */
+    if(!sh_video->fps)
+    {
+	if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &sh_video->fps) != TVI_CONTROL_TRUE)
+	    sh_video->fps = 25.0f; /* on PAL */
+    }
+    sh_video->frametime = 1.0f/sh_video->fps;
+
+    /* set width */
+    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
+
+    /* set height */
+    funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
 
     mp_msg(MSGT_TV, MSGL_INFO, "Output size: %dx%d\n", sh_video->disp_w, sh_video->disp_h);
     
     demuxer->video->sh = sh_video;
     sh_video->ds = demuxer->video;
     demuxer->video->id = 0;
-    demuxer->seekable = 0;
+
+//    demuxer->seekable = 0;
 
     /* here comes audio init */
     if (funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
@@ -227,26 +245,7 @@
     }
 no_audio:
 
-    /* set some params got from cmdline */
-    funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input);
-
-    /* we need to set frequency */
-    if (tv_param_freq && (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE))
-    {
-	unsigned long freq = atof(tv_param_freq)*16;
-
-	printf("freq: %lu\n", freq);
-
-        /* set freq in MHz */
-	funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
-
-	funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
-	mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n",
-	    freq, (float)freq/16);
-    }
-    
-    /* also start device! */
-    return(funcs->start(tvh->priv));	
+    return(1);
 }
 
 /* ================== STREAM_TV ===================== */




More information about the MPlayer-cvslog mailing list