コード例 #1
0
        public static void OnPacketFound(RtmpPacketInterop obj)
        {
            AmfContainer deserializedOutput = null;

//
//            var x = "new byte[]{";
//            foreach(var b in obj.GetBytes())
//            {
//                x += b.ToString("x2") + ",";
//            }
//            x += "};";

            using (var newStream = new MemoryStream(obj.GetBytes()))
            {
                var streamCopy = PruneStreamChunkDelimiters(newStream, obj);

                Console.WriteLine("Found packet {2} from {0} length {1}", obj.GetSourceIP(), obj.GetLength(),
                                  obj.GetRtmpPacketType());


                deserializedOutput = AMFSerializerUtil <AmfContainer> .DeserializeAmf(streamCopy);
            }

            Visualize(deserializedOutput, 0);
        }
コード例 #2
0
        private static void Visualize(AmfContainer container, int count)
        {
            if (container == null)
            {
                return;
            }

            var tabs = Enumerable.Range(0, count).Select(i => "\t").FoldToDelimitedList(i => i, "");

            Console.WriteLine("{0}{1}: {2}", tabs, container.Name, container.Value);

            if (CollectionUtil.IsNullOrEmpty(container.Values))
            {
                return;
            }

            foreach (var value in container.Values)
            {
                Visualize(value, ++count);
            }
        }
コード例 #3
0
        public static AmfContainer DeserializeAmf(MemoryStream stream)
        {
            try
            {
                using (var deserializer = new AMFReader(stream))
                {
                    var method    = deserializer.ReadData();
                    var requestId = deserializer.ReadData();
                    var nullVal   = deserializer.ReadData();

                    Object obj = "na";

                    try
                    {
                        var container = new AmfContainer();
                        obj = deserializer.ReadData();

                        container.Name   = Convert.ToString(method);
                        container.Values = new List <AmfContainer> {
                            new AmfContainer
                            {
                                Value = obj
                            }
                        };

                        return(container);
                    }
                    catch (Exception ex)
                    {
                    }

                    Console.WriteLine("{0}: {1}", method, obj);
                }
            }
            catch
            {
            }
            return(null);
        }