v0

package
v0.0.0-...-e148948 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AMF_NUMBER  = 0x00
	AMF_BOOLEAN = 0x01
	AMF_STRING  = 0x02
	AMF_OBJECT  = 0x03
	// not supported
	AMF_MOVIECLIP  = 0x04
	AMF_NULL       = 0x05
	AMF_UNDEFINED  = 0x06
	AMF_REFERENCE  = 0x07
	AMF_ECMA       = 0x08
	AMF_OBJEND     = 0x09
	AMF_STRICTARR  = 0x0a
	AMF_DATE       = 0x0b
	AMF_LONGSTRING = 0x0c
	// not supported
	AMF_UNSUP     = 0x0d
	AMF_RECORDSET = 0x0e
	AMF_XMLDOC    = 0x0f
	AMF_TYPEDOBJ  = 0x10

	// switch to AMF3
	AVMPLUS_OBJ_MARKER = 0x11
)
View Source
const (
	AMF_STRING_MAXLEN = 65535
)

Variables

This section is empty.

Functions

func AmfBooleanDecode

func AmfBooleanDecode(data []byte) (bool, int, error)

func AmfBooleanEncode

func AmfBooleanEncode(b bool) []byte

func AmfDateEncode

func AmfDateEncode(date AmfDate) []byte

func AmfLongStringDecode

func AmfLongStringDecode(data []byte) (string, int, error)

func AmfLongStringEncode

func AmfLongStringEncode(s string) []byte

func AmfNull

func AmfNull() []byte

func AmfNumberDecode

func AmfNumberDecode(data []byte) (float64, int, error)

func AmfNumberEncode

func AmfNumberEncode(num float64) ([]byte, error)

func AmfObjEnd

func AmfObjEnd() []byte

func AmfRefDecode

func AmfRefDecode(data []byte) (uint16, int, error)

func AmfRefEncode

func AmfRefEncode(ref uint16) []byte

func AmfStringDecode

func AmfStringDecode(data []byte) (string, int, error)

func AmfStringEncode

func AmfStringEncode(s string) []byte

func AmfUTF8Decode

func AmfUTF8Decode(data []byte) (string, int, error)

func AmfUTF8Encode

func AmfUTF8Encode(s string) []byte

If the string is longer than this, it will be truncated to `AMF_STRING_MAXLEN`

func AmfUTF8LongDecode

func AmfUTF8LongDecode(data []byte) (string, int, error)

func AmfUTF8LongEncode

func AmfUTF8LongEncode(s string) []byte

func AmfUndefined

func AmfUndefined() []byte

func AmfXmldocEncode

func AmfXmldocEncode(doc AmfXmldoc) []byte

Types

type AmfArray

type AmfArray []interface{}

func NewAmfArray

func NewAmfArray() *AmfArray

func (*AmfArray) Add

func (arr *AmfArray) Add(value interface{})

type AmfCodec

type AmfCodec struct {
	// contains filtered or unexported fields
}

func NewAmfCodec

func NewAmfCodec() *AmfCodec

func (*AmfCodec) AmfArrayDecode

func (c *AmfCodec) AmfArrayDecode(data []byte) (*AmfArray, int, error)

func (*AmfCodec) AmfArrayEncode

func (c *AmfCodec) AmfArrayEncode(arr *AmfArray) ([]byte, error)

func (*AmfCodec) AmfECMADecode

func (c *AmfCodec) AmfECMADecode(data []byte) (*AmfECMA, int, error)

func (*AmfCodec) AmfECMAEncode

func (c *AmfCodec) AmfECMAEncode(val *AmfECMA) ([]byte, error)

func (*AmfCodec) AmfObjDecode

func (c *AmfCodec) AmfObjDecode(data []byte) (*AmfObj, int, error)

func (*AmfCodec) AmfObjEncode

func (c *AmfCodec) AmfObjEncode(obj *AmfObj) ([]byte, error)

Used to encode an object. Because object passed in is strongly typed, we encode into the TypedObject format. Because we're using `reflect`, all fields must be exported, the unexported fields will be ignored.

func (*AmfCodec) Clear

func (c *AmfCodec) Clear()

func (*AmfCodec) Decode

func (c *AmfCodec) Decode(data []byte) (interface{}, int, error)

Notice both Null and Undefined are decoded as `nil` in golang. Also, when encountered with the following types: 1. AMF_MOVIECLIP 2. AMF_UNDEFINED 3. AMF_UNSUP 4. AMF_RECORDSET Decode will return a `Unsupported type` error. Consider handling these types gracefully, instead of panicking.

func (*AmfCodec) Encode

func (c *AmfCodec) Encode(val interface{}) ([]byte, error)

If a type is implemented because primitive types are not sufficient, then that type would be implemented as a struct. When passing such a type, they should be passed as a pointer. Specifically, the following types needs to be passed as pointers: 1. AmfObj 2. AmfECMA 3. AmfArray Passing primitive types will result in the following encoding: uint*, int* -> float64 -> AmfNumber float64 -> AmfNumber bool -> AmfBoolean string -> AmfStr | AmfLongStr nil -> AmfNull Some types can never come out of Encode():

x -> AmfMovieclip (not used when encoding)
x -> AmfUndefined (not used when encoding)
x -> AmfUnsupported (not used when encoding)
x -> AmfRecordset (not used when encoding)

func (*AmfCodec) GetId

func (c *AmfCodec) GetId(val interface{}) (uint16, error)

func (*AmfCodec) GetObj

func (c *AmfCodec) GetObj(id uint16) (interface{}, error)

func (*AmfCodec) Set

func (c *AmfCodec) Set(val interface{})

type AmfDate

type AmfDate float64

func AmfDateDecode

func AmfDateDecode(data []byte) (AmfDate, int, error)

type AmfECMA

type AmfECMA map[string]interface{}

func NewAmfECMA

func NewAmfECMA() *AmfECMA

type AmfMarker

type AmfMarker uint8

type AmfObj

type AmfObj struct {
	Name  string
	Props []AmfObjProp

	// For easy access. To access, call PopulatePropMp() first.
	PropMp map[string]interface{}
}

func NewAmfObj

func NewAmfObj() *AmfObj

func (*AmfObj) AddProp

func (obj *AmfObj) AddProp(key string, val interface{})

func (*AmfObj) PopulatePropMp

func (obj *AmfObj) PopulatePropMp()

Call this before accessing PropMp

type AmfObjProp

type AmfObjProp struct {
	Key   string
	Value interface{}
}

type AmfXmldoc

type AmfXmldoc string

func AmfXmldocDecode

func AmfXmldocDecode(data []byte) (AmfXmldoc, int, error)

Jump to

Keyboard shortcuts

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