[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-dev] About AMF
[Gnash-dev] About AMF
Thu, 4 Sep 2008 10:57:39 +0200
I've been thinking about AMF and wanted to share some of that.
My impression is that AMF (which may stand for Another Marshalling Format)
is pretty much only needed to serialize function calls:
the version you find in FLV is a function call, what you use for remoting
is a function call.
A function call is a name, a set of args and a return. Mostly just
a string plus as_value types.
One important (and complex) characteristic of as_value is that a value
can be an Object, which can contain references to self (circular
references). This circular reference thing forced us to use a garbage
collector for proper memory managment (refcounting just didn't fit).
The model works fine for as_value.
When serialized, there are no memory management issues and each
circular chain is encoded using REFERENCE types.
Now, the question is: why would we want another pointer-based
(heap-allocated) intermediate class between as_value and AMF itself ?
This intermediate class is amf::Element.
Element is still pointer based (complex Elment have a set or properties
being other Element pointers) but doesn't solve the circular reference
issue, that is memory management of it. If it's true that it takes
a garbage collector to deal with circular refs, the only way to sanely
support Element memory management would be putting it too under
the GC control, which means only being able to create Element instances
in the main thread until we do thread-safe GC.
But again, if we do raise Element at the level of as_value, isn't it
a code duplication ?
One of the reasons for Element to exist (if I got it correctly)
is that it supports more types then as_value.
In particular Video/Audio types.
Do we need to consider them part of the AMF format at all ?
Can it be instead that Video/Audio are RTMP packet types instead
and AMF is another packet type ?
The analogy with FLV looks interesting. FLV is a stream of tags
(or packets if you want). Each packet has a timestamp. Content
of the packet may be: Video, Audio, Meta; Meta is AMF-encoded.
So, my feeling is that:
- AMF is *only* for serializing ActionScript values
- RTMP can contain ActionScript calls encoded in AMF
- FLV can contain ActionScript calls encoded in AMF (an RTMP session
() ASCII Ribbon Campaign
/\ Keep it simple!
- [Gnash-dev] About AMF,