Exemple #1
0
        public override int Read(byte[] Data, int Offset)
        {
            if (Data == null || Data.Length == 0)
            {
                return(-1);
            }
            int offset = Offset;

            StreamIndex = Data[offset++];
            if (offset >= Data.Length)
            {
                return(-1);
            }
            CodecId = Data[offset++];
            if (Data.Length - offset < 0xA)
            {
                return(-1);
            }
            FpsRate      = IOUtil.ReadU16BE(Data, offset);
            FpsScale     = IOUtil.ReadU16BE(Data, offset + 2);
            Width        = IOUtil.ReadU16BE(Data, offset + 4);
            Height       = IOUtil.ReadU16BE(Data, offset + 6);
            PelRatioRate = Data[offset + 8];
            PelRatioRate = Data[offset + 9];
            offset      += 0xA;
            if (offset >= Data.Length)
            {
                return(-1);
            }
            ImageLayout   = (VideoLayout)(Data[offset] & 0xF);
            ImageRotation = (uint)(Data[offset] >> 4);
            offset++;
            return(offset);
        }
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (AudioSources != null)
            {
                p.AddRange(AudioSources.Select(prop => new KeyValuePair <string, string>("AudioSources", prop.ToString())));
            }

            if (VideoSources != null)
            {
                p.AddRange(VideoSources.Select(prop => new KeyValuePair <string, string>("VideoSources", prop.ToString())));
            }

            if (VideoLayout != null)
            {
                p.Add(new KeyValuePair <string, string>("VideoLayout", VideoLayout.ToString()));
            }

            if (Resolution != null)
            {
                p.Add(new KeyValuePair <string, string>("Resolution", Resolution));
            }

            if (Format != null)
            {
                p.Add(new KeyValuePair <string, string>("Format", Format.ToString()));
            }

            if (DesiredBitrate != null)
            {
                p.Add(new KeyValuePair <string, string>("DesiredBitrate", DesiredBitrate.Value.ToString()));
            }

            if (DesiredMaxDuration != null)
            {
                p.Add(new KeyValuePair <string, string>("DesiredMaxDuration", DesiredMaxDuration.Value.ToString()));
            }

            if (StatusCallback != null)
            {
                p.Add(new KeyValuePair <string, string>("StatusCallback", Serializers.Url(StatusCallback)));
            }

            if (StatusCallbackMethod != null)
            {
                p.Add(new KeyValuePair <string, string>("StatusCallbackMethod", StatusCallbackMethod.ToString()));
            }

            return(p);
        }
        public void TestAddTpl()
        {
            var param = new Dictionary <string, string>
            {
                [Const.Sign] = "【企盆阔记】"
            };

            var vl = new VideoLayout {
                Subject = "restapi-" + new DateTime().Millisecond, VlVersion = "0.0.1"
            };

            var frame1 = new VideoFrame {
                Index = 1
            };
            var data1 = new FrameData
            {
                Index    = 1,
                FileName = "data1.txt"
            };
            var data2 = new FrameData
            {
                Index    = 2,
                FileName = "data2.mp4"
            };

            frame1.Attachments = new List <FrameData> {
                data1, data2
            };

            vl.Frames = new List <VideoFrame> {
                frame1
            };

            var fs       = new FileStream("/Users/dzh/temp/vsms/Archive.zip", FileMode.Open);
            var material = new byte[fs.Length];

            fs.Read(material, 0, material.Length);
            fs.Close();

            var layout = vl.ToString();

            Console.WriteLine(layout);
            var r = Clnt.VideoSms().AddTpl(param, layout, material);

            Console.WriteLine(r);
            Console.WriteLine(r.E);
        }
 public override int Read(byte[] Data, int Offset)
 {
     if (Data == null || Data.Length == 0) return -1;
     int offset = Offset;
     StreamIndex = Data[offset++];
     if (offset >= Data.Length) return -1;
     CodecId = Data[offset++];
     if (Data.Length - offset < 0xA) return -1;
     FpsRate = IOUtil.ReadU16BE(Data, offset);
     FpsScale = IOUtil.ReadU16BE(Data, offset + 2);
     Width = IOUtil.ReadU16BE(Data, offset + 4);
     Height = IOUtil.ReadU16BE(Data, offset + 6);
     PelRatioRate = Data[offset + 8];
     PelRatioRate = Data[offset + 9];
     offset += 0xA;
     if (offset >= Data.Length) return -1;
     ImageLayout = (VideoLayout)(Data[offset] & 0xF);
     ImageRotation = (uint)(Data[offset] >> 4);
     offset++;
     return offset;
 }