From owner-freebsd-multimedia@freebsd.org Wed Oct 7 02:51:31 2015 Return-Path: Delivered-To: freebsd-multimedia@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 580779D1ECA for ; Wed, 7 Oct 2015 02:51:31 +0000 (UTC) (envelope-from freebsd-multimedia@herveybayaustralia.com.au) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 4120F3A7 for ; Wed, 7 Oct 2015 02:51:31 +0000 (UTC) (envelope-from freebsd-multimedia@herveybayaustralia.com.au) Received: by mailman.ysv.freebsd.org (Postfix) id 409349D1EC9; Wed, 7 Oct 2015 02:51:31 +0000 (UTC) Delivered-To: multimedia@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27CBC9D1EC8 for ; Wed, 7 Oct 2015 02:51:31 +0000 (UTC) (envelope-from freebsd-multimedia@herveybayaustralia.com.au) Received: from mail.unitedinsong.com.au (mail.unitedinsong.com.au [150.101.178.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 95D7C3A4 for ; Wed, 7 Oct 2015 02:51:30 +0000 (UTC) (envelope-from freebsd-multimedia@herveybayaustralia.com.au) Received: from [192.168.0.185] (laptop1.herveybayaustralia.com.au [192.168.0.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.unitedinsong.com.au (Postfix) with ESMTPSA id 32D096215D for ; Wed, 7 Oct 2015 12:41:35 +1000 (EST) To: multimedia@FreeBSD.org From: Da Rock Subject: V4l api - need some help getting dvb devices to work Message-ID: <5614865E.5040800@herveybayaustralia.com.au> Date: Wed, 7 Oct 2015 12:41:34 +1000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Oct 2015 02:51:31 -0000 I'm trying to get a handle on the v4l api - specifically dvb devices. I've hunted up as much in tutorials as I can, but I cannot seem to get a working system. Mind you I'm just trying to get my feet at this point, and so the code I'm working on is testing only - an app will come later once I get clear in my head. One thing I am wondering is if there isn't something in the FreeBSD implementation that might be stopping things from working correctly - though I don't know why. I started with the code from the tutorial, and I got the frontend setup correctly and tuned. What I need to get working is the dvr device. My aim is to get a full ts stream for ffmpeg or other to mux into respective streams and processing. This means I need to use pid 8192 to be filtered. tzap is incapable of this, as it relies entirely on the apid and vpid, and ignores the sid. Once I got the frontend setup, it took me a while to figure out how to set the pid's and demux use, but I finally got there and I have that set as well; but still the dvr won't work. This is the code (based from http://linuxtv.org/downloads/v4l-dvb-apis/frontend-properties.html, and some of tzap code): #include #include #include #include #include #include static struct dtv_property props[] = { { .cmd = DTV_DELIVERY_SYSTEM, .u.data = SYS_DVBT }, { .cmd = DTV_FREQUENCY, .u.data = 177500000 }, { .cmd = DTV_MODULATION, .u.data = QAM_64 }, { .cmd = DTV_INVERSION, .u.data = INVERSION_AUTO }, { .cmd = DTV_SYMBOL_RATE, .u.data = 7000000 }, { .cmd = DTV_INNER_FEC, .u.data = FEC_3_4 }, { .cmd = DTV_TUNE } }; static struct dtv_properties dtv_prop = { .num = 6, .props = props }; static void print_frontend_stats(int fe_fd, int human_readable) { fe_status_t status; uint16_t snr, _signal; uint32_t ber, uncorrected_blocks; ioctl(fe_fd, FE_READ_STATUS, &status); ioctl(fe_fd, FE_READ_SIGNAL_STRENGTH, &_signal); ioctl(fe_fd, FE_READ_SNR, &snr); ioctl(fe_fd, FE_READ_BER, &ber); ioctl(fe_fd, FE_READ_UNCORRECTED_BLOCKS, &uncorrected_blocks); if (human_readable) { printf ("status %02x | signal %3u%% | snr %3u%% | ber %d | unc %d | ", status, (_signal * 100) / 0xffff, (snr * 100) / 0xffff, ber, uncorrected_blocks); } else { fprintf (stderr, "status %02x | signal %04x | snr %04x | ber %08x | unc %08x | ", status, _signal, snr, ber, uncorrected_blocks); } if (status & FE_HAS_LOCK) //fprintf(stderr,"FE_HAS_LOCK"); printf("FE_HAS_LOCK"); //fprintf(stderr,"\n"); printf("\n"); } int main(void) { int fd = open("/dev/dvb/adapter0/frontend0", O_RDWR); int dd = open("/dev/dvb/adapter0/demux0", O_RDWR); int buffersize = 64 * 100 * 1024; struct dmx_pes_filter_params pesfilter; pesfilter.pid = 8192; pesfilter.input = DMX_IN_FRONTEND; pesfilter.output = DMX_OUT_TS_TAP; pesfilter.pes_type = DMX_PES_OTHER; pesfilter.flags = DMX_IMMEDIATE_START; if (!fd) { perror ("open"); return -1; } if (ioctl(fd, FE_SET_PROPERTY, &dtv_prop) < 0) { perror("ioctl"); return -1; } printf("Frontend set\n"); if (!dd) { perror("open"); return -1; } if (ioctl(dd, DMX_SET_BUFFER_SIZE, buffersize) < 0) { perror("DMX_SET_BUFFER_SIZE failed"); } if (ioctl(dd, DMX_SET_PES_FILTER, &pesfilter) < 0) { perror("Set PES Filter failed"); return -1; } if (ioctl(dd, DMX_START) < 0) { perror("DMX_STOP"); return -1; } while (1) { print_frontend_stats(fd, 1); sleep (1); } return 0; } Could anyone provide some guidance on what is wrong here? Have I not got the concept correctly? Where could I find some good tutorials on v4l?