[Mplayer-cvslog] CVS: main/libmpdemux dvb_tune.c,1.1,1.2 dvbin.c,1.1,1.2 dvbin.h,1.3,1.4 open.c,1.84,1.85 stream.c,1.67,1.68

Arpi of Ize arpi at mplayerhq.hu
Mon Aug 11 02:02:50 CEST 2003


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

Modified Files:
	dvb_tune.c dvbin.c dvbin.h open.c stream.c 
Log Message:
this patch fixes
1)  some bugs introduced in the tuner autodetection and in the channel-parsing functions,
3) retries reading when the mplayer/mencoder don't read fast enough (sooner it exited)
but especially
4) makes the stream compliant with the new, modular stream api (the one
currently in CVS is not and is totally unreachable).
[and maybe more, next time please include cvslog in patch! -- A'rpi]
patch by Nico <nsabbi at libero.it>


Index: dvb_tune.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvb_tune.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dvb_tune.c	16 Mar 2003 20:13:28 -0000	1.1
+++ dvb_tune.c	11 Aug 2003 00:02:46 -0000	1.2
@@ -27,57 +27,104 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <error.h>
+#include <errno.h>
 #include "config.h"
 
 #ifdef HAVE_DVB_HEAD
 	#include <linux/dvb/dmx.h>
 	#include <linux/dvb/frontend.h>
-	char* frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"};
-	char* dvrdev[4]={"/dev/dvb/adapter0/dvr0","/dev/dvb/adapter1/dvr0","/dev/dvb/adapter2/dvr0","/dev/dvb/adapter3/dvr0"};
-	char* demuxdev[4]={"/dev/dvb/adapter0/demux0","/dev/dvb/adapter1/demux0","/dev/dvb/adapter2/demux0","/dev/dvb/adapter3/demux0"};
-	char* secdev[4]={"","","",""};	//UNUSED, ONLY FOR UNIFORMITY
+	static char* dvb_frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"};
+	char* dvb_dvrdev[4]={"/dev/dvb/adapter0/dvr0","/dev/dvb/adapter1/dvr0","/dev/dvb/adapter2/dvr0","/dev/dvb/adapter3/dvr0"};
+	char* dvb_demuxdev[4]={"/dev/dvb/adapter0/demux0","/dev/dvb/adapter1/demux0","/dev/dvb/adapter2/demux0","/dev/dvb/adapter3/demux0"};
+	static char* dvb_secdev[4]={"","","",""};	//UNUSED, ONLY FOR UNIFORMITY
 #else
 	#include <ost/dmx.h>
 	#include <ost/sec.h>
 	#include <ost/frontend.h>
-	char* frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"};
-	char* dvrdev[4]={"/dev/ost/dvr0","/dev/ost/dvr1","/dev/ost/dvr2","/dev/ost/dvr3"};
-	char* secdev[4]={"/dev/ost/sec0","/dev/ost/sec1","/dev/ost/sec2","/dev/ost/sec3"};
-	char* demuxdev[4]={"/dev/ost/demux0","/dev/ost/demux1","/dev/ost/demux2","/dev/ost/demux3"};
+	static char* dvb_frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"};
+	char* dvb_dvrdev[4]={"/dev/ost/dvr0","/dev/ost/dvr1","/dev/ost/dvr2","/dev/ost/dvr3"};
+	static char* dvb_secdev[4]={"/dev/ost/sec0","/dev/ost/sec1","/dev/ost/sec2","/dev/ost/sec3"};
+	char* dvb_demuxdev[4]={"/dev/ost/demux0","/dev/ost/demux1","/dev/ost/demux2","/dev/ost/demux3"};
 #endif
 
 #include "dvbin.h"
-#include "dvb_defaults.h"
 #include "../mp_msg.h"
 
 
-extern int card;
 
-int open_fe(int* fd_frontend, int* fd_sec)
+int dvb_get_tuner_type(dvb_priv_t *priv)
 {
-	if((*fd_frontend = open(frontenddev[card], O_RDWR)) < 0)
+#ifdef HAVE_DVB_HEAD
+  struct dvb_frontend_info fe_info;
+#else
+  FrontendInfo fe_info;
+#endif
+
+  int res, fe_fd = -1;
+  
+  fe_fd = open(dvb_frontenddev[priv->card], O_RDWR);
+  if(fe_fd < 0)
+  {
+  	mp_msg(MSGT_DEMUX, MSGL_ERR, "get_tuner_type(%d, %s), ERROR IN OPENING FRONTEND DEVICE %s: %d\n", priv->card, dvb_frontenddev[priv->card], errno);
+	return 0;
+  }
+  
+  res = ioctl(fe_fd, FE_GET_INFO, &fe_info);
+  if(res < 0)
+  {
+  	mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd);
+	return 0;
+  }
+  close(fe_fd);
+
+  switch(fe_info.type)
+  {
+	case FE_OFDM:
+      mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-T\n");
+	  return TUNER_TER;
+
+	case FE_QPSK:
+      mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-S\n");
+	  return TUNER_SAT;
+	  
+	case FE_QAM:
+      mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-C\n");
+	  return TUNER_CBL;
+	  
+	default:
+	  mp_msg(MSGT_DEMUX, MSGL_ERR, "UNKNOWN TUNER TYPE\n");
+	  return 0;  
+  }
+  
+}	
+
+
+static int open_fe(dvb_priv_t *priv)
+{
+	priv->fe_fd = open(dvb_frontenddev[priv->card], O_RDWR);
+	if(priv->fe_fd < 0)
 	{
-		perror("ERROR IN OPENING FRONTEND DEVICE: ");
-		return -1;
+		mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN OPENING FRONTEND DEVICE %s: %d\n", dvb_frontenddev[priv->card], errno);
+		return 0;
 	}
 #ifdef HAVE_DVB_HEAD
-    	fd_sec=0;
+    priv->sec_fd=0;
 #else
-	if (fd_sec != 0)
-	{
-      		if((*fd_sec = open(secdev[card], O_RDWR)) < 0)
-      		{
-          		perror("ERROR IN OPENING SEC DEVICE: ");
-          		return -1;
-      		}
-    	}
+	priv->sec_fd = open(dvb_secdev[priv->card], O_RDWR);
+    if(priv->sec_fd < 0)
+    {
+		mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN OPENING SEC DEVICE %s: %d\n", dvb_secdev[priv->card], errno);
+		close(priv->fe_fd);
+      	return 0;
+    }
 #endif
-    	return 1;
+
+    return 1;
 }
 
 
 
