// Code generated by glex; DO NOT EDIT. // Lexicon schema: place.stream.segment package placestream import ( "encoding/json" "io" glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen" ) func init() { glex.RegisterType("place.stream.segment", &Segment{}) } // Media file representing a segment of a livestream type Segment struct { LexiconTypeID string `json:"$type,omitempty"` Audio []Segment_Audio `json:"audio,omitempty"` ContentRights *MetadataContentRights `json:"contentRights,omitempty"` ContentWarnings *MetadataContentWarnings `json:"contentWarnings,omitempty"` Creator string `json:"creator"` DistributionPolicy *MetadataDistributionPolicy `json:"distributionPolicy,omitempty"` // duration: The duration of the segment in nanoseconds Duration *int64 `json:"duration,omitempty"` // id: Unique identifier for the segment Id string `json:"id"` // signingKey: The DID of the signing key used for this segment SigningKey string `json:"signingKey"` // size: The size of the segment in bytes Size *int64 `json:"size,omitempty"` // startTime: When this segment started StartTime string `json:"startTime"` Video []Segment_Video `json:"video,omitempty"` } // RecordTypeID implements glex.Record. func (t *Segment) RecordTypeID() string { return "place.stream.segment" } // MarshalJSON stamps the $type field, like MarshalCBOR does. The value // receiver operates on a copy, so the record is never mutated and both // Segment and *Segment marshal with $type. func (t Segment) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "place.stream.segment" type alias Segment return json.Marshal((alias)(t)) } func (t *Segment) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "place.stream.segment" return glex.MarshalCBOR(w, &cp) } func (t *Segment) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Segment_Audio is a "audio" in the place.stream.segment schema. type Segment_Audio struct { LexiconTypeID string `json:"$type,omitempty"` Channels int64 `json:"channels"` Codec string `json:"codec"` Rate int64 `json:"rate"` } // RecordTypeID implements glex.Record. func (t *Segment_Audio) RecordTypeID() string { return "place.stream.segment#audio" } func (t *Segment_Audio) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "place.stream.segment#audio" return glex.MarshalCBOR(w, &cp) } func (t *Segment_Audio) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Segment_Framerate is a "framerate" in the place.stream.segment schema. type Segment_Framerate struct { LexiconTypeID string `json:"$type,omitempty"` Den int64 `json:"den"` Num int64 `json:"num"` } // RecordTypeID implements glex.Record. func (t *Segment_Framerate) RecordTypeID() string { return "place.stream.segment#framerate" } func (t *Segment_Framerate) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "place.stream.segment#framerate" return glex.MarshalCBOR(w, &cp) } func (t *Segment_Framerate) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Segment_SegmentView is a "segmentView" in the place.stream.segment schema. type Segment_SegmentView struct { LexiconTypeID string `json:"$type,omitempty"` Cid string `json:"cid"` Record *glex.LexiconTypeDecoder `json:"record"` } // RecordTypeID implements glex.Record. func (t *Segment_SegmentView) RecordTypeID() string { return "place.stream.segment#segmentView" } func (t *Segment_SegmentView) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "place.stream.segment#segmentView" return glex.MarshalCBOR(w, &cp) } func (t *Segment_SegmentView) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) } // Segment_Video is a "video" in the place.stream.segment schema. type Segment_Video struct { LexiconTypeID string `json:"$type,omitempty"` Bframes *bool `json:"bframes,omitempty"` Codec string `json:"codec"` Framerate *Segment_Framerate `json:"framerate,omitempty"` Height int64 `json:"height"` Width int64 `json:"width"` } // RecordTypeID implements glex.Record. func (t *Segment_Video) RecordTypeID() string { return "place.stream.segment#video" } func (t *Segment_Video) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "place.stream.segment#video" return glex.MarshalCBOR(w, &cp) } func (t *Segment_Video) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) }