AMF

master

An AMF decoder and encoder
MAVISBroadcast/AMF

Swift AMF Encoder/Decoder, using Codable.

Build Status

This is an incomplete/WIP Swift implementation of Action Message Format Encoding and Decoding. Originally built for use in a Swift RTMP implementation in the video broadcast space.

Making AMF parse into Swift Codable objects/structs is quite limiting, inside the confines of the Swift type system and how custom Codable Encoder/Decoders needs to be written to work. It is almost impossible not to loose information/order when encoding in and out of AMF.

A good example of Decoding working (for AMF0) is found in the testAMFObject() test inside the AMF0DecodingTests, which uses real AMF0 in an RTMP situation. Round trip tests demonstrate encoding too.

This implementation will get more battled/performance tested once deployed with an RTMP implementation.

Currently running at an OK >60% coverage

TODO:

Both

  • Refactor away side effecty lazy vars to bubble up throws a bit better
  • Remove some boilerplate with types not easily represented in AMF, but are in Swift

AMF0

  • Better tested reference decoding
  • Reference encoding implementation
  • XML Document Type
  • More unit tests in general

AMF3

  • Reference decoding
  • Reference encoding
  • Typed, Dynamic, Externalizable Objects (currently only Anonymous is supported)
  • XML Type
  • ByteArray Type
  • Vector Types
  • Dictionary Type
  • Sparse ECMA (to be parsed into a dictionary) of the Array Type
  • Keying by types other than strings
  • RTMP based tests
  • More tests

THANKS!

Massive thanks to @mattt for his Flight School Guide to Swift Codable, specifically his MessagePack implementation and DIY Codable Encoder / Decoder Kit both of which were invaluable in understanding how to write a custom Codable Encoder/Decoder and to the existing (but rather dated) CocoaAMF for getting my head around AMF (especially AMF3 - which is totally nutty - with it's proprietary Unsigned29Int that itself is bit shifted all over the place).

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Mar 14 2024 20:19:31 GMT-0900 (Hawaii-Aleutian Daylight Time)