-int set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype)
+int dvb_set_ts_filt(int fd, uint16_t pid, dmx_pes_type_t pestype)
 {
 	int i;
 	struct dmx_pes_filter_params pesFilterParams;
@@ -91,21 +138,22 @@
 	pesFilterParams.pesType = pestype;
 #endif
 
-	//pesFilterParams.pesType = pestype;
-
 	pesFilterParams.flags   = DMX_IMMEDIATE_START;
+	//pesFilterParams.flags   = DMX_START;
 
+	//errno = 0;
 	if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0)
 	{
-		mp_msg(MSGT_DEMUX, MSGL_DBG2, "ERROR IN SETTING DMX_FILTER %i: ", pid);
+		mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN SETTING DMX_FILTER %i for fd %d: ERRNO: %d", pid, fd, errno);
+		return 0;
 	}
 
-	mp_msg(MSGT_DEMUX, MSGL_V, "SET PES FILTER ON PID %d, RESULT: %d\n", pid, i );
+	mp_msg(MSGT_DEMUX, MSGL_V, "SET PES FILTER ON PID %d to fd %d, RESULT: %d, ERRNO: %d\n", pid, fd, i, errno);
 	return 1;
 }
 
 
-int demux_stop(int fd)
+int dvb_demux_stop(int fd)
 {
 	int i;
 	i = ioctl(fd, DMX_STOP);
@@ -116,8 +164,18 @@
 }
 
 
+int dvb_demux_start(int fd)
+{
+	int i;
+	i = ioctl(fd, DMX_START);
+
+	mp_msg(MSGT_DEMUX, MSGL_DBG2, "STARTING FD: %d, RESULT: %d\n", fd, i);
+
+	return (i==0);
+}
+
 
-void make_nonblock(int f)
+static void make_nonblock(int f)
 {
 	int oldflags;
 
@@ -139,48 +197,31 @@
 	fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth);
 
 
