internal static void UpdateDVBChannelPids(IMpeg2Data mpeg2Data, ushort pmtPid, ChannelDVB channelDVB)
{
Hashtable hashtableEcmPids = new Hashtable();
channelDVB.PmtPid = pmtPid;
PSISection[] psiPmts = PSISection.GetPSITable(pmtPid, (int)TABLE_IDS.PMT, mpeg2Data);
for (int i2 = 0; i2 < psiPmts.Length; i2++)
{
PSISection psiPmt = psiPmts[i2];
if (psiPmt != null && psiPmt is PSIPMT)
{
PSIPMT pmt = (PSIPMT)psiPmt;
channelDVB.PcrPid = pmt.PcrPid;
if (pmt.Descriptors != null)
{
foreach (PSIDescriptor descriptor in pmt.Descriptors)
{
switch (descriptor.DescriptorTag)
{
case DESCRIPTOR_TAGS.DESCR_CA:
hashtableEcmPids[(descriptor as PSIDescriptorCA).CaPid] = (descriptor as PSIDescriptorCA).CaSystemId;
break;
}
}
}
channelDVB.VideoPid = -1;
channelDVB.AudioPid = -1;
channelDVB.AudioPids = new int[0];
channelDVB.EcmPids = new int[0];
foreach (PSIPMT.Data data in pmt.Streams)
{
switch ((int)data.StreamType)
{
case (int)STREAM_TYPES.STREAMTYPE_11172_VIDEO:
case (int)STREAM_TYPES.STREAMTYPE_13818_VIDEO:
//channelDVB.VideoDecoderType = ChannelDVB.VideoType.MPEG2;
channelDVB.VideoPid = data.Pid;
if (data.Descriptors != null)
{
foreach (PSIDescriptor descriptor in data.Descriptors)
if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_CA)
hashtableEcmPids[(descriptor as PSIDescriptorCA).CaPid] = (descriptor as PSIDescriptorCA).CaSystemId;
}
break;
case 27: //H264
channelDVB.VideoDecoderType = ChannelDVB.VideoType.H264;
channelDVB.VideoPid = data.Pid;
if (data.Descriptors != null)
{
foreach (PSIDescriptor descriptor in data.Descriptors)
if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_CA)
hashtableEcmPids[(descriptor as PSIDescriptorCA).CaPid] = (descriptor as PSIDescriptorCA).CaSystemId;
}
break;
case (int)STREAM_TYPES.STREAMTYPE_11172_AUDIO:
case (int)STREAM_TYPES.STREAMTYPE_13818_AUDIO:
{
int[] audioPids = new int[channelDVB.AudioPids.Length + 1];
Array.Copy(channelDVB.AudioPids, audioPids, channelDVB.AudioPids.Length);
audioPids[channelDVB.AudioPids.Length] = data.Pid;
channelDVB.AudioPids = audioPids;
if (audioPids.Length == 1) // If it is the first one
{
channelDVB.AudioPid = data.Pid;
channelDVB.AudioDecoderType = ChannelDVB.AudioType.MPEG2;
}
foreach (PSIDescriptor descriptor in data.Descriptors)
if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_CA)
hashtableEcmPids[(descriptor as PSIDescriptorCA).CaPid] = (descriptor as PSIDescriptorCA).CaSystemId;
}
break;
case (int)STREAM_TYPES.STREAMTYPE_13818_PES_PRIVATE:
if (data.Descriptors != null)
{
foreach (PSIDescriptor descriptor in data.Descriptors)
{
if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_TELETEXT)
{
channelDVB.TeletextPid = data.Pid;
}
else if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_AC3 || descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_ENHANCED_AC3)
{
//Audio again
int[] audioPids = new int[channelDVB.AudioPids.Length + 1];
Array.Copy(channelDVB.AudioPids, audioPids, channelDVB.AudioPids.Length);
audioPids[channelDVB.AudioPids.Length] = data.Pid;
channelDVB.AudioPids = audioPids;
if (audioPids.Length == 1) // If it is the first one
{
channelDVB.AudioPid = data.Pid;
if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_AC3)
channelDVB.AudioDecoderType = ChannelDVB.AudioType.AC3;
if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_ENHANCED_AC3)
channelDVB.AudioDecoderType = ChannelDVB.AudioType.EAC3;
}
}
else if (descriptor.DescriptorTag == DESCRIPTOR_TAGS.DESCR_ISO_639_LANGUAGE)
{
}
}
}
break;
}
}
}
}
channelDVB.EcmPids = new int[hashtableEcmPids.Count];
hashtableEcmPids.Keys.CopyTo(channelDVB.EcmPids, 0);
if (channelDVB.EcmPids.Length > 0)
channelDVB.EcmPid = channelDVB.EcmPids[0];
}