Remove unused files iptv_output.[ch] and tsmux.[ch] and related code

This commit is contained in:
Dave Chapman 2013-02-28 12:38:23 +00:00
parent 229a8d75d8
commit 4724e01d13
8 changed files with 1 additions and 1758 deletions

View file

@ -1,211 +0,0 @@
/*
* Output functions for fixed multicast streaming
* Copyright (C) 2007 Andreas Öman
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <syslog.h>
#include "tvhead.h"
#include "iptv_output.h"
#include "dispatch.h"
#include "channels.h"
#include "subscriptions.h"
#include "tsmux.h"
#include "rtp.h"
#define MULTICAST_PKT_SIZ (188 * 7)
typedef struct output_multicast {
ts_muxer_t *om_muxer;
int om_fd;
struct sockaddr_in om_dst;
int om_corruption;
int om_inter_drop_rate;
int om_inter_drop_cnt;
int om_seq;
enum {
OM_RAWUDP,
OM_RTP,
} om_encapsulation;
} output_multicast_t;
/**
* Output MPEG TS
*/
static void
iptv_output_ts(void *opaque, th_subscription_t *s, uint8_t *pkt,
int blocks, int64_t pcr)
{
output_multicast_t *om = opaque;
om->om_seq++;
if(om->om_inter_drop_rate &&
++om->om_inter_drop_cnt == om->om_inter_drop_rate) {
om->om_inter_drop_cnt = 0;
return;
}
switch(om->om_encapsulation) {
case OM_RTP:
rtp_sendmsg(pkt, blocks, pcr, om->om_fd,
(struct sockaddr *)&om->om_dst, sizeof(struct sockaddr_in),
om->om_seq);
break;
case OM_RAWUDP:
sendto(om->om_fd, pkt, blocks * 188, 0,
(struct sockaddr *)&om->om_dst, sizeof(struct sockaddr_in));
break;
}
}
/**
* Called when a subscription gets/loses access to a transport
*/
static void
iptv_subscription_callback(struct th_subscription *s,
subscription_event_t event, void *opaque)
{
output_multicast_t *om = opaque;
switch(event) {
case TRANSPORT_AVAILABLE:
assert(om->om_muxer == NULL);
om->om_muxer = ts_muxer_init(s, iptv_output_ts, om, TS_SEEK,
om->om_corruption);
ts_muxer_play(om->om_muxer, 0);
break;
case TRANSPORT_UNAVAILABLE:
ts_muxer_deinit(om->om_muxer, s);
om->om_muxer = NULL;
break;
}
}
/**
* Setup IPTV (TS over UDP) output
*/
static void
output_multicast_load(struct config_head *head)
{
const char *name, *s, *b;
channel_t *ch;
output_multicast_t *om;
int ttl = 32;
struct sockaddr_in sin;
char title[100];
char title2[100];
if((name = config_get_str_sub(head, "channel", NULL)) == NULL)
return;
ch = channel_find_by_name(name, 1);
om = calloc(1, sizeof(output_multicast_t));
om->om_fd = tvh_socket(AF_INET, SOCK_DGRAM, 0);
if((b = config_get_str_sub(head, "interface-address", NULL)) != NULL) {
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = 0;
sin.sin_addr.s_addr = inet_addr(b);
if(bind(om->om_fd, (struct sockaddr *)&sin, sizeof(sin))==-1) {
fprintf(stderr, "cannot bind to %s\n", b);
goto err;
}
}
if((s = config_get_str_sub(head, "group-address", NULL)) == NULL) {
fprintf(stderr, "no group address configured\n");
goto err;
}
om->om_dst.sin_addr.s_addr = inet_addr(s);
if((s = config_get_str_sub(head, "port", NULL)) == NULL) {
fprintf(stderr, "no port configured\n");
goto err;
}
om->om_dst.sin_port = htons(atoi(s));
if((s = config_get_str_sub(head, "ttl", NULL)) != NULL)
ttl = atoi(s);
if((s = config_get_str_sub(head, "corruption-interval", NULL)) != NULL)
om->om_corruption = atoi(s);
if((s = config_get_str_sub(head, "inter-drop-rate", NULL)) != NULL)
om->om_inter_drop_rate = atoi(s);
if((s = config_get_str_sub(head, "encapsulation", NULL)) != NULL) {
if(!strcasecmp(s, "rtp"))
om->om_encapsulation = OM_RTP;
}
setsockopt(om->om_fd, SOL_IP, IP_MULTICAST_TTL, &ttl, sizeof(int));
snprintf(title, sizeof(title), "%s:%d", inet_ntoa(om->om_dst.sin_addr),
ntohs(om->om_dst.sin_port));
syslog(LOG_INFO, "Static multicast output: \"%s\" to %s, source %s ",
ch->ch_name, title, inet_ntoa(sin.sin_addr));
snprintf(title2, sizeof(title2), "IPTV-OUT: %s", title);
subscription_create(ch, 900, title2, iptv_subscription_callback, om, 0);
return;
err:
close(om->om_fd);
free(om);
}
void
output_multicast_setup(void)
{
config_entry_t *ce;
TAILQ_FOREACH(ce, &config_list, ce_link) {
if(ce->ce_type == CFG_SUB && !strcasecmp("multicast-output", ce->ce_key)) {
output_multicast_load(&ce->ce_sub);
}
}
}