-//int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone)
 dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone,
 		fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval,
 		fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate)
 {
-	mp_msg(MSGT_DEMUX, MSGL_DBG2, "dvb_tune con Freq: %lu, pol: %c, srate: %lu, diseqc %d, tone %d\n", freq, pol, srate, diseqc, tone);
-	/* INPUT: frequency, polarization, srate */
+	mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", freq);
+	if(! open_fe(priv))
+	{
+		return 0;
+	}
+	
 	if(freq > 100000000)
 	{
-		if(open_fe(&(priv->fe_fd), 0))
-		{
-		      //tune_it(fd_frontend, 0, freq, 0, 0, tone, specInv, diseqc,modulation,HP_CodeRate,TransmissionMode,guardInterval,bandWidth);
-			tune_it(priv->fe_fd, 0, freq, 0, 0, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
-
-			close(priv->fe_fd);
-		}
-		else
-			return 0;
+		tune_it(priv->fe_fd, 0, freq, 0, 0, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
 	}
-	else if ((freq != 0) && (pol != 0) && (srate != 0))
+	else if(freq != 0)
 	{
-		if (open_fe(&(priv->fe_fd), &(priv->sec_fd)))
-		{
-			tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
-			close(priv->fe_fd);
-			close(priv->sec_fd);
-		}
-		else
-			return 0;
+		tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
 	}
-
-	priv->channel.freq = freq;
-	priv->channel.srate = srate;
-	priv->channel.pol = pol;
-	priv->channel.diseqc = diseqc;
-	priv->channel.tone = tone;
-	priv->channel.inv = specInv;
-	priv->channel.mod = modulation;
-	priv->channel.gi = guardInterval;
-	priv->channel.trans = TransmissionMode;
-	priv->channel.bw = bandWidth;
-	priv->channel.cr = HP_CodeRate;
+	
+	close(priv->fe_fd);
+	
+#ifdef HAVE_DVB_HEAD
+#else
+	close(priv->sec_fd);
+#endif
 
 	return 1;
 }
@@ -541,7 +582,7 @@
 
 #ifdef HAVE_DVB_HEAD
 
-struct diseqc_cmd {
+static struct diseqc_cmd {
    struct dvb_diseqc_master_cmd cmd;
    uint32_t wait;
 };
@@ -585,6 +626,7 @@
 
 #endif
 
+static unsigned int prev_diseqc = 0;
 
 static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone,
 	fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate,
@@ -602,8 +644,12 @@
   struct secStatus sec_state;
 #endif
 
+  if(diseqc == prev_diseqc)
+	diseqc = 0;
+  else
+	prev_diseqc = diseqc;
 
-  mp_msg(MSGT_DEMUX, MSGL_V,  "TUNE_IT, fd_frontend %d, fd_sec %d, freq %lu, srate %lu, pol %c, tone %i, specInv, diseqc %u, fe_modulation_t modulation,fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth\n",
+  mp_msg(MSGT_DEMUX, MSGL_V,  "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, pol %c, tone %i, specInv, diseqc %u, fe_modulation_t modulation,fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth\n",
 	    fd_frontend, fd_sec, freq, srate, pol, tone, diseqc);
 
 
@@ -615,7 +661,7 @@
 
 
 #ifdef HAVE_DVB_HEAD
-  mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n",fe_info.name);
+  mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name);
 #endif
 
   switch(fe_info.type)
@@ -737,7 +783,7 @@
    }
    else
    {
-	mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING FAILED\n");
+	mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n");
    }
   }
 #else
@@ -768,7 +814,7 @@
         if (ioctl(fd_sec,SEC_SEND_SEQUENCE,&scmds) < 0)
 	{
           mp_msg(MSGT_DEMUX, MSGL_ERR, "Error sending DisEqC");
-          return -1;
+          return 0;
         }
       }
 #endif

Index: dvbin.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvbin.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dvbin.c	16 Mar 2003 20:13:28 -0000	1.1
+++ dvbin.c	11 Aug 2003 00:02:46 -0000	1.2
@@ -23,7 +23,7 @@
 
 */
 
-// Linux includes:
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -31,93 +31,112 @@
 #include <sys/ioctl.h>
 #include <sys/time.h>
[...1080 lines suppressed...]
+	"Nico",
+	"based on the code from ??? (probably Arpi)",
+	dvb_open, 			
+	{ "dvb", NULL },
+	&stream_opts,
+	1 				// Urls are an option string
+};
 
-	mp_msg(MSGT_DEMUX, MSGL_DBG2,  "ESCO da dvb_streaming_start(s)\n");
 
-	return 1;
-}
 
 
-int dvbin_close(dvb_priv_t *priv)
-{
-	//close(priv->dvr_fd);
-	close(priv->demux_fd[0]);
-	close(priv->demux_fd[1]);
-}

Index: dvbin.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvbin.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- dvbin.h	8 Jul 2003 17:01:44 -0000	1.3
+++ dvbin.h	11 Aug 2003 00:02:46 -0000	1.4
@@ -2,6 +2,9 @@
 #ifndef DVBIN_H
 #define DVBIN_H
 
+#include "dvb_defaults.h"
+#include "stream.h"
+
 #ifdef HAVE_DVB_HEAD
 	#include <linux/dvb/dmx.h>
 	#include <linux/dvb/frontend.h>
@@ -57,45 +60,30 @@
 
 
 typedef struct {
+	int card;
     int fe_fd;
     int sec_fd;
     int demux_fd[3];
     int dvr_fd;
-    int input;
-    int output;
-    int discard;
 
-    dvb_channel_t channel;
     dvb_channels_list *list;
+	int tuner_type;
+	int is_on;
+	stream_t *stream;
+	char new_tuning[256], prev_tuning[256];
+	int retry;
 } dvb_priv_t;
 
 
