#define MULTICAST_PKT_SIZ (188 * 7)
typedef struct output_multicast {
- void *om_muxer;
+ th_muxer_t *om_muxer;
int om_fd;
struct sockaddr_in om_dst;
+
+ int om_intra_drop_rate;
+
+ int om_inter_drop_rate;
+ int om_inter_drop_cnt;
+
} output_multicast_t;
/**
{
output_multicast_t *om = opaque;
+ if(om->om_inter_drop_rate &&
+ ++om->om_inter_drop_cnt == om->om_inter_drop_rate) {
+ om->om_inter_drop_cnt = 0;
+ return;
+ }
+
sendto(om->om_fd, pkt, blocks * 188, 0,
(struct sockaddr *)&om->om_dst, sizeof(struct sockaddr_in));
}
case TRANSPORT_AVAILABLE:
assert(om->om_muxer == NULL);
om->om_muxer = ts_muxer_init(s, iptv_output_ts, om, 0);
+ om->om_muxer->tm_drop_rate = om->om_intra_drop_rate;
+ printf("intrarate = %d\n", om->om_muxer->tm_drop_rate);
ts_muxer_play(om->om_muxer, 0);
break;
if((s = config_get_str_sub(head, "ttl", NULL)) != NULL)
ttl = atoi(s);
+
+ if((s = config_get_str_sub(head, "intra-drop-rate", NULL)) != NULL)
+ om->om_intra_drop_rate = atoi(s);
+
+ if((s = config_get_str_sub(head, "inter-drop-rate", NULL)) != NULL)
+ om->om_inter_drop_rate = atoi(s);
+
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),
/* Generate a transport stream packet */
if(ts_make_pkt(tm, tms, outbuf, pcr1) == 0) {
- outbuf += 188;
rem = pkt_len(pkt) - tms->tms_offset;
+
+ /* Periodic drop (for testing purposes) */
+
+ if(i != 0 && i != maxblocks - 1 &&
+ tm->tm_drop_rate && ++tm->tm_drop_cnt == tm->tm_drop_rate) {
+ tm->tm_drop_cnt = 0;
+ i--;
+ } else {
+ outbuf += 188;
+ }
+
} else {
i--;
rem = 0;