TYPE_EIT,
} ts_pid_type_t;
+enum
+{
+ FLAGS_NONE = 0,
+ FLAG_SEEN = 1,
+ FLAG_SCRAMBLED = 2
+};
+
+#define SEEN(x) ((x).i_flags & FLAG_SEEN)
+#define SCRAMBLED(x) ((x).i_flags & FLAG_SCRAMBLED)
+
struct ts_pid_t
{
- int i_pid;
+ uint16_t i_pid;
- bool b_seen;
- int i_cc; /* countinuity counter */
- bool b_scrambled;
+ uint8_t i_flags;
+ uint8_t i_cc; /* countinuity counter */
+ uint8_t type;
/* PSI owner (ie PMT -> PAT, ES -> PMT */
+ uint8_t i_refcount;
ts_pid_t *p_parent;
- int i_refcount;
-
- ts_pid_type_t type;
/* */
union
int i_pcr_pid = 0x1FFF;
int i_num_pes = 0;
- if( p_sys->pid[i_program_pid].b_seen )
+ if( SEEN(p_sys->pid[i_program_pid]) )
{
/* Find a free one */
for( i_program_pid = MIN_ES_PID;
- i_program_pid <= MAX_ES_PID && p_sys->pid[i_program_pid].b_seen;
+ i_program_pid <= MAX_ES_PID && SEEN(p_sys->pid[i_program_pid]);
i_program_pid++ );
}
for( int i = MIN_ES_PID; i <= MAX_ES_PID; i++ )
{
- if( !p_sys->pid[i].b_seen ||
+ if( !SEEN(p_sys->pid[i]) ||
p_sys->pid[i].probed.i_type == -1 )
continue;
int j=0;
for( int i = MIN_ES_PID; i <= MAX_ES_PID; i++ )
{
- if( !p_sys->pid[i].b_seen ||
+ if( !SEEN(p_sys->pid[i]) ||
p_sys->pid[i].probed.i_type == -1 )
continue;
{
ts_pid_t *pid = &p_sys->pid[i];
pid->i_pid = i;
- pid->b_seen = false;
+ pid->i_flags = FLAGS_NONE;
pid->probed.i_fourcc = 0;
pid->probed.i_type = 0;
}
/* PID 8191 is padding */
- p_sys->pid[8191].b_seen = true;
+ p_sys->pid[8191].i_flags = FLAG_SEEN;
p_sys->i_packet_size = i_packet_size;
p_sys->i_packet_header_size = i_packet_header_size;
p_sys->i_ts_read = 50;
bool b_wait_es = p_sys->i_pmt_es <= 0;
/* If we had no PAT within MIN_PAT_INTERVAL, create PAT/PMT from probed streams */
- if( p_sys->i_pmt_es == 0 && !p_sys->pid[0].b_seen && p_sys->patfix.b_pat_deadline )
+ if( p_sys->i_pmt_es == 0 && !SEEN(p_sys->pid[0]) && p_sys->patfix.b_pat_deadline )
MissingPATPMTFixup( p_demux );
/* We read at most 100 TS packet or until a frame is completed */
ts_pid_t *p_pid = &p_sys->pid[PIDGet( p_pkt )];
/* Probe streams to build PAT/PMT after MIN_PAT_INTERVAL in case we don't see any PAT */
- if( !p_sys->pid[0].b_seen &&
+ if( !SEEN(p_sys->pid[0]) &&
(p_pid->probed.i_type == 0 || p_pid->i_pid == p_sys->patfix.i_timesourcepid) &&
(p_pkt->p_buffer[1] & 0xC0) == 0x40 && /* Payload start but not corrupt */
(p_pkt->p_buffer[3] & 0xD0) == 0x10 ) /* Has payload but is not encrypted */
break;
default:
- if( !p_pid->b_seen )
+ if( !SEEN(*p_pid) )
msg_Dbg( p_demux, "pid[%d] unknown", p_pid->i_pid );
/* We have to handle PCR if present */
break;
}
- p_pid->b_seen = true;
+ p_pid->i_flags |= FLAG_SEEN;
if( b_frame || ( b_wait_es && p_sys->i_pmt_es > 0 ) )
break;
{
assert(pid->i_refcount == 0);
pid->i_cc = 0xff;
- pid->b_scrambled = false;
+ pid->i_flags &= ~FLAG_SCRAMBLED;
pid->p_parent = NULL;
pid->type = TYPE_FREE;
}
pid->type = i_type;
pid->p_parent = p_parent;
}
- else if( pid->type == i_type )
+ else if( pid->type == i_type && pid->i_refcount < UINT8_MAX )
{
pid->i_refcount++;
}
return;
}
- if( pid->b_scrambled || header[0] != 0 || header[1] != 0 || header[2] != 1 )
+ if( SCRAMBLED(*pid) || header[0] != 0 || header[1] != 0 || header[2] != 1 )
{
- if ( !pid->b_scrambled )
+ if ( !SCRAMBLED(*pid) )
msg_Warn( p_demux, "invalid header [0x%02x:%02x:%02x:%02x] (pid: %d)",
header[0], header[1],header[2],header[3], pid->i_pid );
block_ChainRelease( p_pes );
}
int i_pid = PIDGet( p_pkt );
- p_sys->pid[i_pid].b_seen = true;
+ p_sys->pid[i_pid].i_flags = FLAG_SEEN;
if( i_pid != 0x1FFF && p_sys->pid[i_pid].type == TYPE_PES &&
(p_pkt->p_buffer[1] & 0xC0) == 0x40 && /* Payload start but not corrupt */
for( int i=0; i<p_pmt->e_streams.i_size; i++ )
{
ts_pid_t *p_pid = p_pmt->e_streams.p_elems[i];
- if( p_pid->b_seen &&
+ if( SEEN(*p_pid) &&
(!p_cand || p_cand->i_pid != i_previous) )
{
if( p_pid->probed.i_pcr_count ) /* check PCR frequency first */
}
/* */
- if( !pid->b_scrambled != !b_scrambled )
+ if( !SCRAMBLED(*pid) != !b_scrambled )
{
msg_Warn( p_demux, "scrambled state changed on pid %d (%d->%d)",
- pid->i_pid, pid->b_scrambled, b_scrambled );
+ pid->i_pid, SCRAMBLED(*pid), b_scrambled );
- pid->b_scrambled = b_scrambled;
+ pid->i_flags |= (b_scrambled) ? FLAG_SCRAMBLED : FLAGS_NONE;
for( int i = 0; i < pid->u.p_pes->extra_es.i_size; i++ )
{
if( pid )
{
- if( pid->b_seen && p_sys->es_creation == DELAY_ES )
+ if( SEEN(*pid) && p_sys->es_creation == DELAY_ES )
{
p_sys->es_creation = CREATE_ES;
b_create_delayed = true;
return;
}
- pmtpid->b_seen = true;
+ pmtpid->i_flags |= FLAG_SEEN;
if( p_pmt->i_version != -1 &&
( !p_dvbpsipmt->b_current_next || p_pmt->i_version == p_dvbpsipmt->i_version ) )
PIDFillFormat( &p_pes->es.fmt, p_dvbpsies->i_type );
- pespid->b_seen = p_sys->pid[p_dvbpsies->i_pid].b_seen;
+ pespid->i_flags |= SEEN(p_sys->pid[p_dvbpsies->i_pid]);
bool b_registration_applied = false;
if ( p_dvbpsies->i_type >= 0x80 ) /* non standard, extensions */
ts_pid_t *patpid = &p_sys->pid[0];
ts_pat_t *p_pat = p_sys->pid[0].u.p_pat;
- patpid->b_seen = true;
+ patpid->i_flags |= FLAG_SEEN;
msg_Dbg( p_demux, "PATCallBack called" );