public dynamic readObject() { PlayScript.Profiler.Begin("amf-parse"); Amf3Parser amfparser = new Amf3Parser(mData, 0, mLength); object obj = amfparser.ReadNextObject(); PlayScript.Profiler.End("amf-parse"); return(obj); }
public static void Parse(Stream stream, TextWriter output) { Amf3Parser parser = new Amf3Parser(stream); parser.OverrideSerializer = new Amf3Object.Serializer(); int time = 0; int enterTime = 0; while (stream.Position < stream.Length) { Variant v = new Variant(); parser.ReadNextObject(ref v); if (!v.IsDefined) { break; } var amfObj = v.AsObject() as Amf3Object; if (amfObj == null) { break; } output.Write("{0:D8}: ", time); switch (amfObj.ClassDef.Name) { case ".value": { output.WriteLine("WriteValue({0}, {1});", Format(amfObj["name"]), Format(amfObj["value"]) ); break; } case ".span": { time += amfObj["delta"].AsInt(); output.WriteLine("WriteSpan({0}, {1}, {2});", Format(amfObj["name"]), amfObj["span"], amfObj["delta"] ); // handle end of frame string name = amfObj["name"].AsString(); if (name == ".exit") { int span = amfObj["span"].AsInt(); int deltas = time - enterTime; output.WriteLine("// frame deltas:{0} span:{1} diff:{2}", deltas, span, deltas - span); } break; } case ".spanValue": { time += amfObj["delta"].AsInt(); output.WriteLine("WriteSpanValue({0}, {1}, {2}, {3});", Format(amfObj["name"]), amfObj["span"], amfObj["delta"], Format(amfObj["value"]) ); break; } case ".time": { time += amfObj["delta"].AsInt(); output.WriteLine("WriteTime({0}, {1});", Format(amfObj["name"]), amfObj["delta"] ); // handle start of frame string name = amfObj["name"].AsString(); if (name == ".enter") { enterTime = time; } } break; default: output.WriteLine(Format(v)); break; } } }
public static void Parse(Stream stream, TextWriter output) { Amf3Parser parser = new Amf3Parser(stream); int time = 0; int enterTime = 0; while (stream.Position < stream.Length) { var o = parser.ReadNextObject(); if (o == null) { break; } var amfObj = (Amf3Object)o; switch (amfObj.ClassDef.Name) { case ".value": { output.WriteLine("WriteValue({0}, {1});", Format(amfObj.Properties["name"]), Format(amfObj.Properties["value"]) ); break; } case ".span": { time += (int)amfObj.Properties["delta"]; output.WriteLine("WriteSpan({0}, {1}, {2});", Format(amfObj.Properties["name"]), amfObj.Properties["span"], amfObj.Properties["delta"] ); // handle end of frame string name = (string)amfObj.Properties["name"]; if (name == ".exit") { int span = (int)amfObj.Properties["span"]; int deltas = time - enterTime; output.WriteLine("// frame deltas:{0} span:{1} diff:{2}", deltas, span, deltas - span); } break; } case ".spanValue": { time += (int)amfObj.Properties["delta"]; output.WriteLine("WriteSpanValue({0}, {1}, {2}, {3});", Format(amfObj.Properties["name"]), amfObj.Properties["span"], amfObj.Properties["delta"], Format(amfObj.Properties["value"]) ); break; } case ".time": { time += (int)amfObj.Properties["delta"]; output.WriteLine("WriteTime({0}, {1});", Format(amfObj.Properties["name"]), amfObj.Properties["delta"] ); // handle start of frame string name = (string)amfObj.Properties["name"]; if (name == ".enter") { enterTime = time; } } break; default: output.WriteLine(Format(o)); break; } } }
public static void Parse(Stream stream, TextWriter output) { Amf3Parser parser = new Amf3Parser(stream); int time = 0; int enterTime = 0; while (stream.Position < stream.Length ) { var o = parser.ReadNextObject(); if (o == null) break; var amfObj = (Amf3Object)o; switch (amfObj.ClassDef.Name) { case ".value": { output.WriteLine("WriteValue({0}, {1});", Format(amfObj.Properties["name"]), Format(amfObj.Properties["value"]) ); break; } case ".span": { time += (int)amfObj.Properties["delta"]; output.WriteLine("WriteSpan({0}, {1}, {2});", Format(amfObj.Properties["name"]), amfObj.Properties["span"], amfObj.Properties["delta"] ); // handle end of frame string name = (string)amfObj.Properties["name"]; if (name == ".exit") { int span = (int)amfObj.Properties["span"]; int deltas = time - enterTime; output.WriteLine("// frame deltas:{0} span:{1} diff:{2}", deltas, span, deltas - span); } break; } case ".spanValue": { time += (int)amfObj.Properties["delta"]; output.WriteLine("WriteSpanValue({0}, {1}, {2}, {3});", Format(amfObj.Properties["name"]), amfObj.Properties["span"], amfObj.Properties["delta"], Format(amfObj.Properties["value"]) ); break; } case ".time": { time += (int)amfObj.Properties["delta"]; output.WriteLine("WriteTime({0}, {1});", Format(amfObj.Properties["name"]), amfObj.Properties["delta"] ); // handle start of frame string name = (string)amfObj.Properties["name"]; if (name == ".enter") { enterTime = time; } } break; default: output.WriteLine(Format(o)); break; } } }