gnutv: change channels quickly with cam suport
Dear all,
I extended gnutv a little in order to make it switch channels
quickly: I'v added a command line option (-remote) to make it read channel names from stdin and change from one channel to another in a few hundred ms.
Hope you find this useful,
Simon
Signature · 4 lines
DI Dr. Simon Vogl | @ [email protected] Leiter Technik & Entwicklung | w www.homebutler.at Competence Center Smart Home Solutions | w www.beko.at BEKO Engineering & Informatik AG | t +43 664 23 12 482 Gruberstr. 2 - 6, 4020 Linz | f +43 732 655465 20
util/gnutv/Makefile +2 -2
@@ -8,9 +8,9 @@ binaries = gnutv inst_bin = $(binaries) -CPPFLAGS += -I../../lib +CPPFLAGS += -I../../lib LDFLAGS += -L../../lib/libdvbapi -L../../lib/libdvbcfg -L../../lib/libdvbsec -L../../lib/libdvben50221 -L../../lib/libucsi -LDLIBS += -ldvbcfg -ldvben50221 -lucsi -ldvbsec -ldvbapi -lpthread +LDLIBS += -ldvbcfg -ldvben50221 -lucsi -ldvbsec -ldvbapi -lpthread -lrt .PHONY: all
util/gnutv/gnutv.c +108 -2
146 lines not on this page · raw message
util/gnutv/gnutv.h +3 -0
@@ -34,4 +34,7 @@#define OUTPUT_TYPE_UDP 5#define OUTPUT_TYPE_STDOUT 6 +extern void start_timer (void ); +void stop_timer (void ); +#endif
util/gnutv/gnutv_ca.c +281 -259
655 lines not on this page · raw message
util/gnutv/gnutv_ca.h +1 -0
@@ -31,6 +31,7 @@ struct gnutv_ca_params { };extern void gnutv_ca_start (struct gnutv_ca_params *params); +extern void gnutv_ca_restart (struct gnutv_ca_params *params);extern void gnutv_ca_ui (void );extern void gnutv_ca_stop (void );
util/gnutv/gnutv_data.c +14 -5
@@ -61,7 +61,7 @@ static int outfd = -1;static int dvrfd =-1 ;static int pat_fd_dvrout =-1 ;static int pmt_fd_dvrout =-1 ; -static int outputthread_shutdown =0 ; +static volatile int outputthread_shutdown =0 ;static int usertp =0 ;static int adapter_id =-1 ;
@@ -86,7 +86,7 @@ void gnutv_data_start(int _output_type, adapter_id = _adapter_id; output_type = _output_type; -// setup output +// setup output switch (output_type) {case OUTPUT_TYPE_DECODER :case OUTPUT_TYPE_DECODER_ABYPASS :
@@ -186,6 +186,11 @@ void gnutv_data_stop()close (pmt_fd_dvrout);if (outaddrs)freeaddrinfo (outaddrs); + + outaddrs =NULL ; + dvrfd =-1 ; + pmt_fd_dvrout =-1 ; + pat_fd_dvrout =-1 ; }void gnutv_data_new_pat (int pmt_pid)
@@ -235,7 +240,9 @@ static void *fileoutputthread_func(void* pollfd.fd = dvrfd; pollfd.events =POLLIN |POLLPRI |POLLERR ; -while (!outputthread_shutdown) { + outputthread_shutdown=0 ; + +while (!outputthread_shutdown) {if (poll (&pollfd,1 ,1000 ) ==-1 ) {if (errno ==EINTR )continue ;
@@ -274,7 +281,7 @@ static void *fileoutputthread_func(void* } } } - +printf ("202 shutdown fileoutputthread\n " );return 0 ; }
@@ -310,6 +317,8 @@ static void *udpoutputthread_func(void* bufbase =12 ; } + outputthread_shutdown=0 ; +while (!outputthread_shutdown) {if (poll (&pollfd,1 ,1000 ) !=1 )continue ;
@@ -403,7 +412,7 @@ static void gnutv_data_decoder_pmt(strucint audio_pid =-1 ;int video_pid =-1 ;struct mpeg_pmt_stream *cur_stream; -mpeg_pmt_section_streams_for_each (pmt, cur_stream) { +mpeg_pmt_section_streams_for_each (pmt, cur_stream) {switch (cur_stream->stream_type) {case 1 :case 2 :// video
util/gnutv/gnutv_dvb.c +9 -2
@@ -57,6 +57,11 @@ static int create_section_filter(int adaint gnutv_dvb_start (struct gnutv_dvb_params *params) { + dvbthread_shutdown =0 ; + pat_version =-1 ; + ca_pmt_version =-1 ; + data_pmt_version =-1 ; +pthread_create (&dvbthread,NULL , dvbthread_func, (void *) params);return 0 ; }
@@ -81,6 +86,8 @@ static void *dvbthread_func(void* arg)struct gnutv_dvb_params *params = (struct gnutv_dvb_params *) arg; + dvbthread_shutdown =0 ; + tune_state =0 ;// create PAT filter
@@ -252,7 +259,7 @@ static void process_pat(int pat_fd, stru// try and find the requested program struct mpeg_pat_program *cur_program;mpeg_pat_section_programs_for_each (pat, cur_program) { -if (cur_program->program_number == params->channel.service_id) { +if (cur_program->program_number == params->channel.service_id) {// close old PMT fd if (*pmt_fd !=-1 )close (*pmt_fd);
@@ -345,7 +352,7 @@ static void process_pmt(int pmt_fd, stru// do ca handling if (section_ext->version_number != ca_pmt_version) { -if (gnutv_ca_new_pmt (pmt) ==1 ) +if (gnutv_ca_new_pmt (pmt) ==1 ) ca_pmt_version = pmt->head.version_number; } }