Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
IPTV / SAT>IP server: allow re-export DVB IPTV as SAT>IP DVB-T
  • Loading branch information
perexg committed Nov 29, 2015
1 parent b1d974e commit 8c5a818
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/input/mpegts/iptv/iptv_mux.c
Expand Up @@ -235,6 +235,13 @@ const idclass_t iptv_mux_class =
.off = offsetof(iptv_mux_t, mm_iptv_tags),
.opts = PO_ADVANCED | PO_MULTILINE
},
{
.type = PT_U32,
.id = "iptv_satip_dvbt_freq",
.name = N_("SAT>IP DVB-T frequency (Hz)"),
.off = offsetof(iptv_mux_t, mm_iptv_satip_dvbt_freq),
.opts = PO_ADVANCED
},
{}
}
};
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/iptv/iptv_private.h
Expand Up @@ -135,6 +135,7 @@ struct iptv_mux
char *mm_iptv_env;
char *mm_iptv_hdr;
char *mm_iptv_tags;
uint32_t mm_iptv_satip_dvbt_freq;

uint32_t mm_iptv_rtp_seq;

Expand Down
46 changes: 32 additions & 14 deletions src/satip/rtsp.c
Expand Up @@ -22,6 +22,7 @@
#include "config.h"
#include "profile.h"
#include "satip/server.h"
#include "input/mpegts/iptv/iptv_private.h"

#include <ctype.h>

Expand Down Expand Up @@ -52,9 +53,10 @@ typedef struct session {
uint32_t nsession;
char session[9];
dvb_mux_conf_t dmc;
dvb_mux_conf_t dmc_tuned;
mpegts_apids_t pids;
gtimer_t timer;
dvb_mux_t *mux;
mpegts_mux_t *mux;
int mux_created;
profile_chain_t prch;
th_subscription_t *subs;
Expand Down Expand Up @@ -365,7 +367,7 @@ rtsp_clean(session_t *rs)
profile_chain_close(&rs->prch);
if (rs->mux && rs->mux_created &&
(rtsp_muxcnf != MUXCNF_KEEP || LIST_EMPTY(&rs->mux->mm_services)))
rs->mux->mm_delete((mpegts_mux_t *)rs->mux, 1);
rs->mux->mm_delete(rs->mux, 1);
rs->mux = NULL;
rs->mux_created = 0;
}
Expand Down Expand Up @@ -477,33 +479,48 @@ rtsp_start
{
mpegts_network_t *mn, *mn2;
dvb_network_t *ln;
dvb_mux_t *mux;
mpegts_mux_t *mux;
mpegts_service_t *svc;
dvb_mux_conf_t dmc;
char buf[384];
int res = HTTP_STATUS_SERVICE, qsize = 3000000, created = 0;

pthread_mutex_lock(&global_lock);
dmc = rs->dmc_tuned;
if (newmux) {
mux = NULL;
mn2 = NULL;
LIST_FOREACH(mn, &mpegts_network_all, mn_global_link) {
if (!idnode_is_instance(&mn->mn_id, &dvb_network_class))
continue;
ln = (dvb_network_t *)mn;
if (ln->ln_type == rs->dmc.dmc_fe_type &&
mn->mn_satip_source == rs->src) {
if (!mn2) mn2 = mn;
mux = dvb_network_find_mux((dvb_network_t *)mn, &rs->dmc,
MPEGTS_ONID_NONE, MPEGTS_TSID_NONE);
if (mux) break;
if (idnode_is_instance(&mn->mn_id, &dvb_network_class)) {
ln = (dvb_network_t *)mn;
if (ln->ln_type == rs->dmc.dmc_fe_type &&
mn->mn_satip_source == rs->src) {
if (!mn2) mn2 = mn;
mux = (mpegts_mux_t *)
dvb_network_find_mux((dvb_network_t *)mn, &rs->dmc,
MPEGTS_ONID_NONE, MPEGTS_TSID_NONE);
if (mux) {
dmc = ((dvb_mux_t *)mux)->lm_tuning;
break;
}
}
}
if (idnode_is_instance(&mn->mn_id, &iptv_network_class)) {
LIST_FOREACH(mux, &mn->mn_muxes, mm_network_link)
if (deltaU32(rs->dmc.dmc_fe_freq, ((iptv_mux_t *)mux)->mm_iptv_satip_dvbt_freq) < 2000)
break;
if (mux) {
dmc = rs->dmc;
break;
}
}
}
if (mux == NULL && mn2 &&
(rtsp_muxcnf == MUXCNF_AUTO || rtsp_muxcnf == MUXCNF_KEEP)) {
dvb_mux_conf_str(&rs->dmc, buf, sizeof(buf));
tvhwarn("satips", "%i/%s/%i: create mux %s",
rs->frontend, rs->session, rs->stream, buf);
mux = (dvb_mux_t *)
mux =
mn2->mn_create_mux(mn2, (void *)(intptr_t)rs->nsession,
MPEGTS_ONID_NONE, MPEGTS_TSID_NONE,
&rs->dmc, 1);
Expand All @@ -520,6 +537,7 @@ rtsp_start
if (rs->mux == mux && rs->subs)
goto pids;
rtsp_clean(rs);
rs->dmc_tuned = dmc;
rs->mux = mux;
rs->mux_created = created;
if (profile_chain_raw_open(&rs->prch, (mpegts_mux_t *)rs->mux, qsize, 0))
Expand Down Expand Up @@ -558,7 +576,7 @@ rtsp_start
rs->subs, &rs->prch.prch_sq,
hc->hc_peer, rs->rtp_peer_port,
rs->udp_rtp->fd, rs->udp_rtcp->fd,
rs->frontend, rs->findex, &rs->mux->lm_tuning,
rs->frontend, rs->findex, &rs->dmc_tuned,
&rs->pids);
if (!rs->pids.all && rs->pids.count == 0)
mpegts_pid_add(&rs->pids, 0, MPS_WEIGHT_RAW);
Expand Down
9 changes: 9 additions & 0 deletions src/satip/server.c
Expand Up @@ -21,6 +21,7 @@
#include "upnp.h"
#include "settings.h"
#include "config.h"
#include "input/mpegts/iptv/iptv_private.h"
#include "satip/server.h"

#define UPNP_MAX_AGE 1800
Expand Down Expand Up @@ -111,6 +112,7 @@ satip_server_http_xml(http_connection_t *hc)
char *devicelist = NULL;
htsbuf_queue_t q;
mpegts_network_t *mn;
mpegts_mux_t *mm;
int dvbt = 0, dvbs = 0, dvbc = 0, atsc = 0;
int srcs = 0, delim = 0, tuners = 0, i;
struct xml_type_xtab *p;
Expand Down Expand Up @@ -145,6 +147,13 @@ satip_server_http_xml(http_connection_t *hc)
dvbc++;
else if (idnode_is_instance(&mn->mn_id, &dvb_network_atsc_class))
atsc++;
else if (idnode_is_instance(&mn->mn_id, &iptv_network_class)) {
LIST_FOREACH(mm, &mn->mn_muxes, mm_network_link)
if (((iptv_mux_t *)mm)->mm_iptv_satip_dvbt_freq) {
dvbt++;
break;
}
}
}
for (p = xtab; p->id; p++) {
i = *p->cptr;
Expand Down

0 comments on commit 8c5a818

Please sign in to comment.