From f228fe45c3ae6f8f8212dca001b7d68421d06022 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 27 Mar 2014 11:27:17 +0100 Subject: [PATCH 1/5] Do not rely on linux kernel's headers - preparing for network tuners (SAT-IP) This is a complete migration to use the own mux configuration scheme without the system limitations to allow write backends for the network tuners like SAT-IP servers. --- src/input/mpegts/dvb.h | 245 ++++++- src/input/mpegts/dvb_psi.c | 166 ++--- src/input/mpegts/dvb_support.c | 639 +++++++----------- src/input/mpegts/linuxdvb/linuxdvb_adapter.c | 43 +- src/input/mpegts/linuxdvb/linuxdvb_en50494.c | 2 + src/input/mpegts/linuxdvb/linuxdvb_frontend.c | 310 +++++++-- src/input/mpegts/linuxdvb/linuxdvb_lnb.c | 18 +- src/input/mpegts/linuxdvb/linuxdvb_mux.c | 230 ++++--- src/input/mpegts/linuxdvb/linuxdvb_network.c | 16 +- src/input/mpegts/linuxdvb/linuxdvb_private.h | 16 +- src/input/mpegts/linuxdvb/linuxdvb_rotor.c | 1 + src/input/mpegts/linuxdvb/linuxdvb_satconf.c | 1 + src/input/mpegts/linuxdvb/linuxdvb_switch.c | 1 + src/input/mpegts/linuxdvb/scanfile.c | 70 +- 14 files changed, 1021 insertions(+), 737 deletions(-) diff --git a/src/input/mpegts/dvb.h b/src/input/mpegts/dvb.h index 3963efa6..00cc7511 100644 --- a/src/input/mpegts/dvb.h +++ b/src/input/mpegts/dvb.h @@ -197,48 +197,224 @@ void psi_tables_atsc_c ( struct mpegts_mux *mm ); */ #if ENABLE_DVBAPI -#include -#include +typedef enum dvb_fe_type { + DVB_TYPE_NONE = 0, + DVB_TYPE_T = 1, /* terrestrial */ + DVB_TYPE_C, /* cable */ + DVB_TYPE_S, /* satellite */ + DVB_TYPE_ATSC, /* terrestrial - north america */ + DVB_TYPE_LAST = DVB_TYPE_ATSC +} dvb_fe_type_t; -#define DVB_VER_INT(maj,min) (((maj) << 16) + (min)) +typedef enum dvb_fe_delivery_system { + DVB_SYS_NONE = 0, + DVB_SYS_DVBC_ANNEX_A = 100, + DVB_SYS_DVBC_ANNEX_B, + DVB_SYS_DVBC_ANNEX_C, + DVB_SYS_DVBT = 200, + DVB_SYS_DVBT2, + DVB_SYS_DVBS = 300, + DVB_SYS_DVBS2, + DVB_SYS_DVBH = 400, + DVB_SYS_DSS = 500, + DVB_SYS_ISDBT = 600, + DVB_SYS_ISDBS, + DVB_SYS_ISDBC, + DVB_SYS_ATSC = 700, + DVB_SYS_ATSCMH, + DVB_SYS_DTMB = 800, + DVB_SYS_CMMB = 900, + DVB_SYS_DAB = 1000, + DVB_SYS_TURBO = 1100, +} dvb_fe_delivery_system_t; -#define DVB_VER_ATLEAST(maj, min) \ - (DVB_VER_INT(DVB_API_VERSION, DVB_API_VERSION_MINOR) >= DVB_VER_INT(maj, min)) +typedef enum dvb_fe_spectral_inversion { + DVB_INVERSION_UNDEFINED, + DVB_INVERSION_AUTO, + DVB_INVERSION_OFF, + DVB_INVERSION_ON, +} dvb_fe_spectral_inversion_t; -typedef struct dvb_frontend_parameters dvb_frontend_parameters_t; +typedef enum dvb_fe_code_rate { + DVB_FEC_NONE = 0, + DVB_FEC_AUTO, + DVB_FEC_1_2 = 102, + DVB_FEC_1_3 = 103, + DVB_FEC_1_5 = 105, + DVB_FEC_2_3 = 203, + DVB_FEC_2_5 = 205, + DVB_FEC_2_9 = 209, + DVB_FEC_3_4 = 304, + DVB_FEC_3_5 = 305, + DVB_FEC_4_5 = 405, + DVB_FEC_4_15 = 415, + DVB_FEC_5_6 = 506, + DVB_FEC_5_9 = 509, + DVB_FEC_6_7 = 607, + DVB_FEC_7_8 = 708, + DVB_FEC_7_9 = 709, + DVB_FEC_7_15 = 715, + DVB_FEC_8_9 = 809, + DVB_FEC_8_15 = 815, + DVB_FEC_9_10 = 910, + DVB_FEC_9_20 = 920, + DVB_FEC_11_15 = 1115, + DVB_FEC_11_20 = 1120, + DVB_FEC_11_45 = 1145, + DVB_FEC_13_18 = 1318, + DVB_FEC_13_45 = 1345, + DVB_FEC_14_45 = 1445, + DVB_FEC_23_36 = 2336, + DVB_FEC_25_36 = 2536, + DVB_FEC_26_45 = 2645, + DVB_FEC_28_45 = 2845, + DVB_FEC_29_45 = 2945, + DVB_FEC_31_45 = 3145, + DVB_FEC_32_45 = 3245, + DVB_FEC_77_90 = 7790, +} dvb_fe_code_rate_t; -typedef enum polarisation { - POLARISATION_HORIZONTAL = 0x00, - POLARISATION_VERTICAL = 0x01, - POLARISATION_CIRCULAR_LEFT = 0x02, - POLARISATION_CIRCULAR_RIGHT = 0x03 -} polarisation_t; +typedef enum dvb_fe_modulation { + DVB_MOD_NONE = 0, + DVB_MOD_AUTO, + DVB_MOD_QPSK = 1001, + DVB_MOD_QAM_4_NR = 2004, + DVB_MOD_QAM_AUTO = 3000, + DVB_MOD_QAM_16 = 3016, + DVB_MOD_QAM_32 = 3032, + DVB_MOD_QAM_64 = 3064, + DVB_MOD_QAM_128 = 3128, + DVB_MOD_QAM_256 = 3256, + DVB_MOD_VSB_8 = 4008, + DVB_MOD_VSB_16 = 4016, + DVB_MOD_PSK_8 = 5008, + DVB_MOD_DQPSK = 6001, + DVB_MOD_BPSK = 7001, + DVB_MOD_BPSK_S = 8001, + DVB_MOD_APSK_16 = 9016, + DVB_MOD_APSK_32 = 9032, + DVB_MOD_APSK_64 = 9064, + DVB_MOD_APSK_128 = 9128, + DVB_MOD_APSK_256 = 9256, + DVB_MOD_APSK_8_L = 10008, + DVB_MOD_APSK_16_L = 10016, + DVB_MOD_APSK_32_L = 10032, + DVB_MOD_APSK_64_L = 10064, + DVB_MOD_APSK_128_L = 10128, + DVB_MOD_APSK_256_L = 10256, +} dvb_fe_modulation_t; + +typedef enum dvb_fe_transmit_mode { + DVB_TRANSMISSION_MODE_NONE = 0, + DVB_TRANSMISSION_MODE_AUTO, + DVB_TRANSMISSION_MODE_1K = 100, + DVB_TRANSMISSION_MODE_2K, + DVB_TRANSMISSION_MODE_4K, + DVB_TRANSMISSION_MODE_8K, + DVB_TRANSMISSION_MODE_16K, + DVB_TRANSMISSION_MODE_32K, + DVB_TRANSMISSION_MODE_C1 = 10001, + DVB_TRANSMISSION_MODE_C3780 = 13780, +} dvb_fe_transmit_mode_t; + +typedef enum dvb_fe_bandwidth { + DVB_BANDWIDTH_NONE = 0, + DVB_BANDWIDTH_AUTO, + DVB_BANDWIDTH_1_712_MHZ = 1712, + DVB_BANDWIDTH_5_MHZ = 5000, + DVB_BANDWIDTH_6_MHZ = 6000, + DVB_BANDWIDTH_7_MHZ = 7000, + DVB_BANDWIDTH_8_MHZ = 8000, + DVB_BANDWIDTH_10_MHZ = 10000, +} dvb_fe_bandwidth_t; + +typedef enum dvb_fe_guard_interval { + DVB_GUARD_INTERVAL_NONE = 0, + DVB_GUARD_INTERVAL_AUTO, + DVB_GUARD_INTERVAL_1_4 = 1004, + DVB_GUARD_INTERVAL_1_8 = 1008, + DVB_GUARD_INTERVAL_1_16 = 1016, + DVB_GUARD_INTERVAL_1_32 = 1032, + DVB_GUARD_INTERVAL_1_128 = 1128, + DVB_GUARD_INTERVAL_19_128 = 19128, + DVB_GUARD_INTERVAL_19_256 = 19256, + DVB_GUARD_INTERVAL_PN420 = 90420, + DVB_GUARD_INTERVAL_PN595 = 90595, + DVB_GUARD_INTERVAL_PN945 = 90945, +} dvb_fe_guard_interval_t; + +typedef enum dvb_fe_hierarchy { + DVB_HIERARCHY_NONE = 0, + DVB_HIERARCHY_AUTO, + DVB_HIERARCHY_1 = 1001, + DVB_HIERARCHY_2 = 1002, + DVB_HIERARCHY_4 = 1004, +} dvb_fe_hierarchy_t; + +typedef enum dvb_fe_pilot { + DVB_PILOT_NONE = 0, + DVB_PILOT_AUTO, + DVB_PILOT_ON, + DVB_PILOT_OFF, +} dvb_fe_pilot_t; + +typedef enum dvb_fe_rolloff { + DVB_ROLLOFF_NONE = 0, + DVB_ROLLOFF_AUTO, + DVB_ROLLOFF_20 = 200, + DVB_ROLLOFF_25 = 250, + DVB_ROLLOFF_35 = 350, +} dvb_fe_rolloff_t; + +typedef enum dvb_polarisation { + DVB_POLARISATION_HORIZONTAL = 0x00, + DVB_POLARISATION_VERTICAL = 0x01, + DVB_POLARISATION_CIRCULAR_LEFT = 0x02, + DVB_POLARISATION_CIRCULAR_RIGHT = 0x03 +} dvb_polarisation_t; + +typedef struct dvb_qpsk_config { + dvb_polarisation_t polarisation; + int orbital_pos; + char orbital_dir; + uint32_t symbol_rate; + dvb_fe_code_rate_t fec_inner; +} dvb_qpsk_config_t; + +typedef struct dvb_qam_config { + uint32_t symbol_rate; + dvb_fe_code_rate_t fec_inner; +} dvb_qam_config_t; + +typedef struct dvb_ofdm_config { + dvb_fe_bandwidth_t bandwidth; + dvb_fe_code_rate_t code_rate_HP; + dvb_fe_code_rate_t code_rate_LP; + dvb_fe_transmit_mode_t transmission_mode; + dvb_fe_guard_interval_t guard_interval; + dvb_fe_hierarchy_t hierarchy_information; +} dvb_ofdm_config_t; typedef struct dvb_mux_conf { - dvb_frontend_parameters_t dmc_fe_params; - - // Additional DVB-S fields - polarisation_t dmc_fe_polarisation; - int dmc_fe_orbital_pos; - char dmc_fe_orbital_dir; -#if DVB_VER_ATLEAST(5,0) - fe_modulation_t dmc_fe_modulation; - fe_delivery_system_t dmc_fe_delsys; - fe_rolloff_t dmc_fe_rolloff; - fe_pilot_t dmc_fe_pilot; -#endif + dvb_fe_type_t dmc_fe_type; + dvb_fe_delivery_system_t dmc_fe_delsys; + dvb_fe_modulation_t dmc_fe_modulation; + uint32_t dmc_fe_freq; + dvb_fe_spectral_inversion_t dmc_fe_inversion; + dvb_fe_rolloff_t dmc_fe_rolloff; + dvb_fe_pilot_t dmc_fe_pilot; + union { + dvb_qpsk_config_t dmc_fe_qpsk; + dvb_qam_config_t dmc_fe_qam; + dvb_ofdm_config_t dmc_fe_ofdm; + } u; // For scan file configurations - LIST_ENTRY(dvb_mux_conf) dmc_link; + LIST_ENTRY(dvb_mux_conf) dmc_link; } dvb_mux_conf_t; -const char *dvb_mux_conf_load - ( fe_type_t type, dvb_mux_conf_t *dmc, htsmsg_t *m ); -void dvb_mux_conf_save - ( fe_type_t type, dvb_mux_conf_t *dmc, htsmsg_t *m ); - /* conversion routines */ const char *dvb_rolloff2str ( int rolloff ); const char *dvb_delsys2str ( int delsys ); @@ -268,11 +444,12 @@ int dvb_str2pilot ( const char *str ); #define dvb_str2feclo dvb_str2fec #define dvb_str2fechi dvb_str2fec -int dvb_bandwidth ( enum fe_bandwidth bw ); +static inline int dvb_bandwidth( dvb_fe_bandwidth_t bw ) +{ + return bw < 1000 ? 0 : bw * 1000; +} -#if DVB_VER_ATLEAST(5,10) -int dvb_delsys2type ( enum fe_delivery_system ds ); -#endif +int dvb_delsys2type ( enum dvb_fe_delivery_system ds ); #endif /* ENABLE_DVBAPI */ diff --git a/src/input/mpegts/dvb_psi.c b/src/input/mpegts/dvb_psi.c index 6e10ad29..112077b8 100644 --- a/src/input/mpegts/dvb_psi.c +++ b/src/input/mpegts/dvb_psi.c @@ -78,22 +78,11 @@ dvb_servicetype_lookup ( int t ) /** * Tables for delivery descriptor parsing */ -static const fe_code_rate_t fec_tab [16] = { - FEC_AUTO, FEC_1_2, FEC_2_3, FEC_3_4, - FEC_5_6, FEC_7_8, FEC_8_9, -#if DVB_VER_ATLEAST(5,0) - FEC_3_5, -#else - FEC_NONE, -#endif - FEC_4_5, -#if DVB_VER_ATLEAST(5,0) - FEC_9_10, -#else - FEC_NONE, -#endif - FEC_NONE, FEC_NONE, - FEC_NONE, FEC_NONE, FEC_NONE, FEC_NONE +static const dvb_fe_code_rate_t fec_tab [16] = { + DVB_FEC_AUTO, DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, + DVB_FEC_5_6, DVB_FEC_7_8, DVB_FEC_8_9, DVB_FEC_3_5, + DVB_FEC_4_5, DVB_FEC_9_10, DVB_FEC_NONE, DVB_FEC_NONE, + DVB_FEC_NONE, DVB_FEC_NONE, DVB_FEC_NONE, DVB_FEC_NONE }; /* @@ -127,58 +116,43 @@ dvb_desc_sat_del } memset(&dmc, 0, sizeof(dmc)); -#if DVB_VER_ATLEAST(5,0) - dmc.dmc_fe_pilot = PILOT_AUTO; -#endif - dmc.dmc_fe_params.inversion = INVERSION_AUTO; - dmc.dmc_fe_params.frequency = frequency; - dmc.dmc_fe_orbital_pos = bcdtoint(ptr[4]) * 100 + bcdtoint(ptr[5]); - dmc.dmc_fe_orbital_dir = (ptr[6] & 0x80) ? 'E' : 'W'; - dmc.dmc_fe_polarisation = (ptr[6] >> 5) & 0x03; + dmc.dmc_fe_pilot = DVB_PILOT_AUTO; + dmc.dmc_fe_inversion = DVB_INVERSION_AUTO; + dmc.dmc_fe_freq = frequency; + dmc.u.dmc_fe_qpsk.orbital_pos = bcdtoint(ptr[4]) * 100 + bcdtoint(ptr[5]); + dmc.u.dmc_fe_qpsk.orbital_dir = (ptr[6] & 0x80) ? 'E' : 'W'; + dmc.u.dmc_fe_qpsk.polarisation = (ptr[6] >> 5) & 0x03; - dmc.dmc_fe_params.u.qpsk.symbol_rate = symrate * 100; - dmc.dmc_fe_params.u.qpsk.fec_inner = fec_tab[ptr[10] & 0x0f]; + dmc.u.dmc_fe_qpsk.symbol_rate = symrate * 100; + dmc.u.dmc_fe_qpsk.fec_inner = fec_tab[ptr[10] & 0x0f]; -#if DVB_VER_ATLEAST(5,0) static int mtab[4] = { - 0, QPSK, -#if DVB_VER_ATLEAST(5,3) - PSK_8, -#else - 0, -#endif - QAM_16 + DVB_MOD_NONE, DVB_MOD_QPSK, DVB_MOD_PSK_8, DVB_MOD_QAM_16 }; static int rtab[4] = { - ROLLOFF_35, ROLLOFF_25, ROLLOFF_20, ROLLOFF_AUTO + DVB_ROLLOFF_35, DVB_ROLLOFF_25, DVB_ROLLOFF_20, DVB_ROLLOFF_AUTO }; - dmc.dmc_fe_delsys = (ptr[6] & 0x4) ? SYS_DVBS2 : SYS_DVBS; + dmc.dmc_fe_delsys = (ptr[6] & 0x4) ? DVB_SYS_DVBS2 : DVB_SYS_DVBS; dmc.dmc_fe_modulation = mtab[ptr[6] & 0x3]; dmc.dmc_fe_rolloff = rtab[(ptr[6] >> 3) & 0x3]; - if (dmc.dmc_fe_delsys == SYS_DVBS && - dmc.dmc_fe_rolloff != ROLLOFF_35) { + if (dmc.dmc_fe_delsys == DVB_SYS_DVBS && + dmc.dmc_fe_rolloff != DVB_ROLLOFF_35) { tvhwarn("nit", "dvb-s rolloff error"); return NULL; } -#endif /* Debug */ - const char *pol = dvb_pol2str(dmc.dmc_fe_polarisation); - tvhdebug("nit", " dvb-s%c pos %d%c freq %d %c sym %d fec %s" -#if DVB_VER_ATLEAST(5,0) - " mod %s roff %s" -#endif - , + const char *pol = dvb_pol2str(dmc.u.dmc_fe_qpsk.polarisation); + tvhdebug("nit", + " dvb-s%c pos %d%c freq %d %c sym %d fec %s mod %s roff %s", (ptr[6] & 0x4) ? '2' : ' ', - dmc.dmc_fe_orbital_pos, dmc.dmc_fe_orbital_dir, - dmc.dmc_fe_params.frequency, + dmc.u.dmc_fe_qpsk.orbital_pos, dmc.u.dmc_fe_qpsk.orbital_dir, + dmc.dmc_fe_freq, pol ? pol[0] : 'X', symrate, - dvb_fec2str(dmc.dmc_fe_params.u.qpsk.fec_inner) -#if DVB_VER_ATLEAST(5,0) - , dvb_qam2str(dmc.dmc_fe_modulation), + dvb_fec2str(dmc.u.dmc_fe_qpsk.fec_inner), + dvb_qam2str(dmc.dmc_fe_modulation), dvb_rolloff2str(dmc.dmc_fe_rolloff) -#endif ); /* Create */ @@ -197,7 +171,8 @@ dvb_desc_cable_del dvb_mux_conf_t dmc; static const fe_modulation_t qtab [6] = { - QAM_AUTO, QAM_16, QAM_32, QAM_64, QAM_128, QAM_256 + DVB_MOD_QAM_AUTO, DVB_MOD_QAM_16, DVB_MOD_QAM_32, DVB_MOD_QAM_64, + DVB_MOD_QAM_128, DVB_MOD_QAM_256 }; /* Not enough data */ @@ -220,25 +195,23 @@ dvb_desc_cable_del } memset(&dmc, 0, sizeof(dmc)); -#if DVB_VER_ATLEAST(5,0) - dmc.dmc_fe_delsys = SYS_DVBC_ANNEX_AC; -#endif - dmc.dmc_fe_params.inversion = INVERSION_AUTO; - dmc.dmc_fe_params.frequency = frequency * 100; + dmc.dmc_fe_delsys = DVB_SYS_DVBC_ANNEX_A; + dmc.dmc_fe_inversion = DVB_INVERSION_AUTO; + dmc.dmc_fe_freq = frequency * 100; - dmc.dmc_fe_params.u.qam.symbol_rate = symrate * 100; + dmc.u.dmc_fe_qam.symbol_rate = symrate * 100; if((ptr[6] & 0x0f) >= sizeof(qtab)) - dmc.dmc_fe_params.u.qam.modulation = QAM_AUTO; + dmc.dmc_fe_modulation = QAM_AUTO; else - dmc.dmc_fe_params.u.qam.modulation = qtab[ptr[6] & 0x0f]; - dmc.dmc_fe_params.u.qam.fec_inner = fec_tab[ptr[10] & 0x07]; + dmc.dmc_fe_modulation = qtab[ptr[6] & 0x0f]; + dmc.u.dmc_fe_qam.fec_inner = fec_tab[ptr[10] & 0x07]; /* Debug */ tvhdebug("nit", " dvb-c freq %d sym %d mod %s fec %s", frequency, symrate, - dvb_qam2str(dmc.dmc_fe_params.u.qam.modulation), - dvb_fec2str(dmc.dmc_fe_params.u.qam.fec_inner)); + dvb_qam2str(dmc.dmc_fe_modulation), + dvb_fec2str(dmc.u.dmc_fe_qam.fec_inner)); /* Create */ return mm->mm_network->mn_create_mux(mm, onid, tsid, &dmc); @@ -253,28 +226,27 @@ dvb_desc_terr_del const uint8_t *ptr, int len ) { static const fe_bandwidth_t btab [8] = { - BANDWIDTH_8_MHZ, BANDWIDTH_7_MHZ, BANDWIDTH_6_MHZ, BANDWIDTH_AUTO, - BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO, BANDWIDTH_AUTO - }; + DVB_BANDWIDTH_8_MHZ, DVB_BANDWIDTH_7_MHZ, + DVB_BANDWIDTH_6_MHZ, DVB_BANDWIDTH_AUTO, + DVB_BANDWIDTH_AUTO, DVB_BANDWIDTH_AUTO, + DVB_BANDWIDTH_AUTO, DVB_BANDWIDTH_AUTO + }; static const fe_modulation_t ctab [4] = { - QPSK, QAM_16, QAM_64, QAM_AUTO + DVB_MOD_QPSK, DVB_MOD_QAM_16, DVB_MOD_QAM_64, DVB_MOD_QAM_AUTO }; static const fe_guard_interval_t gtab [4] = { - GUARD_INTERVAL_1_32, GUARD_INTERVAL_1_16, GUARD_INTERVAL_1_8, GUARD_INTERVAL_1_4 + DVB_GUARD_INTERVAL_1_32, DVB_GUARD_INTERVAL_1_16, + DVB_GUARD_INTERVAL_1_8, DVB_GUARD_INTERVAL_1_4 }; static const fe_transmit_mode_t ttab [4] = { - TRANSMISSION_MODE_2K, - TRANSMISSION_MODE_8K, -#if DVB_VER_ATLEAST(5,1) - TRANSMISSION_MODE_4K, -#else - TRANSMISSION_MODE_AUTO, -#endif - TRANSMISSION_MODE_AUTO -}; + DVB_TRANSMISSION_MODE_2K, + DVB_TRANSMISSION_MODE_8K, + DVB_TRANSMISSION_MODE_4K, + DVB_TRANSMISSION_MODE_AUTO + }; static const fe_hierarchy_t htab [8] = { - HIERARCHY_NONE, HIERARCHY_1, HIERARCHY_2, HIERARCHY_4, - HIERARCHY_NONE, HIERARCHY_1, HIERARCHY_2, HIERARCHY_4 + DVB_HIERARCHY_NONE, DVB_HIERARCHY_1, DVB_HIERARCHY_2, DVB_HIERARCHY_4, + DVB_HIERARCHY_NONE, DVB_HIERARCHY_1, DVB_HIERARCHY_2, DVB_HIERARCHY_4 }; int frequency; @@ -291,30 +263,28 @@ dvb_desc_terr_del } memset(&dmc, 0, sizeof(dmc)); -#if DVB_VER_ATLEAST(5,0) - dmc.dmc_fe_delsys = SYS_DVBT; -#endif - dmc.dmc_fe_params.inversion = INVERSION_AUTO; - dmc.dmc_fe_params.frequency = frequency * 10; + dmc.dmc_fe_delsys = DVB_SYS_DVBT; + dmc.dmc_fe_inversion = DVB_INVERSION_AUTO; + dmc.dmc_fe_freq = frequency * 10; - dmc.dmc_fe_params.u.ofdm.bandwidth = btab[(ptr[4] >> 5) & 0x7]; - dmc.dmc_fe_params.u.ofdm.constellation = ctab[(ptr[5] >> 6) & 0x3]; - dmc.dmc_fe_params.u.ofdm.hierarchy_information = htab[(ptr[5] >> 3) & 0x3]; - dmc.dmc_fe_params.u.ofdm.code_rate_HP = fec_tab[(ptr[5] + 1) & 0x7]; - dmc.dmc_fe_params.u.ofdm.code_rate_LP = fec_tab[((ptr[6] + 1) >> 5) & 0x7]; - dmc.dmc_fe_params.u.ofdm.guard_interval = gtab[(ptr[6] >> 3) & 0x3]; - dmc.dmc_fe_params.u.ofdm.transmission_mode = ttab[(ptr[6] >> 1) & 0x3]; + dmc.u.dmc_fe_ofdm.bandwidth = btab[(ptr[4] >> 5) & 0x7]; + dmc.dmc_fe_modulation = ctab[(ptr[5] >> 6) & 0x3]; + dmc.u.dmc_fe_ofdm.hierarchy_information = htab[(ptr[5] >> 3) & 0x3]; + dmc.u.dmc_fe_ofdm.code_rate_HP = fec_tab[(ptr[5] + 1) & 0x7]; + dmc.u.dmc_fe_ofdm.code_rate_LP = fec_tab[((ptr[6] + 1) >> 5) & 0x7]; + dmc.u.dmc_fe_ofdm.guard_interval = gtab[(ptr[6] >> 3) & 0x3]; + dmc.u.dmc_fe_ofdm.transmission_mode = ttab[(ptr[6] >> 1) & 0x3]; /* Debug */ tvhdebug("nit", " dvb-t freq %d bw %s cons %s hier %s code_rate %s:%s guard %s trans %s", frequency, - dvb_bw2str(dmc.dmc_fe_params.u.ofdm.bandwidth), - dvb_qam2str(dmc.dmc_fe_params.u.ofdm.constellation), - dvb_hier2str(dmc.dmc_fe_params.u.ofdm.hierarchy_information), - dvb_fec2str(dmc.dmc_fe_params.u.ofdm.code_rate_HP), - dvb_fec2str(dmc.dmc_fe_params.u.ofdm.code_rate_LP), - dvb_guard2str(dmc.dmc_fe_params.u.ofdm.guard_interval), - dvb_mode2str(dmc.dmc_fe_params.u.ofdm.transmission_mode)); + dvb_bw2str(dmc.u.dmc_fe_ofdm.bandwidth), + dvb_qam2str(dmc.dmc_fe_modulation), + dvb_hier2str(dmc.u.dmc_fe_ofdm.hierarchy_information), + dvb_fec2str(dmc.u.dmc_fe_ofdm.code_rate_HP), + dvb_fec2str(dmc.u.dmc_fe_ofdm.code_rate_LP), + dvb_guard2str(dmc.u.dmc_fe_ofdm.guard_interval), + dvb_mode2str(dmc.u.dmc_fe_ofdm.transmission_mode)); /* Create */ return mm->mm_network->mn_create_mux(mm, onid, tsid, &dmc); diff --git a/src/input/mpegts/dvb_support.c b/src/input/mpegts/dvb_support.c index acba753b..3f2392ed 100644 --- a/src/input/mpegts/dvb_support.c +++ b/src/input/mpegts/dvb_support.c @@ -380,439 +380,306 @@ dvb_convert_date(const uint8_t *dvb_buf) */ #if ENABLE_DVBAPI + #define dvb_str2val(p)\ const char *dvb_##p##2str (int p) { return val2str(p, p##tab); }\ int dvb_str2##p (const char *p) { return str2val(p, p##tab); } -const static struct strtab rollofftab[] = { -#if DVB_VER_ATLEAST(5,0) - { "35", ROLLOFF_35 }, - { "20", ROLLOFF_20 }, - { "25", ROLLOFF_25 }, - { "AUTO", ROLLOFF_AUTO } -#endif -}; -dvb_str2val(rolloff); +#define DVB_EOD -10 /* end-of-data */ + +static const char *dvb_common2str(int p) +{ + if (p == 0) + return "NONE"; + if (p == 1) + return "AUTO"; + return NULL; +} + +static int dvb_str2common(const char *p) +{ + if (strcmp(p, "NONE") == 0) + return 0; + if (strcmp(p, "AUTO") == 0) + return 1; + return DVB_EOD; +} + +static int dvb_verify(int val, int *table) +{ + while (*table != DVB_EOD) { + if (val == *table) + return val; + table++; + } + return 0; /* NONE */ +} + +const char *dvb_rolloff2str(int p) +{ + static char __thread buf[16]; + const char *res = dvb_common2str(p); + if (res) + return res; + sprintf(buf, "%02i", p / 10); + return buf; +} + +int dvb_str2rolloff(const char *p) +{ + static int rolloff_table[] = { + DVB_ROLLOFF_20, + DVB_ROLLOFF_25, + DVB_ROLLOFF_35, + DVB_EOD, + }; + int res = dvb_str2common(p); + if (res != DVB_EOD) + return res; + res = atoi(p) * 10; + return dvb_verify(atoi(p) * 10, rolloff_table); +} const static struct strtab delsystab[] = { -#if DVB_VER_ATLEAST(5,0) - { "UNDEFINED", SYS_UNDEFINED }, - { "DVBC_ANNEX_AC", SYS_DVBC_ANNEX_AC }, - { "DVBC_ANNEX_B", SYS_DVBC_ANNEX_B }, - { "DVBT", SYS_DVBT }, - { "DVBS", SYS_DVBS }, - { "DVBS2", SYS_DVBS2 }, - { "DVBH", SYS_DVBH }, - { "ISDBT", SYS_ISDBT }, - { "ISDBS", SYS_ISDBS }, - { "ISDBC", SYS_ISDBC }, - { "ATSC", SYS_ATSC }, - { "ATSCMH", SYS_ATSCMH }, - { "DMBTH", SYS_DMBTH }, - { "CMMB", SYS_CMMB }, - { "DAB", SYS_DAB }, -#endif -#if DVB_VER_ATLEAST(5,1) - { "DSS", SYS_DSS }, -#endif -#if DVB_VER_ATLEAST(5,4) - { "DVBT2", SYS_DVBT2 }, - { "TURBO", SYS_TURBO } -#endif + { "NONE", DVB_SYS_NONE }, + { "DVBC_ANNEX_A", DVB_SYS_DVBC_ANNEX_A }, + { "DVBC_ANNEX_B", DVB_SYS_DVBC_ANNEX_B }, + { "DVBC_ANNEX_C", DVB_SYS_DVBC_ANNEX_C }, + { "DVBC_ANNEX_AC",DVB_SYS_DVBC_ANNEX_A }, /* for compatibility */ + { "DVBT", DVB_SYS_DVBT }, + { "DVBT2", DVB_SYS_DVBT2 }, + { "DVBS", DVB_SYS_DVBS }, + { "DVBS2", DVB_SYS_DVBS2 }, + { "DVBH", DVB_SYS_DVBH }, + { "ISDBT", DVB_SYS_ISDBT }, + { "ISDBS", DVB_SYS_ISDBS }, + { "ISDBC", DVB_SYS_ISDBC }, + { "ATSC", DVB_SYS_ATSC }, + { "ATSCMH", DVB_SYS_ATSCMH }, + { "DTMB", DVB_SYS_DTMB }, + { "DMBTH", DVB_SYS_DTMB }, /* for compatibility */ + { "CMMB", DVB_SYS_CMMB }, + { "DAB", DVB_SYS_DAB }, + { "DSS", DVB_SYS_DSS }, + { "TURBO", DVB_SYS_TURBO } }; dvb_str2val(delsys); -#if DVB_VER_ATLEAST(5,10) int -dvb_delsys2type ( fe_delivery_system_t delsys ) +dvb_delsys2type ( dvb_fe_delivery_system_t delsys ) { switch (delsys) { - case SYS_DVBC_ANNEX_AC: - case SYS_DVBC_ANNEX_B: - case SYS_ISDBC: - return FE_QAM; - case SYS_DVBT: - case SYS_DVBT2: - case SYS_TURBO: - case SYS_ISDBT: - return FE_OFDM; - case SYS_DVBS: - case SYS_DVBS2: - case SYS_ISDBS: - return FE_QPSK; - case SYS_ATSC: - case SYS_ATSCMH: - return FE_ATSC; + case DVB_SYS_DVBC_ANNEX_A: + case DVB_SYS_DVBC_ANNEX_B: + case DVB_SYS_DVBC_ANNEX_C: + case DVB_SYS_ISDBC: + return DVB_TYPE_C; + case DVB_SYS_DVBT: + case DVB_SYS_DVBT2: + case DVB_SYS_TURBO: + case DVB_SYS_ISDBT: + return DVB_TYPE_T; + case DVB_SYS_DVBS: + case DVB_SYS_DVBS2: + case DVB_SYS_ISDBS: + return DVB_TYPE_S; + case DVB_SYS_ATSC: + case DVB_SYS_ATSCMH: + return DVB_TYPE_ATSC; default: - return -1; + return DVB_TYPE_NONE; } } -#endif -const static struct strtab fectab[] = { - { "NONE", FEC_NONE }, - { "1/2", FEC_1_2 }, - { "2/3", FEC_2_3 }, - { "3/4", FEC_3_4 }, - { "4/5", FEC_4_5 }, - { "5/6", FEC_5_6 }, - { "6/7", FEC_6_7 }, - { "7/8", FEC_7_8 }, - { "8/9", FEC_8_9 }, - { "AUTO", FEC_AUTO }, -#if DVB_VER_ATLEAST(5,0) - { "3/5", FEC_3_5 }, - { "9/10", FEC_9_10 } -#endif -}; -dvb_str2val(fec); +const char *dvb_fec2str(int p) +{ + static char __thread buf[16]; + const char *res = dvb_common2str(p); + if (res) + return res; + sprintf(buf, "%i/%i", p / 100, p % 100); + return buf; +} + +int dvb_str2fec(const char *p) +{ + static int fec_table[] = { + DVB_FEC_1_2, + DVB_FEC_1_3, + DVB_FEC_1_5, + DVB_FEC_2_3, + DVB_FEC_2_5, + DVB_FEC_2_9, + DVB_FEC_3_4, + DVB_FEC_3_5, + DVB_FEC_4_5, + DVB_FEC_4_15, + DVB_FEC_5_6, + DVB_FEC_5_9, + DVB_FEC_6_7, + DVB_FEC_7_8, + DVB_FEC_7_9, + DVB_FEC_7_15, + DVB_FEC_8_9, + DVB_FEC_8_15, + DVB_FEC_9_10, + DVB_FEC_9_20, + DVB_FEC_11_15, + DVB_FEC_11_20, + DVB_FEC_11_45, + DVB_FEC_13_18, + DVB_FEC_13_45, + DVB_FEC_14_45, + DVB_FEC_23_36, + DVB_FEC_25_36, + DVB_FEC_26_45, + DVB_FEC_28_45, + DVB_FEC_29_45, + DVB_FEC_31_45, + DVB_FEC_32_45, + DVB_FEC_77_90, + DVB_EOD, + }; + int res = dvb_str2common(p); + int hi, lo; + if (res != DVB_EOD) + return res; + hi = lo = 0; + sscanf(p, "%i/%i", &hi, &lo); + return dvb_verify(hi * 100 + lo, fec_table); +} const static struct strtab qamtab[] = { - { "QPSK", QPSK }, - { "QAM16", QAM_16 }, - { "QAM32", QAM_32 }, - { "QAM64", QAM_64 }, - { "QAM128", QAM_128 }, - { "QAM256", QAM_256 }, - { "AUTO", QAM_AUTO }, - { "8VSB", VSB_8 }, - { "16VSB", VSB_16 }, -#if DVB_VER_ATLEAST(5,0) - { "DQPSK", DQPSK }, -#endif -#if DVB_VER_ATLEAST(5,1) - { "8PSK", PSK_8 }, - { "16APSK", APSK_16 }, - { "32APSK", APSK_32 }, -#endif + { "NONE", DVB_MOD_NONE }, + { "AUTO", DVB_MOD_AUTO }, + { "QPSK", DVB_MOD_QPSK }, + { "QAM4NR", DVB_MOD_QAM_4_NR }, + { "QAM-AUTO", DVB_MOD_QAM_AUTO }, + { "QAM16", DVB_MOD_QAM_16 }, + { "QAM32", DVB_MOD_QAM_32 }, + { "QAM64", DVB_MOD_QAM_64 }, + { "QAM128", DVB_MOD_QAM_128 }, + { "QAM256", DVB_MOD_QAM_256 }, + { "8VSB", DVB_MOD_VSB_8 }, + { "16VSB", DVB_MOD_VSB_16 }, + { "8PSK", DVB_MOD_PSK_8 }, + { "DQPSK", DVB_MOD_DQPSK }, + { "BPSK", DVB_MOD_BPSK }, + { "BPSK-S", DVB_MOD_BPSK_S }, + { "16APSK", DVB_MOD_APSK_16 }, + { "32APSK", DVB_MOD_APSK_32 }, + { "64APSK", DVB_MOD_APSK_64 }, + { "128APSK", DVB_MOD_APSK_128 }, + { "256APSK", DVB_MOD_APSK_256 }, + { "8APSK-L", DVB_MOD_APSK_8_L }, + { "16APSK-L", DVB_MOD_APSK_16_L }, + { "32APSK-L", DVB_MOD_APSK_32_L }, + { "64APSK-L", DVB_MOD_APSK_64_L }, + { "128APSK-L", DVB_MOD_APSK_128_L }, + { "256APSK-L", DVB_MOD_APSK_256_L }, }; dvb_str2val(qam); -const static struct strtab bwtab[] = { - { "8MHz", BANDWIDTH_8_MHZ }, - { "7MHz", BANDWIDTH_7_MHZ }, - { "6MHz", BANDWIDTH_6_MHZ }, - { "AUTO", BANDWIDTH_AUTO }, -#if DVB_VER_ATLEAST(5,3) - { "5MHz", BANDWIDTH_5_MHZ }, - { "10MHz", BANDWIDTH_10_MHZ }, - { "1712kHz", BANDWIDTH_1_712_MHZ}, -#endif -}; -dvb_str2val(bw); +const char *dvb_bw2str(int p) +{ + static char __thread buf[16]; + const char *res = dvb_common2str(p); + if (res) + return res; + if (p % 1000) + sprintf(buf, "%i.%iMHz", p / 1000, p % 1000); + else + sprintf(buf, "%iMHz", p / 1000); + return buf; +} + +int dvb_str2bw(const char *p) +{ + static int bw_table[] = { + DVB_BANDWIDTH_1_712_MHZ, + DVB_BANDWIDTH_5_MHZ, + DVB_BANDWIDTH_6_MHZ, + DVB_BANDWIDTH_7_MHZ, + DVB_BANDWIDTH_8_MHZ, + DVB_BANDWIDTH_10_MHZ, + DVB_EOD, + }; + int len, res = dvb_str2common(p); + int hi, lo; + if (res != DVB_EOD) + return res; + len = strlen(p); + hi = lo = 0; + sscanf(p, "%i.%i", &hi, &lo); + if (len > 3 && strcmp(&p[len-3], "MHz") == 0) + hi = hi * 1000 + lo; + return dvb_verify(hi, bw_table); +} const static struct strtab modetab[] = { - { "2k", TRANSMISSION_MODE_2K }, - { "8k", TRANSMISSION_MODE_8K }, - { "AUTO", TRANSMISSION_MODE_AUTO }, -#if DVB_VER_ATLEAST(5,1) - { "4k", TRANSMISSION_MODE_4K }, -#endif -#if DVB_VER_ATLEAST(5,3) - { "1k", TRANSMISSION_MODE_1K }, - { "2k", TRANSMISSION_MODE_16K }, - { "32k", TRANSMISSION_MODE_32K }, -#endif + { "NONE", DVB_TRANSMISSION_MODE_NONE }, + { "AUTO", DVB_TRANSMISSION_MODE_AUTO }, + { "1k", DVB_TRANSMISSION_MODE_1K }, + { "2k", DVB_TRANSMISSION_MODE_2K }, + { "8k", DVB_TRANSMISSION_MODE_8K }, + { "4k", DVB_TRANSMISSION_MODE_4K }, + { "16k", DVB_TRANSMISSION_MODE_16K }, + { "32k", DVB_TRANSMISSION_MODE_32K }, + { "C1", DVB_TRANSMISSION_MODE_C1 }, + { "C3780", DVB_TRANSMISSION_MODE_C3780 }, }; dvb_str2val(mode); const static struct strtab guardtab[] = { - { "1/32", GUARD_INTERVAL_1_32 }, - { "1/16", GUARD_INTERVAL_1_16 }, - { "1/8", GUARD_INTERVAL_1_8 }, - { "1/4", GUARD_INTERVAL_1_4 }, - { "AUTO", GUARD_INTERVAL_AUTO }, -#if DVB_VER_ATLEAST(5,3) - { "1/128", GUARD_INTERVAL_1_128 }, - { "19/128", GUARD_INTERVAL_19_128 }, - { "19/256", GUARD_INTERVAL_19_256}, -#endif + { "NONE", DVB_GUARD_INTERVAL_NONE }, + { "AUTO", DVB_GUARD_INTERVAL_AUTO }, + { "1/4", DVB_GUARD_INTERVAL_1_4 }, + { "1/8", DVB_GUARD_INTERVAL_1_8 }, + { "1/32", DVB_GUARD_INTERVAL_1_32 }, + { "1/16", DVB_GUARD_INTERVAL_1_16 }, + { "1/128", DVB_GUARD_INTERVAL_1_128 }, + { "19/128", DVB_GUARD_INTERVAL_19_128 }, + { "19/256", DVB_GUARD_INTERVAL_19_256 }, + { "PN420", DVB_GUARD_INTERVAL_PN420 }, + { "PN595", DVB_GUARD_INTERVAL_PN595 }, + { "PN945", DVB_GUARD_INTERVAL_PN945 }, }; dvb_str2val(guard); const static struct strtab hiertab[] = { - { "NONE", HIERARCHY_NONE }, - { "1", HIERARCHY_1 }, - { "2", HIERARCHY_2 }, - { "4", HIERARCHY_4 }, - { "AUTO", HIERARCHY_AUTO } + { "NONE", DVB_HIERARCHY_NONE }, + { "AUTO", DVB_HIERARCHY_AUTO }, + { "1", DVB_HIERARCHY_1 }, + { "2", DVB_HIERARCHY_2 }, + { "4", DVB_HIERARCHY_4 }, }; dvb_str2val(hier); const static struct strtab poltab[] = { - { "V", POLARISATION_VERTICAL }, - { "H", POLARISATION_HORIZONTAL }, - { "L", POLARISATION_CIRCULAR_LEFT }, - { "R", POLARISATION_CIRCULAR_RIGHT }, + { "V", DVB_POLARISATION_VERTICAL }, + { "H", DVB_POLARISATION_HORIZONTAL }, + { "L", DVB_POLARISATION_CIRCULAR_LEFT }, + { "R", DVB_POLARISATION_CIRCULAR_RIGHT }, }; dvb_str2val(pol); const static struct strtab typetab[] = { - {"DVB-T", FE_OFDM}, - {"DVB-C", FE_QAM}, - {"DVB-S", FE_QPSK}, - {"ATSC", FE_ATSC}, + {"DVB-T", DVB_TYPE_T}, + {"DVB-C", DVB_TYPE_C}, + {"DVB-S", DVB_TYPE_S}, + {"ATSC", DVB_TYPE_ATSC}, }; dvb_str2val(type); const static struct strtab pilottab[] = { -#if DVB_VER_ATLEAST(5,0) - {"AUTO", PILOT_AUTO}, - {"ON", PILOT_ON}, - {"OFF", PILOT_OFF} -#endif + {"NONE", DVB_PILOT_AUTO}, + {"AUTO", DVB_PILOT_AUTO}, + {"ON", DVB_PILOT_ON}, + {"OFF", DVB_PILOT_OFF} }; dvb_str2val(pilot); #undef dvb_str2val -/* - * Process mux conf - */ -static const char * -dvb_mux_conf_load_dvbt ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - int r; - const char *s; - - s = htsmsg_get_str(m, "bandwidth"); - if(s == NULL || (r = dvb_str2bw(s)) < 0) - return "Invalid bandwidth"; - dmc->dmc_fe_params.u.ofdm.bandwidth = r; - - s = htsmsg_get_str(m, "constellation"); - if(s == NULL || (r = dvb_str2qam(s)) < 0) - return "Invalid QAM constellation"; - dmc->dmc_fe_params.u.ofdm.constellation = r; - - s = htsmsg_get_str(m, "transmission_mode"); - if(s == NULL || (r = dvb_str2mode(s)) < 0) - return "Invalid transmission mode"; - dmc->dmc_fe_params.u.ofdm.transmission_mode = r; - - s = htsmsg_get_str(m, "guard_interval"); - if(s == NULL || (r = dvb_str2guard(s)) < 0) - return "Invalid guard interval"; - dmc->dmc_fe_params.u.ofdm.guard_interval = r; - - s = htsmsg_get_str(m, "hierarchy"); - if(s == NULL || (r = dvb_str2hier(s)) < 0) - return "Invalid heirarchy information"; - dmc->dmc_fe_params.u.ofdm.hierarchy_information = r; - - s = htsmsg_get_str(m, "fec_hi"); - if(s == NULL || (r = dvb_str2fec(s)) < 0) - return "Invalid hi-FEC"; - dmc->dmc_fe_params.u.ofdm.code_rate_HP = r; - - s = htsmsg_get_str(m, "fec_lo"); - if(s == NULL || (r = dvb_str2fec(s)) < 0) - return "Invalid lo-FEC"; - dmc->dmc_fe_params.u.ofdm.code_rate_LP = r; - - return NULL; -} - -static const char * -dvb_mux_conf_load_dvbc ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - int r; - const char *s; - - htsmsg_get_u32(m, "symbol_rate", &dmc->dmc_fe_params.u.qam.symbol_rate); - if(dmc->dmc_fe_params.u.qam.symbol_rate == 0) - return "Invalid symbol rate"; - - s = htsmsg_get_str(m, "constellation"); - if(s == NULL || (r = dvb_str2qam(s)) < 0) - return "Invalid QAM constellation"; - dmc->dmc_fe_params.u.qam.modulation = r; - - s = htsmsg_get_str(m, "fec"); - if(s == NULL || (r = dvb_str2fec(s)) < 0) - return "Invalid FEC"; - dmc->dmc_fe_params.u.qam.fec_inner = r; - - return NULL; -} - -static const char * -dvb_mux_conf_load_dvbs ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - int r; - const char *s; - - htsmsg_get_u32(m, "symbol_rate", &dmc->dmc_fe_params.u.qpsk.symbol_rate); - if(dmc->dmc_fe_params.u.qpsk.symbol_rate == 0) - return "Invalid symbol rate"; - - s = htsmsg_get_str(m, "fec"); - if(s == NULL || (r = dvb_str2fec(s)) < 0) - return "Invalid FEC"; - dmc->dmc_fe_params.u.qpsk.fec_inner = r; - - s = htsmsg_get_str(m, "polarisation"); - if(s == NULL || (r = dvb_str2pol(s)) < 0) - return "Invalid polarisation"; - dmc->dmc_fe_polarisation = r; - -#if DVB_VER_ATLEAST(5,0) - s = htsmsg_get_str(m, "modulation"); - if(s == NULL || (r = dvb_str2qam(s)) < 0) { - r = QPSK; - tvhlog(LOG_INFO, "dvb", "no modulation, using default QPSK"); - } - dmc->dmc_fe_modulation = r; - - s = htsmsg_get_str(m, "rolloff"); - if(s == NULL || (r = dvb_str2rolloff(s)) < 0) { - r = ROLLOFF_35; - tvhlog(LOG_INFO, "dvb", "no rolloff, using default ROLLOFF_35"); - } - dmc->dmc_fe_rolloff = r; - - // TODO: pilot mode -#endif - return NULL; -} - -static const char * -dvb_mux_conf_load_atsc ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - int r; - const char *s; - s = htsmsg_get_str(m, "constellation"); - if(s == NULL || (r = dvb_str2qam(s)) < 0) - return "Invalid VSB constellation"; - dmc->dmc_fe_params.u.vsb.modulation = r; - return NULL; -} - -const char * -dvb_mux_conf_load ( fe_type_t type, dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ -#if DVB_VER_ATLEAST(5,0) - int r; - const char *str; -#endif - uint32_t u32; - - memset(dmc, 0, sizeof(dvb_mux_conf_t)); - dmc->dmc_fe_params.inversion = INVERSION_AUTO; - - /* Delivery system */ -#if DVB_VER_ATLEAST(5,0) - str = htsmsg_get_str(m, "delsys"); - if (!str || (r = dvb_str2delsys(str)) < 0) { - if (type == FE_OFDM) r = SYS_DVBT; - else if (type == FE_QAM) r = SYS_DVBC_ANNEX_AC; - else if (type == FE_QPSK) r = SYS_DVBS; - else if (type == FE_ATSC) r = SYS_ATSC; - else - return "Invalid FE type"; - tvhlog(LOG_INFO, "dvb", "no delsys, using default %s", dvb_delsys2str(r)); - } - dmc->dmc_fe_delsys = r; -#endif - - /* Frequency */ - if (htsmsg_get_u32(m, "frequency", &u32)) - return "Invalid frequency"; - dmc->dmc_fe_params.frequency = u32; - - /* Type specific */ - if (type == FE_OFDM) return dvb_mux_conf_load_dvbt(dmc, m); - else if (type == FE_QAM) return dvb_mux_conf_load_dvbc(dmc, m); - else if (type == FE_QPSK) return dvb_mux_conf_load_dvbs(dmc, m); - else if (type == FE_ATSC) return dvb_mux_conf_load_atsc(dmc, m); - else - return "Invalid FE type"; -} - -static void -dvb_mux_conf_save_dvbt ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - struct dvb_ofdm_parameters *ofdm = &dmc->dmc_fe_params.u.ofdm; - htsmsg_add_str(m, "bandwidth", - dvb_bw2str(ofdm->bandwidth)); - htsmsg_add_str(m, "constellation", - dvb_qam2str(ofdm->constellation)); - htsmsg_add_str(m, "transmission_mode", - dvb_mode2str(ofdm->transmission_mode)); - htsmsg_add_str(m, "guard_interval", - dvb_guard2str(ofdm->guard_interval)); - htsmsg_add_str(m, "hierarchy", - dvb_hier2str(ofdm->hierarchy_information)); - htsmsg_add_str(m, "fec_hi", - dvb_fec2str(ofdm->code_rate_HP)); - htsmsg_add_str(m, "fec_lo", - dvb_fec2str(ofdm->code_rate_LP)); -} - -static void -dvb_mux_conf_save_dvbc ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - struct dvb_qam_parameters *qam = &dmc->dmc_fe_params.u.qam; - htsmsg_add_u32(m, "symbol_rate", qam->symbol_rate); - htsmsg_add_str(m, "constellation", dvb_qam2str(qam->modulation)); - htsmsg_add_str(m, "fec", dvb_fec2str(qam->fec_inner)); -} - -static void -dvb_mux_conf_save_dvbs ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - struct dvb_qpsk_parameters *qpsk = &dmc->dmc_fe_params.u.qpsk; - htsmsg_add_u32(m, "symbol_rate", qpsk->symbol_rate); - htsmsg_add_str(m, "fec", dvb_fec2str(qpsk->fec_inner)); - htsmsg_add_str(m, "polarisation", dvb_pol2str(dmc->dmc_fe_polarisation)); -#if DVB_VER_ATLEAST(5,0) - htsmsg_add_str(m, "modulation", dvb_qam2str(dmc->dmc_fe_modulation)); - htsmsg_add_str(m, "rolloff", dvb_rolloff2str(dmc->dmc_fe_rolloff)); -#endif -} - -static void -dvb_mux_conf_save_atsc ( dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - htsmsg_add_str(m, "constellation", - dvb_qam2str(dmc->dmc_fe_params.u.vsb.modulation)); -} - -void -dvb_mux_conf_save ( fe_type_t type, dvb_mux_conf_t *dmc, htsmsg_t *m ) -{ - htsmsg_add_u32(m, "frequency", dmc->dmc_fe_params.frequency); -#if DVB_VER_ATLEAST(5,0) - htsmsg_add_str(m, "delsys", dvb_delsys2str(dmc->dmc_fe_delsys)); -#endif - if (type == FE_OFDM) dvb_mux_conf_save_dvbt(dmc, m); - else if (type == FE_QAM) dvb_mux_conf_save_dvbc(dmc, m); - else if (type == FE_QPSK) dvb_mux_conf_save_dvbs(dmc, m); - else if (type == FE_ATSC) dvb_mux_conf_save_atsc(dmc, m); -} - -int -dvb_bandwidth ( fe_bandwidth_t bw ) -{ - switch (bw) { -#if DVB_VER_ATLEAST(5,3) - case BANDWIDTH_10_MHZ: - return 10000000; - case BANDWIDTH_5_MHZ: - return 5000000; - case BANDWIDTH_1_712_MHZ: - return 1712000; -#endif - case BANDWIDTH_8_MHZ: - return 8000000; - case BANDWIDTH_7_MHZ: - return 7000000; - case BANDWIDTH_6_MHZ: - return 6000000; - default: - return 0; - } -} - #endif /* ENABLE_DVBAPI */ /** diff --git a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c index 9e8ed91b..7a93ceae 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c @@ -33,6 +33,8 @@ #include #include +#include + #define FE_PATH "%s/frontend%d" #define DVR_PATH "%s/dvr%d" #define DMX_PATH "%s/demux%d" @@ -155,6 +157,26 @@ linuxdvb_adapter_create return la; } +/* + * + */ +static dvb_fe_type_t +linux_dvb_get_type(int linux_type) +{ + switch (linux_type) { + case FE_QPSK: + return DVB_TYPE_S; + case FE_QAM: + return DVB_TYPE_C; + case FE_OFDM: + return DVB_TYPE_T; + case FE_ATSC: + return DVB_TYPE_ATSC; + default: + return DVB_TYPE_NONE; + } +} + /* * Add adapter by path */ @@ -170,8 +192,9 @@ linuxdvb_adapter_add ( const char *path ) uint8_t uuidbin[20]; htsmsg_t *conf, *feconf; int save = 0; + dvb_fe_type_t type; #if DVB_VER_ATLEAST(5,10) - int fetypes[4] = { 0 }; + dvb_fe_type_t fetypes[DVB_TYPE_LAST+1] = { 0 }; struct dtv_property cmd = { .cmd = DTV_ENUM_DELSYS }; @@ -242,6 +265,11 @@ linuxdvb_adapter_add ( const char *path ) tvhlog(LOG_ERR, "linuxdvb", "unable to query %s", fe_path); continue; } + type = linux_dvb_get_type(dfi.type); + if (type == DVB_TYPE_NONE) { + tvhlog(LOG_ERR, "linuxdvb", "unable to determine FE type %s - %i", fe_path, dfi.type); + continue; + } /* DVR/DMX (bit of a guess) */ snprintf(dmx_path, sizeof(dmx_path), DMX_PATH, path, i); @@ -283,22 +311,23 @@ linuxdvb_adapter_add ( const char *path ) } /* Create frontend */ - linuxdvb_frontend_create(feconf, la, i, fe_path, dmx_path, dvr_path, &dfi); + linuxdvb_frontend_create(feconf, la, i, fe_path, dmx_path, dvr_path, type, dfi.name); #if DVB_VER_ATLEAST(5,10) - fetypes[dfi.type] = 1; + fetypes[type] = 1; for (j = 0; j < cmd.u.buffer.len; j++) { /* Invalid */ - if ((dfi.type = dvb_delsys2type(cmd.u.buffer.data[j])) == -1) + if ((type = dvb_delsys2type(cmd.u.buffer.data[j])) == DVB_TYPE_NONE) continue; /* Couldn't find */ - if (fetypes[dfi.type]) + if (fetypes[type]) continue; /* Create */ - linuxdvb_frontend_create(feconf, la, i, fe_path, dmx_path, dvr_path, &dfi); - fetypes[dfi.type] = 1; + linuxdvb_frontend_create(feconf, la, i, fe_path, dmx_path, dvr_path, + type, dfi.name); + fetypes[type] = 1; } #endif pthread_mutex_unlock(&global_lock); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c index 221c7677..ce6fe9a1 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c @@ -30,6 +30,8 @@ #include #include +#include + /* ************************************************************************** * Static definition * *************************************************************************/ diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index d9b9ca87..262c2c86 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -31,6 +31,8 @@ #include #include #include +#include + static void linuxdvb_frontend_monitor ( void *aux ); @@ -331,13 +333,13 @@ linuxdvb_frontend_network_list ( mpegts_input_t *mi ) extern const idclass_t linuxdvb_network_dvbs_class; extern const idclass_t linuxdvb_network_atsc_class; - if (lfe->lfe_info.type == FE_OFDM) + if (lfe->lfe_type == DVB_TYPE_T) idc = &linuxdvb_network_dvbt_class; - else if (lfe->lfe_info.type == FE_QAM) + else if (lfe->lfe_type == DVB_TYPE_C) idc = &linuxdvb_network_dvbc_class; - else if (lfe->lfe_info.type == FE_QPSK) + else if (lfe->lfe_type == DVB_TYPE_S) idc = &linuxdvb_network_dvbs_class; - else if (lfe->lfe_info.type == FE_ATSC) + else if (lfe->lfe_type == DVB_TYPE_ATSC) idc = &linuxdvb_network_atsc_class; else return NULL; @@ -358,8 +360,8 @@ linuxdvb_frontend_default_tables psi_tables_default(mm); /* ATSC */ - if (lfe->lfe_info.type == FE_ATSC) { - if (lm->lm_tuning.dmc_fe_params.u.vsb.modulation == VSB_8) + if (lfe->lfe_type == DVB_TYPE_ATSC) { + if (lm->lm_tuning.dmc_fe_modulation == DVB_MOD_VSB_8) psi_tables_atsc_t(mm); else psi_tables_atsc_c(mm); @@ -666,15 +668,180 @@ linuxdvb_frontend_input_thread ( void *aux ) * Tuning * *************************************************************************/ +typedef struct tvh2linuxdvb { + int t; ///< TVH internal value + int l; ///< LinuxDVB API value +} tvh2linuxdvb_t; + +#define TABLE_EOD -1 + +static int +translate_from_table + (const char *prefix, int src, tvh2linuxdvb_t *tbl, int defval) +{ + while (tbl->t >= 0) { + if (tbl->t == src) + return tbl->l; + tbl++; + } + tvhtrace("linuxdvb", "%s - cannot translate %d", prefix, src); + return defval; +} + +#define TOSTR(s) #s +#define TR(s, t, d) translate_from_table(TOSTR(s), dmc->dmc_fe_##s , t, d) +#define TRU(s, t, d) translate_from_table(TOSTR(s), dmc->u.dmc_fe_##s , t, d) + int linuxdvb_frontend_tune0 ( linuxdvb_frontend_t *lfe, mpegts_mux_instance_t *mmi, uint32_t freq ) { + static tvh2linuxdvb_t inv_tbl[] = { + { .t = DVB_INVERSION_AUTO, .l = INVERSION_AUTO }, + { .t = DVB_INVERSION_OFF, .l = INVERSION_OFF }, + { .t = DVB_INVERSION_ON, .l = INVERSION_ON }, + { .t = TABLE_EOD } + }; + static tvh2linuxdvb_t bw_tbl[] = { + { .t = DVB_BANDWIDTH_AUTO, .l = BANDWIDTH_AUTO }, +#if DVB_VER_ATLEAST(5,3) + { .t = DVB_BANDWIDTH_1_712_MHZ, .l = BANDWIDTH_1_712_MHZ }, + { .t = DVB_BANDWIDTH_5_MHZ, .l = BANDWIDTH_5_MHZ }, +#endif + { .t = DVB_BANDWIDTH_6_MHZ, .l = BANDWIDTH_6_MHZ }, + { .t = DVB_BANDWIDTH_7_MHZ, .l = BANDWIDTH_7_MHZ }, + { .t = DVB_BANDWIDTH_8_MHZ, .l = BANDWIDTH_8_MHZ }, +#if DVB_VER_ATLEAST(5,3) + { .t = DVB_BANDWIDTH_10_MHZ, .l = BANDWIDTH_10_MHZ }, +#endif + { .t = TABLE_EOD } + }; + static tvh2linuxdvb_t fec_tbl[] = { + { .t = DVB_FEC_NONE, .l = FEC_NONE }, + { .t = DVB_FEC_AUTO, .l = FEC_AUTO }, + { .t = DVB_FEC_1_2, .l = FEC_1_2 }, + { .t = DVB_FEC_2_3, .l = FEC_2_3 }, + { .t = DVB_FEC_2_5, .l = FEC_2_5 }, + { .t = DVB_FEC_3_4, .l = FEC_3_4 }, +#if DVB_VER_ATLEAST(5,0) + { .t = DVB_FEC_3_5, .l = FEC_3_5 }, +#endif + { .t = DVB_FEC_4_5, .l = FEC_4_5 }, + { .t = DVB_FEC_5_6, .l = FEC_5_6 }, + { .t = DVB_FEC_6_7, .l = FEC_6_7 }, + { .t = DVB_FEC_7_8, .l = FEC_7_8 }, + { .t = DVB_FEC_8_9, .l = FEC_8_9 }, +#if DVB_VER_ATLEAST(5,0) + { .t = DVB_FEC_9_10, .l = FEC_9_10 }, +#endif + { .t = TABLE_EOD } + }; + static tvh2linuxdvb_t mod_tbl[] = { + { .t = DVB_MOD_AUTO, .l = QAM_AUTO }, + { .t = DVB_MOD_QPSK, .l = QPSK }, + { .t = DVB_MOD_QAM_16, .l = QAM_16 }, + { .t = DVB_MOD_QAM_32, .l = QAM_32 }, + { .t = DVB_MOD_QAM_64, .l = QAM_64 }, + { .t = DVB_MOD_QAM_128, .l = QAM_128 }, + { .t = DVB_MOD_QAM_256, .l = QAM_256 }, + { .t = DVB_MOD_QAM_AUTO, .l = QAM_AUTO }, + { .t = DVB_MOD_VSB_8, .l = VSB_8 }, + { .t = DVB_MOD_VSB_16, .l = VSB_16 }, +#if DVB_VER_ATLEAST(5,1) + { .t = DVB_MOD_PSK_8, .l = PSK_8, }, + { .t = DVB_MOD_APSK_16, .l = APSK_16 }, + { .t = DVB_MOD_APSK_32, .l = APSK_32 }, +#endif +#if DVB_VER_ATLEAST(5,0) + { .t = DVB_MOD_DQPSK, .l = DQPSK }, +#endif +#if DVB_VER_ATLEAST(5,3) + { .t = DVB_MOD_QAM_4_NR, .l = QAM_4_NR }, +#endif + { .t = TABLE_EOD } + }; + static tvh2linuxdvb_t trans_tbl[] = { + { .t = DVB_TRANSMISSION_MODE_AUTO, .l = TRANSMISSION_MODE_AUTO }, +#if DVB_VER_ATLEAST(5,3) + { .t = DVB_TRANSMISSION_MODE_1K, .l = TRANSMISSION_MODE_1K }, +#endif + { .t = DVB_TRANSMISSION_MODE_2K, .l = TRANSMISSION_MODE_2K }, +#if DVB_VER_ATLEAST(5,1) + { .t = DVB_TRANSMISSION_MODE_4K, .l = TRANSMISSION_MODE_4K }, +#endif + { .t = DVB_TRANSMISSION_MODE_8K, .l = TRANSMISSION_MODE_8K }, +#if DVB_VER_ATLEAST(5,3) + { .t = DVB_TRANSMISSION_MODE_16K, .l = TRANSMISSION_MODE_16K }, + { .t = DVB_TRANSMISSION_MODE_32K, .l = TRANSMISSION_MODE_32K }, + { .t = DVB_TRANSMISSION_MODE_C1, .l = TRANSMISSION_MODE_C1 }, + { .t = DVB_TRANSMISSION_MODE_C3780, .l = TRANSMISSION_MODE_C3780 }, +#endif + { .t = TABLE_EOD } + }; + static tvh2linuxdvb_t guard_tbl[] = { + { .t = DVB_GUARD_INTERVAL_AUTO, .l = GUARD_INTERVAL_AUTO }, + { .t = DVB_GUARD_INTERVAL_1_4, .l = GUARD_INTERVAL_1_4 }, + { .t = DVB_GUARD_INTERVAL_1_8, .l = GUARD_INTERVAL_1_8 }, + { .t = DVB_GUARD_INTERVAL_1_16, .l = GUARD_INTERVAL_1_16 }, + { .t = DVB_GUARD_INTERVAL_1_32, .l = GUARD_INTERVAL_1_32 }, +#if DVB_VER_ATLEAST(5,3) + { .t = DVB_GUARD_INTERVAL_1_128, .l = GUARD_INTERVAL_1_128 }, + { .t = DVB_GUARD_INTERVAL_19_128, .l = GUARD_INTERVAL_19_128 }, + { .t = DVB_GUARD_INTERVAL_19_256, .l = GUARD_INTERVAL_19_256 }, +#endif + { .t = TABLE_EOD } + }; + static tvh2linuxdvb_t h_tbl[] = { + { .t = DVB_HIERARCHY_NONE, .l = HIERARCHY_NONE }, + { .t = DVB_HIERARCHY_AUTO, .l = HIERARCHY_AUTO }, + { .t = DVB_HIERARCHY_1, .l = HIERARCHY_1 }, + { .t = DVB_HIERARCHY_2, .l = HIERARCHY_2 }, + { .t = DVB_HIERARCHY_4, .l = HIERARCHY_4 }, + { .t = TABLE_EOD } + }; +#if DVB_API_VERSION >= 5 + static tvh2linuxdvb_t delsys_tbl[] = { + { .t = DVB_SYS_DVBC_ANNEX_A, .l = SYS_DVBC_ANNEX_A }, + { .t = DVB_SYS_DVBC_ANNEX_B, .l = SYS_DVBC_ANNEX_B }, + { .t = DVB_SYS_DVBC_ANNEX_C, .l = SYS_DVBC_ANNEX_C }, + { .t = DVB_SYS_DVBT, .l = SYS_DVBT }, + { .t = DVB_SYS_DVBT2, .l = SYS_DVBT2 }, + { .t = DVB_SYS_DVBS, .l = SYS_DVBS }, + { .t = DVB_SYS_DVBS2, .l = SYS_DVBS2 }, + { .t = DVB_SYS_DVBH, .l = SYS_DVBH }, + { .t = DVB_SYS_DSS, .l = SYS_DSS }, + { .t = DVB_SYS_ISDBT, .l = SYS_ISDBT }, + { .t = DVB_SYS_ISDBS, .l = SYS_ISDBS }, + { .t = DVB_SYS_ISDBC, .l = SYS_ISDBC }, + { .t = DVB_SYS_ATSC, .l = SYS_ATSC }, + { .t = DVB_SYS_ATSCMH, .l = SYS_ATSCMH }, + { .t = DVB_SYS_DTMB, .l = SYS_DTMB }, + { .t = DVB_SYS_CMMB, .l = SYS_CMMB }, + { .t = DVB_SYS_DAB, .l = SYS_DAB }, + { .t = DVB_SYS_TURBO, .l = SYS_TURBO }, + { .t = TABLE_EOD } + }; + static tvh2linuxdvb_t pilot_tbl[] = { + { .t = DVB_PILOT_AUTO, .l = PILOT_AUTO }, + { .t = DVB_PILOT_ON, .l = PILOT_ON }, + { .t = DVB_PILOT_OFF, .l = PILOT_OFF }, + { .l = TABLE_EOD } + }; + static tvh2linuxdvb_t rolloff_tbl[] = { + { .t = DVB_HIERARCHY_AUTO, .l = ROLLOFF_AUTO }, + { .t = DVB_ROLLOFF_20, .l = ROLLOFF_20 }, + { .t = DVB_ROLLOFF_25, .l = ROLLOFF_25 }, + { .t = DVB_ROLLOFF_35, .l = ROLLOFF_35 }, + { .t = TABLE_EOD }, + }; +#endif int r; struct dvb_frontend_event ev; char buf1[256]; mpegts_mux_instance_t *cur = LIST_FIRST(&lfe->mi_mux_active); linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; + dvb_mux_conf_t *dmc; + struct dvb_frontend_parameters p; // Not sure if this is right place? /* Currently active */ @@ -701,10 +868,53 @@ linuxdvb_frontend_tune0 lfe->lfe_locked = 0; lfe->lfe_status = 0; + /* + * copy the universal parameters to the Linux kernel structure + */ + dmc = &lm->lm_tuning; + memset(&p, 0, sizeof(p)); + p.frequency = dmc->dmc_fe_freq; + p.inversion = TR(inversion, inv_tbl, INVERSION_AUTO); + switch (dmc->dmc_fe_type) { + case DVB_TYPE_T: +#define _OFDM(xyz) p.u.ofdm.xyz + _OFDM(bandwidth) = TRU(ofdm.bandwidth, bw_tbl, BANDWIDTH_AUTO); + _OFDM(code_rate_HP) = TRU(ofdm.code_rate_HP, fec_tbl, FEC_AUTO); + _OFDM(code_rate_LP) = TRU(ofdm.code_rate_LP, fec_tbl, FEC_AUTO); + _OFDM(constellation) = TR(modulation, mod_tbl, QAM_AUTO); + _OFDM(transmission_mode) = TRU(ofdm.transmission_mode, trans_tbl, TRANSMISSION_MODE_AUTO); + _OFDM(guard_interval) = TRU(ofdm.guard_interval, guard_tbl, GUARD_INTERVAL_AUTO); + _OFDM(hierarchy_information) + = TRU(ofdm.hierarchy_information, h_tbl, HIERARCHY_AUTO); +#undef _OFDM + break; + case DVB_TYPE_C: + p.u.qam.symbol_rate = dmc->u.dmc_fe_qam.symbol_rate; + p.u.qam.fec_inner = TRU(qam.fec_inner, fec_tbl, FEC_AUTO); + p.u.qam.modulation = TR(modulation, mod_tbl, QAM_AUTO); + break; + case DVB_TYPE_S: + p.u.qpsk.symbol_rate = dmc->u.dmc_fe_qpsk.symbol_rate; + p.u.qpsk.fec_inner = TRU(qpsk.fec_inner, fec_tbl, FEC_AUTO); + break; + case DVB_TYPE_ATSC: + p.u.vsb.modulation = TR(modulation, mod_tbl, QAM_AUTO); + break; + default: + tvherror("linuxdvb", "%s - unknown FE type %d", buf1, dmc->dmc_fe_type); + return SM_CODE_TUNING_FAILED; + } + + if (freq != (uint32_t)-1) + p.frequency = freq; + + if (dmc->dmc_fe_type != lfe->lfe_type) { + tvherror("linuxdvb", "%s - failed to tune [type does not match %i != %i]", buf1, dmc->dmc_fe_type, lfe->lfe_type); + return SM_CODE_TUNING_FAILED; + } + /* S2 tuning */ #if DVB_API_VERSION >= 5 - dvb_mux_conf_t *dmc = &lm->lm_tuning; - struct dvb_frontend_parameters *p = &dmc->dmc_fe_params; struct dtv_property cmds[20]; struct dtv_properties cmdseq = { .num = 0, .props = cmds }; @@ -720,62 +930,58 @@ linuxdvb_frontend_tune0 return -1; if (freq == (uint32_t)-1) - freq = p->frequency; + freq = p.frequency; + /* Tune */ #define S2CMD(c, d)\ cmds[cmdseq.num].cmd = c;\ cmds[cmdseq.num++].u.data = d memset(&cmds, 0, sizeof(cmds)); - S2CMD(DTV_DELIVERY_SYSTEM, lm->lm_tuning.dmc_fe_delsys); + S2CMD(DTV_DELIVERY_SYSTEM, TR(delsys, delsys_tbl, SYS_UNDEFINED)); S2CMD(DTV_FREQUENCY, freq); - S2CMD(DTV_INVERSION, p->inversion); + S2CMD(DTV_INVERSION, p.inversion); /* DVB-T */ - if (lfe->lfe_info.type == FE_OFDM) { - S2CMD(DTV_BANDWIDTH_HZ, dvb_bandwidth(p->u.ofdm.bandwidth)); + if (lfe->lfe_type == DVB_TYPE_T) { + S2CMD(DTV_BANDWIDTH_HZ, dvb_bandwidth(dmc->u.dmc_fe_ofdm.bandwidth)); #if DVB_VER_ATLEAST(5,1) - S2CMD(DTV_CODE_RATE_HP, p->u.ofdm.code_rate_HP); - S2CMD(DTV_CODE_RATE_LP, p->u.ofdm.code_rate_LP); + S2CMD(DTV_CODE_RATE_HP, p.u.ofdm.code_rate_HP); + S2CMD(DTV_CODE_RATE_LP, p.u.ofdm.code_rate_LP); #endif - S2CMD(DTV_MODULATION, p->u.ofdm.constellation); + S2CMD(DTV_MODULATION, p.u.ofdm.constellation); #if DVB_VER_ATLEAST(5,1) - S2CMD(DTV_TRANSMISSION_MODE, p->u.ofdm.transmission_mode); - S2CMD(DTV_GUARD_INTERVAL, p->u.ofdm.guard_interval); - S2CMD(DTV_HIERARCHY, p->u.ofdm.hierarchy_information); + S2CMD(DTV_TRANSMISSION_MODE, p.u.ofdm.transmission_mode); + S2CMD(DTV_GUARD_INTERVAL, p.u.ofdm.guard_interval); + S2CMD(DTV_HIERARCHY, p.u.ofdm.hierarchy_information); #endif /* DVB-C */ - } else if (lfe->lfe_info.type == FE_QAM) { - S2CMD(DTV_SYMBOL_RATE, p->u.qam.symbol_rate); - S2CMD(DTV_MODULATION, p->u.qam.modulation); - S2CMD(DTV_INNER_FEC, p->u.qam.fec_inner); + } else if (lfe->lfe_type == DVB_TYPE_C) { + S2CMD(DTV_SYMBOL_RATE, p.u.qam.symbol_rate); + S2CMD(DTV_MODULATION, p.u.qam.modulation); + S2CMD(DTV_INNER_FEC, p.u.qam.fec_inner); /* DVB-S */ - } else if (lfe->lfe_info.type == FE_QPSK) { - S2CMD(DTV_SYMBOL_RATE, p->u.qpsk.symbol_rate); - S2CMD(DTV_INNER_FEC, p->u.qpsk.fec_inner); - S2CMD(DTV_PILOT, dmc->dmc_fe_pilot); - S2CMD(DTV_MODULATION, dmc->dmc_fe_modulation); - if (lm->lm_tuning.dmc_fe_delsys == SYS_DVBS) { - S2CMD(DTV_ROLLOFF, ROLLOFF_35); + } else if (lfe->lfe_type == DVB_TYPE_S) { + S2CMD(DTV_SYMBOL_RATE, p.u.qpsk.symbol_rate); + S2CMD(DTV_INNER_FEC, p.u.qpsk.fec_inner); + S2CMD(DTV_PILOT, TR(pilot, pilot_tbl, PILOT_AUTO)); + S2CMD(DTV_MODULATION, TR(modulation, mod_tbl, QPSK)); + if (lm->lm_tuning.dmc_fe_delsys == DVB_SYS_DVBS) { + S2CMD(DTV_ROLLOFF, ROLLOFF_35); } else { - S2CMD(DTV_ROLLOFF, dmc->dmc_fe_rolloff); + S2CMD(DTV_ROLLOFF, TR(rolloff, rolloff_tbl, ROLLOFF_AUTO)); } /* ATSC */ } else { - S2CMD(DTV_MODULATION, p->u.vsb.modulation); + S2CMD(DTV_MODULATION, p.u.vsb.modulation); } /* Tune */ S2CMD(DTV_TUNE, 0); #undef S2CMD -#else - dvb_mux_conf_t dmc = lm->lm_tuning; - struct dvb_frontend_parameters *p = &dmc.dmc_fe_params; - if (freq != (uint32_t)-1) - p->frequency = freq; #endif /* discard stale events */ @@ -842,16 +1048,16 @@ linuxdvb_frontend_t * linuxdvb_frontend_create ( htsmsg_t *conf, linuxdvb_adapter_t *la, int number, const char *fe_path, const char *dmx_path, const char *dvr_path, - struct dvb_frontend_info *dfi ) + dvb_fe_type_t type, const char *name ) { const idclass_t *idc; const char *str, *uuid = NULL, *scuuid = NULL, *sctype = NULL; - char id[12], name[256]; + char id[12], lname[256]; linuxdvb_frontend_t *lfe; htsmsg_t *scconf = NULL; /* Internal config ID */ - snprintf(id, sizeof(id), "%s #%d", dvb_type2str(dfi->type), number); + snprintf(id, sizeof(id), "%s #%d", dvb_type2str(type), number); if (conf) conf = htsmsg_get_map(conf, id); if (conf) @@ -868,16 +1074,16 @@ linuxdvb_frontend_create } /* Class */ - if (dfi->type == FE_QPSK) + if (type == DVB_TYPE_S) idc = &linuxdvb_frontend_dvbs_class; - else if (dfi->type == FE_QAM) + else if (type == DVB_TYPE_C) idc = &linuxdvb_frontend_dvbc_class; - else if (dfi->type == FE_OFDM) + else if (type == DVB_TYPE_T) idc = &linuxdvb_frontend_dvbt_class; - else if (dfi->type == FE_ATSC) + else if (type == DVB_TYPE_ATSC) idc = &linuxdvb_frontend_atsc_class; else { - tvherror("linuxdvb", "unknown FE type %d", dfi->type); + tvherror("linuxdvb", "unknown FE type %d", type); return NULL; } @@ -887,7 +1093,9 @@ linuxdvb_frontend_create // in mpegts_input_create()). So we must set early. lfe = calloc(1, sizeof(linuxdvb_frontend_t)); lfe->lfe_number = number; - memcpy(&lfe->lfe_info, dfi, sizeof(struct dvb_frontend_info)); + lfe->lfe_type = type; + strncpy(lfe->lfe_name, name, sizeof(lfe->lfe_name)); + lfe->lfe_name[sizeof(lfe->lfe_name)-1] = '\0'; lfe = (linuxdvb_frontend_t*)mpegts_input_create0((mpegts_input_t*)lfe, idc, uuid, conf); if (!lfe) return NULL; @@ -897,8 +1105,8 @@ linuxdvb_frontend_create /* Default name */ if (!lfe->mi_name) { - snprintf(name, sizeof(name), "%s : %s", dfi->name, id); - lfe->mi_name = strdup(name); + snprintf(lname, sizeof(lname), "%s : %s", name, id); + lfe->mi_name = strdup(lname); } /* Set paths */ @@ -933,7 +1141,7 @@ linuxdvb_frontend_create } /* Create satconf */ - if (dfi->type == FE_QPSK && !lfe->lfe_satconf) + if (lfe->lfe_type == DVB_TYPE_S && !lfe->lfe_satconf) lfe->lfe_satconf = linuxdvb_satconf_create(lfe, sctype, scuuid, scconf); return lfe; @@ -947,7 +1155,7 @@ linuxdvb_frontend_save ( linuxdvb_frontend_t *lfe, htsmsg_t *fe ) /* Save frontend */ mpegts_input_save((mpegts_input_t*)lfe, m); - htsmsg_add_str(m, "type", dvb_type2str(lfe->lfe_info.type)); + htsmsg_add_str(m, "type", dvb_type2str(lfe->lfe_type)); if (lfe->lfe_satconf) { htsmsg_t *s = htsmsg_create_map(); linuxdvb_satconf_save(lfe->lfe_satconf, s); @@ -956,7 +1164,7 @@ linuxdvb_frontend_save ( linuxdvb_frontend_t *lfe, htsmsg_t *fe ) } /* Add to list */ - snprintf(id, sizeof(id), "%s #%d", dvb_type2str(lfe->lfe_info.type), lfe->lfe_number); + snprintf(id, sizeof(id), "%s #%d", dvb_type2str(lfe->lfe_type), lfe->lfe_number); htsmsg_add_msg(fe, id, m); } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_lnb.c b/src/input/mpegts/linuxdvb/linuxdvb_lnb.c index 49a4328a..85ae5503 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_lnb.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_lnb.c @@ -75,7 +75,7 @@ linuxdvb_lnb_standard_freq ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) { linuxdvb_lnb_conf_t *lnb = (linuxdvb_lnb_conf_t*)l; - int32_t f = (int32_t)lm->lm_tuning.dmc_fe_params.frequency; + int32_t f = (int32_t)lm->lm_tuning.dmc_fe_freq; if (lnb->lnb_switch && f > lnb->lnb_switch) f -= lnb->lnb_high; else @@ -88,7 +88,7 @@ linuxdvb_lnb_standard_band ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) { linuxdvb_lnb_conf_t *lnb = (linuxdvb_lnb_conf_t*)l; - uint32_t f = lm->lm_tuning.dmc_fe_params.frequency; + uint32_t f = lm->lm_tuning.dmc_fe_freq; return (lnb->lnb_switch && f > lnb->lnb_switch); } @@ -97,8 +97,8 @@ linuxdvb_lnb_standard_pol ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) { dvb_mux_conf_t *dmc = &lm->lm_tuning; - return dmc->dmc_fe_polarisation == POLARISATION_HORIZONTAL || - dmc->dmc_fe_polarisation == POLARISATION_CIRCULAR_LEFT; + return dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_HORIZONTAL || + dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_CIRCULAR_LEFT; } static int @@ -118,10 +118,10 @@ linuxdvb_lnb_bandstack_freq ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) { linuxdvb_lnb_conf_t *lnb = (linuxdvb_lnb_conf_t*)l; - int32_t f = (int32_t)lm->lm_tuning.dmc_fe_params.frequency; + int32_t f = (int32_t)lm->lm_tuning.dmc_fe_freq; dvb_mux_conf_t *dmc = &lm->lm_tuning; - int pol = dmc->dmc_fe_polarisation == POLARISATION_HORIZONTAL || - dmc->dmc_fe_polarisation == POLARISATION_CIRCULAR_LEFT; + int pol = dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_HORIZONTAL || + dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_CIRCULAR_LEFT; if (pol) f -= lnb->lnb_high; else @@ -134,8 +134,8 @@ linuxdvb_lnb_bandstack_band ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) { dvb_mux_conf_t *dmc = &lm->lm_tuning; - int pol = dmc->dmc_fe_polarisation == POLARISATION_HORIZONTAL || - dmc->dmc_fe_polarisation == POLARISATION_CIRCULAR_LEFT; + int pol = dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_HORIZONTAL || + dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_CIRCULAR_LEFT; return pol; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_mux.c b/src/input/mpegts/linuxdvb/linuxdvb_mux.c index 501a2a50..21b75b01 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_mux.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_mux.c @@ -44,21 +44,47 @@ extern const idclass_t mpegts_mux_class; * Generic */ -/* Macro to defien mux class str get/set */ -#define linuxdvb_mux_class_X(c, f, p, l, ...)\ +/* Macro to define mux class str get/set */ +#define linuxdvb_mux_class_R(c, f, l, ...)\ static const void * \ linuxdvb_mux_##c##_class_##l##_get (void *o)\ {\ static const char *s;\ linuxdvb_mux_t *lm = o;\ - s = dvb_##l##2str(lm->lm_tuning.dmc_fe_params.u.f.p);\ + s = dvb_##l##2str(lm->lm_tuning.dmc_fe_##f);\ return &s;\ }\ static int \ linuxdvb_mux_##c##_class_##l##_set (void *o, const void *v)\ {\ linuxdvb_mux_t *lm = o;\ - lm->lm_tuning.dmc_fe_params.u.f.p = dvb_str2##l ((const char*)v);\ + lm->lm_tuning.dmc_fe_##f = dvb_str2##l ((const char*)v);\ + return 1;\ +}\ +static htsmsg_t *\ +linuxdvb_mux_##c##_class_##l##_enum (void *o)\ +{\ + static const int t[] = { __VA_ARGS__ };\ + int i;\ + htsmsg_t *m = htsmsg_create_list();\ + for (i = 0; i < ARRAY_SIZE(t); i++)\ + htsmsg_add_str(m, NULL, dvb_##l##2str(t[i]));\ + return m;\ +} +#define linuxdvb_mux_class_X(c, f, p, l, ...)\ +static const void * \ +linuxdvb_mux_##c##_class_##l##_get (void *o)\ +{\ + static const char *s;\ + linuxdvb_mux_t *lm = o;\ + s = dvb_##l##2str(lm->lm_tuning.u.dmc_fe_##f.p);\ + return &s;\ +}\ +static int \ +linuxdvb_mux_##c##_class_##l##_set (void *o, const void *v)\ +{\ + linuxdvb_mux_t *lm = o;\ + lm->lm_tuning.u.dmc_fe_##f.p = dvb_str2##l ((const char*)v);\ return 1;\ }\ static htsmsg_t *\ @@ -84,12 +110,8 @@ static const void * linuxdvb_mux_class_delsys_get (void *o) { static const char *s; -#if DVB_VER_ATLEAST(5,0) linuxdvb_mux_t *lm = o; s = dvb_delsys2str(lm->lm_tuning.dmc_fe_delsys); -#else - s = NULL; -#endif return &s; } static int @@ -122,50 +144,54 @@ const idclass_t linuxdvb_mux_class = */ linuxdvb_mux_class_X(dvbt, ofdm, bandwidth, bw, - BANDWIDTH_AUTO - , BANDWIDTH_8_MHZ, BANDWIDTH_7_MHZ, BANDWIDTH_6_MHZ + DVB_BANDWIDTH_AUTO + , DVB_BANDWIDTH_8_MHZ, DVB_BANDWIDTH_7_MHZ + , DVB_BANDWIDTH_6_MHZ #if DVB_VER_ATLEAST(5,4) - , BANDWIDTH_5_MHZ - , BANDWIDTH_10_MHZ - , BANDWIDTH_1_712_MHZ + , DVB_BANDWIDTH_5_MHZ + , DVB_BANDWIDTH_10_MHZ + , DVB_BANDWIDTH_1_712_MHZ #endif ); -linuxdvb_mux_class_X(dvbt, ofdm, constellation, qam, - QAM_AUTO, QPSK, QAM_16, QAM_64, QAM_256 +linuxdvb_mux_class_R(dvbt, modulation, qam, + DVB_MOD_QAM_AUTO, DVB_MOD_QPSK, DVB_MOD_QAM_16, + DVB_MOD_QAM_64, DVB_MOD_QAM_256 ); linuxdvb_mux_class_X(dvbt, ofdm, transmission_mode, mode, - TRANSMISSION_MODE_AUTO, - TRANSMISSION_MODE_2K, TRANSMISSION_MODE_8K + DVB_TRANSMISSION_MODE_AUTO, + DVB_TRANSMISSION_MODE_2K, DVB_TRANSMISSION_MODE_8K #if DVB_VER_ATLEAST(5,4) - , TRANSMISSION_MODE_1K, TRANSMISSION_MODE_16K - , TRANSMISSION_MODE_32K + , DVB_TRANSMISSION_MODE_1K, DVB_TRANSMISSION_MODE_16K + , DVB_TRANSMISSION_MODE_32K #endif ); linuxdvb_mux_class_X(dvbt, ofdm, guard_interval, guard, - GUARD_INTERVAL_AUTO, GUARD_INTERVAL_1_4, - GUARD_INTERVAL_1_8, GUARD_INTERVAL_1_16, - GUARD_INTERVAL_1_32 + DVB_GUARD_INTERVAL_AUTO, DVB_GUARD_INTERVAL_1_4, + DVB_GUARD_INTERVAL_1_8, DVB_GUARD_INTERVAL_1_16, + DVB_GUARD_INTERVAL_1_32 #if DVB_VER_ATLEAST(5,4) - , GUARD_INTERVAL_1_128, GUARD_INTERVAL_19_128 - , GUARD_INTERVAL_19_256 + , DVB_GUARD_INTERVAL_1_128, DVB_GUARD_INTERVAL_19_128 + , DVB_GUARD_INTERVAL_19_256 #endif ); linuxdvb_mux_class_X(dvbt, ofdm, hierarchy_information, hier, - HIERARCHY_AUTO, HIERARCHY_NONE, - HIERARCHY_1, HIERARCHY_2, HIERARCHY_4 + DVB_HIERARCHY_AUTO, DVB_HIERARCHY_NONE, + DVB_HIERARCHY_1, DVB_HIERARCHY_2, DVB_HIERARCHY_4 ); linuxdvb_mux_class_X(dvbt, ofdm, code_rate_HP, fechi, - FEC_AUTO, - FEC_1_2, FEC_2_3, FEC_3_4, FEC_4_5, FEC_5_6, FEC_7_8 + DVB_FEC_AUTO, + DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, DVB_FEC_4_5, + DVB_FEC_5_6, DVB_FEC_7_8 #if DVB_VER_ATLEAST(5,4) - , FEC_3_5 + , DVB_FEC_3_5 #endif ); linuxdvb_mux_class_X(dvbt, ofdm, code_rate_LP, feclo, - FEC_AUTO, - FEC_1_2, FEC_2_3, FEC_3_4, FEC_4_5, FEC_5_6, FEC_7_8 + DVB_FEC_AUTO, + DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, + DVB_FEC_4_5, DVB_FEC_5_6, DVB_FEC_7_8 #if DVB_VER_ATLEAST(5,4) - , FEC_3_5 + , DVB_FEC_3_5 #endif ); @@ -176,11 +202,11 @@ linuxdvb_mux_dvbt_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); #if DVB_VER_ATLEAST(5,0) - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_DVBT)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBT)); #endif #if DVB_VER_ATLEAST(5,4) - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_DVBT2)); - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_TURBO)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBT2)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_TURBO)); #endif return list; } @@ -199,7 +225,7 @@ const idclass_t linuxdvb_mux_dvbt_class = .id = "frequency", .name = "Frequency (Hz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_params.frequency), + .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), }, { MUX_PROP_STR("bandwidth", "Bandwidth", dvbt, bw, "AUTO") @@ -230,14 +256,16 @@ const idclass_t linuxdvb_mux_dvbt_class = * DVB-C */ -linuxdvb_mux_class_X(dvbc, qam, modulation, qam, - QAM_AUTO, QAM_16, QAM_32, QAM_64, QAM_128, QAM_256 +linuxdvb_mux_class_R(dvbc, modulation, qam, + DVB_MOD_QAM_AUTO, DVB_MOD_QAM_16, DVB_MOD_QAM_32, + DVB_MOD_QAM_64, DVB_MOD_QAM_128, DVB_MOD_QAM_256 ); linuxdvb_mux_class_X(dvbc, qam, fec_inner, fec, - FEC_AUTO, FEC_NONE, - FEC_1_2, FEC_2_3, FEC_3_4, FEC_4_5, FEC_5_6, FEC_8_9 + DVB_FEC_AUTO, DVB_FEC_NONE, + DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, DVB_FEC_4_5, + DVB_FEC_5_6, DVB_FEC_8_9 #if DVB_VER_ATLEAST(5,4) - , FEC_9_10 + , DVB_FEC_9_10 #endif ); @@ -248,8 +276,11 @@ linuxdvb_mux_dvbc_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); #if DVB_VER_ATLEAST(5,0) - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_DVBC_ANNEX_AC)); - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_DVBC_ANNEX_B)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBC_ANNEX_A)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBC_ANNEX_B)); +#if DVB_VER_ATLEAST(5,3) + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBC_ANNEX_C)); +#endif #endif return list; } @@ -268,14 +299,14 @@ const idclass_t linuxdvb_mux_dvbc_class = .id = "frequency", .name = "Frequency (Hz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_params.frequency), + .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), }, { .type = PT_U32, .id = "symbolrate", .name = "Symbol Rate (Sym/s)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_params.u.qam.symbol_rate), + .off = offsetof(linuxdvb_mux_t, lm_tuning.u.dmc_fe_qam.symbol_rate), }, { MUX_PROP_STR("constellation", "Constellation", dvbc, qam, "AUTO") @@ -288,11 +319,11 @@ const idclass_t linuxdvb_mux_dvbc_class = }; linuxdvb_mux_class_X(dvbs, qpsk, fec_inner, fec, - FEC_AUTO, FEC_NONE, - FEC_1_2, FEC_2_3, FEC_3_4, FEC_4_5, FEC_5_6, FEC_7_8, - FEC_8_9 + DVB_FEC_AUTO, DVB_FEC_NONE, + DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, DVB_FEC_4_5, + DVB_FEC_5_6, DVB_FEC_7_8, DVB_FEC_8_9 #if DVB_VER_ATLEAST(5,4) - , FEC_3_5, FEC_9_10 + , DVB_FEC_3_5, DVB_FEC_9_10 #endif ); static const void * @@ -300,24 +331,24 @@ linuxdvb_mux_dvbs_class_polarity_get (void *o) { static const char *s; linuxdvb_mux_t *lm = o; - s = dvb_pol2str(lm->lm_tuning.dmc_fe_polarisation); + s = dvb_pol2str(lm->lm_tuning.u.dmc_fe_qpsk.polarisation); return &s; } static int linuxdvb_mux_dvbs_class_polarity_set (void *o, const void *s) { linuxdvb_mux_t *lm = o; - lm->lm_tuning.dmc_fe_polarisation = dvb_str2pol((const char*)s); + lm->lm_tuning.u.dmc_fe_qpsk.polarisation = dvb_str2pol((const char*)s); return 1; } static htsmsg_t * linuxdvb_mux_dvbs_class_polarity_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); - htsmsg_add_str(list, NULL, dvb_pol2str(POLARISATION_VERTICAL)); - htsmsg_add_str(list, NULL, dvb_pol2str(POLARISATION_HORIZONTAL)); - htsmsg_add_str(list, NULL, dvb_pol2str(POLARISATION_CIRCULAR_LEFT)); - htsmsg_add_str(list, NULL, dvb_pol2str(POLARISATION_CIRCULAR_RIGHT)); + htsmsg_add_str(list, NULL, dvb_pol2str(DVB_POLARISATION_VERTICAL)); + htsmsg_add_str(list, NULL, dvb_pol2str(DVB_POLARISATION_HORIZONTAL)); + htsmsg_add_str(list, NULL, dvb_pol2str(DVB_POLARISATION_CIRCULAR_LEFT)); + htsmsg_add_str(list, NULL, dvb_pol2str(DVB_POLARISATION_CIRCULAR_RIGHT)); return list; } @@ -325,36 +356,32 @@ static const void * linuxdvb_mux_dvbs_class_modulation_get ( void *o ) { static const char *s; -#if DVB_VER_ATLEAST(5,0) linuxdvb_mux_t *lm = o; s = dvb_qam2str(lm->lm_tuning.dmc_fe_modulation); -#endif return &s; } static int linuxdvb_mux_dvbs_class_modulation_set (void *o, const void *s) { -#if DVB_VER_ATLEAST(5,0) int mod = dvb_str2qam(s); linuxdvb_mux_t *lm = o; if (mod != lm->lm_tuning.dmc_fe_modulation) { lm->lm_tuning.dmc_fe_modulation = mod; return 1; } -#endif return 0; } static htsmsg_t * linuxdvb_mux_dvbs_class_modulation_list ( void *o ) { htsmsg_t *list = htsmsg_create_list(); - htsmsg_add_str(list, NULL, dvb_qam2str(QAM_AUTO)); - htsmsg_add_str(list, NULL, dvb_qam2str(QPSK)); - htsmsg_add_str(list, NULL, dvb_qam2str(QAM_16)); + htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_QAM_AUTO)); + htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_QPSK)); + htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_QAM_16)); #if DVB_VER_ATLEAST(5,4) - htsmsg_add_str(list, NULL, dvb_qam2str(PSK_8)); - htsmsg_add_str(list, NULL, dvb_qam2str(APSK_16)); - htsmsg_add_str(list, NULL, dvb_qam2str(APSK_32)); + htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_PSK_8)); + htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_APSK_16)); + htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_APSK_32)); #endif return list; } @@ -379,12 +406,12 @@ static htsmsg_t * linuxdvb_mux_dvbs_class_rolloff_list ( void *o ) { htsmsg_t *list = htsmsg_create_list(); - htsmsg_add_str(list, NULL, dvb_rolloff2str(ROLLOFF_35)); + htsmsg_add_str(list, NULL, dvb_rolloff2str(DVB_ROLLOFF_35)); // Note: this is a bit naff, as the below values are only relevant // to S2 muxes, but currently have no way to model that - htsmsg_add_str(list, NULL, dvb_rolloff2str(ROLLOFF_20)); - htsmsg_add_str(list, NULL, dvb_rolloff2str(ROLLOFF_25)); - htsmsg_add_str(list, NULL, dvb_rolloff2str(ROLLOFF_AUTO)); + htsmsg_add_str(list, NULL, dvb_rolloff2str(DVB_ROLLOFF_20)); + htsmsg_add_str(list, NULL, dvb_rolloff2str(DVB_ROLLOFF_25)); + htsmsg_add_str(list, NULL, dvb_rolloff2str(DVB_ROLLOFF_AUTO)); return list; } @@ -407,9 +434,9 @@ static htsmsg_t * linuxdvb_mux_dvbs_class_pilot_list ( void *o ) { htsmsg_t *list = htsmsg_create_list(); - htsmsg_add_str(list, NULL, dvb_pilot2str(PILOT_AUTO)); - htsmsg_add_str(list, NULL, dvb_pilot2str(PILOT_ON)); - htsmsg_add_str(list, NULL, dvb_pilot2str(PILOT_OFF)); + htsmsg_add_str(list, NULL, dvb_pilot2str(DVB_PILOT_AUTO)); + htsmsg_add_str(list, NULL, dvb_pilot2str(DVB_PILOT_ON)); + htsmsg_add_str(list, NULL, dvb_pilot2str(DVB_PILOT_OFF)); return list; } #endif @@ -420,10 +447,8 @@ static htsmsg_t * linuxdvb_mux_dvbs_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); -#if DVB_VER_ATLEAST(5,0) - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_DVBS)); - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_DVBS2)); -#endif + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBS)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBS2)); return list; } @@ -433,8 +458,8 @@ linuxdvb_mux_dvbs_class_orbital_get ( void *o ) static char buf[256], *s = buf; linuxdvb_mux_t *lm = o; snprintf(buf, sizeof(buf), "%0.1f%c", - lm->lm_tuning.dmc_fe_orbital_pos / 10.0, - lm->lm_tuning.dmc_fe_orbital_dir); + lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos / 10.0, + lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir); return &s; } @@ -450,10 +475,10 @@ linuxdvb_mux_dvbs_class_orbital_set ( void *o, const void *s ) tmp[strlen(tmp)-1] = '\0'; pos = (int)floorf(atof(tmp) * 10.0); - if (pos != lm->lm_tuning.dmc_fe_orbital_pos || - dir != lm->lm_tuning.dmc_fe_orbital_dir) { - lm->lm_tuning.dmc_fe_orbital_pos = pos; - lm->lm_tuning.dmc_fe_orbital_dir = dir; + if (pos != lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos || + dir != lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir) { + lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos = pos; + lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir = dir; save = 1; } return save; @@ -473,14 +498,14 @@ const idclass_t linuxdvb_mux_dvbs_class = .id = "frequency", .name = "Frequency (kHz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_params.frequency), + .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), }, { .type = PT_U32, .id = "symbolrate", .name = "Symbol Rate (Sym/s)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_params.u.qpsk.symbol_rate), + .off = offsetof(linuxdvb_mux_t, lm_tuning.u.dmc_fe_qpsk.symbol_rate), }, { MUX_PROP_STR("polarisation", "Polarisation", dvbs, polarity, NULL) @@ -536,14 +561,14 @@ linuxdvb_mux_atsc_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); #if DVB_VER_ATLEAST(5,0) - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_ATSC)); - htsmsg_add_str(list, NULL, dvb_delsys2str(SYS_ATSCMH)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_ATSC)); + htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_ATSCMH)); #endif return list; } -linuxdvb_mux_class_X(atsc, vsb, modulation, qam, - QAM_AUTO, QAM_256, VSB_8); +linuxdvb_mux_class_R(atsc, modulation, qam, + DVB_MOD_QAM_AUTO, DVB_MOD_QAM_256, DVB_MOD_VSB_8); const idclass_t linuxdvb_mux_atsc_class = { @@ -559,7 +584,7 @@ const idclass_t linuxdvb_mux_atsc_class = .id = "frequency", .name = "Frequency (kHz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_params.frequency), + .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), }, { MUX_PROP_STR("modulation", "Modulation", atsc, qam, "AUTO") @@ -588,15 +613,15 @@ linuxdvb_mux_display_name ( mpegts_mux_t *mm, char *buf, size_t len ) { linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; linuxdvb_network_t *ln = (linuxdvb_network_t*)mm->mm_network; - uint32_t freq = lm->lm_tuning.dmc_fe_params.frequency; + uint32_t freq = lm->lm_tuning.dmc_fe_freq; char pol[2] = { 0 }; - if (ln->ln_type == FE_QPSK) { - const char *s = dvb_pol2str(lm->lm_tuning.dmc_fe_polarisation); + if (ln->ln_type == DVB_TYPE_S) { + const char *s = dvb_pol2str(lm->lm_tuning.u.dmc_fe_qpsk.polarisation); if (s) pol[0] = *s; freq /= 1000; } else { freq /= 1000; - } + } snprintf(buf, len, "%d%s", freq, pol); } @@ -641,13 +666,13 @@ linuxdvb_mux_create0 htsmsg_field_t *f; /* Class */ - if (ln->ln_type == FE_QPSK) + if (ln->ln_type == DVB_TYPE_S) idc = &linuxdvb_mux_dvbs_class; - else if (ln->ln_type == FE_QAM) + else if (ln->ln_type == DVB_TYPE_C) idc = &linuxdvb_mux_dvbc_class; - else if (ln->ln_type == FE_OFDM) + else if (ln->ln_type == DVB_TYPE_T) idc = &linuxdvb_mux_dvbt_class; - else if (ln->ln_type == FE_ATSC) + else if (ln->ln_type == DVB_TYPE_ATSC) idc = &linuxdvb_mux_atsc_class; else { tvherror("linuxdvb", "unknown FE type %d", ln->ln_type); @@ -659,10 +684,13 @@ linuxdvb_mux_create0 (mpegts_network_t*)ln, onid, tsid, conf))) return NULL; lm = (linuxdvb_mux_t*)mm; + lm->lm_tuning.dmc_fe_type = ln->ln_type; /* Tuning */ - if (dmc) + if (dmc) { + assert(dmc->dmc_fe_type == lm->lm_tuning.dmc_fe_type); memcpy(&lm->lm_tuning, dmc, sizeof(dvb_mux_conf_t)); + } /* Callbacks */ lm->mm_delete = linuxdvb_mux_delete; @@ -671,10 +699,12 @@ linuxdvb_mux_create0 lm->mm_create_instances = linuxdvb_mux_create_instances; /* Defaults */ - lm->lm_tuning.dmc_fe_params.inversion = INVERSION_AUTO; + if (dmc == NULL) { + lm->lm_tuning.dmc_fe_inversion = DVB_INVERSION_AUTO; #if DVB_VER_ATLEAST(5,0) - lm->lm_tuning.dmc_fe_pilot = PILOT_AUTO; + lm->lm_tuning.dmc_fe_pilot = DVB_PILOT_AUTO; #endif + } /* No config */ if (!conf) return lm; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_network.c b/src/input/mpegts/linuxdvb/linuxdvb_network.c index 3c775226..f15dca21 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_network.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_network.c @@ -216,9 +216,9 @@ linuxdvb_network_find_mux mpegts_mux_t *mm; LIST_FOREACH(mm, &ln->mn_muxes, mm_network_link) { linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; - if (abs(lm->lm_tuning.dmc_fe_params.frequency - - dmc->dmc_fe_params.frequency) > LINUXDVB_FREQ_TOL) continue; - if (lm->lm_tuning.dmc_fe_polarisation != dmc->dmc_fe_polarisation) continue; + if (abs(lm->lm_tuning.dmc_fe_freq + - dmc->dmc_fe_freq) > LINUXDVB_FREQ_TOL) continue; + if (lm->lm_tuning.u.dmc_fe_qpsk.polarisation != dmc->u.dmc_fe_qpsk.polarisation) continue; break; } return mm; @@ -247,7 +247,7 @@ linuxdvb_network_create_mux save = 1; } else if (mm) { linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; - dmc->dmc_fe_params.frequency = lm->lm_tuning.dmc_fe_params.frequency; + dmc->dmc_fe_freq = lm->lm_tuning.dmc_fe_freq; // Note: keep original freq, else it can bounce around if diff transponders // report it slightly differently. // TODO: Note: should we also leave AUTO settings as is? @@ -312,13 +312,13 @@ linuxdvb_network_create0 ln = calloc(1, sizeof(linuxdvb_network_t)); if (idc == &linuxdvb_network_dvbt_class) - ln->ln_type = FE_OFDM; + ln->ln_type = DVB_TYPE_T; else if (idc == &linuxdvb_network_dvbc_class) - ln->ln_type = FE_QAM; + ln->ln_type = DVB_TYPE_C; else if (idc == &linuxdvb_network_dvbs_class) - ln->ln_type = FE_QPSK; + ln->ln_type = DVB_TYPE_S; else - ln->ln_type = FE_ATSC; + ln->ln_type = DVB_TYPE_ATSC; /* Create */ if (!(ln = (linuxdvb_network_t*)mpegts_network_create0((void*)ln, diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index 6c5c27a7..18b87fa8 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -22,6 +22,13 @@ #include "input/mpegts.h" +#include + +#define DVB_VER_INT(maj,min) (((maj) << 16) + (min)) + +#define DVB_VER_ATLEAST(maj, min) \ + (DVB_VER_INT(DVB_API_VERSION, DVB_API_VERSION_MINOR) >= DVB_VER_INT(maj, min)) + /* Max allowed frequency variation for something to be considered the same */ #define LINUXDVB_FREQ_TOL 2000 @@ -75,7 +82,8 @@ struct linuxdvb_frontend * Frontend info */ int lfe_number; - struct dvb_frontend_info lfe_info; + dvb_fe_type_t lfe_type; + char lfe_name[128]; char *lfe_fe_path; char *lfe_dmx_path; char *lfe_dvr_path; @@ -93,7 +101,7 @@ struct linuxdvb_frontend * Tuning */ int lfe_locked; - fe_status_t lfe_status; + int lfe_status; time_t lfe_monitor; gtimer_t lfe_monitor_timer; @@ -218,7 +226,7 @@ linuxdvb_frontend_t * linuxdvb_frontend_create ( htsmsg_t *conf, linuxdvb_adapter_t *la, int number, const char *fe_path, const char *dmx_path, const char *dvr_path, - struct dvb_frontend_info *dfi ); + dvb_fe_type_t type, const char *name ); void linuxdvb_frontend_save ( linuxdvb_frontend_t *lfe, htsmsg_t *m ); @@ -243,7 +251,7 @@ struct linuxdvb_network /* * Network type */ - fe_type_t ln_type; + dvb_fe_type_t ln_type; }; void linuxdvb_network_init ( void ); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c index 6d9b19b3..0d432abc 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c @@ -28,6 +28,7 @@ #include #include #include +#include /* ************************************************************************** * Class definition diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index d406fdfe..1ba7ad07 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -28,6 +28,7 @@ #include #include #include +#include static struct linuxdvb_satconf_type * linuxdvb_satconf_type_find ( const char *type ); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_switch.c b/src/input/mpegts/linuxdvb/linuxdvb_switch.c index 9bf559de..afe62a9b 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_switch.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_switch.c @@ -28,6 +28,7 @@ #include #include #include +#include /* ************************************************************************** * Class definition diff --git a/src/input/mpegts/linuxdvb/scanfile.c b/src/input/mpegts/linuxdvb/scanfile.c index 2851c0a2..eea125b9 100644 --- a/src/input/mpegts/linuxdvb/scanfile.c +++ b/src/input/mpegts/linuxdvb/scanfile.c @@ -112,14 +112,12 @@ scanfile_load_atsc ( dvb_mux_conf_t *mux, const char *line ) { char qam[20]; int r; - dvb_frontend_parameters_t *p = &mux->dmc_fe_params; - r = sscanf(line, "%u %s", &p->frequency, qam); + r = sscanf(line, "%u %s", &mux->dmc_fe_freq, qam); if (r != 2) return 1; -#if DVB_VER_ATLEAST(5,0) - mux->dmc_fe_delsys = SYS_ATSC; -#endif - if ((p->u.vsb.modulation = dvb_str2qam(qam)) == -1) return 1; + mux->dmc_fe_type = DVB_TYPE_ATSC; + mux->dmc_fe_delsys = DVB_SYS_ATSC; + if ((mux->dmc_fe_modulation = dvb_str2qam(qam)) == -1) return 1; return 0; } @@ -130,31 +128,28 @@ scanfile_load_dvbt ( dvb_mux_conf_t *mux, const char *line ) char bw[20], fec[20], fec2[20], qam[20], mode[20], guard[20], hier[20]; int r; uint32_t i; - dvb_frontend_parameters_t *p = &mux->dmc_fe_params; if (*line == '2') { r = sscanf(line+1, "%u %u %u %10s %10s %10s %10s %10s %10s %10s", - &i, &i, &p->frequency, bw, fec, fec2, qam, mode, guard, hier); + &i, &i, &mux->dmc_fe_freq, bw, fec, fec2, qam, + mode, guard, hier); if(r != 10) return 1; -#if DVB_VER_ATLEAST(5,4) - mux->dmc_fe_delsys = SYS_DVBT2; -#endif + mux->dmc_fe_delsys = DVB_SYS_DVBT2; } else { r = sscanf(line, "%u %10s %10s %10s %10s %10s %10s %10s", - &p->frequency, bw, fec, fec2, qam, mode, guard, hier); + &mux->dmc_fe_freq, bw, fec, fec2, qam, mode, guard, hier); if(r != 8) return 1; -#if DVB_VER_ATLEAST(5,0) - mux->dmc_fe_delsys = SYS_DVBT; -#endif + mux->dmc_fe_delsys = DVB_SYS_DVBT; } - if ((p->u.ofdm.bandwidth = dvb_str2bw(bw)) == -1) return 1; - if ((p->u.ofdm.constellation = dvb_str2qam(qam)) == -1) return 1; - if ((p->u.ofdm.code_rate_HP = dvb_str2fec(fec)) == -1) return 1; - if ((p->u.ofdm.code_rate_LP = dvb_str2fec(fec2)) == -1) return 1; - if ((p->u.ofdm.transmission_mode = dvb_str2mode(mode)) == -1) return 1; - if ((p->u.ofdm.guard_interval = dvb_str2guard(guard)) == -1) return 1; - if ((p->u.ofdm.hierarchy_information = dvb_str2hier(hier)) == -1) return 1; + mux->dmc_fe_type = DVB_TYPE_T; + if ((mux->u.dmc_fe_ofdm.bandwidth = dvb_str2bw(bw)) == -1) return 1; + if ((mux->dmc_fe_modulation = dvb_str2qam(qam)) == -1) return 1; + if ((mux->u.dmc_fe_ofdm.code_rate_HP = dvb_str2fec(fec)) == -1) return 1; + if ((mux->u.dmc_fe_ofdm.code_rate_LP = dvb_str2fec(fec2)) == -1) return 1; + if ((mux->u.dmc_fe_ofdm.transmission_mode = dvb_str2mode(mode)) == -1) return 1; + if ((mux->u.dmc_fe_ofdm.guard_interval = dvb_str2guard(guard)) == -1) return 1; + if ((mux->u.dmc_fe_ofdm.hierarchy_information = dvb_str2hier(hier)) == -1) return 1; return 0; } @@ -164,7 +159,6 @@ scanfile_load_dvbs ( dvb_mux_conf_t *mux, const char *line ) { char pol[20], fec[20], qam[20], rolloff[20]; int r, v2 = 0; - dvb_frontend_parameters_t *p = &mux->dmc_fe_params; if (*line == '2') { v2 = 2; @@ -172,25 +166,23 @@ scanfile_load_dvbs ( dvb_mux_conf_t *mux, const char *line ) } r = sscanf(line, "%u %s %u %s %s %s", - &p->frequency, pol, &p->u.qpsk.symbol_rate, + &mux->dmc_fe_freq, pol, &mux->u.dmc_fe_qpsk.symbol_rate, fec, rolloff, qam); if (r < (4+v2)) return 1; - if ((mux->dmc_fe_polarisation = dvb_str2pol(pol)) == -1) return 1; - if ((p->u.qpsk.fec_inner = dvb_str2fec(fec)) == -1) return 1; -#if DVB_VER_ATLEAST(5,0) + mux->dmc_fe_type = DVB_TYPE_S; + if ((mux->u.dmc_fe_qpsk.polarisation = dvb_str2pol(pol)) == -1) return 1; + if ((mux->u.dmc_fe_qpsk.fec_inner = dvb_str2fec(fec)) == -1) return 1; if (v2) { - mux->dmc_fe_delsys = SYS_DVBS2; + mux->dmc_fe_delsys = DVB_SYS_DVBS2; if ((mux->dmc_fe_rolloff = dvb_str2rolloff(rolloff)) == -1) return 1; if ((mux->dmc_fe_modulation = dvb_str2qam(qam)) == -1) return 1; } else { - mux->dmc_fe_delsys = SYS_DVBS; - mux->dmc_fe_rolloff = ROLLOFF_35; - mux->dmc_fe_modulation = QPSK; + mux->dmc_fe_delsys = DVB_SYS_DVBS; + mux->dmc_fe_rolloff = DVB_ROLLOFF_35; + mux->dmc_fe_modulation = DVB_MOD_QPSK; } -#else if (v2) return 1; -#endif return 0; } @@ -200,17 +192,15 @@ scanfile_load_dvbc ( dvb_mux_conf_t *mux, const char *line ) { char fec[20], qam[20]; int r; - dvb_frontend_parameters_t *p = &mux->dmc_fe_params; r = sscanf(line, "%u %u %s %s", - &p->frequency, &p->u.qam.symbol_rate, fec, qam); + &mux->dmc_fe_freq, &mux->u.dmc_fe_qam.symbol_rate, fec, qam); if(r != 4) return 1; -#if DVB_VER_ATLEAST(5,0) - mux->dmc_fe_delsys = SYS_DVBC_ANNEX_AC; -#endif - if ((p->u.qam.fec_inner = dvb_str2fec(fec)) == -1) return 1; - if ((p->u.qam.modulation = dvb_str2qam(qam)) == -1) return 1; + mux->dmc_fe_type = DVB_TYPE_C; + mux->dmc_fe_delsys = DVB_SYS_DVBC_ANNEX_A; + if ((mux->u.dmc_fe_qam.fec_inner = dvb_str2fec(fec)) == -1) return 1; + if ((mux->dmc_fe_modulation = dvb_str2qam(qam)) == -1) return 1; return 0; } From c36c733519a92013e9bbe6e1d15eca61ae2f2849 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sat, 29 Mar 2014 21:18:52 +0100 Subject: [PATCH 2/5] linuxdvb: remove the satconf mpegts_input_t proxy to cleanup input handlers --- src/idnode.c | 22 + src/idnode.h | 2 + src/input/mpegts.h | 4 +- src/input/mpegts/linuxdvb/linuxdvb_en50494.c | 4 +- src/input/mpegts/linuxdvb/linuxdvb_frontend.c | 32 +- src/input/mpegts/linuxdvb/linuxdvb_private.h | 46 +- src/input/mpegts/linuxdvb/linuxdvb_rotor.c | 4 +- src/input/mpegts/linuxdvb/linuxdvb_satconf.c | 763 +++++++++--------- src/input/mpegts/linuxdvb/linuxdvb_switch.c | 8 +- src/input/mpegts/mpegts_input.c | 4 +- src/input/mpegts/mpegts_service.c | 2 +- 11 files changed, 493 insertions(+), 398 deletions(-) diff --git a/src/idnode.c b/src/idnode.c index b06756e8..cfcbd069 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -683,6 +683,17 @@ idnode_set_add is->is_array[is->is_count++] = in; } +int +idnode_set_exists + ( idnode_set_t *is, idnode_t * in ) +{ + int i; + for (i = 0; i < is->is_count; i++) + if (memcmp(is->is_array[i]->in_uuid, in->in_uuid, sizeof(in->in_uuid)) == 0) + return 1; + return 0; +} + void idnode_set_sort ( idnode_set_t *is, idnode_sort_t *sort ) @@ -697,6 +708,17 @@ idnode_set_sort_by_title qsort(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_title); } +htsmsg_t * +idnode_set_as_htsmsg + ( idnode_set_t *is ) +{ + htsmsg_t *l = htsmsg_create_list(); + int i; + for (i = 0; i < is->is_count; i++) + htsmsg_add_str(l, NULL, idnode_uuid_as_str(is->is_array[i])); + return l; +} + void idnode_set_free ( idnode_set_t *is ) { diff --git a/src/idnode.h b/src/idnode.h index a10c1056..b71c86b7 100644 --- a/src/idnode.h +++ b/src/idnode.h @@ -162,8 +162,10 @@ int idnode_filter #define idnode_set_create() calloc(1, sizeof(idnode_set_t)) void idnode_set_add ( idnode_set_t *is, idnode_t *in, idnode_filter_t *filt ); +int idnode_set_exists ( idnode_set_t *is, idnode_t *in ); void idnode_set_sort ( idnode_set_t *is, idnode_sort_t *s ); void idnode_set_sort_by_title ( idnode_set_t *is ); +htsmsg_t *idnode_set_as_htsmsg ( idnode_set_t *is ); void idnode_set_free ( idnode_set_t *is ); #endif /* __TVH_IDNODE_H__ */ diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 1e537316..77840726 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -468,7 +468,7 @@ struct mpegts_input void (*mi_display_name) (mpegts_input_t*, char *buf, size_t len); int (*mi_is_free) (mpegts_input_t*); int (*mi_get_weight) (mpegts_input_t*); - int (*mi_get_priority) (mpegts_input_t*); + int (*mi_get_priority) (mpegts_input_t*, mpegts_mux_t *mm); int (*mi_get_grace) (mpegts_input_t*, mpegts_mux_t *mm); int (*mi_start_mux) (mpegts_input_t*,mpegts_mux_instance_t*); void (*mi_stop_mux) (mpegts_input_t*,mpegts_mux_instance_t*); @@ -644,7 +644,7 @@ void mpegts_input_table_thread_stop( mpegts_input_t *mi ); int mpegts_input_is_free ( mpegts_input_t *mi ); int mpegts_input_get_weight ( mpegts_input_t *mi ); -int mpegts_input_get_priority ( mpegts_input_t *mi ); +int mpegts_input_get_priority ( mpegts_input_t *mi, mpegts_mux_t *mm ); int mpegts_input_get_grace ( mpegts_input_t *mi, mpegts_mux_t *mm ); void mpegts_input_save ( mpegts_input_t *mi, htsmsg_t *c ); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c index ce6fe9a1..9a09bcba 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c @@ -148,7 +148,7 @@ linuxdvb_en50494_tune int ret = 0; int i; linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld; - linuxdvb_lnb_t *lnb = sc->ls_lnb; + linuxdvb_lnb_t *lnb = sc->lse_lnb; /* band & polarisation */ uint8_t pol = lnb->lnb_pol(lnb, lm); @@ -179,7 +179,7 @@ linuxdvb_en50494_tune band, freq, data1, data2); pthread_mutex_lock(&linuxdvb_en50494_lock); - for (i = 0; i <= sc->ls_parent->ls_diseqc_repeats; i++) { + for (i = 0; i <= sc->lse_parent->ls_diseqc_repeats; i++) { /* to avoid repeated collision, wait a random time (5-25ms) */ if (i != 0) { int ms = rand()%20 + 5; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 262c2c86..7ff71a2d 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -214,6 +214,26 @@ linuxdvb_frontend_get_weight ( mpegts_input_t *mi ) return weight; } +static int +linuxdvb_frontend_get_priority ( mpegts_input_t *mi, mpegts_mux_t *mm ) +{ + linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi; + int r = mpegts_input_get_priority(mi, mm); + if (lfe->lfe_satconf) + r += linuxdvb_satconf_get_priority(lfe->lfe_satconf, mm); + return r; +} + +static int +linuxdvb_frontend_get_grace ( mpegts_input_t *mi, mpegts_mux_t *mm ) +{ + linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi; + int r = 5; + if (lfe->lfe_satconf) + r = linuxdvb_satconf_get_grace(lfe->lfe_satconf, mm); + return r; +} + static int linuxdvb_frontend_is_enabled ( mpegts_input_t *mi ) { @@ -250,12 +270,18 @@ linuxdvb_frontend_stop_mux /* Ensure it won't happen immediately */ gtimer_arm(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, 2); + + if (lfe->lfe_satconf) + linuxdvb_satconf_post_stop_mux(lfe->lfe_satconf); } static int linuxdvb_frontend_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi ) { + linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi; + if (lfe->lfe_satconf) + return linuxdvb_satconf_start_mux(lfe->lfe_satconf, mmi); return linuxdvb_frontend_tune1((linuxdvb_frontend_t*)mi, mmi, -1); } @@ -1100,8 +1126,10 @@ linuxdvb_frontend_create if (!lfe) return NULL; /* Callbacks */ - lfe->mi_is_free = linuxdvb_frontend_is_free; - lfe->mi_get_weight = linuxdvb_frontend_get_weight; + lfe->mi_is_free = linuxdvb_frontend_is_free; + lfe->mi_get_weight = linuxdvb_frontend_get_weight; + lfe->mi_get_priority = linuxdvb_frontend_get_priority; + lfe->mi_get_grace = linuxdvb_frontend_get_grace; /* Default name */ if (!lfe->mi_name) { diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index 18b87fa8..2880d577 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -147,31 +147,36 @@ struct linuxdvb_satconf }; /* - * Internal wrapper for a satconf entry - * - * Note: this is a bit cumbersome, it comes from how I first did the satconf - * and was subsequently bullied (by amet) into changing it (probably - * for the better, just don't tell him, no danger he'll read this!) - * - * maybe one day I'll do it again properly + * Elementary satconf entry */ struct linuxdvb_satconf_ele { - mpegts_input_t; // This acts as proxy for the frontend - + idnode_t lse_id; /* * Parent */ - linuxdvb_satconf_t *ls_parent; - TAILQ_ENTRY(linuxdvb_satconf_ele) ls_link; + linuxdvb_satconf_t *lse_parent; + TAILQ_ENTRY(linuxdvb_satconf_ele) lse_link; + + /* + * Config + */ + int lse_enabled; + int lse_priority; + char *lse_name; + + /* + * Assigned networks to this SAT configuration + */ + idnode_set_t *lse_networks; /* * Diseqc kit */ - linuxdvb_lnb_t *ls_lnb; - linuxdvb_diseqc_t *ls_switch; - linuxdvb_diseqc_t *ls_rotor; - linuxdvb_diseqc_t *ls_en50494; + linuxdvb_lnb_t *lse_lnb; + linuxdvb_diseqc_t *lse_switch; + linuxdvb_diseqc_t *lse_rotor; + linuxdvb_diseqc_t *lse_en50494; }; struct linuxdvb_diseqc @@ -346,4 +351,15 @@ linuxdvb_satconf_t *linuxdvb_satconf_create void linuxdvb_satconf_delete ( linuxdvb_satconf_t *ls, int delconf ); +int linuxdvb_satconf_get_priority + ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm ); + +int linuxdvb_satconf_get_grace + ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm ); + +void linuxdvb_satconf_post_stop_mux( linuxdvb_satconf_t *ls ); + +int linuxdvb_satconf_start_mux + ( linuxdvb_satconf_t *ls, mpegts_mux_instance_t *mmi ); + #endif /* __TVH_LINUXDVB_PRIVATE_H__ */ diff --git a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c index 0d432abc..74fbf3e2 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c @@ -135,7 +135,7 @@ linuxdvb_rotor_gotox_tune ( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) { int i; - for (i = 0; i <= ls->ls_parent->ls_diseqc_repeats; i++) { + for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) { if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) { tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position); return -1; @@ -203,7 +203,7 @@ linuxdvb_rotor_usals_tune fabs(pos), (pos > 0.0) ? 'E' : 'W', motor_angle, (motor_angle > 0.0) ? "counter-" : ""); - for (i = 0; i <= ls->ls_parent->ls_diseqc_repeats; i++) { + for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) { if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6E, 2, angle_1, angle_2)) { tvherror("diseqc", "failed to send USALS command"); return -1; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 1ba7ad07..13da461f 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -44,38 +44,42 @@ struct linuxdvb_satconf_type { * Types * *************************************************************************/ -static const void * -linuxdvb_satconf_class_network_get - ( linuxdvb_satconf_t *ls, int idx ) +static linuxdvb_satconf_ele_t * +linuxdvb_satconf_class_find_ele( linuxdvb_satconf_t *ls, int idx ) { int i = 0; linuxdvb_satconf_ele_t *lse; - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link) { + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link) { if (i == idx) break; i++; } + return lse; +} + +static const void * +linuxdvb_satconf_class_network_get( linuxdvb_satconf_t *ls, int idx ) +{ + linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_class_find_ele(ls, idx); if (lse) - return mpegts_input_class_network_get(lse); + return idnode_set_as_htsmsg(lse->lse_networks); return NULL; } +static int +linuxdvb_satconf_ele_class_network_set( void *o, const void *p ); + static int linuxdvb_satconf_class_network_set ( linuxdvb_satconf_t *ls, int idx, const void *networks ) { - int i = 0; - linuxdvb_satconf_ele_t *lse; - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link) { - if (i == idx) break; - i++; - } + linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_class_find_ele(ls, idx); if (lse) - return mpegts_input_class_network_set(lse, networks); + return linuxdvb_satconf_ele_class_network_set(lse, networks); return 0; } static htsmsg_t * -linuxdvb_satconf_class_network_enum(void *o) +linuxdvb_satconf_class_network_enum( void *o ) { extern const idclass_t linuxdvb_network_dvbs_class; htsmsg_t *m = htsmsg_create_map(); @@ -90,6 +94,17 @@ linuxdvb_satconf_class_network_enum(void *o) return m; } +static char * +linuxdvb_satconf_ele_class_network_rend( void *o ); + +static char * +linuxdvb_satconf_class_network_rend( linuxdvb_satconf_t *ls, int idx ) +{ + linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_class_find_ele(ls, idx); + if (lse) + return linuxdvb_satconf_ele_class_network_rend(lse); + return NULL; +} #define linuxdvb_satconf_class_network_getset(x)\ static int \ @@ -101,6 +116,11 @@ static const void * \ linuxdvb_satconf_class_network_get##x ( void *o )\ {\ return linuxdvb_satconf_class_network_get(o, x);\ +}\ +static char * \ +linuxdvb_satconf_class_network_rend##x ( void *o )\ +{\ + return linuxdvb_satconf_class_network_rend(o, x);\ } linuxdvb_satconf_class_network_getset(0); @@ -133,7 +153,7 @@ linuxdvb_satconf_class_orbitalpos_get ( void *p ) linuxdvb_satconf_t *ls = p; linuxdvb_satconf_ele_t *lse; n = 0; - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link) + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link) n++; return &n; } @@ -175,8 +195,8 @@ linuxdvb_satconf_class_get_childs ( idnode_t *o ) linuxdvb_satconf_t *ls = (linuxdvb_satconf_t*)o; linuxdvb_satconf_ele_t *lse; idnode_set_t *is = idnode_set_create(); - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link) - idnode_set_add(is, &lse->ti_id, NULL); + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link) + idnode_set_add(is, &lse->lse_id, NULL); return is; } @@ -227,7 +247,7 @@ const idclass_t linuxdvb_satconf_lnbonly_class = .get = linuxdvb_satconf_class_network_get0, .set = linuxdvb_satconf_class_network_set0, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend0, .opts = PO_NOSAVE, }, {} @@ -251,7 +271,7 @@ const idclass_t linuxdvb_satconf_2port_class = .get = linuxdvb_satconf_class_network_get0, .set = linuxdvb_satconf_class_network_set0, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend0, .opts = PO_NOSAVE, }, { @@ -262,7 +282,7 @@ const idclass_t linuxdvb_satconf_2port_class = .get = linuxdvb_satconf_class_network_get1, .set = linuxdvb_satconf_class_network_set1, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend1, .opts = PO_NOSAVE, }, {} @@ -286,7 +306,7 @@ const idclass_t linuxdvb_satconf_4port_class = .get = linuxdvb_satconf_class_network_get0, .set = linuxdvb_satconf_class_network_set0, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend0, .opts = PO_NOSAVE, }, { @@ -297,7 +317,7 @@ const idclass_t linuxdvb_satconf_4port_class = .get = linuxdvb_satconf_class_network_get1, .set = linuxdvb_satconf_class_network_set1, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend1, .opts = PO_NOSAVE, }, { @@ -308,7 +328,7 @@ const idclass_t linuxdvb_satconf_4port_class = .get = linuxdvb_satconf_class_network_get2, .set = linuxdvb_satconf_class_network_set2, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend2, .opts = PO_NOSAVE, }, { @@ -319,7 +339,7 @@ const idclass_t linuxdvb_satconf_4port_class = .get = linuxdvb_satconf_class_network_get3, .set = linuxdvb_satconf_class_network_set3, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend3, .opts = PO_NOSAVE, }, {} @@ -334,7 +354,7 @@ linuxdvb_satconf_class_en50494_id_get ( void *p ) { linuxdvb_satconf_t *ls = p; linuxdvb_satconf_ele_t *lse = TAILQ_FIRST(&ls->ls_elements); - return &(((linuxdvb_en50494_t*)lse->ls_en50494)->le_id); + return &(((linuxdvb_en50494_t*)lse->lse_en50494)->le_id); } static int @@ -343,8 +363,8 @@ linuxdvb_satconf_class_en50494_id_set { linuxdvb_satconf_t *ls = p; linuxdvb_satconf_ele_t *lse; - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link) - (((linuxdvb_en50494_t*)lse->ls_en50494)->le_id) = *(uint16_t*)v; + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link) + (((linuxdvb_en50494_t*)lse->lse_en50494)->le_id) = *(uint16_t*)v; return 0; } @@ -353,7 +373,7 @@ linuxdvb_satconf_class_en50494_pin_get ( void *p ) { linuxdvb_satconf_t *ls = p; linuxdvb_satconf_ele_t *lse = TAILQ_FIRST(&ls->ls_elements); - return &(((linuxdvb_en50494_t*)lse->ls_en50494)->le_pin); + return &(((linuxdvb_en50494_t*)lse->lse_en50494)->le_pin); } static int @@ -362,8 +382,8 @@ linuxdvb_satconf_class_en50494_pin_set { linuxdvb_satconf_t *ls = p; linuxdvb_satconf_ele_t *lse; - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link) - (((linuxdvb_en50494_t*)lse->ls_en50494)->le_pin) = *(uint16_t*)v; + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link) + (((linuxdvb_en50494_t*)lse->lse_en50494)->le_pin) = *(uint16_t*)v; return 0; } @@ -372,7 +392,7 @@ linuxdvb_satconf_class_en50494_freq_get ( void *p ) { linuxdvb_satconf_t *ls = p; linuxdvb_satconf_ele_t *lse = TAILQ_FIRST(&ls->ls_elements); - return &(((linuxdvb_en50494_t*)lse->ls_en50494)->le_frequency); + return &(((linuxdvb_en50494_t*)lse->lse_en50494)->le_frequency); } static int @@ -381,8 +401,8 @@ linuxdvb_satconf_class_en50494_freq_set { linuxdvb_satconf_t *ls = p; linuxdvb_satconf_ele_t *lse; - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link) - (((linuxdvb_en50494_t*)lse->ls_en50494)->le_frequency) = *(uint16_t*)v; + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link) + (((linuxdvb_en50494_t*)lse->lse_en50494)->le_frequency) = *(uint16_t*)v; return 0; } @@ -425,7 +445,7 @@ const idclass_t linuxdvb_satconf_en50494_class = .get = linuxdvb_satconf_class_network_get0, .set = linuxdvb_satconf_class_network_set0, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend0, .opts = PO_NOSAVE, }, { @@ -435,7 +455,7 @@ const idclass_t linuxdvb_satconf_en50494_class = .get = linuxdvb_satconf_class_network_get1, .set = linuxdvb_satconf_class_network_set1, .list = linuxdvb_satconf_class_network_enum, - .rend = mpegts_input_class_network_rend, + .rend = linuxdvb_satconf_class_network_rend1, .opts = PO_NOSAVE, }, {} @@ -528,6 +548,159 @@ linuxdvb_satconf_type_list ( void *p ) return m; } +/* + * Frontend callbacks + */ + +static linuxdvb_satconf_ele_t * +linuxdvb_satconf_find_ele( linuxdvb_satconf_t *ls, mpegts_mux_t *mux ) +{ + linuxdvb_satconf_ele_t *lse; + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link) { + if (idnode_set_exists(lse->lse_networks, &mux->mm_network->mn_id)) + return lse; + } + return NULL; +} + +int +linuxdvb_satconf_get_priority + ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm ) +{ + linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_find_ele(ls, mm); + return lse->lse_priority; +} + +void +linuxdvb_satconf_post_stop_mux + ( linuxdvb_satconf_t *ls ) +{ + gtimer_disarm(&ls->ls_diseqc_timer); + if (ls->ls_frontend && ls->ls_lnb_poweroff) + linuxdvb_diseqc_set_volt( + ((linuxdvb_frontend_t *)ls->ls_frontend)->lfe_fe_fd, -1); +} + +int +linuxdvb_satconf_get_grace + ( linuxdvb_satconf_t *ls, mpegts_mux_t *mm ) +{ + linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_find_ele(ls, mm); + int i, r = 10; + linuxdvb_diseqc_t *lds[] = { + (linuxdvb_diseqc_t*)lse->lse_en50494, + (linuxdvb_diseqc_t*)lse->lse_switch, + (linuxdvb_diseqc_t*)lse->lse_rotor, + (linuxdvb_diseqc_t*)lse->lse_lnb + }; + + /* Add diseqc delay */ + for (i = 0; i < 3; i++) { + if (lds[i] && lds[i]->ld_grace) + r += lds[i]->ld_grace(lds[i], (linuxdvb_mux_t*)mm); + } + + return r; +} + +static void linuxdvb_satconf_ele_tune_cb ( void *o ); + +static int +linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) +{ + int r, i, b; + uint32_t f; + linuxdvb_satconf_t *ls = lse->lse_parent; + + /* Get beans in a row */ + mpegts_mux_instance_t *mmi = ls->ls_mmi; + linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ls->ls_frontend; + linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; + linuxdvb_diseqc_t *lds[] = { + lse->lse_rotor ? (linuxdvb_diseqc_t*)lse->lse_switch : NULL, + (linuxdvb_diseqc_t*)lse->lse_rotor, + (linuxdvb_diseqc_t*)lse->lse_switch, + (linuxdvb_diseqc_t*)lse->lse_en50494, + (linuxdvb_diseqc_t*)lse->lse_lnb + }; + // TODO: really need to understand whether or not we need to pre configure + // and/or re-affirm the switch + + /* Disable tone */ + if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, SEC_TONE_OFF)) { + tvherror("diseqc", "failed to disable tone"); + return -1; + } + + /* Diseqc */ + i = ls->ls_diseqc_idx; + for (i = ls->ls_diseqc_idx; i < ARRAY_SIZE(lds); i++) { + if (!lds[i]) continue; + r = lds[i]->ld_tune(lds[i], lm, lse, lfe->lfe_fe_fd); + + /* Error */ + if (r < 0) return r; + + /* Pending */ + if (r != 0) { + gtimer_arm_ms(&ls->ls_diseqc_timer, linuxdvb_satconf_ele_tune_cb, lse, r); + ls->ls_diseqc_idx = i + 1; + return 0; + } + } + + /* Set the tone */ + b = lse->lse_lnb->lnb_band(lse->lse_lnb, lm); + tvhtrace("disqec", "set diseqc tone %s", b ? "on" : "off"); + if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, b ? SEC_TONE_ON : SEC_TONE_OFF)) { + tvherror("diseqc", "failed to set diseqc tone (e=%s)", strerror(errno)); + return -1; + } + usleep(20000); // Allow LNB to settle before tuning + + /* Frontend */ + /* use en50494 tuning frequency, if needed (not channel frequency) */ + f = lse->lse_en50494 + ? ((linuxdvb_en50494_t*)lse->lse_en50494)->le_tune_freq + : lse->lse_lnb->lnb_freq(lse->lse_lnb, lm); + return linuxdvb_frontend_tune1(lfe, mmi, f); +} + +static void +linuxdvb_satconf_ele_tune_cb ( void *o ) +{ + (void)linuxdvb_satconf_ele_tune(o); + // TODO: how to signal error +} + +int +linuxdvb_satconf_start_mux + ( linuxdvb_satconf_t *ls, mpegts_mux_instance_t *mmi ) +{ + int r; + uint32_t f; + linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_find_ele(ls, mmi->mmi_mux); + linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ls->ls_frontend; + linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; + + /* Test run */ + // Note: basically this ensures the tuning params are acceptable + // for the FE, so that if they're not we don't have to wait + // for things like rotors and switches + if (!lse->lse_lnb) + return SM_CODE_TUNING_FAILED; + f = lse->lse_lnb->lnb_freq(lse->lse_lnb, lm); + if (f == (uint32_t)-1) + return SM_CODE_TUNING_FAILED; + r = linuxdvb_frontend_tune0(lfe, mmi, f); + if (r) return r; + + /* Diseqc */ + ls->ls_mmi = mmi; + ls->ls_diseqc_idx = 0; + return linuxdvb_satconf_ele_tune(lse); +} + /* ************************************************************************** * Create/Delete satconf * *************************************************************************/ @@ -542,8 +715,7 @@ linuxdvb_satconf_create htsmsg_field_t *f; linuxdvb_satconf_ele_t *lse; const char *str; - struct linuxdvb_satconf_type *lst - = linuxdvb_satconf_type_find(type); + struct linuxdvb_satconf_type *lst = linuxdvb_satconf_type_find(type); assert(lst); linuxdvb_satconf_t *ls = calloc(1, sizeof(linuxdvb_satconf_t)); @@ -588,18 +760,18 @@ linuxdvb_satconf_create while (i < lst->ports) { if (!lse) lse = linuxdvb_satconf_ele_create0(NULL, NULL, ls); - if (!lse->ls_lnb) - lse->ls_lnb = linuxdvb_lnb_create0(NULL, NULL, lse); + if (!lse->lse_lnb) + lse->lse_lnb = linuxdvb_lnb_create0(NULL, NULL, lse); if (lst->ports > 1) { if (!strcmp(lst->type, "en50494")) { - if (!lse->ls_en50494) - lse->ls_en50494 = linuxdvb_en50494_create0("Generic", NULL, lse, i); + if (!lse->lse_en50494) + lse->lse_en50494 = linuxdvb_en50494_create0("Generic", NULL, lse, i); } else { - if (!lse->ls_switch) - lse->ls_switch = linuxdvb_switch_create0("Generic", NULL, lse, i, -1); + if (!lse->lse_switch) + lse->lse_switch = linuxdvb_switch_create0("Generic", NULL, lse, i, -1); } } - lse = TAILQ_NEXT(lse, ls_link); + lse = TAILQ_NEXT(lse, lse_link); i++; } @@ -614,28 +786,28 @@ linuxdvb_satconf_save ( linuxdvb_satconf_t *ls, htsmsg_t *m ) htsmsg_add_str(m, "type", ls->ls_type); idnode_save(&ls->ls_id, m); l = htsmsg_create_list(); - TAILQ_FOREACH(lse, &ls->ls_elements, ls_link){ + TAILQ_FOREACH(lse, &ls->ls_elements, lse_link){ e = htsmsg_create_map(); - idnode_save(&lse->ti_id, e); - htsmsg_add_str(e, "uuid", idnode_uuid_as_str(&lse->ti_id)); - if (lse->ls_lnb) { + idnode_save(&lse->lse_id, e); + htsmsg_add_str(e, "uuid", idnode_uuid_as_str(&lse->lse_id)); + if (lse->lse_lnb) { c = htsmsg_create_map(); - idnode_save(&lse->ls_lnb->ld_id, c); + idnode_save(&lse->lse_lnb->ld_id, c); htsmsg_add_msg(e, "lnb_conf", c); } - if (lse->ls_switch) { + if (lse->lse_switch) { c = htsmsg_create_map(); - idnode_save(&lse->ls_switch->ld_id, c); + idnode_save(&lse->lse_switch->ld_id, c); htsmsg_add_msg(e, "switch_conf", c); } - if (lse->ls_rotor) { + if (lse->lse_rotor) { c = htsmsg_create_map(); - idnode_save(&lse->ls_rotor->ld_id, c); + idnode_save(&lse->lse_rotor->ld_id, c); htsmsg_add_msg(e, "rotor_conf", c); } - if (lse->ls_en50494) { + if (lse->lse_en50494) { c = htsmsg_create_map(); - idnode_save(&lse->ls_en50494->ld_id, c); + idnode_save(&lse->lse_en50494->ld_id, c); htsmsg_add_msg(e, "en50494_conf", c); } htsmsg_add_msg(l, NULL, e); @@ -649,15 +821,85 @@ linuxdvb_satconf_save ( linuxdvb_satconf_t *ls, htsmsg_t *m ) extern const idclass_t mpegts_input_class; +static const void * +linuxdvb_satconf_ele_class_network_get( void *o ) +{ + linuxdvb_satconf_ele_t *ls = o; + return idnode_set_as_htsmsg(ls->lse_networks); +} + +static int +linuxdvb_satconf_ele_class_network_set( void *o, const void *p ) +{ + linuxdvb_satconf_ele_t *ls = o; + const htsmsg_t *msg = p; + mpegts_network_t *mn; + idnode_set_t *n = idnode_set_create(); + htsmsg_field_t *f; + const char *str; + int i, save; + + HTSMSG_FOREACH(f, msg) { + if (!(str = htsmsg_field_get_str(f))) continue; + if (!(mn = mpegts_network_find(str))) continue; + idnode_set_add(n, &mn->mn_id, NULL); + } + + save = n->is_count != ls->lse_networks->is_count; + if (!save) { + for (i = 0; i < n->is_count; i++) + if (!idnode_set_exists(ls->lse_networks, n->is_array[i])) { + save = 1; + break; + } + } + if (save) { + /* update the local (antenna satconf) network list */ + idnode_set_free(ls->lse_networks); + ls->lse_networks = n; + /* update the input (frontend) network list */ + htsmsg_t *l = htsmsg_create_list(); + linuxdvb_satconf_t *sc = ls->lse_parent; + linuxdvb_satconf_ele_t *lse; + TAILQ_FOREACH(lse, &sc->ls_elements, lse_link) { + for (i = 0; i < lse->lse_networks->is_count; i++) + htsmsg_add_str(l, NULL, + idnode_uuid_as_str(lse->lse_networks->is_array[i])); + } + mpegts_input_class_network_set(ls->lse_parent->ls_frontend, l); + htsmsg_destroy(l); + } else { + idnode_set_free(n); + } + return save; +} + +static htsmsg_t * +linuxdvb_satconf_ele_class_network_enum( void *o ) +{ + linuxdvb_satconf_ele_t *ls = o; + return mpegts_input_class_network_enum(ls->lse_parent->ls_frontend); +} + +static char * +linuxdvb_satconf_ele_class_network_rend( void *o ) +{ + linuxdvb_satconf_ele_t *ls = o; + htsmsg_t *l = idnode_set_as_htsmsg(ls->lse_networks); + char *str = htsmsg_list_2_csv(l); + htsmsg_destroy(l); + return str; +} + static int linuxdvb_satconf_ele_class_lnbtype_set ( void *o, const void *p ) { linuxdvb_satconf_ele_t *ls = o; const char *str = p; - if (ls->ls_lnb && !strcmp(str ?: "", ls->ls_lnb->ld_type)) + if (ls->lse_lnb && !strcmp(str ?: "", ls->lse_lnb->ld_type)) return 0; - if (ls->ls_lnb) linuxdvb_lnb_destroy(ls->ls_lnb); - ls->ls_lnb = linuxdvb_lnb_create0(str, NULL, ls); + if (ls->lse_lnb) linuxdvb_lnb_destroy(ls->lse_lnb); + ls->lse_lnb = linuxdvb_lnb_create0(str, NULL, ls); return 1; } @@ -666,7 +908,7 @@ linuxdvb_satconf_ele_class_lnbtype_get ( void *o ) { static const char *s; linuxdvb_satconf_ele_t *ls = o; - s = ls->ls_lnb ? ls->ls_lnb->ld_type : NULL; + s = ls->lse_lnb ? ls->lse_lnb->ld_type : NULL; return &s; } @@ -675,9 +917,9 @@ linuxdvb_satconf_ele_class_en50494type_set ( void *o, const void *p ) { linuxdvb_satconf_ele_t *ls = o; const char *str = p; - if (ls->ls_en50494) - linuxdvb_en50494_destroy(ls->ls_en50494); - ls->ls_en50494 = linuxdvb_en50494_create0(str, NULL, ls, 0); + if (ls->lse_en50494) + linuxdvb_en50494_destroy(ls->lse_en50494); + ls->lse_en50494 = linuxdvb_en50494_create0(str, NULL, ls, 0); return 1; } @@ -686,7 +928,7 @@ linuxdvb_satconf_ele_class_en50494type_get ( void *o ) { static const char *s; linuxdvb_satconf_ele_t *ls = o; - s = ls->ls_en50494 ? ls->ls_en50494->ld_type : NULL; + s = ls->lse_en50494 ? ls->lse_en50494->ld_type : NULL; return &s; } @@ -695,10 +937,10 @@ linuxdvb_satconf_ele_class_switchtype_set ( void *o, const void *p ) { linuxdvb_satconf_ele_t *ls = o; const char *str = p; - if (ls->ls_switch && !strcmp(str ?: "", ls->ls_switch->ld_type)) + if (ls->lse_switch && !strcmp(str ?: "", ls->lse_switch->ld_type)) return 0; - if (ls->ls_switch) linuxdvb_switch_destroy(ls->ls_switch); - ls->ls_switch = linuxdvb_switch_create0(str, NULL, ls, 0, 0); + if (ls->lse_switch) linuxdvb_switch_destroy(ls->lse_switch); + ls->lse_switch = linuxdvb_switch_create0(str, NULL, ls, 0, 0); return 1; } @@ -707,7 +949,7 @@ linuxdvb_satconf_ele_class_switchtype_get ( void *o ) { static const char *s; linuxdvb_satconf_ele_t *ls = o; - s = ls->ls_switch ? ls->ls_switch->ld_type : NULL; + s = ls->lse_switch ? ls->lse_switch->ld_type : NULL; return &s; } @@ -716,10 +958,10 @@ linuxdvb_satconf_ele_class_rotortype_set ( void *o, const void *p ) { linuxdvb_satconf_ele_t *ls = o; const char *str = p; - if (ls->ls_rotor && !strcmp(str ?: "", ls->ls_rotor->ld_type)) + if (ls->lse_rotor && !strcmp(str ?: "", ls->lse_rotor->ld_type)) return 0; - if (ls->ls_rotor) linuxdvb_rotor_destroy(ls->ls_rotor); - ls->ls_rotor = linuxdvb_rotor_create0(str, NULL, ls); + if (ls->lse_rotor) linuxdvb_rotor_destroy(ls->lse_rotor); + ls->lse_rotor = linuxdvb_rotor_create0(str, NULL, ls); return 1; } @@ -728,22 +970,14 @@ linuxdvb_satconf_ele_class_rotortype_get ( void *o ) { static const char *s; linuxdvb_satconf_ele_t *ls = o; - s = ls->ls_rotor ? ls->ls_rotor->ld_type : NULL; + s = ls->lse_rotor ? ls->lse_rotor->ld_type : NULL; return &s; } static const char * linuxdvb_satconf_ele_class_get_title ( idnode_t *o ) { - static char buf[128]; -#if 0 - linuxdvb_satconf_ele_t *ls = (linuxdvb_satconf_ele_t*)o; - if (ls->mi_network) - ls->mi_network->mn_display_name(ls->mi_network, buf, sizeof(buf)); - else - *buf = 0; -#endif - return buf; + return ((linuxdvb_satconf_ele_t *)o)->lse_name; } static idnode_set_t * @@ -751,14 +985,14 @@ linuxdvb_satconf_ele_class_get_childs ( idnode_t *o ) { linuxdvb_satconf_ele_t *ls = (linuxdvb_satconf_ele_t*)o; idnode_set_t *is = idnode_set_create(); - if (ls->ls_lnb) - idnode_set_add(is, &ls->ls_lnb->ld_id, NULL); - if (ls->ls_switch) - idnode_set_add(is, &ls->ls_switch->ld_id, NULL); - if (ls->ls_rotor) - idnode_set_add(is, &ls->ls_rotor->ld_id, NULL); - if (ls->ls_en50494) - idnode_set_add(is, &ls->ls_en50494->ld_id, NULL); + if (ls->lse_lnb) + idnode_set_add(is, &ls->lse_lnb->ld_id, NULL); + if (ls->lse_switch) + idnode_set_add(is, &ls->lse_switch->ld_id, NULL); + if (ls->lse_rotor) + idnode_set_add(is, &ls->lse_rotor->ld_id, NULL); + if (ls->lse_en50494) + idnode_set_add(is, &ls->lse_en50494->ld_id, NULL); return is; } @@ -766,18 +1000,48 @@ static void linuxdvb_satconf_ele_class_save ( idnode_t *in ) { linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)in; - linuxdvb_satconf_class_save(&lse->ls_parent->ls_id); + linuxdvb_satconf_class_save(&lse->lse_parent->ls_id); } const idclass_t linuxdvb_satconf_ele_class = { - .ic_super = &mpegts_input_class, .ic_class = "linuxdvb_satconf_ele", .ic_caption = "Satconf", .ic_get_title = linuxdvb_satconf_ele_class_get_title, .ic_get_childs = linuxdvb_satconf_ele_class_get_childs, .ic_save = linuxdvb_satconf_ele_class_save, .ic_properties = (const property_t[]) { + { + .type = PT_BOOL, + .id = "enabled", + .name = "Enabled", + .off = offsetof(linuxdvb_satconf_ele_t, lse_enabled), + }, + { + .type = PT_STR, + .id = "displayname", + .name = "Name", + .off = offsetof(linuxdvb_satconf_ele_t, lse_name), + .notify = idnode_notify_title_changed, + }, + { + .type = PT_INT, + .id = "priority", + .name = "Priority", + .off = offsetof(linuxdvb_satconf_ele_t, lse_priority), + .def.i = 1, + .opts = PO_ADVANCED, + }, + { + .type = PT_STR, + .id = "networks", + .name = "Networks", + .islist = 1, + .set = linuxdvb_satconf_ele_class_network_set, + .get = linuxdvb_satconf_ele_class_network_get, + .list = linuxdvb_satconf_ele_class_network_enum, + .rend = linuxdvb_satconf_ele_class_network_rend, + }, { .type = PT_STR, .id = "lnb_type", @@ -818,237 +1082,6 @@ const idclass_t linuxdvb_satconf_ele_class = } }; -/* ************************************************************************** - * MPEG-TS Class methods - * *************************************************************************/ - -static void -linuxdvb_satconf_ele_display_name ( mpegts_input_t* mi, char *buf, size_t len ) -{ - linuxdvb_satconf_t *ls = ((linuxdvb_satconf_ele_t*)mi)->ls_parent; - if (ls->ls_frontend) - ls->ls_frontend->mi_display_name(ls->ls_frontend, buf, len); - else - strncpy(buf, "Unknown", len); -} - -#define linuxdvb_satconf_ele_proxy(type, func)\ -static type \ -linuxdvb_satconf_ele_##func ( mpegts_input_t *mi )\ -{\ - linuxdvb_satconf_t *ls = ((linuxdvb_satconf_ele_t*)mi)->ls_parent;\ - return ls->ls_frontend->mi_##func(ls->ls_frontend);\ -} - -linuxdvb_satconf_ele_proxy(int, is_enabled); -linuxdvb_satconf_ele_proxy(int, is_free); -linuxdvb_satconf_ele_proxy(int, get_weight); - -static int -linuxdvb_satconf_ele_get_priority ( mpegts_input_t *mi ) -{ - int prio = 0; - linuxdvb_satconf_t *ls = ((linuxdvb_satconf_ele_t*)mi)->ls_parent; - if (ls->ls_frontend) - prio = ls->ls_frontend->mi_get_priority(ls->ls_frontend); - return prio + mpegts_input_get_priority(mi); -} - -static void -linuxdvb_satconf_ele_stop_mux - ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi ) -{ - linuxdvb_satconf_t *ls = ((linuxdvb_satconf_ele_t*)mi)->ls_parent; - if (ls->ls_frontend) - ls->ls_frontend->mi_stop_mux(ls->ls_frontend, mmi); - gtimer_disarm(&ls->ls_diseqc_timer); - if (ls->ls_frontend && ls->ls_lnb_poweroff) - linuxdvb_diseqc_set_volt( - ((linuxdvb_frontend_t *)ls->ls_frontend)->lfe_fe_fd, -1); -} - -static void linuxdvb_satconf_ele_tune_cb ( void *o ); - -static int -linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) -{ - int r, i, b; - uint32_t f; - linuxdvb_satconf_t *ls = lse->ls_parent; - - /* Get beans in a row */ - mpegts_mux_instance_t *mmi = ls->ls_mmi; - linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ls->ls_frontend; - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; - linuxdvb_diseqc_t *lds[] = { - lse->ls_rotor ? (linuxdvb_diseqc_t*)lse->ls_switch : NULL, - (linuxdvb_diseqc_t*)lse->ls_rotor, - (linuxdvb_diseqc_t*)lse->ls_switch, - (linuxdvb_diseqc_t*)lse->ls_en50494, - (linuxdvb_diseqc_t*)lse->ls_lnb - }; - // TODO: really need to understand whether or not we need to pre configure - // and/or re-affirm the switch - - /* Disable tone */ - if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, SEC_TONE_OFF)) { - tvherror("diseqc", "failed to disable tone"); - return -1; - } - - /* Diseqc */ - i = ls->ls_diseqc_idx; - for (i = ls->ls_diseqc_idx; i < ARRAY_SIZE(lds); i++) { - if (!lds[i]) continue; - r = lds[i]->ld_tune(lds[i], lm, lse, lfe->lfe_fe_fd); - - /* Error */ - if (r < 0) return r; - - /* Pending */ - if (r != 0) { - gtimer_arm_ms(&ls->ls_diseqc_timer, linuxdvb_satconf_ele_tune_cb, lse, r); - ls->ls_diseqc_idx = i + 1; - return 0; - } - } - - /* Set the tone */ - b = lse->ls_lnb->lnb_band(lse->ls_lnb, lm); - tvhtrace("disqec", "set diseqc tone %s", b ? "on" : "off"); - if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, b ? SEC_TONE_ON : SEC_TONE_OFF)) { - tvherror("diseqc", "failed to set diseqc tone (e=%s)", strerror(errno)); - return -1; - } - usleep(20000); // Allow LNB to settle before tuning - - /* Frontend */ - /* use en50494 tuning frequency, if needed (not channel frequency) */ - f = lse->ls_en50494 - ? ((linuxdvb_en50494_t*)lse->ls_en50494)->le_tune_freq - : lse->ls_lnb->lnb_freq(lse->ls_lnb, lm); - return linuxdvb_frontend_tune1(lfe, mmi, f); -} - -static void -linuxdvb_satconf_ele_tune_cb ( void *o ) -{ - (void)linuxdvb_satconf_ele_tune(o); - // TODO: how to signal error -} - -static int -linuxdvb_satconf_ele_start_mux - ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi ) -{ - int r; - uint32_t f; - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ls->ls_frontend; - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; - - /* Test run */ - // Note: basically this ensures the tuning params are acceptable - // for the FE, so that if they're not we don't have to wait - // for things like rotors and switches - if (!lse->ls_lnb) - return SM_CODE_TUNING_FAILED; - f = lse->ls_lnb->lnb_freq(lse->ls_lnb, lm); - if (f == (uint32_t)-1) - return SM_CODE_TUNING_FAILED; - r = linuxdvb_frontend_tune0(lfe, mmi, f); - if (r) return r; - - /* Diseqc */ - ls->ls_mmi = mmi; - ls->ls_diseqc_idx = 0; - return linuxdvb_satconf_ele_tune(lse); -} - -static void -linuxdvb_satconf_ele_open_service - ( mpegts_input_t *mi, mpegts_service_t *s, int init ) -{ - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - ls->ls_frontend->mi_open_service(ls->ls_frontend, s, init); -} - -static void -linuxdvb_satconf_ele_close_service - ( mpegts_input_t *mi, mpegts_service_t *s ) -{ - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - ls->ls_frontend->mi_close_service(ls->ls_frontend, s); -} - -static void -linuxdvb_satconf_ele_started_mux - ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi ) -{ - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - ls->ls_frontend->mi_started_mux(ls->ls_frontend, mmi); -} - -static void -linuxdvb_satconf_ele_stopped_mux - ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi ) -{ - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - ls->ls_frontend->mi_stopped_mux(ls->ls_frontend, mmi); -} - -static int -linuxdvb_satconf_ele_has_subscription - ( mpegts_input_t *mi, mpegts_mux_t *mm ) -{ - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - return ls->ls_frontend->mi_has_subscription(ls->ls_frontend, mm); -} - -static int -linuxdvb_satconf_ele_get_grace - ( mpegts_input_t *mi, mpegts_mux_t *mm ) -{ - int i, r; - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - linuxdvb_diseqc_t *lds[] = { - (linuxdvb_diseqc_t*)lse->ls_en50494, - (linuxdvb_diseqc_t*)lse->ls_switch, - (linuxdvb_diseqc_t*)lse->ls_rotor, - (linuxdvb_diseqc_t*)lse->ls_lnb - }; - - /* Get underlying value */ - if (ls->ls_frontend->mi_get_grace) - r = ls->ls_frontend->mi_get_grace(mi, mm); - else - r = 10; - - /* Add diseqc delay */ - for (i = 0; i < 3; i++) { - if (lds[i] && lds[i]->ld_grace) - r += lds[i]->ld_grace(lds[i], (linuxdvb_mux_t*)mm); - } - - return r; -} - -static mpegts_pid_t * -linuxdvb_satconf_ele_open_pid - ( mpegts_input_t *mi, mpegts_mux_t *mm, int pid, int type, void *owner ) -{ - linuxdvb_satconf_ele_t *lse = (linuxdvb_satconf_ele_t*)mi; - linuxdvb_satconf_t *ls = lse->ls_parent; - return ls->ls_frontend->mi_open_pid(ls->ls_frontend, mm, pid, type, owner); -} - /* ************************************************************************** * Creation/Config * *************************************************************************/ @@ -1056,12 +1089,14 @@ linuxdvb_satconf_ele_open_pid void linuxdvb_satconf_ele_destroy ( linuxdvb_satconf_ele_t *ls ) { - TAILQ_REMOVE(&ls->ls_parent->ls_elements, ls, ls_link); - if (ls->ls_lnb) linuxdvb_lnb_destroy(ls->ls_lnb); - if (ls->ls_switch) linuxdvb_switch_destroy(ls->ls_switch); - if (ls->ls_rotor) linuxdvb_rotor_destroy(ls->ls_rotor); - if (ls->ls_en50494) linuxdvb_en50494_destroy(ls->ls_en50494); - mpegts_input_delete((mpegts_input_t*)ls, 1); + TAILQ_REMOVE(&ls->lse_parent->ls_elements, ls, lse_link); + idnode_unlink(&ls->lse_id); + if (ls->lse_lnb) linuxdvb_lnb_destroy(ls->lse_lnb); + if (ls->lse_switch) linuxdvb_switch_destroy(ls->lse_switch); + if (ls->lse_rotor) linuxdvb_rotor_destroy(ls->lse_rotor); + if (ls->lse_en50494) linuxdvb_en50494_destroy(ls->lse_en50494); + free(ls->lse_name); + free(ls); } linuxdvb_satconf_ele_t * @@ -1069,50 +1104,40 @@ linuxdvb_satconf_ele_create0 ( const char *uuid, htsmsg_t *conf, linuxdvb_satconf_t *ls ) { htsmsg_t *e; - linuxdvb_satconf_ele_t *lse - = mpegts_input_create(linuxdvb_satconf_ele, uuid, conf); - lse->ls_parent = ls; - TAILQ_INSERT_TAIL(&ls->ls_elements, lse, ls_link); - - /* Input callbacks */ - lse->mi_is_enabled = linuxdvb_satconf_ele_is_enabled; - lse->mi_is_free = linuxdvb_satconf_ele_is_free; - lse->mi_get_weight = linuxdvb_satconf_ele_get_weight; - lse->mi_get_priority = linuxdvb_satconf_ele_get_priority; - lse->mi_get_grace = linuxdvb_satconf_ele_get_grace; - lse->mi_display_name = linuxdvb_satconf_ele_display_name; - lse->mi_start_mux = linuxdvb_satconf_ele_start_mux; - lse->mi_stop_mux = linuxdvb_satconf_ele_stop_mux; - lse->mi_open_service = linuxdvb_satconf_ele_open_service; - lse->mi_close_service = linuxdvb_satconf_ele_close_service; - lse->mi_started_mux = linuxdvb_satconf_ele_started_mux; - lse->mi_stopped_mux = linuxdvb_satconf_ele_stopped_mux; - lse->mi_has_subscription = linuxdvb_satconf_ele_has_subscription; - lse->mi_open_pid = linuxdvb_satconf_ele_open_pid; + linuxdvb_satconf_ele_t *lse = calloc(1, sizeof(*lse)); + if (idnode_insert(&lse->lse_id, uuid, &linuxdvb_satconf_ele_class)) { + free(lse); + return NULL; + } + lse->lse_networks = idnode_set_create(); + lse->lse_parent = ls; + TAILQ_INSERT_TAIL(&ls->ls_elements, lse, lse_link); + if (conf) + idnode_load(&lse->lse_id, conf); /* Config */ if (conf) { /* LNB */ - if (lse->ls_lnb && (e = htsmsg_get_map(conf, "lnb_conf"))) - idnode_load(&lse->ls_lnb->ld_id, e); + if (lse->lse_lnb && (e = htsmsg_get_map(conf, "lnb_conf"))) + idnode_load(&lse->lse_lnb->ld_id, e); /* Switch */ - if (lse->ls_switch && (e = htsmsg_get_map(conf, "switch_conf"))) - idnode_load(&lse->ls_switch->ld_id, e); + if (lse->lse_switch && (e = htsmsg_get_map(conf, "switch_conf"))) + idnode_load(&lse->lse_switch->ld_id, e); /* Rotor */ - if (lse->ls_rotor && (e = htsmsg_get_map(conf, "rotor_conf"))) - idnode_load(&lse->ls_rotor->ld_id, e); + if (lse->lse_rotor && (e = htsmsg_get_map(conf, "rotor_conf"))) + idnode_load(&lse->lse_rotor->ld_id, e); /* EN50494 */ - if (lse->ls_en50494 && (e = htsmsg_get_map(conf, "en50494_conf"))) - idnode_load(&lse->ls_en50494->ld_id, e); + if (lse->lse_en50494 && (e = htsmsg_get_map(conf, "en50494_conf"))) + idnode_load(&lse->lse_en50494->ld_id, e); } /* Create default LNB */ - if (!lse->ls_lnb) - lse->ls_lnb = linuxdvb_lnb_create0(NULL, NULL, lse); + if (!lse->lse_lnb) + lse->lse_lnb = linuxdvb_lnb_create0(NULL, NULL, lse); return lse; } @@ -1126,17 +1151,19 @@ linuxdvb_satconf_delete ( linuxdvb_satconf_t *ls, int delconf ) hts_settings_remove("input/linuxdvb/satconfs/%s", uuid); gtimer_disarm(&ls->ls_diseqc_timer); for (lse = TAILQ_FIRST(&ls->ls_elements); lse != NULL; lse = nxt) { - nxt = TAILQ_NEXT(lse, ls_link); - TAILQ_REMOVE(&ls->ls_elements, lse, ls_link); - if (lse->ls_lnb) - linuxdvb_lnb_destroy(lse->ls_lnb); - if (lse->ls_switch) - linuxdvb_switch_destroy(lse->ls_switch); - if (lse->ls_rotor) - linuxdvb_rotor_destroy(lse->ls_rotor); - if (lse->ls_en50494) - linuxdvb_en50494_destroy(lse->ls_en50494); - mpegts_input_delete((mpegts_input_t*)lse, delconf); + nxt = TAILQ_NEXT(lse, lse_link); + TAILQ_REMOVE(&ls->ls_elements, lse, lse_link); + if (lse->lse_lnb) + linuxdvb_lnb_destroy(lse->lse_lnb); + if (lse->lse_switch) + linuxdvb_switch_destroy(lse->lse_switch); + if (lse->lse_rotor) + linuxdvb_rotor_destroy(lse->lse_rotor); + if (lse->lse_en50494) + linuxdvb_en50494_destroy(lse->lse_en50494); + idnode_unlink(&lse->lse_id); + idnode_set_free(lse->lse_networks); + free(lse); } idnode_unlink(&ls->ls_id); free(ls); @@ -1158,7 +1185,7 @@ linuxdvb_diseqc_class_save ( idnode_t *o ) { linuxdvb_diseqc_t *ld = (linuxdvb_diseqc_t*)o; if (ld->ld_satconf) - linuxdvb_satconf_ele_class_save(&ld->ld_satconf->ti_id); + linuxdvb_satconf_ele_class_save(&ld->ld_satconf->lse_id); } const idclass_t linuxdvb_diseqc_class = diff --git a/src/input/mpegts/linuxdvb/linuxdvb_switch.c b/src/input/mpegts/linuxdvb/linuxdvb_switch.c index afe62a9b..b45f0d8c 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_switch.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_switch.c @@ -120,8 +120,8 @@ linuxdvb_switch_tune linuxdvb_switch_t *ls = (linuxdvb_switch_t*)ld; /* LNB settings */ - pol = (sc->ls_lnb) ? sc->ls_lnb->lnb_pol (sc->ls_lnb, lm) & 0x1 : 0; - band = (sc->ls_lnb) ? sc->ls_lnb->lnb_band(sc->ls_lnb, lm) & 0x1 : 0; + pol = (sc->lse_lnb) ? sc->lse_lnb->lnb_pol (sc->lse_lnb, lm) & 0x1 : 0; + band = (sc->lse_lnb) ? sc->lse_lnb->lnb_band(sc->lse_lnb, lm) & 0x1 : 0; /* Set the voltage */ if (linuxdvb_diseqc_set_volt(fd, pol)) @@ -131,7 +131,7 @@ linuxdvb_switch_tune com = 0xF0 | (ls->ls_committed << 2) | (pol << 1) | band; /* Single committed (before repeats) */ - if (sc->ls_parent->ls_diseqc_repeats > 0) { + if (sc->lse_parent->ls_diseqc_repeats > 0) { r2 = 1; if (linuxdvb_diseqc_send(fd, 0xE0, 0x10, 0x38, 1, com)) return -1; @@ -139,7 +139,7 @@ linuxdvb_switch_tune } /* Repeats */ - for (i = 0; i <= sc->ls_parent->ls_diseqc_repeats; i++) { + for (i = 0; i <= sc->lse_parent->ls_diseqc_repeats; i++) { /* Uncommitted */ if (linuxdvb_diseqc_send(fd, 0xE0 | r1, 0x10, 0x39, 1, diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 9d715ac3..7cd44e5d 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -197,7 +197,7 @@ mpegts_input_get_weight ( mpegts_input_t *mi ) } int -mpegts_input_get_priority ( mpegts_input_t *mi ) +mpegts_input_get_priority ( mpegts_input_t *mi, mpegts_mux_t *mm ) { return mi->mi_priority; } @@ -839,7 +839,7 @@ mpegts_input_set_networks ( mpegts_input_t *mi, htsmsg_t *msg ) htsmsg_field_t *f; mpegts_network_t *mn; mpegts_network_link_t *mnl, *nxt; - + /* Mark for deletion */ LIST_FOREACH(mnl, &mi->mi_networks, mnl_mi_link) mnl->mnl_mark = 1; diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index 76391338..03c5c720 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -181,7 +181,7 @@ mpegts_service_enlist(service_t *t, struct service_instance_list *sil) p = -1; } else { w = mmi->mmi_input->mi_get_weight(mmi->mmi_input); - p = mmi->mmi_input->mi_get_priority(mmi->mmi_input); + p = mmi->mmi_input->mi_get_priority(mmi->mmi_input, mmi->mmi_mux); } service_instance_add(sil, t, mmi->mmi_input->mi_instance, p, w); From 8b98f9c4a6908121039442efe649b21f00ed858f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 27 Mar 2014 12:23:18 +0100 Subject: [PATCH 3/5] Move the linuxdvb service code to the shared mpegts service code ... introduce $CFG/input/dvb/networks/... structure --- Makefile | 1 - src/input/mpegts.h | 2 - src/input/mpegts/linuxdvb/linuxdvb_mux.c | 18 ++++++- src/input/mpegts/linuxdvb/linuxdvb_network.c | 3 +- src/input/mpegts/linuxdvb/linuxdvb_private.h | 7 --- src/input/mpegts/linuxdvb/linuxdvb_service.c | 57 -------------------- src/input/mpegts/mpegts_service.c | 21 ++++---- 7 files changed, 27 insertions(+), 82 deletions(-) delete mode 100644 src/input/mpegts/linuxdvb/linuxdvb_service.c diff --git a/Makefile b/Makefile index 275e3435..1b5bb61a 100644 --- a/Makefile +++ b/Makefile @@ -191,7 +191,6 @@ SRCS-${CONFIG_LINUXDVB} += \ src/input/mpegts/linuxdvb/linuxdvb_frontend.c \ src/input/mpegts/linuxdvb/linuxdvb_network.c \ src/input/mpegts/linuxdvb/linuxdvb_mux.c \ - src/input/mpegts/linuxdvb/linuxdvb_service.c \ src/input/mpegts/linuxdvb/linuxdvb_satconf.c \ src/input/mpegts/linuxdvb/linuxdvb_lnb.c \ src/input/mpegts/linuxdvb/linuxdvb_switch.c \ diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 77840726..b1106ea6 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -689,8 +689,6 @@ mpegts_service_t *mpegts_service_create0 mpegts_service_t *mpegts_service_find ( mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid, int create, int *save ); -void mpegts_service_save ( mpegts_service_t *s, htsmsg_t *c ); - void mpegts_service_delete ( service_t *s, int delconf ); /* diff --git a/src/input/mpegts/linuxdvb/linuxdvb_mux.c b/src/input/mpegts/linuxdvb/linuxdvb_mux.c index 21b75b01..3fe7d350 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_mux.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_mux.c @@ -664,6 +664,8 @@ linuxdvb_mux_create0 linuxdvb_mux_t *lm; htsmsg_t *c, *e; htsmsg_field_t *f; + mpegts_service_t *ts; + int move = 0; /* Class */ if (ln->ln_type == DVB_TYPE_S) @@ -710,15 +712,27 @@ linuxdvb_mux_create0 if (!conf) return lm; /* Services */ - c = hts_settings_load_r(1, "input/linuxdvb/networks/%s/muxes/%s/services", + c = hts_settings_load_r(1, "input/dvb/networks/%s/muxes/%s/services", idnode_uuid_as_str(&ln->mn_id), idnode_uuid_as_str(&mm->mm_id)); + if (!c) { + move = 1; + c = hts_settings_load_r(1, "input/linuxdvb/networks/%s/muxes/%s/services", + idnode_uuid_as_str(&ln->mn_id), + idnode_uuid_as_str(&mm->mm_id)); + } if (c) { HTSMSG_FOREACH(f, c) { if (!(e = htsmsg_get_map_by_field(f))) continue; - (void)linuxdvb_service_create0(lm, 0, 0, f->hmf_name, e); + ts = mpegts_service_create1(f->hmf_name, (mpegts_mux_t *)lm, 0, 0, e); + if (ts && move) + ts->s_config_save((service_t *)ts); } htsmsg_destroy(c); + if (move) + hts_settings_remove("input/linuxdvb/networks/%s/muxes/%s/services", + idnode_uuid_as_str(&ln->mn_id), + idnode_uuid_as_str(&mm->mm_id)); } return lm; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_network.c b/src/input/mpegts/linuxdvb/linuxdvb_network.c index f15dca21..ede48535 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_network.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_network.c @@ -265,8 +265,7 @@ static mpegts_service_t * linuxdvb_network_create_service ( mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid ) { - return linuxdvb_service_create0((linuxdvb_mux_t*)mm, sid, - pmt_pid, NULL, NULL); + return mpegts_service_create1(NULL, mm, sid, pmt_pid, NULL); } static const idclass_t * diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index 2880d577..3602cddf 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -284,13 +284,6 @@ linuxdvb_mux_t *linuxdvb_mux_create0 linuxdvb_mux_create0(n, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE,\ NULL, u, c) -/* - * Service - */ -mpegts_service_t *linuxdvb_service_create0 - (linuxdvb_mux_t *lm, uint16_t sid, uint16_t pmt_pid, - const char *uuid, htsmsg_t *conf); - /* * Diseqc gear */ diff --git a/src/input/mpegts/linuxdvb/linuxdvb_service.c b/src/input/mpegts/linuxdvb/linuxdvb_service.c deleted file mode 100644 index 0081db56..00000000 --- a/src/input/mpegts/linuxdvb/linuxdvb_service.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Tvheadend - Linux DVB Service - * - * Copyright (C) 2013 Adam Sutton - * - * 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 . - */ - -#include "tvheadend.h" -#include "input.h" -#include "linuxdvb_private.h" -#include "queue.h" -#include "settings.h" - -#include -#include -#include -#include -#include -#include - -static void -linuxdvb_service_config_save ( service_t *t ) -{ - htsmsg_t *c = htsmsg_create_map(); - mpegts_service_t *s = (mpegts_service_t*)t; - mpegts_service_save(s, c); - hts_settings_save(c, "input/linuxdvb/networks/%s/muxes/%s/services/%s", - idnode_uuid_as_str(&s->s_dvb_mux->mm_network->mn_id), - idnode_uuid_as_str(&s->s_dvb_mux->mm_id), - idnode_uuid_as_str(&s->s_id)); - htsmsg_destroy(c); -} - -mpegts_service_t * -linuxdvb_service_create0 - ( linuxdvb_mux_t *mm, uint16_t sid, uint16_t pmt_pid, - const char *uuid, htsmsg_t *conf ) -{ - extern const idclass_t mpegts_service_class; - mpegts_service_t *s - = mpegts_service_create1(uuid, (mpegts_mux_t*)mm, sid, pmt_pid, conf); - if (s) - s->s_config_save = linuxdvb_service_config_save; - return s; -} diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index 03c5c720..debc23eb 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -148,8 +148,16 @@ mpegts_service_is_enabled(service_t *t) * Save */ static void -mpegts_service_config_save(service_t *t) +mpegts_service_config_save ( service_t *t ) { + htsmsg_t *c = htsmsg_create_map(); + mpegts_service_t *s = (mpegts_service_t*)t; + service_save(t, c); + hts_settings_save(c, "input/dvb/networks/%s/muxes/%s/services/%s", + idnode_uuid_as_str(&s->s_dvb_mux->mm_network->mn_id), + idnode_uuid_as_str(&s->s_dvb_mux->mm_id), + idnode_uuid_as_str(&s->s_id)); + htsmsg_destroy(c); } /* @@ -348,7 +356,7 @@ mpegts_service_delete ( service_t *t, int delconf ) /* Remove config */ if (delconf) - hts_settings_remove("input/linuxdvb/networks/%s/muxes/%s/services/%s", + hts_settings_remove("input/dvb/networks/%s/muxes/%s/services/%s", idnode_uuid_as_str(&mm->mm_network->mn_id), idnode_uuid_as_str(&mm->mm_id), idnode_uuid_as_str(&t->s_id)); @@ -451,15 +459,6 @@ mpegts_service_find return s; } -/* - * Save - */ -void -mpegts_service_save ( mpegts_service_t *s, htsmsg_t *c ) -{ - service_save((service_t*)s, c); -} - /****************************************************************************** * Editor Configuration * From 23d330de12515c0ea78428713355c029ca5775a4 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 30 Mar 2014 21:46:43 +0200 Subject: [PATCH 4/5] Move the linuxdvb network code to the shared mpegts network code ... introduce $CFG/input/dvb/networks/... structure --- Makefile | 11 +- configure | 6 +- src/api/api_mpegts.c | 16 +- src/descrambler/capmt.c | 2 +- src/descrambler/cwc.c | 2 +- src/descrambler/tvhcsa.c | 2 +- src/epggrab/module/eit.c | 3 +- src/epggrab/module/opentv.c | 2 +- src/epggrab/otamux.c | 2 +- src/input.h | 3 + src/input/mpegts.h | 5 + src/input/mpegts/dvb.h | 7 +- src/input/mpegts/dvb_charset.c | 2 +- src/input/mpegts/dvb_psi.c | 6 +- src/input/mpegts/dvb_support.c | 8 +- src/input/mpegts/iptv/iptv_private.h | 3 +- src/input/mpegts/linuxdvb/linuxdvb.c | 14 -- src/input/mpegts/linuxdvb/linuxdvb_frontend.c | 12 +- src/input/mpegts/linuxdvb/linuxdvb_mux.c | 4 +- src/input/mpegts/linuxdvb/linuxdvb_private.h | 24 +- src/input/mpegts/linuxdvb/linuxdvb_satconf.c | 3 +- src/input/mpegts/mpegts_dvb.h | 49 ++++ src/input/mpegts/mpegts_input.c | 2 +- src/input/mpegts/mpegts_mux.c | 2 +- src/input/mpegts/mpegts_network.c | 2 +- ...inuxdvb_network.c => mpegts_network_dvb.c} | 232 ++++++++++-------- src/input/mpegts/mpegts_service.c | 2 +- src/input/mpegts/mpegts_table.c | 2 +- src/input/mpegts/{linuxdvb => }/scanfile.c | 6 +- src/input/mpegts/{linuxdvb => }/scanfile.h | 6 +- src/input/mpegts/tsdemux.c | 2 +- src/input/mpegts/tsfile/tsfile_private.h | 2 +- src/main.c | 6 + src/parsers/parser_teletext.c | 2 +- src/service.c | 2 +- src/subscriptions.c | 4 +- src/webui/webui.c | 2 +- 37 files changed, 256 insertions(+), 204 deletions(-) create mode 100644 src/input/mpegts/mpegts_dvb.h rename src/input/mpegts/{linuxdvb/linuxdvb_network.c => mpegts_network_dvb.c} (58%) rename src/input/mpegts/{linuxdvb => }/scanfile.c (99%) rename src/input/mpegts/{linuxdvb => }/scanfile.h (93%) diff --git a/Makefile b/Makefile index 1b5bb61a..7f10ae99 100644 --- a/Makefile +++ b/Makefile @@ -177,6 +177,11 @@ SRCS-$(CONFIG_MPEGTS) += \ src/input/mpegts/dvb_psi.c \ src/input/mpegts/tsdemux.c \ +# MPEGTS DVB +SRCS-${CONFIG_MPEGTS_DVB} += \ + src/input/mpegts/mpegts_network_dvb.c \ + src/input/mpegts/scanfile.c + # MPEGTS EPG SRCS-$(CONFIG_MPEGTS) += \ src/epggrab/otamux.c\ @@ -184,19 +189,17 @@ SRCS-$(CONFIG_MPEGTS) += \ src/epggrab/support/freesat_huffman.c \ src/epggrab/module/opentv.c \ -# DVB +# LINUX DVB SRCS-${CONFIG_LINUXDVB} += \ src/input/mpegts/linuxdvb/linuxdvb.c \ src/input/mpegts/linuxdvb/linuxdvb_adapter.c \ src/input/mpegts/linuxdvb/linuxdvb_frontend.c \ - src/input/mpegts/linuxdvb/linuxdvb_network.c \ src/input/mpegts/linuxdvb/linuxdvb_mux.c \ src/input/mpegts/linuxdvb/linuxdvb_satconf.c \ src/input/mpegts/linuxdvb/linuxdvb_lnb.c \ src/input/mpegts/linuxdvb/linuxdvb_switch.c \ src/input/mpegts/linuxdvb/linuxdvb_rotor.c \ - src/input/mpegts/linuxdvb/linuxdvb_en50494.c \ - src/input/mpegts/linuxdvb/scanfile.c \ + src/input/mpegts/linuxdvb/linuxdvb_en50494.c # IPTV SRCS-${CONFIG_IPTV} += \ diff --git a/configure b/configure index 4446e349..3cd02ea3 100755 --- a/configure +++ b/configure @@ -36,6 +36,7 @@ OPTIONS=( "bundle:no" "dvbcsa:no" "kqueue:no" + "mpegts_dvb:auto" ) # @@ -138,10 +139,11 @@ fi # # DVB API # -check_cc_header 'linux/dvb/version' dvbapi +check_cc_header 'linux/dvb/version' linuxdvbapi if enabled_or_auto linuxdvb; then - if enabled dvbapi; then + if enabled linuxdvbapi; then enable linuxdvb + enable mpegts_dvb elif enabled linuxdvb; then die "Linux DVB API not found (use --disable-linuxdvb)" fi diff --git a/src/api/api_mpegts.c b/src/api/api_mpegts.c index 30a179fd..9409319e 100644 --- a/src/api/api_mpegts.c +++ b/src/api/api_mpegts.c @@ -21,11 +21,9 @@ #include "access.h" #include "htsmsg.h" #include "api.h" -#include "input/mpegts.h" -#if ENABLE_LINUXDVB -#include "input/mpegts/linuxdvb.h" -#include "input/mpegts/linuxdvb/linuxdvb_private.h" -#include "input/mpegts/linuxdvb/scanfile.h" +#include "input.h" +#if ENABLE_MPEGTS_DVB +#include "input/mpegts/scanfile.h" #endif /* @@ -253,9 +251,9 @@ api_mpegts_service_grid } } -#if ENABLE_LINUXDVB +#if ENABLE_MPEGTS_DVB static int -api_linuxdvb_scanfile_list +api_dvb_scanfile_list ( void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp ) { char buf[512]; @@ -323,8 +321,8 @@ api_mpegts_init ( void ) { "mpegts/mux/class", ACCESS_ANONYMOUS, api_idnode_class, (void*)&mpegts_mux_class }, { "mpegts/service/grid", ACCESS_ANONYMOUS, api_idnode_grid, api_mpegts_service_grid }, { "mpegts/service/class", ACCESS_ANONYMOUS, api_idnode_class, (void*)&mpegts_service_class }, -#if ENABLE_LINUXDVB - { "linuxdvb/scanfile/list", ACCESS_ANONYMOUS, api_linuxdvb_scanfile_list, NULL }, +#if ENABLE_MPEGTS_DVB + { "dvb/scanfile/list", ACCESS_ANONYMOUS, api_dvb_scanfile_list, NULL }, #endif { NULL }, }; diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 9c3d206c..cf64e46d 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -37,7 +37,7 @@ #include #include "tvheadend.h" -#include "input/mpegts.h" +#include "input.h" #include "tcp.h" #include "capmt.h" #include "notify.h" diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index 37fa28cc..ad37af7e 100755 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -40,7 +40,7 @@ #include "dtable.h" #include "subscriptions.h" #include "service.h" -#include "input/mpegts.h" +#include "input.h" #include "input/mpegts/tsdemux.h" #include "tvhcsa.h" diff --git a/src/descrambler/tvhcsa.c b/src/descrambler/tvhcsa.c index e7aa1afd..cd883cb1 100644 --- a/src/descrambler/tvhcsa.c +++ b/src/descrambler/tvhcsa.c @@ -17,7 +17,7 @@ */ #include "tvhcsa.h" -#include "input/mpegts.h" +#include "input.h" #include "input/mpegts/tsdemux.h" #include diff --git a/src/epggrab/module/eit.c b/src/epggrab/module/eit.c index 896ce929..3e101aa6 100644 --- a/src/epggrab/module/eit.c +++ b/src/epggrab/module/eit.c @@ -24,8 +24,7 @@ #include "epg.h" #include "epggrab.h" #include "epggrab/private.h" -#include "input/mpegts.h" -#include "input/mpegts/dvb.h" +#include "input.h" #include "input/mpegts/dvb_charset.h" /* ************************************************************************ diff --git a/src/epggrab/module/opentv.c b/src/epggrab/module/opentv.c index c28650f2..dbee117e 100644 --- a/src/epggrab/module/opentv.c +++ b/src/epggrab/module/opentv.c @@ -32,7 +32,7 @@ #include "service.h" #include "htsmsg.h" #include "settings.h" -#include "input/mpegts.h" +#include "input.h" static epggrab_channel_tree_t _opentv_channels; diff --git a/src/epggrab/otamux.c b/src/epggrab/otamux.c index feb6d5f5..9a3be5c5 100644 --- a/src/epggrab/otamux.c +++ b/src/epggrab/otamux.c @@ -22,7 +22,7 @@ #include "epg.h" #include "epggrab.h" #include "epggrab/private.h" -#include "input/mpegts.h" +#include "input.h" #include "subscriptions.h" #include diff --git a/src/input.h b/src/input.h index 019397cd..c4e162c3 100644 --- a/src/input.h +++ b/src/input.h @@ -113,6 +113,9 @@ void tvh_input_stream_destroy ( tvh_input_stream_t *st ); #if ENABLE_MPEGTS #include "input/mpegts.h" +#if ENABLE_MPEGTS_DVB +#include "input/mpegts/mpegts_dvb.h" +#endif #if ENABLE_TSFILE #include "input/mpegts/tsfile.h" #endif diff --git a/src/input/mpegts.h b/src/input/mpegts.h index b1106ea6..a1a70d1d 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -20,6 +20,10 @@ #ifndef __TVH_MPEGTS_H__ #define __TVH_MPEGTS_H__ +#ifndef __TVH_INPUT_H__ +#error "Use header file input.h not input/mpegts.h" +#endif + #include "input.h" #include "service.h" #include "mpegts/dvb.h" @@ -727,3 +731,4 @@ LIST_HEAD(,mpegts_listener) mpegts_listeners; * * vim:sts=2:ts=2:sw=2:et *****************************************************************************/ + diff --git a/src/input/mpegts/dvb.h b/src/input/mpegts/dvb.h index 00cc7511..6285474a 100644 --- a/src/input/mpegts/dvb.h +++ b/src/input/mpegts/dvb.h @@ -190,12 +190,9 @@ void psi_tables_atsc_t ( struct mpegts_mux *mm ); void psi_tables_atsc_c ( struct mpegts_mux *mm ); /* - * Delivery systems and DVB API wrappers * - * Note: although these are really only useful for linuxDVB, they are - * used in mpegts so that tsfile can be used to debug issues */ -#if ENABLE_DVBAPI +#if ENABLE_MPEGTS_DVB typedef enum dvb_fe_type { DVB_TYPE_NONE = 0, @@ -451,7 +448,7 @@ static inline int dvb_bandwidth( dvb_fe_bandwidth_t bw ) int dvb_delsys2type ( enum dvb_fe_delivery_system ds ); -#endif /* ENABLE_DVBAPI */ +#endif /* ENABLE_MPEGTS_DVB */ void dvb_done ( void ); diff --git a/src/input/mpegts/dvb_charset.c b/src/input/mpegts/dvb_charset.c index d2a30378..f7c0fcde 100644 --- a/src/input/mpegts/dvb_charset.c +++ b/src/input/mpegts/dvb_charset.c @@ -20,7 +20,7 @@ #include "tvheadend.h" #include "settings.h" #include "dvb_charset.h" -#include "../mpegts.h" +#include "input.h" static LIST_HEAD(,dvb_charset) dvb_charset_list; diff --git a/src/input/mpegts/dvb_psi.c b/src/input/mpegts/dvb_psi.c index 112077b8..5b65f3a3 100644 --- a/src/input/mpegts/dvb_psi.c +++ b/src/input/mpegts/dvb_psi.c @@ -17,7 +17,7 @@ */ #include "tvheadend.h" -#include "input/mpegts.h" +#include "input.h" #include "dvb.h" #include "tsdemux.h" #include "parsers.h" @@ -73,7 +73,7 @@ dvb_servicetype_lookup ( int t ) * Descriptors * *************************************************************************/ -#if ENABLE_DVBAPI +#if ENABLE_MPEGTS_DVB /** * Tables for delivery descriptor parsing @@ -290,7 +290,7 @@ dvb_desc_terr_del return mm->mm_network->mn_create_mux(mm, onid, tsid, &dmc); } -#endif /* ENABLE_DVBAPI */ +#endif /* ENABLE_MPEGTS_DVB */ static int dvb_desc_service diff --git a/src/input/mpegts/dvb_support.c b/src/input/mpegts/dvb_support.c index 3f2392ed..ea98ad9c 100644 --- a/src/input/mpegts/dvb_support.c +++ b/src/input/mpegts/dvb_support.c @@ -26,12 +26,10 @@ #include #include -#include - #include "tvheadend.h" #include "dvb.h" #include "dvb_charset_tables.h" -#include "../mpegts.h" +#include "input.h" static int convert_iso_8859[16] = { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 11, 12, 13 @@ -378,7 +376,7 @@ dvb_convert_date(const uint8_t *dvb_buf) /* * DVB API helpers */ -#if ENABLE_DVBAPI +#if ENABLE_MPEGTS_DVB #define dvb_str2val(p)\ @@ -680,7 +678,7 @@ const static struct strtab pilottab[] = { dvb_str2val(pilot); #undef dvb_str2val -#endif /* ENABLE_DVBAPI */ +#endif /* ENABLE_MPEGTS_DVB */ /** * diff --git a/src/input/mpegts/iptv/iptv_private.h b/src/input/mpegts/iptv/iptv_private.h index d6e1c557..865799c4 100644 --- a/src/input/mpegts/iptv/iptv_private.h +++ b/src/input/mpegts/iptv/iptv_private.h @@ -20,8 +20,7 @@ #ifndef __IPTV_PRIVATE_H__ #define __IPTV_PRIVATE_H__ -#include "input/mpegts.h" -#include "input/mpegts/iptv.h" +#include "input.h" #include "htsbuf.h" #include "url.h" diff --git a/src/input/mpegts/linuxdvb/linuxdvb.c b/src/input/mpegts/linuxdvb/linuxdvb.c index 0d71fa26..ef0982da 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb.c +++ b/src/input/mpegts/linuxdvb/linuxdvb.c @@ -21,8 +21,6 @@ #include "input.h" #include "settings.h" #include "linuxdvb_private.h" -#include "scanfile.h" -#include "../dvb_charset.h" int linuxdvb_adapter_mask; @@ -30,26 +28,14 @@ void linuxdvb_init ( int adapter_mask ) { linuxdvb_adapter_mask = adapter_mask; - /* Load scan files */ - scanfile_init(); - - /* Load list of mux charset global overrides */ - dvb_charset_init(); - /* Initialise en50494 locks */ linuxdvb_en50494_init(); - /* Initialise networks */ - linuxdvb_network_init(); - /* Initialsie devices */ linuxdvb_adapter_init(); } void linuxdvb_done ( void ) { - linuxdvb_network_done(); linuxdvb_adapter_done(); - dvb_charset_done(); - scanfile_done(); } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 7ff71a2d..ce563403 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -354,19 +354,15 @@ linuxdvb_frontend_network_list ( mpegts_input_t *mi ) { linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi; const idclass_t *idc; - extern const idclass_t linuxdvb_network_dvbt_class; - extern const idclass_t linuxdvb_network_dvbc_class; - extern const idclass_t linuxdvb_network_dvbs_class; - extern const idclass_t linuxdvb_network_atsc_class; if (lfe->lfe_type == DVB_TYPE_T) - idc = &linuxdvb_network_dvbt_class; + idc = &dvb_network_dvbt_class; else if (lfe->lfe_type == DVB_TYPE_C) - idc = &linuxdvb_network_dvbc_class; + idc = &dvb_network_dvbc_class; else if (lfe->lfe_type == DVB_TYPE_S) - idc = &linuxdvb_network_dvbs_class; + idc = &dvb_network_dvbs_class; else if (lfe->lfe_type == DVB_TYPE_ATSC) - idc = &linuxdvb_network_atsc_class; + idc = &dvb_network_atsc_class; else return NULL; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_mux.c b/src/input/mpegts/linuxdvb/linuxdvb_mux.c index 3fe7d350..568c931f 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_mux.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_mux.c @@ -612,7 +612,7 @@ static void linuxdvb_mux_display_name ( mpegts_mux_t *mm, char *buf, size_t len ) { linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; - linuxdvb_network_t *ln = (linuxdvb_network_t*)mm->mm_network; + dvb_network_t *ln = (dvb_network_t*)mm->mm_network; uint32_t freq = lm->lm_tuning.dmc_fe_freq; char pol[2] = { 0 }; if (ln->ln_type == DVB_TYPE_S) { @@ -655,7 +655,7 @@ linuxdvb_mux_delete ( mpegts_mux_t *mm, int delconf ) linuxdvb_mux_t * linuxdvb_mux_create0 - ( linuxdvb_network_t *ln, + ( dvb_network_t *ln, uint16_t onid, uint16_t tsid, const dvb_mux_conf_t *dmc, const char *uuid, htsmsg_t *conf ) { diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index 3602cddf..fe96a029 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -20,7 +20,7 @@ #ifndef __TVH_LINUXDVB_PRIVATE_H__ #define __TVH_LINUXDVB_PRIVATE_H__ -#include "input/mpegts.h" +#include "input.h" #include @@ -246,26 +246,8 @@ int linuxdvb_frontend_tune1 ( linuxdvb_frontend_t *lfe, mpegts_mux_instance_t *mmi, uint32_t freq ); /* - * Network + * */ - -struct linuxdvb_network -{ - mpegts_network_t; - - /* - * Network type - */ - dvb_fe_type_t ln_type; -}; - -void linuxdvb_network_init ( void ); -void linuxdvb_network_done ( void ); -linuxdvb_network_t *linuxdvb_network_find_by_uuid(const char *uuid); - -linuxdvb_network_t *linuxdvb_network_create0 - ( const char *uuid, const idclass_t *idc, htsmsg_t *conf ); - struct linuxdvb_mux { mpegts_mux_t; @@ -277,7 +259,7 @@ struct linuxdvb_mux }; linuxdvb_mux_t *linuxdvb_mux_create0 - (linuxdvb_network_t *ln, uint16_t onid, uint16_t tsid, + (dvb_network_t *ln, uint16_t onid, uint16_t tsid, const dvb_mux_conf_t *dmc, const char *uuid, htsmsg_t *conf); #define linuxdvb_mux_create1(n, u, c)\ diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 13da461f..387fcf61 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -81,14 +81,13 @@ linuxdvb_satconf_class_network_set static htsmsg_t * linuxdvb_satconf_class_network_enum( void *o ) { - extern const idclass_t linuxdvb_network_dvbs_class; htsmsg_t *m = htsmsg_create_map(); htsmsg_t *p = htsmsg_create_map(); htsmsg_add_str(m, "type", "api"); htsmsg_add_str(m, "uri", "idnode/load"); htsmsg_add_str(m, "event", "mpegts_network"); htsmsg_add_u32(p, "enum", 1); - htsmsg_add_str(p, "class", linuxdvb_network_dvbs_class.ic_class); + htsmsg_add_str(p, "class", dvb_network_dvbs_class.ic_class); htsmsg_add_msg(m, "params", p); return m; diff --git a/src/input/mpegts/mpegts_dvb.h b/src/input/mpegts/mpegts_dvb.h new file mode 100644 index 00000000..bf0d7abe --- /dev/null +++ b/src/input/mpegts/mpegts_dvb.h @@ -0,0 +1,49 @@ +/* + * Tvheadend - MPEGTS DVB support routines and defines + * Copyright (C) 2013 Adam Sutton + * Copyright (C) 2014 Jaroslav Kysela + * + * 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 . + */ + +#ifndef __TVH_MPEGTS_DVB_H__ +#define __TVH_MPEGTS_DVB_H__ + +/* + * Network + */ + +typedef struct dvb_network +{ + mpegts_network_t; + + /* + * Network type + */ + dvb_fe_type_t ln_type; +} dvb_network_t; + +extern const idclass_t dvb_network_dvbt_class; +extern const idclass_t dvb_network_dvbc_class; +extern const idclass_t dvb_network_dvbs_class; +extern const idclass_t dvb_network_atsc_class; + +void dvb_network_init ( void ); +void dvb_network_done ( void ); +dvb_network_t *dvb_network_find_by_uuid(const char *uuid); + +dvb_network_t *dvb_network_create0 + ( const char *uuid, const idclass_t *idc, htsmsg_t *conf ); + +#endif /* __TVH_MPEGTS_DVB_H__ */ diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 7cd44e5d..dabc9779 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include "input/mpegts.h" +#include "input.h" #include "tsdemux.h" #include "packet.h" #include "streaming.h" diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index b2c02591..0ccdcaf4 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -19,7 +19,7 @@ #include "idnode.h" #include "queue.h" -#include "input/mpegts.h" +#include "input.h" #include "subscriptions.h" #include "dvb_charset.h" diff --git a/src/input/mpegts/mpegts_network.c b/src/input/mpegts/mpegts_network.c index b62cffcd..caf3433a 100644 --- a/src/input/mpegts/mpegts_network.c +++ b/src/input/mpegts/mpegts_network.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include "input/mpegts.h" +#include "input.h" #include "subscriptions.h" #include "dvb_charset.h" diff --git a/src/input/mpegts/linuxdvb/linuxdvb_network.c b/src/input/mpegts/mpegts_network_dvb.c similarity index 58% rename from src/input/mpegts/linuxdvb/linuxdvb_network.c rename to src/input/mpegts/mpegts_network_dvb.c index ede48535..852317a7 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_network.c +++ b/src/input/mpegts/mpegts_network_dvb.c @@ -19,9 +19,11 @@ #include "tvheadend.h" #include "input.h" -#include "linuxdvb_private.h" #include "queue.h" #include "settings.h" +#include "mpegts_dvb.h" +#include "linuxdvb/linuxdvb_private.h" +#include "dvb_charset.h" #include "scanfile.h" #include @@ -32,8 +34,8 @@ #include static mpegts_mux_t * -linuxdvb_network_find_mux - ( linuxdvb_network_t *ln, dvb_mux_conf_t *dmc ); +dvb_network_find_mux + ( dvb_network_t *ln, dvb_mux_conf_t *dmc ); /* **************************************************************************** * Class definition @@ -42,12 +44,12 @@ linuxdvb_network_find_mux extern const idclass_t mpegts_network_class; static void -linuxdvb_network_class_delete ( idnode_t *in ) +dvb_network_class_delete ( idnode_t *in ) { mpegts_network_t *mn = (mpegts_network_t*)in; /* remove config */ - hts_settings_remove("input/linuxdvb/networks/%s", + hts_settings_remove("input/dvb/networks/%s", idnode_uuid_as_str(in)); /* Parent delete */ @@ -55,13 +57,13 @@ linuxdvb_network_class_delete ( idnode_t *in ) } static const void * -linuxdvb_network_class_scanfile_get ( void *o ) +dvb_network_class_scanfile_get ( void *o ) { static const char *s = NULL; return &s; } static int -linuxdvb_network_class_scanfile_set ( void *o, const void *s ) +dvb_network_class_scanfile_set ( void *o, const void *s ) { dvb_mux_conf_t *dmc; scanfile_network_t *sfn; @@ -75,7 +77,7 @@ linuxdvb_network_class_scanfile_set ( void *o, const void *s ) /* Create */ LIST_FOREACH(dmc, &sfn->sfn_muxes, dmc_link) { - if (!(mm = linuxdvb_network_find_mux(o, dmc))) { + if (!(mm = dvb_network_find_mux(o, dmc))) { mm = (mpegts_mux_t*)linuxdvb_mux_create0(o, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, @@ -87,118 +89,118 @@ linuxdvb_network_class_scanfile_set ( void *o, const void *s ) return 0; } static htsmsg_t * -linuxdvb_network_class_scanfile_list ( const char *type ) +dvb_network_class_scanfile_list ( const char *type ) { htsmsg_t *e, *m = htsmsg_create_map(); htsmsg_add_str(m, "type", "api"); - htsmsg_add_str(m, "uri", "linuxdvb/scanfile/list"); + htsmsg_add_str(m, "uri", "dvb/scanfile/list"); e = htsmsg_create_map(); htsmsg_add_str(e, "type", type); htsmsg_add_msg(m, "params", e); return m; } static htsmsg_t * -linuxdvb_network_dvbt_class_scanfile_list ( void *o ) +dvb_network_dvbt_class_scanfile_list ( void *o ) { - return linuxdvb_network_class_scanfile_list("dvbt"); + return dvb_network_class_scanfile_list("dvbt"); } static htsmsg_t * -linuxdvb_network_dvbc_class_scanfile_list ( void *o ) +dvb_network_dvbc_class_scanfile_list ( void *o ) { - return linuxdvb_network_class_scanfile_list("dvbc"); + return dvb_network_class_scanfile_list("dvbc"); } static htsmsg_t * -linuxdvb_network_dvbs_class_scanfile_list ( void *o ) +dvb_network_dvbs_class_scanfile_list ( void *o ) { - return linuxdvb_network_class_scanfile_list("dvbs"); + return dvb_network_class_scanfile_list("dvbs"); } static htsmsg_t * -linuxdvb_network_atsc_class_scanfile_list ( void *o ) +dvb_network_atsc_class_scanfile_list ( void *o ) { - return linuxdvb_network_class_scanfile_list("atsc"); + return dvb_network_class_scanfile_list("atsc"); } -const idclass_t linuxdvb_network_class = +const idclass_t dvb_network_class = { .ic_super = &mpegts_network_class, - .ic_class = "linuxdvb_network", + .ic_class = "dvb_network", .ic_caption = "LinuxDVB Network", - .ic_delete = linuxdvb_network_class_delete, + .ic_delete = dvb_network_class_delete, .ic_properties = (const property_t[]){ {} } }; -const idclass_t linuxdvb_network_dvbt_class = +const idclass_t dvb_network_dvbt_class = { - .ic_super = &linuxdvb_network_class, - .ic_class = "linuxdvb_network_dvbt", + .ic_super = &dvb_network_class, + .ic_class = "dvb_network_dvbt", .ic_caption = "DVB-T Network", .ic_properties = (const property_t[]) { { .type = PT_STR, .id = "scanfile", .name = "Pre-defined Muxes", - .set = linuxdvb_network_class_scanfile_set, - .get = linuxdvb_network_class_scanfile_get, - .list = linuxdvb_network_dvbt_class_scanfile_list, + .set = dvb_network_class_scanfile_set, + .get = dvb_network_class_scanfile_get, + .list = dvb_network_dvbt_class_scanfile_list, .opts = PO_NOSAVE, }, {} } }; -const idclass_t linuxdvb_network_dvbc_class = +const idclass_t dvb_network_dvbc_class = { - .ic_super = &linuxdvb_network_class, - .ic_class = "linuxdvb_network_dvbc", + .ic_super = &dvb_network_class, + .ic_class = "dvb_network_dvbc", .ic_caption = "DVB-C Network", .ic_properties = (const property_t[]) { { .type = PT_STR, .id = "scanfile", .name = "Pre-defined Muxes", - .set = linuxdvb_network_class_scanfile_set, - .get = linuxdvb_network_class_scanfile_get, - .list = linuxdvb_network_dvbc_class_scanfile_list, + .set = dvb_network_class_scanfile_set, + .get = dvb_network_class_scanfile_get, + .list = dvb_network_dvbc_class_scanfile_list, .opts = PO_NOSAVE, }, {} } }; -const idclass_t linuxdvb_network_dvbs_class = +const idclass_t dvb_network_dvbs_class = { - .ic_super = &linuxdvb_network_class, - .ic_class = "linuxdvb_network_dvbs", + .ic_super = &dvb_network_class, + .ic_class = "dvb_network_dvbs", .ic_caption = "DVB-S Network", .ic_properties = (const property_t[]) { { .type = PT_STR, .id = "scanfile", .name = "Pre-defined Muxes", - .set = linuxdvb_network_class_scanfile_set, - .get = linuxdvb_network_class_scanfile_get, - .list = linuxdvb_network_dvbs_class_scanfile_list, + .set = dvb_network_class_scanfile_set, + .get = dvb_network_class_scanfile_get, + .list = dvb_network_dvbs_class_scanfile_list, .opts = PO_NOSAVE, }, {} } }; -const idclass_t linuxdvb_network_atsc_class = +const idclass_t dvb_network_atsc_class = { - .ic_super = &linuxdvb_network_class, - .ic_class = "linuxdvb_network_atsc", + .ic_super = &dvb_network_class, + .ic_class = "dvb_network_atsc", .ic_caption = "ATSC Network", .ic_properties = (const property_t[]) { { .type = PT_STR, .id = "scanfile", .name = "Pre-defined Muxes", - .set = linuxdvb_network_class_scanfile_set, - .get = linuxdvb_network_class_scanfile_get, - .list = linuxdvb_network_atsc_class_scanfile_list, + .set = dvb_network_class_scanfile_set, + .get = dvb_network_class_scanfile_get, + .list = dvb_network_atsc_class_scanfile_list, .opts = PO_NOSAVE, }, {} @@ -210,8 +212,8 @@ const idclass_t linuxdvb_network_atsc_class = * ***************************************************************************/ static mpegts_mux_t * -linuxdvb_network_find_mux - ( linuxdvb_network_t *ln, dvb_mux_conf_t *dmc ) +dvb_network_find_mux + ( dvb_network_t *ln, dvb_mux_conf_t *dmc ) { mpegts_mux_t *mm; LIST_FOREACH(mm, &ln->mn_muxes, mm_network_link) { @@ -225,23 +227,23 @@ linuxdvb_network_find_mux } static void -linuxdvb_network_config_save ( mpegts_network_t *mn ) +dvb_network_config_save ( mpegts_network_t *mn ) { htsmsg_t *c = htsmsg_create_map(); idnode_save(&mn->mn_id, c); htsmsg_add_str(c, "class", mn->mn_id.in_class->ic_class); - hts_settings_save(c, "input/linuxdvb/networks/%s/config", + hts_settings_save(c, "input/dvb/networks/%s/config", idnode_uuid_as_str(&mn->mn_id)); htsmsg_destroy(c); } static mpegts_mux_t * -linuxdvb_network_create_mux +dvb_network_create_mux ( mpegts_mux_t *mm, uint16_t onid, uint16_t tsid, dvb_mux_conf_t *dmc ) { int save = 0; - linuxdvb_network_t *ln = (linuxdvb_network_t*)mm->mm_network; - mm = linuxdvb_network_find_mux(ln, dmc); + dvb_network_t *ln = (dvb_network_t*)mm->mm_network; + mm = dvb_network_find_mux(ln, dmc); if (!mm && ln->mn_autodiscovery) { mm = (mpegts_mux_t*)linuxdvb_mux_create0(ln, onid, tsid, dmc, NULL, NULL); save = 1; @@ -262,36 +264,36 @@ linuxdvb_network_create_mux } static mpegts_service_t * -linuxdvb_network_create_service +dvb_network_create_service ( mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid ) { return mpegts_service_create1(NULL, mm, sid, pmt_pid, NULL); } static const idclass_t * -linuxdvb_network_mux_class +dvb_network_mux_class ( mpegts_network_t *mn ) { extern const idclass_t linuxdvb_mux_dvbt_class; extern const idclass_t linuxdvb_mux_dvbc_class; extern const idclass_t linuxdvb_mux_dvbs_class; extern const idclass_t linuxdvb_mux_atsc_class; - if (idnode_is_instance(&mn->mn_id, &linuxdvb_network_dvbt_class)) + if (idnode_is_instance(&mn->mn_id, &dvb_network_dvbt_class)) return &linuxdvb_mux_dvbt_class; - if (idnode_is_instance(&mn->mn_id, &linuxdvb_network_dvbc_class)) + if (idnode_is_instance(&mn->mn_id, &dvb_network_dvbc_class)) return &linuxdvb_mux_dvbc_class; - if (idnode_is_instance(&mn->mn_id, &linuxdvb_network_dvbs_class)) + if (idnode_is_instance(&mn->mn_id, &dvb_network_dvbs_class)) return &linuxdvb_mux_dvbs_class; - if (idnode_is_instance(&mn->mn_id, &linuxdvb_network_atsc_class)) + if (idnode_is_instance(&mn->mn_id, &dvb_network_atsc_class)) return &linuxdvb_mux_atsc_class; return NULL; } static mpegts_mux_t * -linuxdvb_network_mux_create2 +dvb_network_mux_create2 ( mpegts_network_t *mn, htsmsg_t *conf ) { - linuxdvb_network_t *ln = (linuxdvb_network_t*)mn; + dvb_network_t *ln = (dvb_network_t*)mn; return (mpegts_mux_t*) linuxdvb_mux_create0(ln, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, NULL, NULL, conf); @@ -301,119 +303,149 @@ linuxdvb_network_mux_create2 * Creation/Config * ***************************************************************************/ -linuxdvb_network_t * -linuxdvb_network_create0 +dvb_network_t * +dvb_network_create0 ( const char *uuid, const idclass_t *idc, htsmsg_t *conf ) { - linuxdvb_network_t *ln; + dvb_network_t *ln; htsmsg_t *c, *e; htsmsg_field_t *f; + mpegts_mux_t *mm; + int move = 0; - ln = calloc(1, sizeof(linuxdvb_network_t)); - if (idc == &linuxdvb_network_dvbt_class) + ln = calloc(1, sizeof(dvb_network_t)); + if (idc == &dvb_network_dvbt_class) ln->ln_type = DVB_TYPE_T; - else if (idc == &linuxdvb_network_dvbc_class) + else if (idc == &dvb_network_dvbc_class) ln->ln_type = DVB_TYPE_C; - else if (idc == &linuxdvb_network_dvbs_class) + else if (idc == &dvb_network_dvbs_class) ln->ln_type = DVB_TYPE_S; else ln->ln_type = DVB_TYPE_ATSC; /* Create */ - if (!(ln = (linuxdvb_network_t*)mpegts_network_create0((void*)ln, + if (!(ln = (dvb_network_t*)mpegts_network_create0((void*)ln, idc, uuid, NULL, conf))) return NULL; /* Callbacks */ - ln->mn_create_mux = linuxdvb_network_create_mux; - ln->mn_create_service = linuxdvb_network_create_service; - ln->mn_config_save = linuxdvb_network_config_save; - ln->mn_mux_class = linuxdvb_network_mux_class; - ln->mn_mux_create2 = linuxdvb_network_mux_create2; + ln->mn_create_mux = dvb_network_create_mux; + ln->mn_create_service = dvb_network_create_service; + ln->mn_config_save = dvb_network_config_save; + ln->mn_mux_class = dvb_network_mux_class; + ln->mn_mux_create2 = dvb_network_mux_create2; /* No config */ if (!conf) return ln; /* Load muxes */ - if ((c = hts_settings_load_r(1, "input/linuxdvb/networks/%s/muxes", uuid))) { + c = hts_settings_load_r(1, "input/dvb/networks/%s/muxes", uuid); + if (!c) { + c = hts_settings_load_r(1, "input/linuxdvb/networks/%s/muxes", uuid); + move = 1; + } + if (c) { HTSMSG_FOREACH(f, c) { if (!(e = htsmsg_get_map_by_field(f))) continue; if (!(e = htsmsg_get_map(e, "config"))) continue; - (void)linuxdvb_mux_create1(ln, f->hmf_name, e); + mm = (mpegts_mux_t *)linuxdvb_mux_create1(ln, f->hmf_name, e); + if (mm && move) + mm->mm_config_save(mm); } htsmsg_destroy(c); + if (move) + hts_settings_remove("input/linuxdvb/networks/%s/muxes", uuid); } return ln; } static mpegts_network_t * -linuxdvb_network_builder +dvb_network_builder ( const idclass_t *idc, htsmsg_t *conf ) { - return (mpegts_network_t*)linuxdvb_network_create0(NULL, idc, conf); + return (mpegts_network_t*)dvb_network_create0(NULL, idc, conf); } -static const idclass_t* linuxdvb_network_classes[] = { - &linuxdvb_network_dvbt_class, - &linuxdvb_network_dvbc_class, - &linuxdvb_network_dvbs_class, - &linuxdvb_network_atsc_class, +static const idclass_t* dvb_network_classes[] = { + &dvb_network_dvbt_class, + &dvb_network_dvbc_class, + &dvb_network_dvbs_class, + &dvb_network_atsc_class, }; -void linuxdvb_network_init ( void ) +void dvb_network_init ( void ) { htsmsg_t *c, *e; htsmsg_field_t *f; const char *s; - int i; + dvb_network_t *ln; + int i, move = 0; + + /* Load scan files */ + scanfile_init(); + + /* Load list of mux charset global overrides */ + dvb_charset_init(); /* Register class builders */ - for (i = 0; i < ARRAY_SIZE(linuxdvb_network_classes); i++) - mpegts_network_register_builder(linuxdvb_network_classes[i], - linuxdvb_network_builder); + for (i = 0; i < ARRAY_SIZE(dvb_network_classes); i++) + mpegts_network_register_builder(dvb_network_classes[i], + dvb_network_builder); /* Load settings */ - if (!(c = hts_settings_load_r(1, "input/linuxdvb/networks"))) - return; + if (!(c = hts_settings_load_r(1, "input/dvb/networks"))) { + if (!(c = hts_settings_load_r(1, "input/linuxdvb/networks"))) { + printf("RETURN!!\n"); + return; + } + move = 1; + } HTSMSG_FOREACH(f, c) { if (!(e = htsmsg_get_map_by_field(f))) continue; if (!(e = htsmsg_get_map(e, "config"))) continue; if (!(s = htsmsg_get_str(e, "class"))) continue; - for (i = 0; i < ARRAY_SIZE(linuxdvb_network_classes); i++) { - if(!strcmp(linuxdvb_network_classes[i]->ic_class, s)) { - (void)linuxdvb_network_create0(f->hmf_name, linuxdvb_network_classes[i], e); + for (i = 0; i < ARRAY_SIZE(dvb_network_classes); i++) { + if(!strcmp(dvb_network_classes[i]->ic_class, s + (move ? 5 : 0))) { + ln = dvb_network_create0(f->hmf_name, dvb_network_classes[i], e); + if (ln && move) + ln->mn_config_save((mpegts_network_t *)ln); break; } } } htsmsg_destroy(c); + if (move) + hts_settings_remove("input/linuxdvb/networks"); } -void linuxdvb_network_done ( void ) +void dvb_network_done ( void ) { int i; pthread_mutex_lock(&global_lock); /* Unregister class builders */ - for (i = 0; i < ARRAY_SIZE(linuxdvb_network_classes); i++) { - mpegts_network_unregister_builder(linuxdvb_network_classes[i]); - mpegts_network_class_delete(linuxdvb_network_classes[i], 0); + for (i = 0; i < ARRAY_SIZE(dvb_network_classes); i++) { + mpegts_network_unregister_builder(dvb_network_classes[i]); + mpegts_network_class_delete(dvb_network_classes[i], 0); } pthread_mutex_unlock(&global_lock); + + dvb_charset_done(); + scanfile_done(); } /* **************************************************************************** * Search * ***************************************************************************/ -linuxdvb_network_t* -linuxdvb_network_find_by_uuid(const char *uuid) +dvb_network_t* +dvb_network_find_by_uuid(const char *uuid) { - idnode_t *in = idnode_find(uuid, &linuxdvb_network_class); - return (linuxdvb_network_t*)in; + idnode_t *in = idnode_find(uuid, &dvb_network_class); + return (dvb_network_t*)in; } /****************************************************************************** diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index debc23eb..57e5199d 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -20,7 +20,7 @@ #include #include "service.h" -#include "input/mpegts.h" +#include "input.h" #include "settings.h" #include "dvb_charset.h" diff --git a/src/input/mpegts/mpegts_table.c b/src/input/mpegts/mpegts_table.c index 55e5d21b..e05f69f3 100644 --- a/src/input/mpegts/mpegts_table.c +++ b/src/input/mpegts/mpegts_table.c @@ -17,7 +17,7 @@ */ #include "tvheadend.h" -#include "input/mpegts.h" +#include "input.h" #include diff --git a/src/input/mpegts/linuxdvb/scanfile.c b/src/input/mpegts/scanfile.c similarity index 99% rename from src/input/mpegts/linuxdvb/scanfile.c rename to src/input/mpegts/scanfile.c index eea125b9..f1fdf7ca 100644 --- a/src/input/mpegts/linuxdvb/scanfile.c +++ b/src/input/mpegts/scanfile.c @@ -17,7 +17,7 @@ */ #include "tvheadend.h" -#include "../dvb.h" +#include "dvb.h" #include "filebundle.h" #include "config2.h" #include "scanfile.h" @@ -174,7 +174,7 @@ scanfile_load_dvbs ( dvb_mux_conf_t *mux, const char *line ) if ((mux->u.dmc_fe_qpsk.polarisation = dvb_str2pol(pol)) == -1) return 1; if ((mux->u.dmc_fe_qpsk.fec_inner = dvb_str2fec(fec)) == -1) return 1; if (v2) { - mux->dmc_fe_delsys = DVB_SYS_DVBS2; + mux->dmc_fe_delsys = DVB_SYS_DVBS2; if ((mux->dmc_fe_rolloff = dvb_str2rolloff(rolloff)) == -1) return 1; if ((mux->dmc_fe_modulation = dvb_str2qam(qam)) == -1) return 1; } else { @@ -197,7 +197,7 @@ scanfile_load_dvbc ( dvb_mux_conf_t *mux, const char *line ) &mux->dmc_fe_freq, &mux->u.dmc_fe_qam.symbol_rate, fec, qam); if(r != 4) return 1; - mux->dmc_fe_type = DVB_TYPE_C; + mux->dmc_fe_type = DVB_TYPE_C; mux->dmc_fe_delsys = DVB_SYS_DVBC_ANNEX_A; if ((mux->u.dmc_fe_qam.fec_inner = dvb_str2fec(fec)) == -1) return 1; if ((mux->dmc_fe_modulation = dvb_str2qam(qam)) == -1) return 1; diff --git a/src/input/mpegts/linuxdvb/scanfile.h b/src/input/mpegts/scanfile.h similarity index 93% rename from src/input/mpegts/linuxdvb/scanfile.h rename to src/input/mpegts/scanfile.h index ee08a95c..b8547758 100644 --- a/src/input/mpegts/linuxdvb/scanfile.h +++ b/src/input/mpegts/scanfile.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef __LINUXDVB_SCANFILES_H__ -#define __LINUXDVB_SCANFILES_H__ +#ifndef __DVB_SCANFILES_H__ +#define __DVB_SCANFILES_H__ typedef struct scanfile_network { const char *sfn_id; @@ -44,4 +44,4 @@ void scanfile_done ( void ); scanfile_network_t *scanfile_find ( const char *id ); -#endif /* __LINUXDVB_SCANFILES_H__ */ +#endif /* __DVB_SCANFILES_H__ */ diff --git a/src/input/mpegts/tsdemux.c b/src/input/mpegts/tsdemux.c index d9b7ee4d..fea2045f 100644 --- a/src/input/mpegts/tsdemux.c +++ b/src/input/mpegts/tsdemux.c @@ -36,7 +36,7 @@ #include "subscriptions.h" #include "parsers.h" #include "streaming.h" -#include "input/mpegts.h" +#include "input.h" #include "parsers/parser_teletext.h" #include "tsdemux.h" diff --git a/src/input/mpegts/tsfile/tsfile_private.h b/src/input/mpegts/tsfile/tsfile_private.h index afb8c404..1c45a38c 100644 --- a/src/input/mpegts/tsfile/tsfile_private.h +++ b/src/input/mpegts/tsfile/tsfile_private.h @@ -20,7 +20,7 @@ #ifndef __TVH_TSFILE_PRIVATE_H__ #define __TVH_TSFILE_PRIVATE_H__ -#include "input/mpegts.h" +#include "input.h" /* * Globals diff --git a/src/main.c b/src/main.c index c419af2a..90d9106e 100644 --- a/src/main.c +++ b/src/main.c @@ -763,6 +763,9 @@ main(int argc, char **argv) tsfile_add_file(opt_tsfile.str[i]); } #endif +#if ENABLE_MPEGTS_DVB + dvb_network_init(); +#endif #if ENABLE_IPTV iptv_init(); #endif @@ -835,6 +838,9 @@ main(int argc, char **argv) tvhftrace("main", webui_done); tvhftrace("main", http_client_done); tvhftrace("main", fsmonitor_done); +#if ENABLE_MPEGTS_DVB + tvhftrace("main", dvb_network_done); +#endif #if ENABLE_IPTV tvhftrace("main", iptv_done); #endif diff --git a/src/parsers/parser_teletext.c b/src/parsers/parser_teletext.c index 9cd96c07..f154c123 100644 --- a/src/parsers/parser_teletext.c +++ b/src/parsers/parser_teletext.c @@ -35,7 +35,7 @@ #include "packet.h" #include "streaming.h" #include "service.h" -#include "input/mpegts.h" +#include "input.h" #include "parser_teletext.h" /** diff --git a/src/service.c b/src/service.c index 053b74fb..1a9cb7ef 100644 --- a/src/service.c +++ b/src/service.c @@ -43,7 +43,7 @@ #include "htsp_server.h" #include "lang_codes.h" #include "descrambler.h" -#include "input/mpegts.h" +#include "input.h" static void service_data_timeout(void *aux); static void service_class_save(struct idnode *self); diff --git a/src/subscriptions.c b/src/subscriptions.c index 96cd7f27..199aae31 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -39,9 +39,7 @@ #include "htsmsg.h" #include "notify.h" #include "atomic.h" -#if ENABLE_MPEGTS -#include "input/mpegts.h" -#endif +#include "input.h" struct th_subscription_list subscriptions; struct th_subscription_list subscriptions_remove; diff --git a/src/webui/webui.c b/src/webui/webui.c index 56dcb7d2..a18d597b 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -724,7 +724,7 @@ http_stream_service(http_connection_t *hc, service_t *service, int weight) * TODO: can't currently force this to be on a particular input */ #if ENABLE_MPEGTS -#include "src/input/mpegts.h" +#include "input.h" static int http_stream_mux(http_connection_t *hc, mpegts_mux_t *mm, int weight) { From d1ad5631b51f3017f2eda7a47ac6090ea21f3a1e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 31 Mar 2014 19:52:36 +0200 Subject: [PATCH 5/5] Move the linuxdvb mux code to the shared mpegts network code ... introduce $CFG/input/dvb/networks/... structure --- Makefile | 2 +- src/input/mpegts/linuxdvb/linuxdvb_en50494.c | 2 +- src/input/mpegts/linuxdvb/linuxdvb_frontend.c | 6 +- src/input/mpegts/linuxdvb/linuxdvb_lnb.c | 16 +- src/input/mpegts/linuxdvb/linuxdvb_private.h | 32 +- src/input/mpegts/linuxdvb/linuxdvb_rotor.c | 8 +- src/input/mpegts/linuxdvb/linuxdvb_satconf.c | 6 +- src/input/mpegts/linuxdvb/linuxdvb_switch.c | 2 +- src/input/mpegts/mpegts_dvb.h | 25 ++ .../linuxdvb_mux.c => mpegts_mux_dvb.c} | 351 ++++++++---------- src/input/mpegts/mpegts_network_dvb.c | 32 +- 11 files changed, 220 insertions(+), 262 deletions(-) rename src/input/mpegts/{linuxdvb/linuxdvb_mux.c => mpegts_mux_dvb.c} (62%) diff --git a/Makefile b/Makefile index 7f10ae99..8b9ee45b 100644 --- a/Makefile +++ b/Makefile @@ -180,6 +180,7 @@ SRCS-$(CONFIG_MPEGTS) += \ # MPEGTS DVB SRCS-${CONFIG_MPEGTS_DVB} += \ src/input/mpegts/mpegts_network_dvb.c \ + src/input/mpegts/mpegts_mux_dvb.c \ src/input/mpegts/scanfile.c # MPEGTS EPG @@ -194,7 +195,6 @@ SRCS-${CONFIG_LINUXDVB} += \ src/input/mpegts/linuxdvb/linuxdvb.c \ src/input/mpegts/linuxdvb/linuxdvb_adapter.c \ src/input/mpegts/linuxdvb/linuxdvb_frontend.c \ - src/input/mpegts/linuxdvb/linuxdvb_mux.c \ src/input/mpegts/linuxdvb/linuxdvb_satconf.c \ src/input/mpegts/linuxdvb/linuxdvb_lnb.c \ src/input/mpegts/linuxdvb/linuxdvb_switch.c \ diff --git a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c index 9a09bcba..ad92cefe 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c @@ -143,7 +143,7 @@ const idclass_t linuxdvb_en50494_class = static int linuxdvb_en50494_tune - ( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd ) + ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd ) { int ret = 0; int i; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index ce563403..3df44d65 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -375,7 +375,7 @@ linuxdvb_frontend_network_list ( mpegts_input_t *mi ) static void linuxdvb_frontend_default_tables - ( linuxdvb_frontend_t *lfe, linuxdvb_mux_t *lm ) + ( linuxdvb_frontend_t *lfe, dvb_mux_t *lm ) { mpegts_mux_t *mm = (mpegts_mux_t*)lm; @@ -486,7 +486,7 @@ linuxdvb_frontend_monitor ( void *aux ) pthread_mutex_unlock(&lfe->lfe_dvr_lock); /* Table handlers */ - linuxdvb_frontend_default_tables(lfe, (linuxdvb_mux_t*)mm); + linuxdvb_frontend_default_tables(lfe, (dvb_mux_t*)mm); /* Locked - ensure everything is open */ pthread_mutex_lock(&lfe->mi_delivery_mutex); @@ -861,7 +861,7 @@ linuxdvb_frontend_tune0 struct dvb_frontend_event ev; char buf1[256]; mpegts_mux_instance_t *cur = LIST_FIRST(&lfe->mi_mux_active); - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; + dvb_mux_t *lm = (dvb_mux_t*)mmi->mmi_mux; dvb_mux_conf_t *dmc; struct dvb_frontend_parameters p; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_lnb.c b/src/input/mpegts/linuxdvb/linuxdvb_lnb.c index 85ae5503..6085cd91 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_lnb.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_lnb.c @@ -72,7 +72,7 @@ const idclass_t linuxdvb_lnb_class = static uint32_t linuxdvb_lnb_standard_freq - ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) + ( linuxdvb_lnb_t *l, dvb_mux_t *lm ) { linuxdvb_lnb_conf_t *lnb = (linuxdvb_lnb_conf_t*)l; int32_t f = (int32_t)lm->lm_tuning.dmc_fe_freq; @@ -85,7 +85,7 @@ linuxdvb_lnb_standard_freq static int linuxdvb_lnb_standard_band - ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) + ( linuxdvb_lnb_t *l, dvb_mux_t *lm ) { linuxdvb_lnb_conf_t *lnb = (linuxdvb_lnb_conf_t*)l; uint32_t f = lm->lm_tuning.dmc_fe_freq; @@ -94,7 +94,7 @@ linuxdvb_lnb_standard_band static int linuxdvb_lnb_standard_pol - ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) + ( linuxdvb_lnb_t *l, dvb_mux_t *lm ) { dvb_mux_conf_t *dmc = &lm->lm_tuning; return dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_HORIZONTAL || @@ -103,7 +103,7 @@ linuxdvb_lnb_standard_pol static int linuxdvb_lnb_standard_tune - ( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) + ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) { int pol = linuxdvb_lnb_standard_pol((linuxdvb_lnb_t*)ld, lm); return linuxdvb_diseqc_set_volt(fd, pol); @@ -115,7 +115,7 @@ linuxdvb_lnb_standard_tune static uint32_t linuxdvb_lnb_bandstack_freq - ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) + ( linuxdvb_lnb_t *l, dvb_mux_t *lm ) { linuxdvb_lnb_conf_t *lnb = (linuxdvb_lnb_conf_t*)l; int32_t f = (int32_t)lm->lm_tuning.dmc_fe_freq; @@ -131,7 +131,7 @@ linuxdvb_lnb_bandstack_freq static int linuxdvb_lnb_bandstack_band - ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) + ( linuxdvb_lnb_t *l, dvb_mux_t *lm ) { dvb_mux_conf_t *dmc = &lm->lm_tuning; int pol = dmc->u.dmc_fe_qpsk.polarisation == DVB_POLARISATION_HORIZONTAL || @@ -141,14 +141,14 @@ linuxdvb_lnb_bandstack_band static int linuxdvb_lnb_bandstack_pol - ( linuxdvb_lnb_t *l, linuxdvb_mux_t *lm ) + ( linuxdvb_lnb_t *l, dvb_mux_t *lm ) { return 0; } static int linuxdvb_lnb_bandstack_tune - ( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) + ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) { int pol = linuxdvb_lnb_bandstack_pol((linuxdvb_lnb_t*)ld, lm); return linuxdvb_diseqc_set_volt(fd, pol); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index fe96a029..1cf9dd38 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -40,7 +40,6 @@ typedef struct linuxdvb_satconf_ele linuxdvb_satconf_ele_t; typedef struct linuxdvb_diseqc linuxdvb_diseqc_t; typedef struct linuxdvb_lnb linuxdvb_lnb_t; typedef struct linuxdvb_network linuxdvb_network_t; -typedef struct linuxdvb_mux linuxdvb_mux_t; typedef struct linuxdvb_en50494 linuxdvb_en50494_t; typedef LIST_HEAD(,linuxdvb_hardware) linuxdvb_hardware_list_t; @@ -184,17 +183,17 @@ struct linuxdvb_diseqc idnode_t ld_id; const char *ld_type; linuxdvb_satconf_ele_t *ld_satconf; - int (*ld_grace) (linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm); - int (*ld_tune) (linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, + int (*ld_grace) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm); + int (*ld_tune) (linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd); }; struct linuxdvb_lnb { linuxdvb_diseqc_t; - uint32_t (*lnb_freq)(linuxdvb_lnb_t*, linuxdvb_mux_t*); - int (*lnb_band)(linuxdvb_lnb_t*, linuxdvb_mux_t*); - int (*lnb_pol) (linuxdvb_lnb_t*, linuxdvb_mux_t*); + uint32_t (*lnb_freq)(linuxdvb_lnb_t*, dvb_mux_t*); + int (*lnb_band)(linuxdvb_lnb_t*, dvb_mux_t*); + int (*lnb_pol) (linuxdvb_lnb_t*, dvb_mux_t*); }; struct linuxdvb_en50494 @@ -245,27 +244,6 @@ int linuxdvb_frontend_tune0 int linuxdvb_frontend_tune1 ( linuxdvb_frontend_t *lfe, mpegts_mux_instance_t *mmi, uint32_t freq ); -/* - * - */ -struct linuxdvb_mux -{ - mpegts_mux_t; - - /* - * Tuning information - */ - dvb_mux_conf_t lm_tuning; -}; - -linuxdvb_mux_t *linuxdvb_mux_create0 - (dvb_network_t *ln, uint16_t onid, uint16_t tsid, - const dvb_mux_conf_t *dmc, const char *uuid, htsmsg_t *conf); - -#define linuxdvb_mux_create1(n, u, c)\ - linuxdvb_mux_create0(n, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE,\ - NULL, u, c) - /* * Diseqc gear */ diff --git a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c index 74fbf3e2..4ded7004 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c @@ -132,7 +132,7 @@ const idclass_t linuxdvb_rotor_usals_class = /* GotoX */ static int linuxdvb_rotor_gotox_tune - ( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) + ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) { int i; for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) { @@ -150,7 +150,7 @@ linuxdvb_rotor_gotox_tune /* USALS */ static int linuxdvb_rotor_usals_tune - ( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) + ( linuxdvb_rotor_t *lr, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) { /* * Code originally written in PR #238 by Jason Millard jsm174 @@ -219,7 +219,7 @@ linuxdvb_rotor_usals_tune static int linuxdvb_rotor_tune - ( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) + ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd ) { linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld; @@ -240,7 +240,7 @@ linuxdvb_rotor_tune static int linuxdvb_rotor_grace - ( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm ) + ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm ) { return 120; // TODO: calculate approx period } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 387fcf61..89412ea5 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -596,7 +596,7 @@ linuxdvb_satconf_get_grace /* Add diseqc delay */ for (i = 0; i < 3; i++) { if (lds[i] && lds[i]->ld_grace) - r += lds[i]->ld_grace(lds[i], (linuxdvb_mux_t*)mm); + r += lds[i]->ld_grace(lds[i], (dvb_mux_t*)mm); } return r; @@ -614,7 +614,7 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) /* Get beans in a row */ mpegts_mux_instance_t *mmi = ls->ls_mmi; linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ls->ls_frontend; - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; + dvb_mux_t *lm = (dvb_mux_t*)mmi->mmi_mux; linuxdvb_diseqc_t *lds[] = { lse->lse_rotor ? (linuxdvb_diseqc_t*)lse->lse_switch : NULL, (linuxdvb_diseqc_t*)lse->lse_rotor, @@ -680,7 +680,7 @@ linuxdvb_satconf_start_mux uint32_t f; linuxdvb_satconf_ele_t *lse = linuxdvb_satconf_find_ele(ls, mmi->mmi_mux); linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)ls->ls_frontend; - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mmi->mmi_mux; + dvb_mux_t *lm = (dvb_mux_t*)mmi->mmi_mux; /* Test run */ // Note: basically this ensures the tuning params are acceptable diff --git a/src/input/mpegts/linuxdvb/linuxdvb_switch.c b/src/input/mpegts/linuxdvb/linuxdvb_switch.c index b45f0d8c..f795dc72 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_switch.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_switch.c @@ -113,7 +113,7 @@ const idclass_t linuxdvb_switch_class = static int linuxdvb_switch_tune - ( linuxdvb_diseqc_t *ld, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd ) + ( linuxdvb_diseqc_t *ld, dvb_mux_t *lm, linuxdvb_satconf_ele_t *sc, int fd ) { int i, com, r1 = 0, r2 = 0; int pol, band; diff --git a/src/input/mpegts/mpegts_dvb.h b/src/input/mpegts/mpegts_dvb.h index bf0d7abe..5c3ed2bd 100644 --- a/src/input/mpegts/mpegts_dvb.h +++ b/src/input/mpegts/mpegts_dvb.h @@ -46,4 +46,29 @@ dvb_network_t *dvb_network_find_by_uuid(const char *uuid); dvb_network_t *dvb_network_create0 ( const char *uuid, const idclass_t *idc, htsmsg_t *conf ); +/* + * + */ +typedef struct dvb_mux +{ + mpegts_mux_t; + + /* + * Tuning information + */ + dvb_mux_conf_t lm_tuning; +} dvb_mux_t; + +extern const idclass_t dvb_mux_dvbt_class; +extern const idclass_t dvb_mux_dvbc_class; +extern const idclass_t dvb_mux_dvbs_class; +extern const idclass_t dvb_mux_atsc_class; + +dvb_mux_t *dvb_mux_create0 + (dvb_network_t *ln, uint16_t onid, uint16_t tsid, + const dvb_mux_conf_t *dmc, const char *uuid, htsmsg_t *conf); + +#define dvb_mux_create1(n, u, c)\ + dvb_mux_create0(n, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, NULL, u, c) + #endif /* __TVH_MPEGTS_DVB_H__ */ diff --git a/src/input/mpegts/linuxdvb/linuxdvb_mux.c b/src/input/mpegts/mpegts_mux_dvb.c similarity index 62% rename from src/input/mpegts/linuxdvb/linuxdvb_mux.c rename to src/input/mpegts/mpegts_mux_dvb.c index 568c931f..ac37b5eb 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_mux.c +++ b/src/input/mpegts/mpegts_mux_dvb.c @@ -19,7 +19,7 @@ #include "tvheadend.h" #include "input.h" -#include "linuxdvb_private.h" +#include "mpegts_dvb.h" #include "queue.h" #include "settings.h" @@ -36,7 +36,7 @@ * *************************************************************************/ static void -linuxdvb_mux_delete ( mpegts_mux_t *mm, int delconf ); +dvb_mux_delete ( mpegts_mux_t *mm, int delconf ); extern const idclass_t mpegts_mux_class; @@ -45,24 +45,24 @@ extern const idclass_t mpegts_mux_class; */ /* Macro to define mux class str get/set */ -#define linuxdvb_mux_class_R(c, f, l, ...)\ +#define dvb_mux_class_R(c, f, l, ...)\ static const void * \ -linuxdvb_mux_##c##_class_##l##_get (void *o)\ +dvb_mux_##c##_class_##l##_get (void *o)\ {\ static const char *s;\ - linuxdvb_mux_t *lm = o;\ + dvb_mux_t *lm = o;\ s = dvb_##l##2str(lm->lm_tuning.dmc_fe_##f);\ return &s;\ }\ static int \ -linuxdvb_mux_##c##_class_##l##_set (void *o, const void *v)\ +dvb_mux_##c##_class_##l##_set (void *o, const void *v)\ {\ - linuxdvb_mux_t *lm = o;\ + dvb_mux_t *lm = o;\ lm->lm_tuning.dmc_fe_##f = dvb_str2##l ((const char*)v);\ return 1;\ }\ static htsmsg_t *\ -linuxdvb_mux_##c##_class_##l##_enum (void *o)\ +dvb_mux_##c##_class_##l##_enum (void *o)\ {\ static const int t[] = { __VA_ARGS__ };\ int i;\ @@ -71,24 +71,24 @@ linuxdvb_mux_##c##_class_##l##_enum (void *o)\ htsmsg_add_str(m, NULL, dvb_##l##2str(t[i]));\ return m;\ } -#define linuxdvb_mux_class_X(c, f, p, l, ...)\ +#define dvb_mux_class_X(c, f, p, l, ...)\ static const void * \ -linuxdvb_mux_##c##_class_##l##_get (void *o)\ +dvb_mux_##c##_class_##l##_get (void *o)\ {\ static const char *s;\ - linuxdvb_mux_t *lm = o;\ + dvb_mux_t *lm = o;\ s = dvb_##l##2str(lm->lm_tuning.u.dmc_fe_##f.p);\ return &s;\ }\ static int \ -linuxdvb_mux_##c##_class_##l##_set (void *o, const void *v)\ +dvb_mux_##c##_class_##l##_set (void *o, const void *v)\ {\ - linuxdvb_mux_t *lm = o;\ + dvb_mux_t *lm = o;\ lm->lm_tuning.u.dmc_fe_##f.p = dvb_str2##l ((const char*)v);\ return 1;\ }\ static htsmsg_t *\ -linuxdvb_mux_##c##_class_##l##_enum (void *o)\ +dvb_mux_##c##_class_##l##_enum (void *o)\ {\ static const int t[] = { __VA_ARGS__ };\ int i;\ @@ -101,38 +101,37 @@ linuxdvb_mux_##c##_class_##l##_enum (void *o)\ .type = PT_STR,\ .id = _id,\ .name = _name,\ - .get = linuxdvb_mux_##t##_class_##l##_get,\ - .set = linuxdvb_mux_##t##_class_##l##_set,\ - .list = linuxdvb_mux_##t##_class_##l##_enum,\ + .get = dvb_mux_##t##_class_##l##_get,\ + .set = dvb_mux_##t##_class_##l##_set,\ + .list = dvb_mux_##t##_class_##l##_enum,\ .def.s = d static const void * -linuxdvb_mux_class_delsys_get (void *o) +dvb_mux_class_delsys_get (void *o) { static const char *s; - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; s = dvb_delsys2str(lm->lm_tuning.dmc_fe_delsys); return &s; } + static int -linuxdvb_mux_class_delsys_set (void *o, const void *v) +dvb_mux_class_delsys_set (void *o, const void *v) { -#if DVB_VER_ATLEAST(5,0) const char *s = v; int delsys = dvb_str2delsys(s); - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; if (delsys != lm->lm_tuning.dmc_fe_delsys) { lm->lm_tuning.dmc_fe_delsys = dvb_str2delsys(s); return 1; } -#endif return 0; } -const idclass_t linuxdvb_mux_class = +const idclass_t dvb_mux_class = { .ic_super = &mpegts_mux_class, - .ic_class = "linuxdvb_mux", + .ic_class = "dvb_mux", .ic_caption = "Linux DVB Multiplex", .ic_properties = (const property_t[]){ {} @@ -143,78 +142,50 @@ const idclass_t linuxdvb_mux_class = * DVB-T */ -linuxdvb_mux_class_X(dvbt, ofdm, bandwidth, bw, - DVB_BANDWIDTH_AUTO - , DVB_BANDWIDTH_8_MHZ, DVB_BANDWIDTH_7_MHZ - , DVB_BANDWIDTH_6_MHZ -#if DVB_VER_ATLEAST(5,4) - , DVB_BANDWIDTH_5_MHZ - , DVB_BANDWIDTH_10_MHZ - , DVB_BANDWIDTH_1_712_MHZ -#endif - ); -linuxdvb_mux_class_R(dvbt, modulation, qam, +dvb_mux_class_X(dvbt, ofdm, bandwidth, bw, + DVB_BANDWIDTH_AUTO, DVB_BANDWIDTH_10_MHZ, + DVB_BANDWIDTH_8_MHZ, DVB_BANDWIDTH_7_MHZ, + DVB_BANDWIDTH_6_MHZ, DVB_BANDWIDTH_5_MHZ, + DVB_BANDWIDTH_1_712_MHZ); +dvb_mux_class_R(dvbt, modulation, qam, DVB_MOD_QAM_AUTO, DVB_MOD_QPSK, DVB_MOD_QAM_16, - DVB_MOD_QAM_64, DVB_MOD_QAM_256 - ); -linuxdvb_mux_class_X(dvbt, ofdm, transmission_mode, mode, - DVB_TRANSMISSION_MODE_AUTO, - DVB_TRANSMISSION_MODE_2K, DVB_TRANSMISSION_MODE_8K -#if DVB_VER_ATLEAST(5,4) - , DVB_TRANSMISSION_MODE_1K, DVB_TRANSMISSION_MODE_16K - , DVB_TRANSMISSION_MODE_32K -#endif - ); -linuxdvb_mux_class_X(dvbt, ofdm, guard_interval, guard, - DVB_GUARD_INTERVAL_AUTO, DVB_GUARD_INTERVAL_1_4, - DVB_GUARD_INTERVAL_1_8, DVB_GUARD_INTERVAL_1_16, - DVB_GUARD_INTERVAL_1_32 -#if DVB_VER_ATLEAST(5,4) - , DVB_GUARD_INTERVAL_1_128, DVB_GUARD_INTERVAL_19_128 - , DVB_GUARD_INTERVAL_19_256 -#endif - ); -linuxdvb_mux_class_X(dvbt, ofdm, hierarchy_information, hier, + DVB_MOD_QAM_64, DVB_MOD_QAM_256); +dvb_mux_class_X(dvbt, ofdm, transmission_mode, mode, + DVB_TRANSMISSION_MODE_AUTO, DVB_TRANSMISSION_MODE_32K, + DVB_TRANSMISSION_MODE_16K, DVB_TRANSMISSION_MODE_8K, + DVB_TRANSMISSION_MODE_2K, DVB_TRANSMISSION_MODE_1K); +dvb_mux_class_X(dvbt, ofdm, guard_interval, guard, + DVB_GUARD_INTERVAL_AUTO, DVB_GUARD_INTERVAL_1_32, + DVB_GUARD_INTERVAL_1_16, DVB_GUARD_INTERVAL_1_8, + DVB_GUARD_INTERVAL_1_4, DVB_GUARD_INTERVAL_1_128, + DVB_GUARD_INTERVAL_19_128, DVB_GUARD_INTERVAL_19_256); +dvb_mux_class_X(dvbt, ofdm, hierarchy_information, hier, DVB_HIERARCHY_AUTO, DVB_HIERARCHY_NONE, - DVB_HIERARCHY_1, DVB_HIERARCHY_2, DVB_HIERARCHY_4 - ); -linuxdvb_mux_class_X(dvbt, ofdm, code_rate_HP, fechi, - DVB_FEC_AUTO, - DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, DVB_FEC_4_5, - DVB_FEC_5_6, DVB_FEC_7_8 -#if DVB_VER_ATLEAST(5,4) - , DVB_FEC_3_5 -#endif - ); -linuxdvb_mux_class_X(dvbt, ofdm, code_rate_LP, feclo, - DVB_FEC_AUTO, - DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, - DVB_FEC_4_5, DVB_FEC_5_6, DVB_FEC_7_8 -#if DVB_VER_ATLEAST(5,4) - , DVB_FEC_3_5 -#endif - ); + DVB_HIERARCHY_1, DVB_HIERARCHY_2, DVB_HIERARCHY_4); +dvb_mux_class_X(dvbt, ofdm, code_rate_HP, fechi, + DVB_FEC_AUTO, DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, + DVB_FEC_3_5, DVB_FEC_4_5, DVB_FEC_5_6, DVB_FEC_7_8); +dvb_mux_class_X(dvbt, ofdm, code_rate_LP, feclo, + DVB_FEC_AUTO, DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, + DVB_FEC_3_5, DVB_FEC_4_5, DVB_FEC_5_6, DVB_FEC_7_8); + +#define dvb_mux_dvbt_class_delsys_get dvb_mux_class_delsys_get +#define dvb_mux_dvbt_class_delsys_set dvb_mux_class_delsys_set -#define linuxdvb_mux_dvbt_class_delsys_get linuxdvb_mux_class_delsys_get -#define linuxdvb_mux_dvbt_class_delsys_set linuxdvb_mux_class_delsys_set static htsmsg_t * -linuxdvb_mux_dvbt_class_delsys_enum (void *o) +dvb_mux_dvbt_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); -#if DVB_VER_ATLEAST(5,0) htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBT)); -#endif -#if DVB_VER_ATLEAST(5,4) htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBT2)); htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_TURBO)); -#endif return list; } -const idclass_t linuxdvb_mux_dvbt_class = +const idclass_t dvb_mux_dvbt_class = { - .ic_super = &linuxdvb_mux_class, - .ic_class = "linuxdvb_mux_dvbt", + .ic_super = &dvb_mux_class, + .ic_class = "dvb_mux_dvbt", .ic_caption = "Linux DVB-T Multiplex", .ic_properties = (const property_t[]){ { @@ -225,7 +196,7 @@ const idclass_t linuxdvb_mux_dvbt_class = .id = "frequency", .name = "Frequency (Hz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), + .off = offsetof(dvb_mux_t, lm_tuning.dmc_fe_freq), }, { MUX_PROP_STR("bandwidth", "Bandwidth", dvbt, bw, "AUTO") @@ -256,39 +227,30 @@ const idclass_t linuxdvb_mux_dvbt_class = * DVB-C */ -linuxdvb_mux_class_R(dvbc, modulation, qam, +dvb_mux_class_R(dvbc, modulation, qam, DVB_MOD_QAM_AUTO, DVB_MOD_QAM_16, DVB_MOD_QAM_32, - DVB_MOD_QAM_64, DVB_MOD_QAM_128, DVB_MOD_QAM_256 - ); -linuxdvb_mux_class_X(dvbc, qam, fec_inner, fec, + DVB_MOD_QAM_64, DVB_MOD_QAM_128, DVB_MOD_QAM_256); +dvb_mux_class_X(dvbc, qam, fec_inner, fec, DVB_FEC_AUTO, DVB_FEC_NONE, DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, DVB_FEC_4_5, - DVB_FEC_5_6, DVB_FEC_8_9 -#if DVB_VER_ATLEAST(5,4) - , DVB_FEC_9_10 -#endif - ); + DVB_FEC_5_6, DVB_FEC_8_9, DVB_FEC_9_10); -#define linuxdvb_mux_dvbc_class_delsys_get linuxdvb_mux_class_delsys_get -#define linuxdvb_mux_dvbc_class_delsys_set linuxdvb_mux_class_delsys_set +#define dvb_mux_dvbc_class_delsys_get dvb_mux_class_delsys_get +#define dvb_mux_dvbc_class_delsys_set dvb_mux_class_delsys_set static htsmsg_t * -linuxdvb_mux_dvbc_class_delsys_enum (void *o) +dvb_mux_dvbc_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); -#if DVB_VER_ATLEAST(5,0) htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBC_ANNEX_A)); htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBC_ANNEX_B)); -#if DVB_VER_ATLEAST(5,3) htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBC_ANNEX_C)); -#endif -#endif return list; } -const idclass_t linuxdvb_mux_dvbc_class = +const idclass_t dvb_mux_dvbc_class = { - .ic_super = &linuxdvb_mux_class, - .ic_class = "linuxdvb_mux_dvbc", + .ic_super = &dvb_mux_class, + .ic_class = "dvb_mux_dvbc", .ic_caption = "Linux DVB-C Multiplex", .ic_properties = (const property_t[]){ { @@ -299,14 +261,14 @@ const idclass_t linuxdvb_mux_dvbc_class = .id = "frequency", .name = "Frequency (Hz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), + .off = offsetof(dvb_mux_t, lm_tuning.dmc_fe_freq), }, { .type = PT_U32, .id = "symbolrate", .name = "Symbol Rate (Sym/s)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.u.dmc_fe_qam.symbol_rate), + .off = offsetof(dvb_mux_t, lm_tuning.u.dmc_fe_qam.symbol_rate), }, { MUX_PROP_STR("constellation", "Constellation", dvbc, qam, "AUTO") @@ -318,31 +280,31 @@ const idclass_t linuxdvb_mux_dvbc_class = } }; -linuxdvb_mux_class_X(dvbs, qpsk, fec_inner, fec, +dvb_mux_class_X(dvbs, qpsk, fec_inner, fec, DVB_FEC_AUTO, DVB_FEC_NONE, - DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, DVB_FEC_4_5, - DVB_FEC_5_6, DVB_FEC_7_8, DVB_FEC_8_9 -#if DVB_VER_ATLEAST(5,4) - , DVB_FEC_3_5, DVB_FEC_9_10 -#endif - ); + DVB_FEC_1_2, DVB_FEC_2_3, DVB_FEC_3_4, DVB_FEC_3_5, + DVB_FEC_4_5, DVB_FEC_5_6, DVB_FEC_7_8, DVB_FEC_8_9, + DVB_FEC_9_10); + static const void * -linuxdvb_mux_dvbs_class_polarity_get (void *o) +dvb_mux_dvbs_class_polarity_get (void *o) { static const char *s; - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; s = dvb_pol2str(lm->lm_tuning.u.dmc_fe_qpsk.polarisation); return &s; } + static int -linuxdvb_mux_dvbs_class_polarity_set (void *o, const void *s) +dvb_mux_dvbs_class_polarity_set (void *o, const void *s) { - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; lm->lm_tuning.u.dmc_fe_qpsk.polarisation = dvb_str2pol((const char*)s); return 1; } + static htsmsg_t * -linuxdvb_mux_dvbs_class_polarity_enum (void *o) +dvb_mux_dvbs_class_polarity_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); htsmsg_add_str(list, NULL, dvb_pol2str(DVB_POLARISATION_VERTICAL)); @@ -353,57 +315,58 @@ linuxdvb_mux_dvbs_class_polarity_enum (void *o) } static const void * -linuxdvb_mux_dvbs_class_modulation_get ( void *o ) +dvb_mux_dvbs_class_modulation_get ( void *o ) { static const char *s; - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; s = dvb_qam2str(lm->lm_tuning.dmc_fe_modulation); return &s; } + static int -linuxdvb_mux_dvbs_class_modulation_set (void *o, const void *s) +dvb_mux_dvbs_class_modulation_set (void *o, const void *s) { int mod = dvb_str2qam(s); - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; if (mod != lm->lm_tuning.dmc_fe_modulation) { lm->lm_tuning.dmc_fe_modulation = mod; return 1; } return 0; } + static htsmsg_t * -linuxdvb_mux_dvbs_class_modulation_list ( void *o ) +dvb_mux_dvbs_class_modulation_list ( void *o ) { htsmsg_t *list = htsmsg_create_list(); - htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_QAM_AUTO)); + htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_AUTO)); htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_QPSK)); htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_QAM_16)); -#if DVB_VER_ATLEAST(5,4) htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_PSK_8)); htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_APSK_16)); htsmsg_add_str(list, NULL, dvb_qam2str(DVB_MOD_APSK_32)); -#endif return list; } -#if DVB_VER_ATLEAST(5,0) static const void * -linuxdvb_mux_dvbs_class_rolloff_get ( void *o ) +dvb_mux_dvbs_class_rolloff_get ( void *o ) { static const char *s; - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; s = dvb_rolloff2str(lm->lm_tuning.dmc_fe_rolloff); return &s; } + static int -linuxdvb_mux_dvbs_class_rolloff_set ( void *o, const void *s ) +dvb_mux_dvbs_class_rolloff_set ( void *o, const void *s ) { - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; lm->lm_tuning.dmc_fe_rolloff = dvb_str2rolloff(s); return 1; } + static htsmsg_t * -linuxdvb_mux_dvbs_class_rolloff_list ( void *o ) +dvb_mux_dvbs_class_rolloff_list ( void *o ) { htsmsg_t *list = htsmsg_create_list(); htsmsg_add_str(list, NULL, dvb_rolloff2str(DVB_ROLLOFF_35)); @@ -416,22 +379,23 @@ linuxdvb_mux_dvbs_class_rolloff_list ( void *o ) } static const void * -linuxdvb_mux_dvbs_class_pilot_get ( void *o ) +dvb_mux_dvbs_class_pilot_get ( void *o ) { static const char *s; - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; s = dvb_pilot2str(lm->lm_tuning.dmc_fe_pilot); return &s; } + static int -linuxdvb_mux_dvbs_class_pilot_set ( void *o, const void *s ) +dvb_mux_dvbs_class_pilot_set ( void *o, const void *s ) { - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; lm->lm_tuning.dmc_fe_pilot = dvb_str2pilot(s); return 1; } static htsmsg_t * -linuxdvb_mux_dvbs_class_pilot_list ( void *o ) +dvb_mux_dvbs_class_pilot_list ( void *o ) { htsmsg_t *list = htsmsg_create_list(); htsmsg_add_str(list, NULL, dvb_pilot2str(DVB_PILOT_AUTO)); @@ -439,12 +403,12 @@ linuxdvb_mux_dvbs_class_pilot_list ( void *o ) htsmsg_add_str(list, NULL, dvb_pilot2str(DVB_PILOT_OFF)); return list; } -#endif -#define linuxdvb_mux_dvbs_class_delsys_get linuxdvb_mux_class_delsys_get -#define linuxdvb_mux_dvbs_class_delsys_set linuxdvb_mux_class_delsys_set +#define dvb_mux_dvbs_class_delsys_get dvb_mux_class_delsys_get +#define dvb_mux_dvbs_class_delsys_set dvb_mux_class_delsys_set + static htsmsg_t * -linuxdvb_mux_dvbs_class_delsys_enum (void *o) +dvb_mux_dvbs_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_DVBS)); @@ -453,10 +417,10 @@ linuxdvb_mux_dvbs_class_delsys_enum (void *o) } static const void * -linuxdvb_mux_dvbs_class_orbital_get ( void *o ) +dvb_mux_dvbs_class_orbital_get ( void *o ) { static char buf[256], *s = buf; - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; snprintf(buf, sizeof(buf), "%0.1f%c", lm->lm_tuning.u.dmc_fe_qpsk.orbital_pos / 10.0, lm->lm_tuning.u.dmc_fe_qpsk.orbital_dir); @@ -464,12 +428,12 @@ linuxdvb_mux_dvbs_class_orbital_get ( void *o ) } static int -linuxdvb_mux_dvbs_class_orbital_set ( void *o, const void *s ) +dvb_mux_dvbs_class_orbital_set ( void *o, const void *s ) { int pos, save = 0; char dir; char *tmp = tvh_strdupa(s); - linuxdvb_mux_t *lm = o; + dvb_mux_t *lm = o; dir = tmp[strlen(tmp)-1]; tmp[strlen(tmp)-1] = '\0'; @@ -484,10 +448,10 @@ linuxdvb_mux_dvbs_class_orbital_set ( void *o, const void *s ) return save; } -const idclass_t linuxdvb_mux_dvbs_class = +const idclass_t dvb_mux_dvbs_class = { - .ic_super = &linuxdvb_mux_class, - .ic_class = "linuxdvb_mux_dvbs", + .ic_super = &dvb_mux_class, + .ic_class = "dvb_mux_dvbs", .ic_caption = "Linux DVB-S Multiplex", .ic_properties = (const property_t[]){ { @@ -498,14 +462,14 @@ const idclass_t linuxdvb_mux_dvbs_class = .id = "frequency", .name = "Frequency (kHz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), + .off = offsetof(dvb_mux_t, lm_tuning.dmc_fe_freq), }, { .type = PT_U32, .id = "symbolrate", .name = "Symbol Rate (Sym/s)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.u.dmc_fe_qpsk.symbol_rate), + .off = offsetof(dvb_mux_t, lm_tuning.u.dmc_fe_qpsk.symbol_rate), }, { MUX_PROP_STR("polarisation", "Polarisation", dvbs, polarity, NULL) @@ -514,22 +478,21 @@ const idclass_t linuxdvb_mux_dvbs_class = .type = PT_STR, .id = "modulation", .name = "Modulation", - .set = linuxdvb_mux_dvbs_class_modulation_set, - .get = linuxdvb_mux_dvbs_class_modulation_get, - .list = linuxdvb_mux_dvbs_class_modulation_list, + .set = dvb_mux_dvbs_class_modulation_set, + .get = dvb_mux_dvbs_class_modulation_get, + .list = dvb_mux_dvbs_class_modulation_list, .def.s = "AUTO", }, { MUX_PROP_STR("fec", "FEC", dvbs, fec, "AUTO") }, -#if DVB_VER_ATLEAST(5,0) { .type = PT_STR, .id = "rolloff", .name = "Rolloff", - .set = linuxdvb_mux_dvbs_class_rolloff_set, - .get = linuxdvb_mux_dvbs_class_rolloff_get, - .list = linuxdvb_mux_dvbs_class_rolloff_list, + .set = dvb_mux_dvbs_class_rolloff_set, + .get = dvb_mux_dvbs_class_rolloff_get, + .list = dvb_mux_dvbs_class_rolloff_list, .def.s = "AUTO" }, { @@ -537,43 +500,41 @@ const idclass_t linuxdvb_mux_dvbs_class = .id = "pilot", .name = "Pilot", .opts = PO_ADVANCED, - .set = linuxdvb_mux_dvbs_class_pilot_set, - .get = linuxdvb_mux_dvbs_class_pilot_get, - .list = linuxdvb_mux_dvbs_class_pilot_list, + .set = dvb_mux_dvbs_class_pilot_set, + .get = dvb_mux_dvbs_class_pilot_get, + .list = dvb_mux_dvbs_class_pilot_list, }, -#endif { .type = PT_STR, .id = "orbital", .name = "Orbital Pos.", - .set = linuxdvb_mux_dvbs_class_orbital_set, - .get = linuxdvb_mux_dvbs_class_orbital_get, + .set = dvb_mux_dvbs_class_orbital_set, + .get = dvb_mux_dvbs_class_orbital_get, .opts = PO_ADVANCED | PO_RDONLY }, {} } }; -#define linuxdvb_mux_atsc_class_delsys_get linuxdvb_mux_class_delsys_get -#define linuxdvb_mux_atsc_class_delsys_set linuxdvb_mux_class_delsys_set +#define dvb_mux_atsc_class_delsys_get dvb_mux_class_delsys_get +#define dvb_mux_atsc_class_delsys_set dvb_mux_class_delsys_set + static htsmsg_t * -linuxdvb_mux_atsc_class_delsys_enum (void *o) +dvb_mux_atsc_class_delsys_enum (void *o) { htsmsg_t *list = htsmsg_create_list(); -#if DVB_VER_ATLEAST(5,0) htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_ATSC)); htsmsg_add_str(list, NULL, dvb_delsys2str(DVB_SYS_ATSCMH)); -#endif return list; } -linuxdvb_mux_class_R(atsc, modulation, qam, +dvb_mux_class_R(atsc, modulation, qam, DVB_MOD_QAM_AUTO, DVB_MOD_QAM_256, DVB_MOD_VSB_8); -const idclass_t linuxdvb_mux_atsc_class = +const idclass_t dvb_mux_atsc_class = { - .ic_super = &linuxdvb_mux_class, - .ic_class = "linuxdvb_mux_atsc", + .ic_super = &dvb_mux_class, + .ic_class = "dvb_mux_atsc", .ic_caption = "Linux ATSC Multiplex", .ic_properties = (const property_t[]){ { @@ -584,7 +545,7 @@ const idclass_t linuxdvb_mux_atsc_class = .id = "frequency", .name = "Frequency (kHz)", .opts = PO_WRONCE, - .off = offsetof(linuxdvb_mux_t, lm_tuning.dmc_fe_freq), + .off = offsetof(dvb_mux_t, lm_tuning.dmc_fe_freq), }, { MUX_PROP_STR("modulation", "Modulation", atsc, qam, "AUTO") @@ -598,20 +559,20 @@ const idclass_t linuxdvb_mux_atsc_class = * *************************************************************************/ static void -linuxdvb_mux_config_save ( mpegts_mux_t *mm ) +dvb_mux_config_save ( mpegts_mux_t *mm ) { htsmsg_t *c = htsmsg_create_map(); mpegts_mux_save(mm, c); - hts_settings_save(c, "input/linuxdvb/networks/%s/muxes/%s/config", + hts_settings_save(c, "input/dvb/networks/%s/muxes/%s/config", idnode_uuid_as_str(&mm->mm_network->mn_id), idnode_uuid_as_str(&mm->mm_id)); htsmsg_destroy(c); } static void -linuxdvb_mux_display_name ( mpegts_mux_t *mm, char *buf, size_t len ) +dvb_mux_display_name ( mpegts_mux_t *mm, char *buf, size_t len ) { - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; + dvb_mux_t *lm = (dvb_mux_t*)mm; dvb_network_t *ln = (dvb_network_t*)mm->mm_network; uint32_t freq = lm->lm_tuning.dmc_fe_freq; char pol[2] = { 0 }; @@ -626,7 +587,7 @@ linuxdvb_mux_display_name ( mpegts_mux_t *mm, char *buf, size_t len ) } static void -linuxdvb_mux_create_instances ( mpegts_mux_t *mm ) +dvb_mux_create_instances ( mpegts_mux_t *mm ) { mpegts_network_link_t *mnl; LIST_FOREACH(mnl, &mm->mm_network->mn_inputs, mnl_mn_link) { @@ -637,11 +598,11 @@ linuxdvb_mux_create_instances ( mpegts_mux_t *mm ) } static void -linuxdvb_mux_delete ( mpegts_mux_t *mm, int delconf ) +dvb_mux_delete ( mpegts_mux_t *mm, int delconf ) { /* Remove config */ if (delconf) - hts_settings_remove("input/linuxdvb/networks/%s/muxes/%s", + hts_settings_remove("input/dvb/networks/%s/muxes/%s", idnode_uuid_as_str(&mm->mm_network->mn_id), idnode_uuid_as_str(&mm->mm_id)); @@ -653,15 +614,15 @@ linuxdvb_mux_delete ( mpegts_mux_t *mm, int delconf ) * Creation/Config * *************************************************************************/ -linuxdvb_mux_t * -linuxdvb_mux_create0 +dvb_mux_t * +dvb_mux_create0 ( dvb_network_t *ln, uint16_t onid, uint16_t tsid, const dvb_mux_conf_t *dmc, const char *uuid, htsmsg_t *conf ) { const idclass_t *idc; mpegts_mux_t *mm; - linuxdvb_mux_t *lm; + dvb_mux_t *lm; htsmsg_t *c, *e; htsmsg_field_t *f; mpegts_service_t *ts; @@ -669,23 +630,23 @@ linuxdvb_mux_create0 /* Class */ if (ln->ln_type == DVB_TYPE_S) - idc = &linuxdvb_mux_dvbs_class; + idc = &dvb_mux_dvbs_class; else if (ln->ln_type == DVB_TYPE_C) - idc = &linuxdvb_mux_dvbc_class; + idc = &dvb_mux_dvbc_class; else if (ln->ln_type == DVB_TYPE_T) - idc = &linuxdvb_mux_dvbt_class; + idc = &dvb_mux_dvbt_class; else if (ln->ln_type == DVB_TYPE_ATSC) - idc = &linuxdvb_mux_atsc_class; + idc = &dvb_mux_atsc_class; else { - tvherror("linuxdvb", "unknown FE type %d", ln->ln_type); + tvherror("dvb", "unknown FE type %d", ln->ln_type); return NULL; } /* Create */ - if (!(mm = mpegts_mux_create0(calloc(1, sizeof(linuxdvb_mux_t)), idc, uuid, + if (!(mm = mpegts_mux_create0(calloc(1, sizeof(dvb_mux_t)), idc, uuid, (mpegts_network_t*)ln, onid, tsid, conf))) return NULL; - lm = (linuxdvb_mux_t*)mm; + lm = (dvb_mux_t*)mm; lm->lm_tuning.dmc_fe_type = ln->ln_type; /* Tuning */ @@ -695,17 +656,15 @@ linuxdvb_mux_create0 } /* Callbacks */ - lm->mm_delete = linuxdvb_mux_delete; - lm->mm_display_name = linuxdvb_mux_display_name; - lm->mm_config_save = linuxdvb_mux_config_save; - lm->mm_create_instances = linuxdvb_mux_create_instances; + lm->mm_delete = dvb_mux_delete; + lm->mm_display_name = dvb_mux_display_name; + lm->mm_config_save = dvb_mux_config_save; + lm->mm_create_instances = dvb_mux_create_instances; /* Defaults */ if (dmc == NULL) { lm->lm_tuning.dmc_fe_inversion = DVB_INVERSION_AUTO; -#if DVB_VER_ATLEAST(5,0) lm->lm_tuning.dmc_fe_pilot = DVB_PILOT_AUTO; -#endif } /* No config */ diff --git a/src/input/mpegts/mpegts_network_dvb.c b/src/input/mpegts/mpegts_network_dvb.c index 852317a7..6b7efa5c 100644 --- a/src/input/mpegts/mpegts_network_dvb.c +++ b/src/input/mpegts/mpegts_network_dvb.c @@ -78,10 +78,10 @@ dvb_network_class_scanfile_set ( void *o, const void *s ) /* Create */ LIST_FOREACH(dmc, &sfn->sfn_muxes, dmc_link) { if (!(mm = dvb_network_find_mux(o, dmc))) { - mm = (mpegts_mux_t*)linuxdvb_mux_create0(o, - MPEGTS_ONID_NONE, - MPEGTS_TSID_NONE, - dmc, NULL, NULL); + mm = (mpegts_mux_t*)dvb_mux_create0(o, + MPEGTS_ONID_NONE, + MPEGTS_TSID_NONE, + dmc, NULL, NULL); if (mm) mm->mm_config_save(mm); } @@ -217,7 +217,7 @@ dvb_network_find_mux { mpegts_mux_t *mm; LIST_FOREACH(mm, &ln->mn_muxes, mm_network_link) { - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; + dvb_mux_t *lm = (dvb_mux_t*)mm; if (abs(lm->lm_tuning.dmc_fe_freq - dmc->dmc_fe_freq) > LINUXDVB_FREQ_TOL) continue; if (lm->lm_tuning.u.dmc_fe_qpsk.polarisation != dmc->u.dmc_fe_qpsk.polarisation) continue; @@ -245,10 +245,10 @@ dvb_network_create_mux dvb_network_t *ln = (dvb_network_t*)mm->mm_network; mm = dvb_network_find_mux(ln, dmc); if (!mm && ln->mn_autodiscovery) { - mm = (mpegts_mux_t*)linuxdvb_mux_create0(ln, onid, tsid, dmc, NULL, NULL); + mm = (mpegts_mux_t*)dvb_mux_create0(ln, onid, tsid, dmc, NULL, NULL); save = 1; } else if (mm) { - linuxdvb_mux_t *lm = (linuxdvb_mux_t*)mm; + dvb_mux_t *lm = (dvb_mux_t*)mm; dmc->dmc_fe_freq = lm->lm_tuning.dmc_fe_freq; // Note: keep original freq, else it can bounce around if diff transponders // report it slightly differently. @@ -274,18 +274,14 @@ static const idclass_t * dvb_network_mux_class ( mpegts_network_t *mn ) { - extern const idclass_t linuxdvb_mux_dvbt_class; - extern const idclass_t linuxdvb_mux_dvbc_class; - extern const idclass_t linuxdvb_mux_dvbs_class; - extern const idclass_t linuxdvb_mux_atsc_class; if (idnode_is_instance(&mn->mn_id, &dvb_network_dvbt_class)) - return &linuxdvb_mux_dvbt_class; + return &dvb_mux_dvbt_class; if (idnode_is_instance(&mn->mn_id, &dvb_network_dvbc_class)) - return &linuxdvb_mux_dvbc_class; + return &dvb_mux_dvbc_class; if (idnode_is_instance(&mn->mn_id, &dvb_network_dvbs_class)) - return &linuxdvb_mux_dvbs_class; + return &dvb_mux_dvbs_class; if (idnode_is_instance(&mn->mn_id, &dvb_network_atsc_class)) - return &linuxdvb_mux_atsc_class; + return &dvb_mux_atsc_class; return NULL; } @@ -295,8 +291,8 @@ dvb_network_mux_create2 { dvb_network_t *ln = (dvb_network_t*)mn; return (mpegts_mux_t*) - linuxdvb_mux_create0(ln, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, - NULL, NULL, conf); + dvb_mux_create0(ln, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, + NULL, NULL, conf); } /* **************************************************************************** @@ -349,7 +345,7 @@ dvb_network_create0 HTSMSG_FOREACH(f, c) { if (!(e = htsmsg_get_map_by_field(f))) continue; if (!(e = htsmsg_get_map(e, "config"))) continue; - mm = (mpegts_mux_t *)linuxdvb_mux_create1(ln, f->hmf_name, e); + mm = (mpegts_mux_t *)dvb_mux_create1(ln, f->hmf_name, e); if (mm && move) mm->mm_config_save(mm); }