View file

@ -1,24 +0,0 @@
/*
* Output functions for fixed multicast streaming
* Copyright (C) 2007 Andreas Öman
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IPTV_OUTPUT_H_
#define IPTV_OUTPUT_H_
void output_multicast_setup(void);
#endif /* IPTV_OUTPUT_H_ */

View file

@ -110,44 +110,6 @@ psi_section_reassemble(psi_section_t *ps, const uint8_t *tsb, int crc,
}
/**
* PAT parser, from ISO 13818-1
*/
int
psi_parse_pat(service_t *t, uint8_t *ptr, int len,
pid_section_callback_t *pmt_callback)
{
uint16_t prognum;
uint16_t pid;
elementary_stream_t *st;
lock_assert(&t->s_stream_mutex);
if(len < 5)
return -1;
ptr += 5;
len -= 5;
while(len >= 4) {
prognum = ptr[0] << 8 | ptr[1];
pid = (ptr[2] & 0x1f) << 8 | ptr[3];
if(prognum != 0) {
if(service_stream_find(t, pid) == NULL) {
st = service_stream_create(t, pid, SCT_PMT);
st->es_section_docrc = 1;
st->es_got_section = pmt_callback;
}
}
ptr += 4;
len -= 4;
}
return 0;
}
/**
* Append CRC
*/
@ -954,7 +916,6 @@ static struct strtab streamtypetab[] = {
{ "DVBSUB", SCT_DVBSUB },
{ "CA", SCT_CA },
{ "PMT", SCT_PMT },
{ "PAT", SCT_PAT },
{ "AAC", SCT_AAC },
{ "MPEGTS", SCT_MPEGTS },
{ "TEXTSUB", SCT_TEXTSUB },

View file

@ -37,9 +37,6 @@ typedef struct psi_section {
void psi_section_reassemble(psi_section_t *ps, const uint8_t *tsb, int crc,
section_handler_t *cb, void *opaque);
int psi_parse_pat(struct service *t, uint8_t *ptr, int len,
pid_section_callback_t *pmt_callback);
int psi_parse_pmt(struct service *t, const uint8_t *ptr, int len, int chksvcid,
int delete);

View file

@ -103,7 +103,6 @@ ts_recv_packet0(service_t *t, elementary_stream_t *st, const uint8_t *tsb)
switch(st->es_type) {
case SCT_CA:
case SCT_PAT:
case SCT_PMT:
if(st->es_section == NULL)
st->es_section = calloc(1, sizeof(struct psi_section));
@ -224,7 +223,7 @@ ts_recv_packet1(service_t *t, const uint8_t *tsb, int64_t *pcrp)
if((tsb[3] & 0xc0) ||
(t->s_scrambled_seen && st->es_type != SCT_CA &&
st->es_type != SCT_PAT && st->es_type != SCT_PMT)) {
st->es_type != SCT_PMT)) {
/**
* Lock for descrambling, but only if packet was not in error

File diff suppressed because it is too large Load diff

View file

@ -1,75 +0,0 @@
/*
* tvheadend, MPEG transport stream muxer
* Copyright (C) 2008 - 2009 Andreas Öman
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TSMUX_H
#define TSMUX_H
void tsm_init(void);
#if 0
typedef void (ts_mux_output_t)(void *opaque, th_subscription_t *s,
uint8_t *pkt, int npackets, int64_t pcr_ref);
typedef struct ts_muxer {
th_subscription_t *ts_subscription;
int ts_flags;
#define TS_SEEK 0x1
#define TS_HTSCLIENT 0x2
enum {
TS_SRC_MUX,
TS_SRC_RAW_TS,
} ts_source;
th_muxer_t *ts_muxer;
ts_mux_output_t *ts_output;
void *ts_output_opaque;
int ts_pat_cc;
int ts_pmt_cc;
dtimer_t ts_patpmt_timer;
uint8_t *ts_packet;
int ts_block;
int ts_blocks_per_packet;
th_muxstream_t *ts_pcr_stream;
int64_t ts_pcr_start;
int64_t ts_pcr_ref; /* System clock when PCR was/is/will be 0 */
int64_t ts_pcr_last;
} ts_muxer_t;
ts_muxer_t *ts_muxer_init(th_subscription_t *s, ts_mux_output_t *output,
void *opaque, int flags, int corruption);
void ts_muxer_deinit(ts_muxer_t *ts, th_subscription_t *s);
void ts_muxer_play(ts_muxer_t *ts, int64_t toffset);
void ts_muxer_pause(ts_muxer_t *ts);
#endif
#endif /* TSMUX_H */

View file

@ -185,7 +185,6 @@ typedef enum {
SCT_TELETEXT,
SCT_DVBSUB,
SCT_CA,
SCT_PAT,
SCT_PMT,
SCT_AAC,
SCT_MPEGTS,