コード例 #1
0
ファイル: TSEncoder.cs プロジェクト: ymd1223/JT1078
 public byte[] CreatePAT(JT1078Package jt1078Package, int minBufferSize = 188)
 {
     byte[] buffer = TSArrayPool.Rent(minBufferSize);
     try
     {
         TS_PAT_Package package = new TS_PAT_Package();
         package.Header = new TS_Header();
         package.Header.ContinuityCounter         = 0;
         package.Header.AdaptationFieldControl    = AdaptationFieldControl.无自适应域_仅含有效负载;
         package.Header.PayloadUnitStartIndicator = 1;
         package.Header.PID = 0;
         package.Programs   = new List <TS_PAT_Program>();
         package.Programs.Add(new TS_PAT_Program()
         {
             ProgramNumber = 0x0001,
             PID           = 0x1000,
         });
         TSMessagePackWriter messagePackReader = new TSMessagePackWriter(buffer);
         package.ToBuffer(ref messagePackReader);
         return(messagePackReader.FlushAndGetArray());
     }
     finally
     {
         TSArrayPool.Return(buffer);
     }
 }
コード例 #2
0
ファイル: TSEncoder.cs プロジェクト: ewsq/JT1078
 //private ConcurrentDictionary<string, byte> AudioCounter = new ConcurrentDictionary<string, byte>();
 public byte[] CreatePAT(JT1078Package jt1078Package, int minBufferSize = 188)
 {
     byte[] buffer = TSArrayPool.Rent(minBufferSize);
     try
     {
         TS_PAT_Package package = new TS_PAT_Package();
         package.Header = new TS_Header();
         package.Header.ContinuityCounter = PATCounter.AddOrUpdate(jt1078Package.GetKey(), 0, (a, b) =>
         {
             if (b > 0xf)
             {
                 return(0);
             }
             else
             {
                 return((byte)(b + 1));
             }
         });
         package.Header.AdaptationFieldControl    = AdaptationFieldControl.无自适应域_仅含有效负载;
         package.Header.PayloadUnitStartIndicator = 1;
         package.Header.PID = 0;
         TSMessagePackWriter messagePackReader = new TSMessagePackWriter(buffer);
         package.ToBuffer(ref messagePackReader);
         return(messagePackReader.FlushAndGetArray());
     }
     finally
     {
         TSArrayPool.Return(buffer);
     }
 }