amf

package module
v0.0.0-...-cc4cad5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2020 License: MIT Imports: 9 Imported by: 0

README

GoAMF Build Status

AFM0 & AMF3 encoding.

Spec:

Todo:

  • AMF0 - MovieClip type, Reference type, Unsupported type, RecordSet type, XML document type, Typed object type
  • AMF3 - Reference type, Date type, Read Array type

Documentation

Index

Constants

View Source
const (
	AMF0 = uint(0)
	AMF3 = uint(3)
)
View Source
const (
	AMF0_NUMBER_MARKER         = 0x00
	AMF0_BOOLEAN_MARKER        = 0x01
	AMF0_STRING_MARKER         = 0x02
	AMF0_OBJECT_MARKER         = 0x03
	AMF0_MOVIECLIP_MARKER      = 0x04
	AMF0_NULL_MARKER           = 0x05
	AMF0_UNDEFINED_MARKER      = 0x06
	AMF0_REFERENCE_MARKER      = 0x07
	AMF0_ECMA_ARRAY_MARKER     = 0x08
	AMF0_OBJECT_END_MARKER     = 0x09
	AMF0_STRICT_ARRAY_MARKER   = 0x0a
	AMF0_DATE_MARKER           = 0x0b
	AMF0_LONG_STRING_MARKER    = 0x0c
	AMF0_UNSUPPORTED_MARKER    = 0x0d
	AMF0_RECORDSET_MARKER      = 0x0e
	AMF0_XML_DOCUMENT_MARKER   = 0x0f
	AMF0_TYPED_OBJECT_MARKER   = 0x10
	AMF0_ACMPLUS_OBJECT_MARKER = 0x11
)
View Source
const (
	AMF3_UNDEFINED_MARKER = 0x00
	AMF3_NULL_MARKER      = 0x01
	AMF3_FALSE_MARKER     = 0x02
	AMF3_TRUE_MARKER      = 0x03
	AMF3_INTEGER_MARKER   = 0x04
	AMF3_DOUBLE_MARKER    = 0x05
	AMF3_STRING_MARKER    = 0x06
	AMF3_XMLDOC_MARKER    = 0x07
	AMF3_DATE_MARKER      = 0x08
	AMF3_ARRAY_MARKER     = 0x09
	AMF3_OBJECT_MARKER    = 0x0a
	AMF3_XML_MARKER       = 0x0b
	AMF3_BYTEARRAY_MARKER = 0x0c
)
View Source
const (
	ADD = 0x0
	DEL = 0x3
)
View Source
const (
	SetDataFrame string = "@setDataFrame"
	OnMetaData   string = "onMetaData"
)
View Source
const (
	AMF0_MAX_STRING_LEN = 65535
)

Variables

This section is empty.

Functions

func AMF3_ReadByteArray

func AMF3_ReadByteArray(r Reader) ([]byte, error)

func AMF3_ReadDouble

func AMF3_ReadDouble(r Reader) (num float64, err error)

func AMF3_ReadInteger

func AMF3_ReadInteger(r Reader) (num uint32, err error)

func AMF3_ReadObjectName

func AMF3_ReadObjectName(r Reader) (name string, err error)

func AMF3_ReadString

func AMF3_ReadString(r Reader) (str string, err error)

func AMF3_ReadU29

func AMF3_ReadU29(r Reader) (n uint32, err error)

----------------------------------------------------------------------- AMF3 Read functions

func AMF3_ReadUTF8

func AMF3_ReadUTF8(r Reader) (string, error)

func AMF3_ReadValue

func AMF3_ReadValue(r Reader) (value interface{}, err error)

func AMF3_WriteBoolean

func AMF3_WriteBoolean(w Writer, b bool) (n int, err error)

func AMF3_WriteDouble

func AMF3_WriteDouble(w Writer, num float64) (n int, err error)

func AMF3_WriteNull

func AMF3_WriteNull(w Writer) (n int, err error)

func AMF3_WriteObject

func AMF3_WriteObject(w Writer, obj Object) (n int, err error)

Object's item order is uncertainty.

func AMF3_WriteObjectEndMarker

func AMF3_WriteObjectEndMarker(w Writer) (n int, err error)

func AMF3_WriteObjectMarker

func AMF3_WriteObjectMarker(w Writer) (n int, err error)

func AMF3_WriteObjectName

func AMF3_WriteObjectName(w Writer, name string) (n int, err error)

func AMF3_WriteString

