/// <summary> /// Append the binary formatted descriptor to the buffer provided. /// </summary> /// <param name="buffer">Some buffer.</param> internal void CreateDescriptor(TableConstructor buffer) { // Write the tag buffer.Add((byte)Tag); // Position of length int lengthPos = buffer.CreateDynamicLength(); // Add payload CreatePayload(buffer); // Update the length buffer.SetDynamicLength(lengthPos); }
/// <summary> /// Create a PMT for the program. /// </summary> /// <remarks> /// There will be a lot of randomly choosen values just to make the transport /// stream valid. Each audio stream will be reported as <i>german</i> and /// similiar defaults are attached to a teletext stream. /// </remarks> /// <returns>The table describing the related program.</returns> protected override byte[] CreateTable() { // Create buffer TableConstructor buffer = new TableConstructor(); // Append to buffer buffer.Add( (byte) (0xe0 | (PCRPID / 256)) ); buffer.Add( (byte) (PCRPID & 0xff) ); buffer.Add( 0xf0, 0x00 ); // All entries for (int ip = 0; ip < m_Streams.Count; ) { // Load short pid = m_Streams[ip++]; StreamTypes type = m_Type[pid]; // Is teletext or audio bool ttx = (StreamTypes.TeleText == type); bool sub = !ttx && (StreamTypes.SubTitles == type); bool ac3 = !ttx && !sub && (StreamTypes.Private == type); bool aud = ac3 || (!ttx && !sub && (StreamTypes.Audio == type)); // Append to buffer buffer.Add( (ttx || sub) ? (byte) StreamTypes.Private : m_Encoding[pid] ); buffer.Add( (byte) (0xe0 | (pid / 256)) ); buffer.Add( (byte) (pid & 0xff) ); buffer.Add( 0xf0 ); // Length int lengthPos = buffer.CreateDynamicLength(); // Create stream identifier buffer.Add( new StreamIdentifier( (byte) ip ) ); // Check for additional data if (ttx) { // Create teletext descriptor buffer.Add( new Teletext() ); } else if (sub) { // Load descriptor list SubtitleInfo[] subInfos = DVBSubtitles[pid]; // Create the descriptor Subtitle subDescr = new Subtitle(); // Check mode if ((null == subInfos) || (subInfos.Length < 1)) { // Create a brand new pseudo entry subDescr.Subtitles.Add( new SubtitleInfo( "deu", EPG.SubtitleTypes.DVBNormal, 1, 1 ) ); } else { // Use as is subDescr.Subtitles.AddRange( subInfos ); } // Serialize to buffer buffer.Add( subDescr ); } else if (aud) { // Load language string language; if (!m_AudioNames.TryGetValue( pid, out language )) language = "deu"; // Create language descriptor ISOLanguage audioDescriptor = new ISOLanguage(); // Append language item audioDescriptor.Languages.Add( new LanguageItem( language, ac3 ? EPG.AudioTypes.Undefined : EPG.AudioTypes.CleanEffects ) ); // Append to buffer buffer.Add( audioDescriptor ); // Fill AC3 descriptor if (ac3) buffer.Add( new AC3() ); } // Finish buffer.SetDynamicLength( lengthPos ); } // Report return buffer.ToArray(); }