int main(int argc, char *argv[]) { if(argc < 2) { std::cout << USAGE << std::endl; exit(1); } std::ifstream ifs; char *inp_filename = argv[1]; unsigned char ts_pkt[256]; int n_pkts = 0; uint64_t curr_pcr; uint64_t pcr_ext; int inp_pid; ifs.open(inp_filename, std::ios::in); if(!ifs.is_open()) { std::cout << "Unable to open " << inp_filename; exit(1); } while(!ifs.eof()) { ifs.read((char*)ts_pkt, 188); inp_pid = ts_get_pid(ts_pkt); if(ts_has_adaptation(ts_pkt)) { printf("Adaptation=%d\n", (ts_pkt[3] & 0x30) >> 4); if(tsaf_has_discontinuity(ts_pkt)) { printf("PCR Discontinuity %ld %d %d\n", (int64_t)ifs.tellg()/188, inp_pid, ts_get_adaptation(ts_pkt)); } } if(ts_has_adaptation(ts_pkt) && ts_get_adaptation(ts_pkt) > 0) { if(tsaf_has_pcr(ts_pkt)) { curr_pcr = tsaf_get_pcr(ts_pkt); pcr_ext = tsaf_get_pcrext(ts_pkt); curr_pcr = (300 * curr_pcr) + pcr_ext; printf("%d %lld %lld %d\n", inp_pid, curr_pcr/(300 * 90), (int64_t)ifs.tellg()/188, ts_get_unitstart(ts_pkt)); } } n_pkts++; //std::cout << n_pkts <<std::endl; } std::cout << "Completed" << std::endl; }
/***************************************************************************** * output_Put : called from demux *****************************************************************************/ void output_Put( output_t *p_output, block_t *p_block ) { int i_block_cnt = output_BlockCount( p_output ); packet_t *p_packet; p_block->i_refcount++; if ( p_output->p_last_packet != NULL && p_output->p_last_packet->i_depth < i_block_cnt && p_output->p_last_packet->i_dts + p_output->config.i_max_retention > p_block->i_dts ) { p_packet = p_output->p_last_packet; if ( ts_has_adaptation( p_block->p_ts ) && ts_get_adaptation( p_block->p_ts ) && tsaf_has_pcr( p_block->p_ts ) ) p_packet->i_dts = p_block->i_dts; } else { /* This isn't the cleanest allocation of the world. */ p_packet = malloc( sizeof(packet_t) + (i_block_cnt - 1) * sizeof(block_t *) ); p_packet->pp_blocks = &p_packet->p_blocks; p_packet->i_depth = 0; p_packet->p_next = NULL; p_packet->i_dts = p_block->i_dts; if ( p_output->p_last_packet != NULL ) p_output->p_last_packet->p_next = p_packet; else p_output->p_packets = p_packet; p_output->p_last_packet = p_packet; } p_packet->pp_blocks[p_packet->i_depth] = p_block; p_packet->i_depth++; }