dvr_entry_t *de = aux;
streaming_queue_t *sq = &de->de_sq;
streaming_message_t *sm;
+ th_pkt_t *pkt;
int run = 1;
int started = 0;
pthread_mutex_unlock(&sq->sq_mutex);
switch(sm->sm_type) {
- case SMT_MPEGTS:
+
case SMT_PACKET:
+ pkt = sm->sm_data;
+ if(pkt->pkt_commercial == COMMERCIAL_YES) {
+ dvr_rec_set_state(de, DVR_RS_COMMERCIAL, 0);
+ tsfix_set_comm_skip(de->de_tsfix, 1);
+ break;
+ }
+
+ dvr_rec_set_state(de, DVR_RS_RUNNING, 0);
+ tsfix_set_comm_skip(de->de_tsfix, 0);
+
+ if(started) {
+ muxer_write_pkt(de->de_mux, sm->sm_type, sm->sm_data);
+ sm->sm_data = NULL;
+ }
+ break;
+
+ case SMT_MPEGTS:
if(started) {
dvr_rec_set_state(de, DVR_RS_RUNNING, 0);
muxer_write_pkt(de->de_mux, sm->sm_type, sm->sm_data);
int64_t tfs_dts_epoch;
int64_t tfs_last_dts_in;
+ int64_t tfs_drops;
} tfstream_t;
int tf_hasvideo;
int64_t tf_tsref;
time_t tf_start_time;
+ int tf_comm_skip;
struct th_pktref_queue tf_ptsq;
/* Subtract the transport wide start offset */
dts = pkt->pkt_dts - tf->tf_tsref;
+ /* Subtract dropped packets due to commercial breaks */
+ dts -= tfs->tfs_drops;
+
if(tfs->tfs_last_dts_norm == PTS_UNSET) {
if(dts < 0) {
/* Early packet with negative time stamp, drop those */
tsfixprintf("reference clock set to %"PRId64"\n", tf->tf_tsref);
}
- if(pkt->pkt_dts == PTS_UNSET) {
-
- int pdur = pkt->pkt_duration >> pkt->pkt_field;
+ int pdur = pkt->pkt_duration >> pkt->pkt_field;
+ if(pkt->pkt_dts == PTS_UNSET) {
if(tfs->tfs_last_dts_in == PTS_UNSET) {
+ tfs->tfs_drops += pdur;
pkt_ref_dec(pkt);
return;
}
streaming_component_type2txt(tfs->tfs_type),
tfs->tfs_last_dts_in, pdur, pkt->pkt_dts);
}
+
+ if(tf->tf_comm_skip && pkt->pkt_commercial == COMMERCIAL_YES) {
+ tfs->tfs_drops += pdur;
+ pkt_ref_dec(pkt);
+ return;
+ }
+
tfs->tfs_last_dts_in = pkt->pkt_dts;
compute_pts(tf, tfs, pkt);
}
+/**
+ *
+ */
+void
+tsfix_set_comm_skip(streaming_target_t *pad, int bool) {
+ tsfix_t *tf = (tsfix_t *)pad;
+
+ tf->tf_comm_skip = !!bool;
+}
+
+
/**
*
*/