From gitlab at videolan.org Tue Jan 21 11:06:25 2025 From: gitlab at videolan.org (Christophe Massiot (@cmassiot)) Date: Tue, 21 Jan 2025 12:06:25 +0100 Subject: [dvblast-devel] [Git][videolan/dvblast][master] 2 commits: Support DVB CI cards to descramble udp input Message-ID: <678f7fb1a88d2_2b114f8f262034115522c7@gitlab.mail> Christophe Massiot pushed to branch master at VideoLAN / dvblast Commits: 1a0474b7 by Arnaud de Turckheim at 2025-01-14T16:01:20+01:00 Support DVB CI cards to descramble udp input - - - - - 405917e7 by Christophe Massiot at 2025-01-21T12:06:08+01:00 Merge branch 'quarium-dvb-ci' - - - - - 5 changed files: - comm.c - dvb.c - dvblast.c - dvblast.h - udp.c Changes: ===================================== comm.c ===================================== @@ -121,6 +121,16 @@ static void comm_Read(struct ev_loop *loop, struct ev_io *w, int revents) switch ( i_command ) { case CMD_FRONTEND_STATUS: + i_answer = RET_NODATA; + i_answer_size = 0; + goto return_answer; + } + } + + if ( i_frequency == 0 && i_secnum < 0 ) + { + switch ( i_command ) + { case CMD_MMI_STATUS: case CMD_MMI_SLOT_STATUS: case CMD_MMI_OPEN: ===================================== dvb.c ===================================== @@ -72,7 +72,7 @@ int i_dvr_buffer_size = DVR_BUFFER_SIZE; -static int i_frontend, i_dvr; +static int i_frontend, i_dvr, i_sec; static struct ev_io frontend_watcher, dvr_watcher; static struct ev_timer lock_watcher, mute_watcher, print_watcher; static fe_status_t i_last_status; @@ -87,6 +87,59 @@ static void FrontendRead(struct ev_loop *loop, struct ev_io *w, int revents); static void FrontendLockCb(struct ev_loop *loop, struct ev_timer *w, int revents); static void FrontendSet( bool b_reset ); +/***************************************************************************** + * dvb_OpenDvr + *****************************************************************************/ +void dvb_OpenDvr( void ) +{ + char psz_tmp[128]; + + sprintf( psz_tmp, "/dev/dvb/adapter%d/dvr%d", i_adapter, i_fenum ); + if( (i_dvr = open(psz_tmp, O_RDONLY | O_NONBLOCK)) < 0 ) + { + msg_Info(NULL, "opening device %s failed (%s), fallback on sec device", + psz_tmp, strerror(errno)); + + /* try to read from sec device */ + sprintf(psz_tmp, "/dev/dvb/adapter%d/sec%d", i_adapter, i_fenum); + if ( (i_dvr = open(psz_tmp, O_RDONLY | O_NONBLOCK)) < 0 ) + { + msg_Err(NULL, "opening device %s failed (%s)", psz_tmp, + strerror(errno)); + exit(1); + } + } + + if ( ioctl( i_dvr, DMX_SET_BUFFER_SIZE, i_dvr_buffer_size ) < 0 ) + { + msg_Warn( NULL, "couldn't set %s buffer size (%s)", psz_tmp, + strerror(errno) ); + } + + ev_io_init(&dvr_watcher, DVRRead, i_dvr, EV_READ); + ev_io_start(event_loop, &dvr_watcher); +} + +/***************************************************************************** + * dvb_OpenSec + *****************************************************************************/ +void dvb_OpenSec( void ) +{ + char psz_tmp[128]; + + msg_Dbg( NULL, "compiled with DVB API version %d.%d", DVB_API_VERSION, DVB_API_VERSION_MINOR ); + + i_frontend = -1; + + sprintf( psz_tmp, "/dev/dvb/adapter%d/sec%d", i_adapter, i_secnum ); + if( (i_sec = open(psz_tmp, O_WRONLY)) < 0 ) + { + msg_Err(NULL, "opening device %s failed (%s)", psz_tmp, + strerror(errno)); + exit(1); + } +} + /***************************************************************************** * dvb_Open *****************************************************************************/ @@ -113,23 +166,7 @@ void dvb_Open( void ) i_frontend = -1; } - sprintf( psz_tmp, "/dev/dvb/adapter%d/dvr%d", i_adapter, i_fenum ); - - if( (i_dvr = open(psz_tmp, O_RDONLY | O_NONBLOCK)) < 0 ) - { - msg_Err( NULL, "opening device %s failed (%s)", psz_tmp, - strerror(errno) ); - exit(1); - } - - if ( ioctl( i_dvr, DMX_SET_BUFFER_SIZE, i_dvr_buffer_size ) < 0 ) - { - msg_Warn( NULL, "couldn't set %s buffer size (%s)", psz_tmp, - strerror(errno) ); - } - - ev_io_init(&dvr_watcher, DVRRead, i_dvr, EV_READ); - ev_io_start(event_loop, &dvr_watcher); + dvb_OpenDvr(); if ( i_frontend != -1 ) { @@ -271,6 +308,33 @@ void dvb_UnsetFilter( int i_fd, uint16_t i_pid ) close( i_fd ); } +/***************************************************************************** + * dvb_WriteSec: write data to sec device + *****************************************************************************/ +void dvb_WriteSec( block_t *p_ts ) +{ + int i_iov = 0; + + for (block_t *p_b = p_ts; p_b; p_b = p_b->p_next) + i_iov++; + + struct iovec p_iov[i_iov]; + struct iovec *p_current = &p_iov[0]; + for (block_t *p_b = p_ts; p_b; p_b = p_b->p_next) + { + p_current->iov_base = p_b->p_ts; + p_current->iov_len = TS_SIZE; + p_current++; + } + + int i_len; + if ( (i_len = writev( i_sec, p_iov, i_iov )) < 0 ) + { + msg_Err( NULL, "couldn't write to DVB sec (%s)", strerror(errno) ); + } + + block_DeleteChain( p_ts ); +} /* * Frontend ===================================== dvblast.c ===================================== @@ -65,6 +65,7 @@ static int i_priority = -1; int i_adapter = 0; int i_fenum = 0; int i_canum = 0; +int i_secnum = -1; char *psz_delsys = NULL; int i_frequency = 0; char *psz_lnb_type = "universal"; @@ -661,6 +662,7 @@ void usage() msg_Raw( NULL, " DVB-T qam_16|qam_32|qam_64|qam_128|qam_256 (default qam_auto)" ); msg_Raw( NULL, " DVB-S2 qpsk|psk_8|apsk_16|apsk_32 (default legacy DVB-S)" ); msg_Raw( NULL, " -n --frontend-number " ); + msg_Raw( NULL, " --sec-number " ); msg_Raw( NULL, " -p --force-pulse force 22kHz pulses for high-band selection (DVB-S)" ); msg_Raw( NULL, " -P --pilot DVB-S2 Pilot (-1 auto, 0 off, 1 on)" ); msg_Raw( NULL, " -R --rolloff DVB-S2 Rolloff value" ); @@ -753,6 +755,7 @@ int main( int i_argc, char **pp_argv ) { "priority", required_argument, NULL, 'i' }, { "adapter", required_argument, NULL, 'a' }, { "frontend-number", required_argument, NULL, 'n' }, + { "sec-number", required_argument, NULL, 0x100004 }, { "delsys", required_argument, NULL, '5' }, { "dvb-plp-id", required_argument, NULL, '9' }, { "frequency", required_argument, NULL, 'f' }, @@ -880,6 +883,10 @@ int main( int i_argc, char **pp_argv ) i_fenum = strtol( optarg, NULL, 0 ); break; + case 0x100004: + i_secnum = strtol( optarg, NULL, 0 ); + break; + case 'y': i_canum = strtol( optarg, NULL, 0 ); break; ===================================== dvblast.h ===================================== @@ -218,6 +218,7 @@ extern char *psz_srv_socket; extern int i_adapter; extern int i_fenum; extern int i_canum; +extern int i_secnum; extern char *psz_delsys; extern int i_dvr_buffer_size; extern int i_frequency; @@ -319,6 +320,9 @@ void dvb_Open( void ); void dvb_Reset( void ); int dvb_SetFilter( uint16_t i_pid ); void dvb_UnsetFilter( int i_fd, uint16_t i_pid ); +void dvb_OpenDvr( void ); +void dvb_OpenSec( void ); +void dvb_WriteSec( block_t *p_ts ); uint8_t dvb_FrontendStatus( uint8_t *p_answer, ssize_t *pi_size ); void udp_Open( void ); ===================================== udp.c ===================================== @@ -44,6 +44,7 @@ #include #include "dvblast.h" +#include "en50221.h" /***************************************************************************** * Local declarations @@ -279,6 +280,13 @@ void udp_Open( void ) ev_timer_init(&mute_watcher, udp_MuteCb, i_udp_lock_timeout / 1000000., i_udp_lock_timeout / 1000000.); memset(&last_addr, 0, sizeof(last_addr)); + + if ( i_secnum >= 0 ) + { + dvb_OpenDvr(); + dvb_OpenSec(); + en50221_Init(); + } } /***************************************************************************** @@ -431,7 +439,10 @@ err: block_DeleteChain( *pp_current ); *pp_current = NULL; - demux_Run( p_ts ); + if ( i_secnum < 0 ) + demux_Run(p_ts); + else + dvb_WriteSec(p_ts); } static void udp_MuteCb(struct ev_loop *loop, struct ev_timer *w, int revents) View it on GitLab: https://code.videolan.org/videolan/dvblast/-/compare/bca0be676f33889e38a9a63a0b7b498663e1bdc0...405917e77f0f08b4c130ae4611c3ca6cf82119c1 -- View it on GitLab: https://code.videolan.org/videolan/dvblast/-/compare/bca0be676f33889e38a9a63a0b7b498663e1bdc0...405917e77f0f08b4c130ae4611c3ca6cf82119c1 You're receiving this email because of your account on code.videolan.org. VideoLAN code repository instance