예제 #1
0
파일: MetaData.cs 프로젝트: haibocheng/Sky
 private MetaArray ReadStrictArray(BinaryReader br)
 {
     var len = br.ReadBytes(4).ToUInt32(false);
     offset += 4;
     var array = new MetaArray();
     for (uint i = 0; i < len; i++)
     {
         array.Add(ReadElement(br));
     }
     return array;
 }
예제 #2
0
파일: FlvDealer.cs 프로젝트: haibocheng/Sky
        private MetaObject GetSegments(MetaArray filepositions, MetaArray times)
        {
            var timeLine = 0d;
            var segments = new MetaObject();

            segments["extension"] = ".dat";
            var positions = new MetaArray();
            var files = new MetaArray();

            if (filepositions.Length != times.Length)
            {
                throw new InvalidDataException("keyframes data is invalid");
            }

            for (int i = 0, len = times.Length; i < len; i++)
            {
                var time = Convert.ToDouble(times[i]);
                if (time - timeLine >= INTERNAL)
                {
                    positions.Add(Convert.ToDouble(filepositions[i]));
                    files.Add(positions.Length.ToString());
                    timeLine = time;
                }
            }

            positions.Add(Convert.ToDouble(this.endPosition));
            files.Add(positions.Length.ToString());

            segments["positions"] = positions;
            segments["files"] = files;
            return segments;
        }
예제 #3
0
파일: FlvDealer.cs 프로젝트: haibocheng/Sky
 private uint WriteStrictArray(Stream st, MetaArray content)
 {
     var count = (uint)content.Length;
     var byts = BitConverter.GetBytes(count).Reverse().ToArray();
     st.Write(byts, 0, byts.Length);
     var total = 4u;
     for (int i = 0; i < count; i++)
     {
         total += WriteElement(st, content[i]);
     }
     return total;
 }
예제 #4
0
파일: FlvDealer.cs 프로젝트: haibocheng/Sky
        private MetaObject GetKeyFrames(MetaObject obj)
        {
            var vTags = info.Body.Tags.Where(t => t.TagType == TagType.Video && ((t as VideoTag).Data as VideoData).Type == FrameType.KeyFrame);
            this.startPosition = info.Body.Tags[0].Start + info.Body.Tags[0].Size + 4;
            //this.endPosition = info.Body.Tags.Last().Start + info.Body.Tags.Last().Size + 4;
            this.endPosition = info.Body.Start + info.Body.Size;

            if (obj.Contains("keyframes"))
            {
                hasKeyFrames = true;
                return obj["keyframes"] as MetaObject;
            }

            hasKeyFrames = false;
            var filepositions = new MetaArray();
            var times = new MetaArray();
            foreach (var tag in vTags)
            {
                filepositions.Add(Convert.ToDouble(tag.Start));
                times.Add(tag.Header.Timestamp / 1000d);
            }
            var keyFrames = new MetaObject();
            keyFrames["filepositions"] = filepositions;
            keyFrames["times"] = times;
            return keyFrames;
        }