func AMF3_WriteString(w Writer, str string) (n int, err error)

func AMF3_WriteU29

func AMF3_WriteU29(w Writer, n uint32) (num int, err error)

----------------------------------------------------------------------- AMF3 Write functions

func AMF3_WriteUTF8

func AMF3_WriteUTF8(w Writer, str string) (num int, err error)

func AMF3_WriteUndefined

func AMF3_WriteUndefined(w Writer) (n int, err error)

func AMF3_WriteValue

func AMF3_WriteValue(w Writer, value interface{}) (n int, err error)

func AMF3_readByteArray

func AMF3_readByteArray(r Reader) ([]byte, error)

func MetaDataReform

func MetaDataReform(p []byte, flag byte) ([]byte, error)

func ReadBoolean

func ReadBoolean(r Reader) (b bool, err error)

func ReadDate

func ReadDate(r Reader) (t time.Time, err error)

An ActionScript Date is serialized as the number of milliseconds elapsed since the epoch of midnight on 1st Jan 1970 in the UTC time zone. While the design of this type reserves room for time zone offset information, it should not be filled in, nor used, as it is unconventional to change time zones when serializing dates on a network. It is suggested that the time zone be queried independently as needed. time-zone = S16 ; reserved,

; not supported
; should be set

Keng-die: time-zone = int16 * -60 (seconds)

; to 0x0000

date-type = date-marker DOUBLE time-zone

func ReadDouble

func ReadDouble(r Reader) (num float64, err error)

func ReadMarker

func ReadMarker(r Reader) (mark byte, err error)

----------------------------------------------------------------------- AMF0 Read functions

func ReadObjectName

func ReadObjectName(r Reader) (name string, err error)

func ReadStrictArray

func ReadStrictArray(r Reader) (arr []interface{}, err error)

A strict Array contains only ordinal indices; however, in AMF 0 the indices can be dense or sparse. Undefined entries in the sparse regions between indices are serialized as undefined.

array-count = U32 strict-array-type = array-count *(value-type)

A 32-bit array-count implies a theoretical maximum of 4,294,967,295 array entries.

func ReadString

func ReadString(r Reader) (str string, err error)

func ReadUTF8

func ReadUTF8(r Reader) (string, error)

func ReadUTF8Long

func ReadUTF8Long(r Reader) (string, error)

func ReadValue

func ReadValue(r Reader) (value interface{}, err error)

func WriteBoolean

func WriteBoolean(w Writer, b bool) (n int, err error)

func WriteDouble

func WriteDouble(w Writer, num float64) (n int, err error)

func WriteEcmaArray

func WriteEcmaArray(w Writer, arr []interface{}) (n int, err error)

func WriteMarker

func WriteMarker(w Writer, mark byte) (n int, err error)

func WriteNull

func WriteNull(w Writer) (n int, err error)

func WriteObject

func WriteObject(w Writer, obj Object) (n int, err error)

Object's item order is uncertainty.

func WriteObjectEndMarker

func WriteObjectEndMarker(w Writer) (n int, err error)

func WriteObjectMarker

func WriteObjectMarker(w Writer) (n int, err error)

func WriteObjectName

func WriteObjectName(w Writer, name string) (n int, err error)

func WriteString

func WriteString(w Writer, str string) (n int, err error)

func WriteStruct

func WriteStruct(w Writer, value reflect.Value) (n int, err error)

func WriteUTF8

func WriteUTF8(w Writer, s string, length uint16) error

func WriteUTF8Long

func WriteUTF8Long(w Writer, s string, length uint32) error

func WriteUndefined

func WriteUndefined(w Writer) (n int, err error)

func WriteValue

func WriteValue(w Writer, value interface{}) (n int, err error)

Types

type Object

type Object map[string]interface{}

Object Type

func AMF3_ReadObject

func AMF3_ReadObject(r Reader) (obj Object, err error)

func AMF3_ReadObjectProperty

func AMF3_ReadObjectProperty(r Reader) (Object, error)

func ReadObject

func ReadObject(r Reader) (obj Object, err error)

func ReadObjectProperty

func ReadObjectProperty(r Reader) (Object, error)

type Reader

type Reader interface {
	Read(p []byte) (n int, err error)
	ReadByte() (c byte, err error)
}

type Undefined

type Undefined struct{}

Undefined Type

type Writer

type Writer interface {
	Write(p []byte) (nn int, err error)
	WriteByte(c byte) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL