case TRANSPORT_AVAILABLE:
assert(c->c_muxer == NULL);
c->c_muxer = ts_muxer_init(s, client_output_ts, c,
- TS_HTSCLIENT | TS_SEEK);
+ TS_HTSCLIENT | TS_SEEK, 0);
ts_muxer_play(c->c_muxer, 0);
break;
int om_fd;
struct sockaddr_in om_dst;
- int om_intra_drop_rate;
+ int om_corruption;
int om_inter_drop_rate;
int om_inter_drop_cnt;
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_muxer->tm_drop_rate = om->om_intra_drop_rate;
+ om->om_muxer = ts_muxer_init(s, iptv_output_ts, om, TS_SEEK,
+ om->om_corruption);
ts_muxer_play(om->om_muxer, 0);
break;
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, "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);
case TRANSPORT_AVAILABLE:
assert(rs->rs_muxer == NULL);
rs->rs_muxer = ts_muxer_init(s, rtp_output_ts, &rs->rs_rtp_streamer,
- TS_SEEK);
+ TS_SEEK, 0);
break;
case TRANSPORT_UNAVAILABLE:
if(tms->tms_mux_offset == AV_NOPTS_VALUE) {
if(tms->tms_stream->st_vbv_delay == -1)
- tms->tms_mux_offset = tdur + pkt->pkt_duration;
+ tms->tms_mux_offset = tdur - pkt->pkt_duration;
else
tms->tms_mux_offset = tms->tms_stream->st_vbv_delay;
}
*tsb++ = u16 >> 8;
*tsb++ = u16;
}
-
+
memcpy(tsb, pkt->pkt_payload + off, tsrem);
+
+ if(tms->tms_corruption_interval != 0) {
+ /* Only corruption payload, never the header */
+ if(tms->tms_corruption_last + tms->tms_corruption_interval < pcr &&
+ off != 0 && pkt->pkt_frametype == PKT_I_FRAME) {
+ tms->tms_corruption_counter = 50;
+ tms->tms_corruption_last = pcr;
+ }
+
+ if(tms->tms_corruption_counter) {
+ tms->tms_cc++;
+ tms->tms_corruption_counter--;
+ }
+ }
+
tm->tm_contentsize = tsrem;
tmf_enq(&tms->tms_delivery_fifo, tm);
toff += tsrem;
off += tsrem;
- }
+
+ }
tms->tms_lookahead_depth -= pkt->pkt_payloadlen;
tms->tms_lookahead_packets--;
*/
ts_muxer_t *
ts_muxer_init(th_subscription_t *s, ts_mux_output_t *output,
- void *opaque, int flags)
+ void *opaque, int flags, int corruption)
{
ts_muxer_t *ts = calloc(1, sizeof(ts_muxer_t));
int dopcr;
ts->ts_pcr_start = AV_NOPTS_VALUE;
ts->ts_pcr_ref = AV_NOPTS_VALUE;
ts->ts_pcr_last = INT64_MIN;
+
/* Do TS MUX specific init per stream */
dopcr = 0;
switch(st->st_type) {
case HTSTV_MPEG2VIDEO:
+ tms->tms_corruption_interval = (int64_t)corruption * 1000000LL;
tms->tms_sc = 0x1e0;
dopcr = 1;
break;
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);
+ void *opaque, int flags, int corruption);
void ts_muxer_deinit(ts_muxer_t *ts, th_subscription_t *s);
int tms_sc; /* start code */
int tms_cc;
-
+
+ int64_t tms_corruption_interval;
+ int64_t tms_corruption_last;
+ int tms_corruption_counter;
+
/* Memebers used when running with ffmpeg */
struct AVStream *tms_avstream;