Beispiel #1
0
        public void Load(FlvTag scriptTag)
        {
            var value       = scriptTag.ScriptData.Values[1].Value;
            var hasKeyFrame = (value as ScriptObject)["hasKeyframes"];

            if (hasKeyFrame != null && hasKeyFrame.ToString() == "1")
            {
                var keyframes     = (value as ScriptObject)["keyframes"];
                var times         = (keyframes as ScriptObject)["times"] as ScriptArray;
                var filepositions = (keyframes as ScriptObject)["filepositions"] as ScriptArray;

                if (times.Values.Count == filepositions.Values.Count)
                {
                    for (int i = 0; i < times.Values.Count; i++)
                    {
                        var timeCode = TimeSpan.FromSeconds((double)times.Values[i]).Ticks;
                        var offset   = (long)(double)filepositions.Values[i];
                        //설정
                        this[timeCode] = offset;
                    }

                    IsScriptLoad = true;
                }
            }
        }
Beispiel #2
0
        public void Load(TagType type)
        {
            FlvTag  ft       = null;
            TagType loadType = TagType.None;

            do
            {
                ft = new FlvTag(this.Stream, ref offset);
                if (ft.TagType == TagType.Video)
                {
                    if (ft.VideoData.CodecID != CodecID.AVC || ft.VideoData.AVCVideoPacket.AVCPacketType != AVCPacketType.AVCSequenceHeader)
                    {
                        videoTagQueue.Enqueue(ft);
                        loadType = ft.TagType;
                        //seek 데이터 추가
                        SeekData.Add(ft);
                    }
                }
                else if (ft.TagType == TagType.Audio)
                {
                    if (ft.AudioData.SoundFormat != SoundFormat.AAC ||
                        (ft.AudioData.SoundData as AACAudioData).AACPacketType != AACPacketType.AACSequenceHeader)
                    {
                        audioTagQueue.Enqueue(ft);
                        loadType = ft.TagType;
                    }
                }
            } while (loadType != type);
            //System.Diagnostics.Debug.WriteLine("a : {0} , v : {1}", audioTagQueue.Count, videoTagQueue.Count);
        }
Beispiel #3
0
 public void Add(FlvTag videoTag)
 {
     if (videoTag.VideoData.FrameType == FrameType.Keyframe && !IsScriptLoad)
     {
         AddTag(videoTag.Timestamp, videoTag.Offset - 16);
     }
 }
Beispiel #4
0
        public FlvFileBody(Stream stream, ref long offset)
        {
            //uint previousTagSize = stream.ReadUInt32(ref offset);
            offset      = stream.Position += 4;
            this.Stream = stream;
            SeekData    = new FlvSeekData();

            do
            {
                FlvTag ft = new FlvTag(stream, ref offset);
                if (ft.TagType == TagType.Video)
                {
                    if (ft.VideoData.CodecID == CodecID.AVC)
                    {
                        //H264 코덱
                        if (ft.VideoData.AVCVideoPacket.AVCPacketType == AVCPacketType.AVCSequenceHeader)
                        {
                            videoInfoTag = ft;
                        }
                        else
                        {
                            videoTagQueue.Enqueue(ft);
                            //seek 데이터 추가
                            SeekData.Add(ft);
                        }
                    }
                    else
                    {
                        //가상 infoTag
                        videoInfoTag = ft;
                        videoTagQueue.Enqueue(ft);
                        //seek 데이터 추가
                        SeekData.Add(ft);
                    }
                }
                else if (ft.TagType == TagType.Audio)
                {
                    if (ft.AudioData.SoundFormat == SoundFormat.AAC)
                    {
                        if ((ft.AudioData.SoundData as AACAudioData).AACPacketType == AACPacketType.AACSequenceHeader)
                        {
                            audioInfoflvTag = ft;
                        }
                        else
                        {
                            audioTagQueue.Enqueue(ft);
                        }
                    }
                    else
                    {
                        //가상 infotag
                        audioInfoflvTag = ft;
                        //실제 데이터
                        audioTagQueue.Enqueue(ft);
                    }
                }
                else
                {
                    scriptTageList.Add(ft);
                    SeekData.Load(ft);
                }
            } while (scriptTageList.Count == 0 ||
                     audioTagQueue.Count == 0 ||
                     videoTagQueue.Count == 0);

            this.offset = offset;
        }