-extern dvb_history_t *dvb_step_channel(dvb_priv_t*, int, dvb_history_t*);
-
-extern dvb_channels_list *dvb_get_channels(char *, const char *);
-extern dvb_history_t dvb_prev_next;
-
-
+#define TUNER_SAT	1
+#define TUNER_TER	2
+#define TUNER_CBL	3
 
+extern int dvb_step_channel(dvb_priv_t *, int);
+extern int dvb_set_channel(dvb_priv_t *, int);
 
-#ifndef DVB_T_LOCATION
-    #ifndef UK
-    #warning No DVB-T country defined in dvb_defaults.h, defaulting to UK
-    #endif
-
-    /* UNITED KINGDOM settings */
-    #define DVB_T_LOCATION              "in United Kingdom"
-    #define BANDWIDTH_DEFAULT           BANDWIDTH_8_MHZ
-    #define HP_CODERATE_DEFAULT         FEC_2_3
-    #define CONSTELLATION_DEFAULT       QAM_64
-    #define TRANSMISSION_MODE_DEFAULT   TRANSMISSION_MODE_2K
-    #define GUARD_INTERVAL_DEFAULT      GUARD_INTERVAL_1_32
-    #define HIERARCHY_DEFAULT           HIERARCHY_NONE
-#endif
-
-#define HIERARCHY_DEFAULT           HIERARCHY_NONE
-#define LP_CODERATE_DEFAULT (0)
-
+extern dvb_channels_list *dvb_get_channels(char *, int);
+extern dvb_history_t dvb_prev_next;
 
 
 #endif

Index: open.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/open.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- open.c	9 Aug 2003 14:23:16 -0000	1.84
+++ open.c	11 Aug 2003 00:02:46 -0000	1.85
@@ -30,8 +30,6 @@
 static URL_t* url;
 #endif
 
-int dvbin_param_on=0;
-
 /// We keep these 2 for the gui atm, but they will be removed.
 int dvd_title=0;
 int vcd_track=0;
@@ -71,10 +69,6 @@
 
 #include "cue_read.h"
 
-#ifdef HAS_DVBIN_SUPPORT
-#include "dvbin.h"
-#endif
-
 
 
 // Define function about auth the libsmbclient library
@@ -455,18 +449,6 @@
 }
 #endif
 
-#ifdef HAS_DVBIN_SUPPORT
-if(strncmp("dvbin://",filename,8) == 0)
-{
-	stream = new_stream(-1, STREAMTYPE_DVB);
-	if (!stream)
-	   return(NULL);
-       	if (!dvb_streaming_start(stream))
-	   return NULL;
-
-       	return stream;
-}
-#endif
 
 #ifdef MPLAYER_NETWORK
 #ifdef STREAMING_LIVE_DOT_COM

Index: stream.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/stream.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- stream.c	11 Jun 2003 16:48:07 -0000	1.67
+++ stream.c	11 Aug 2003 00:02:46 -0000	1.68
@@ -58,6 +58,10 @@
 #ifdef MPLAYER_NETWORK
 extern stream_info_t stream_info_netstream;
 #endif
+#ifdef HAS_DVBIN_SUPPORT
+extern stream_info_t stream_info_dvb;
+#endif
+
 extern stream_info_t stream_info_null;
 extern stream_info_t stream_info_file;
 
@@ -71,6 +75,10 @@
 #ifdef MPLAYER_NETWORK
   &stream_info_netstream,
 #endif
+#ifdef HAS_DVBIN_SUPPORT
+  &stream_info_dvb,
+#endif
+
   &stream_info_null,
   &stream_info_file,
   NULL
@@ -207,13 +215,6 @@
     len = demux_read_data((demux_stream_t*)s->priv,s->buffer,STREAM_BUFFER_SIZE);
     break;
   
-#ifdef HAS_DVBIN_SUPPORT
-  case STREAMTYPE_DVB:
-   len = dvb_streaming_read(s->fd, s->buffer, STREAM_BUFFER_SIZE, s->priv);
-  break;
-#endif
-
-
     
   default: 
     len= s->fill_buffer ? s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE) : 0;
@@ -415,11 +416,6 @@
   case STREAMTYPE_SMB:
     smbc_close(s->fd);
     break;    
-#endif
-#ifdef HAS_DVBIN_SUPPORT
-  case STREAMTYPE_DVB:
-    dvbin_close(s->priv);
-  break;
 #endif
 
 #ifdef USE_DVDREAD



More information about the MPlayer-cvslog mailing list