Example #1
0
        public void ParseSegments()
        {
            if (SubtitleSegments != null)
            {
                return;
            }

            SubtitleSegments   = new List <SubtitleSegment>();
            ClutDefinitions    = new List <ClutDefinitionSegment>();
            RegionCompositions = new List <RegionCompositionSegment>();
            PageCompositions   = new List <PageCompositionSegment>();
            ObjectDataList     = new List <ObjectDataSegment>();

            int index = 2;
            var ss    = new SubtitleSegment(_dataBuffer, index);

            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < _dataBuffer.Length)
                {
                    ss = new SubtitleSegment(_dataBuffer, index);
                }
                else
                {
                    ss.SyncByte = Helper.B11111111;
                }
            }
        }
Example #2
0
        public void ParseSegments()
        {
            if (SubtitleSegments != null)
                return;

            SubtitleSegments = new List<SubtitleSegment>();
            ClutDefinitions = new List<ClutDefinitionSegment>();
            RegionCompositions = new List<RegionCompositionSegment>();
            PageCompositions = new List<PageCompositionSegment>();
            ObjectDataList = new List<ObjectDataSegment>();

            int index = 2;
            var ss = new SubtitleSegment(_dataBuffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < _dataBuffer.Length)
                    ss = new SubtitleSegment(_dataBuffer, index);
                else
                    ss.SyncByte = Helper.B11111111;
            }
        }
Example #3
0
        public DvbSubPes(int index, byte[] buffer)
        {
            int start = index;

            Length = index + 1;

            if (index + 9 >= buffer.Length)
            {
                return;
            }

            if (buffer[0 + index] != 0x20)
            {
                return;
            }

            if (buffer[1 + index] != 0)
            {
                return;
            }

            SubtitleSegments   = new List <SubtitleSegment>();
            ClutDefinitions    = new List <ClutDefinitionSegment>();
            RegionCompositions = new List <RegionCompositionSegment>();
            PageCompositions   = new List <PageCompositionSegment>();
            ObjectDataList     = new List <ObjectDataSegment>();

            // Find length of segments
            index = start + 2;
            var ss = new SubtitleSegment(buffer, index);

            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                index += 6 + ss.SegmentLength;
                if (index + 6 < buffer.Length)
                {
                    ss = new SubtitleSegment(buffer, index);
                }
                else
                {
                    ss.SyncByte = Helper.B11111111;
                }
            }
            Length = index;
            int size = index - start;

            _dataBuffer = new byte[size];
            Buffer.BlockCopy(buffer, start, _dataBuffer, 0, _dataBuffer.Length);

            // Parse segments
            index = 2;
            ss    = new SubtitleSegment(_dataBuffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < _dataBuffer.Length)
                {
                    ss = new SubtitleSegment(_dataBuffer, index);
                }
                else
                {
                    ss.SyncByte = Helper.B11111111;
                }
            }
        }
Example #4
0
        public DvbSubPes(int index, byte[] buffer)
        {
            int start = index;
            Length = index + 1;

            if (index + 9 >= buffer.Length)
                return;

            if (buffer[0 + index] != 0x20)
                return;

            if (buffer[1 + index] != 0)
                return;

            SubtitleSegments = new List<SubtitleSegment>();
            ClutDefinitions = new List<ClutDefinitionSegment>();
            RegionCompositions = new List<RegionCompositionSegment>();
            PageCompositions = new List<PageCompositionSegment>();
            ObjectDataList = new List<ObjectDataSegment>();

            // Find length of segments
            index = start + 2;
            var ss = new SubtitleSegment(buffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                index += 6 + ss.SegmentLength;
                if (index + 6 < buffer.Length)
                    ss = new SubtitleSegment(buffer, index);
                else
                    ss.SyncByte = Helper.B11111111;
            }
            Length = index;
            int size = index - start;
            _dataBuffer = new byte[size];
            Buffer.BlockCopy(buffer, start, _dataBuffer, 0, _dataBuffer.Length);

            // Parse segments
            index = 2;
            ss = new SubtitleSegment(_dataBuffer, index);
            while (ss.SyncByte == Helper.B00001111)
            {
                SubtitleSegments.Add(ss);
                if (ss.ClutDefinition != null)
                {
                    ClutDefinitions.Add(ss.ClutDefinition);
                }
                else if (ss.RegionComposition != null)
                {
                    RegionCompositions.Add(ss.RegionComposition);
                }
                else if (ss.PageComposition != null)
                {
                    PageCompositions.Add(ss.PageComposition);
                }
                else if (ss.ObjectData != null)
                {
                    ObjectDataList.Add(ss.ObjectData);
                }

                index += 6 + ss.SegmentLength;
                if (index + 6 < _dataBuffer.Length)
                    ss = new SubtitleSegment(_dataBuffer, index);
                else
                    ss.SyncByte = Helper.B11111111;
            }
        }