Beispiel #1
0
        internal void CreateSegmentPES(ref TSMessagePackWriter writer, byte[] nalu, byte counter)
        {
            TS_Segment_Package package = new TS_Segment_Package();

            package.Header     = new TS_Header();
            package.Header.PID = 256;
            package.Header.ContinuityCounter         = counter;
            package.Header.PayloadUnitStartIndicator = 0;
            package.Payload = nalu;
            //这个很重要,需要控制
            //package.Header.AdaptationFieldControl= AdaptationFieldControl.同时带有自适应域和有效负载
            //这个很重要,填充大小
            //package.Header.Adaptation.FillSize
            if (nalu.Length < FiexdSegmentPESLength)
            {
                package.Header.Adaptation             = new TS_AdaptationInfo();
                package.Header.Adaptation.PCRIncluded = PCRInclude.包含;
                package.Header.Adaptation.FillSize    = (byte)(FiexdSegmentPESLength - nalu.Length);
                package.Header.AdaptationFieldControl = AdaptationFieldControl.时带有自适应域和有效负载;
            }
            else
            {
                package.Header.AdaptationFieldControl = AdaptationFieldControl.无自适应域_仅含有效负载;
            }
            package.Payload = nalu;
            package.ToBuffer(ref writer);
        }
Beispiel #2
0
        internal void CreateSegmentPES(ref TSMessagePackWriter writer, byte[] nalu, byte counter)
        {
            TS_Segment_Package package = new TS_Segment_Package();

            package.Header     = new TS_Header();
            package.Header.PID = 256;
            package.Header.ContinuityCounter         = counter;
            package.Header.PayloadUnitStartIndicator = 0;
            package.Payload = nalu;
            //这个很重要,需要控制
            //package.Header.AdaptationFieldControl= AdaptationFieldControl.同时带有自适应域和有效负载
            //这个很重要,填充大小
            //package.Header.Adaptation.FillSize
            //AdaptationLengthPosition + PCRIncluded
            //1 + 1
            if (nalu.Length < (FiexdSegmentPESLength))
            {
                int size = FiexdSegmentPESLength - 1 - 1 - nalu.Length;
                package.Header.PackageType = PackageType.Data_End;
                if (size < 0)
                {
                    // nalu剩余183字节的时候
                    // 头部4个字节 + 自适应域长度1字节(0)+183 =188
                    package.Header.AdaptationFieldControl = AdaptationFieldControl.仅含自适应域_无有效负载;
                }
                else
                {
                    package.Header.Adaptation             = new TS_AdaptationInfo();
                    package.Header.Adaptation.PCRIncluded = PCRInclude.包含;
                    package.Header.Adaptation.FillSize    = (byte)(size);
                    package.Header.AdaptationFieldControl = AdaptationFieldControl.时带有自适应域和有效负载;
                }
            }
            else
            {
                package.Header.PackageType            = PackageType.Data_Segment;
                package.Header.AdaptationFieldControl = AdaptationFieldControl.无自适应域_仅含有效负载;
            }
            package.Payload = nalu;
            package.ToBuffer(ref writer);
        }