func (r *Reader) readObjectValue() (*amf.Object, error) { if v, err := r.Read7BitValue32(); err != nil { return nil, errors.New("amf3.read object.head") } else { if (v & 0x01) == 0 { if o, err := r.getObjectRef(int(v >> 1)); err != nil { return nil, err } else if obj, ok := o.(*amf.Object); ok { return obj, nil } else { return nil, errors.New("amf3.ref not object") } } else { if t, err := r.loadTraits(v); err != nil { return nil, err } else { o := amf.NewObject() r.addObjectRef(o) for e := t.infos.Front(); e != nil; e = e.Next() { s := e.Value.(string) if v, err := r.Read(); err != nil { return nil, errors.New("amf3.read object.body") } else if err := o.Set(s, v); err != nil { return nil, err } } return o, nil } } } }
func (h *streamHandler) newPublishSuccessResponse(stream string, callback float64) error { if w, err := newAmfMessageWriter("onStatus", callback); err != nil { return err } else { obj := amf.NewObject() obj.SetString("level", "status") obj.SetString("code", "NetStream.Publish.Start") obj.SetString("description", stream+" is now published") if err := w.WriteObject(obj); err != nil { return err } h.fw.AddFragments(true, split(w.Bytes())...) return nil } }
func (h *streamHandler) newPlayResetResponse(stream string, callback float64) error { if w, err := newAmfMessageWriter("onStatus", callback); err != nil { return err } else { obj := amf.NewObject() obj.SetString("level", "status") obj.SetString("code", "NetStream.Play.Reset") obj.SetString("description", "Playing and resetting "+stream) if err := w.WriteObject(obj); err != nil { return err } h.fw.AddFragments(true, split(w.Bytes())...) return nil } }
func (r *Reader) readObjectValue() (*amf.Object, error) { o := amf.NewObject() r.addObjectRef(o) for { if s, err := r.readStringValue(); err != nil { return nil, errors.New("amf0.read traits.info") } else { if len(s) == 0 { break } if v, err := r.Read(); err != nil { return nil, errors.New("amf0.read object.body") } else if err := o.Set(s, v); err != nil { return nil, err } } } if t, err := r.Read8(); err != nil { return nil, errors.New("amf0.read object.end") } else if t != Amf0ObjectEnd { return nil, errors.New("amf0.not object end") } return o, nil }