dvb: Move out PID specific stuff from dvb_service.c
This commit is contained in:
parent
cd52d7c216
commit
65a8fa5f28
5 changed files with 130 additions and 57 deletions
1
Makefile
1
Makefile
|
@ -155,6 +155,7 @@ SRCS-${CONFIG_LINUXDVB} += \
|
|||
src/dvb/dvb_service.c \
|
||||
src/dvb/dvb_preconf.c \
|
||||
src/dvb/dvb_satconf.c \
|
||||
src/dvb/dvb_input_filtered.c \
|
||||
src/webui/extjs_dvb.c \
|
||||
|
||||
# V4L
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <pthread.h>
|
||||
#include "htsmsg.h"
|
||||
|
||||
struct service;
|
||||
|
||||
#define DVB_VER_INT(maj,min) (((maj) << 16) + (min))
|
||||
|
||||
#define DVB_VER_ATLEAST(maj, min) \
|
||||
|
@ -231,6 +233,9 @@ typedef struct th_dvb_adapter {
|
|||
|
||||
uint32_t tda_extrapriority; // extra priority for choosing the best adapter/service
|
||||
|
||||
void (*tda_open_service)(struct th_dvb_adapter *tda, struct service *s);
|
||||
void (*tda_close_service)(struct th_dvb_adapter *tda, struct service *s);
|
||||
|
||||
} th_dvb_adapter_t;
|
||||
|
||||
/**
|
||||
|
@ -336,6 +341,9 @@ void dvb_adapter_set_extrapriority(th_dvb_adapter_t *tda, int extrapriority);
|
|||
|
||||
void dvb_adapter_poweroff(th_dvb_adapter_t *tda);
|
||||
|
||||
void dvb_input_filtered_setup(th_dvb_adapter_t *tda);
|
||||
|
||||
|
||||
/**
|
||||
* DVB Multiplex
|
||||
*/
|
||||
|
|
|
@ -68,6 +68,8 @@ tda_alloc(void)
|
|||
tda->tda_allpids_dmx_fd = -1;
|
||||
tda->tda_dump_fd = -1;
|
||||
|
||||
dvb_input_filtered_setup(tda);
|
||||
|
||||
return tda;
|
||||
}
|
||||
|
||||
|
|
115
src/dvb/dvb_input_filtered.c
Normal file
115
src/dvb/dvb_input_filtered.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* TV Input - Linux DVB interface
|
||||
* Copyright (C) 2012 Andreas Öman
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DVB input using hardware filters
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/dvb/frontend.h>
|
||||
#include <linux/dvb/dmx.h>
|
||||
|
||||
#include "tvheadend.h"
|
||||
#include "dvb.h"
|
||||
#include "service.h"
|
||||
|
||||
/**
|
||||
* Install filters for a service
|
||||
*
|
||||
* global_lock must be held
|
||||
*/
|
||||
static void
|
||||
open_service(th_dvb_adapter_t *tda, service_t *s)
|
||||
{
|
||||
struct dmx_pes_filter_params dmx_param;
|
||||
int fd;
|
||||
elementary_stream_t *st;
|
||||
|
||||
TAILQ_FOREACH(st, &s->s_components, es_link) {
|
||||
if(st->es_pid >= 0x2000)
|
||||
continue;
|
||||
|
||||
if(st->es_demuxer_fd != -1)
|
||||
continue;
|
||||
|
||||
fd = tvh_open(tda->tda_demux_path, O_RDWR, 0);
|
||||
st->es_cc_valid = 0;
|
||||
|
||||
if(fd == -1) {
|
||||
st->es_demuxer_fd = -1;
|
||||
tvhlog(LOG_ERR, "dvb",
|
||||
"\"%s\" unable to open demuxer \"%s\" for pid %d -- %s",
|
||||
s->s_identifier, tda->tda_demux_path,
|
||||
st->es_pid, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&dmx_param, 0, sizeof(dmx_param));
|
||||
dmx_param.pid = st->es_pid;
|
||||
dmx_param.input = DMX_IN_FRONTEND;
|
||||
dmx_param.output = DMX_OUT_TS_TAP;
|
||||
dmx_param.pes_type = DMX_PES_OTHER;
|
||||
dmx_param.flags = DMX_IMMEDIATE_START;
|
||||
|
||||
if(ioctl(fd, DMX_SET_PES_FILTER, &dmx_param)) {
|
||||
tvhlog(LOG_ERR, "dvb",
|
||||
"\"%s\" unable to configure demuxer \"%s\" for pid %d -- %s",
|
||||
s->s_identifier, tda->tda_demux_path,
|
||||
st->es_pid, strerror(errno));
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
st->es_demuxer_fd = fd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove filters for a service
|
||||
*
|
||||
* global_lock must be held
|
||||
*/
|
||||
static void
|
||||
close_service(th_dvb_adapter_t *tda, service_t *s)
|
||||
{
|
||||
elementary_stream_t *es;
|
||||
|
||||
TAILQ_FOREACH(es, &s->s_components, es_link) {
|
||||
if(es->es_demuxer_fd != -1) {
|
||||
close(es->es_demuxer_fd);
|
||||
es->es_demuxer_fd = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
dvb_input_filtered_setup(th_dvb_adapter_t *tda)
|
||||
{
|
||||
tda->tda_open_service = open_service;
|
||||
tda->tda_close_service = close_service;
|
||||
}
|
||||
|
|
@ -44,54 +44,6 @@
|
|||
#include "dvb_support.h"
|
||||
#include "notify.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void
|
||||
dvb_service_open_demuxers(th_dvb_adapter_t *tda, service_t *t)
|
||||
{
|
||||
struct dmx_pes_filter_params dmx_param;
|
||||
int fd;
|
||||
elementary_stream_t *st;
|
||||
|
||||
TAILQ_FOREACH(st, &t->s_components, es_link) {
|
||||
if(st->es_pid >= 0x2000)
|
||||
continue;
|
||||
|
||||
if(st->es_demuxer_fd != -1)
|
||||
continue;
|
||||
|
||||
fd = tvh_open(tda->tda_demux_path, O_RDWR, 0);
|
||||
st->es_cc_valid = 0;
|
||||
|
||||
if(fd == -1) {
|
||||
st->es_demuxer_fd = -1;
|
||||
tvhlog(LOG_ERR, "dvb",
|
||||
"\"%s\" unable to open demuxer \"%s\" for pid %d -- %s",
|
||||
t->s_identifier, tda->tda_demux_path,
|
||||
st->es_pid, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&dmx_param, 0, sizeof(dmx_param));
|
||||
dmx_param.pid = st->es_pid;
|
||||
dmx_param.input = DMX_IN_FRONTEND;
|
||||
dmx_param.output = DMX_OUT_TS_TAP;
|
||||
dmx_param.pes_type = DMX_PES_OTHER;
|
||||
dmx_param.flags = DMX_IMMEDIATE_START;
|
||||
|
||||
if(ioctl(fd, DMX_SET_PES_FILTER, &dmx_param)) {
|
||||
tvhlog(LOG_ERR, "dvb",
|
||||
"\"%s\" unable to configure demuxer \"%s\" for pid %d -- %s",
|
||||
t->s_identifier, tda->tda_demux_path,
|
||||
st->es_pid, strerror(errno));
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
st->es_demuxer_fd = fd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -140,7 +92,7 @@ dvb_service_start(service_t *t, unsigned int weight, int force_start)
|
|||
pthread_mutex_unlock(&tda->tda_delivery_mutex);
|
||||
|
||||
if(!r)
|
||||
dvb_service_open_demuxers(tda, t);
|
||||
tda->tda_open_service(tda, t);
|
||||
|
||||
dvb_table_add_pmt(t->s_dvb_mux_instance, t->s_pmt_pid);
|
||||
|
||||
|
@ -155,7 +107,6 @@ static void
|
|||
dvb_service_stop(service_t *t)
|
||||
{
|
||||
th_dvb_adapter_t *tda = t->s_dvb_mux_instance->tdmi_adapter;
|
||||
elementary_stream_t *st;
|
||||
|
||||
lock_assert(&global_lock);
|
||||
|
||||
|
@ -163,12 +114,8 @@ dvb_service_stop(service_t *t)
|
|||
LIST_REMOVE(t, s_active_link);
|
||||
pthread_mutex_unlock(&tda->tda_delivery_mutex);
|
||||
|
||||
TAILQ_FOREACH(st, &t->s_components, es_link) {
|
||||
if(st->es_demuxer_fd != -1) {
|
||||
close(st->es_demuxer_fd);
|
||||
st->es_demuxer_fd = -1;
|
||||
}
|
||||
}
|
||||
tda->tda_close_service(tda, t);
|
||||
|
||||
t->s_status = SERVICE_IDLE;
|
||||
}
|
||||
|
||||
|
@ -182,7 +129,7 @@ dvb_service_refresh(service_t *t)
|
|||
th_dvb_adapter_t *tda = t->s_dvb_mux_instance->tdmi_adapter;
|
||||
|
||||
lock_assert(&global_lock);
|
||||
dvb_service_open_demuxers(tda, t);
|
||||
tda->tda_open_service(tda, t);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue