Documentation ¶
Overview ¶
Package encode is for encoding mrx files. It contains a generic interface for you to include your own data inputs for mxf files
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RIPKey = []byte{0x6, 0xe, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01, 0x11, 0x01, 0x00}
RIPKey is the Byte key for the random index pack of the mrx file
Functions ¶
func EncodeMultipleDataStreams ¶
func EncodeMultipleDataStreams(destination io.Writer, streams []SingleStream, streamConfig manifest.Configuration, encodeOptions *MrxEncodeOptions) error
EncodeSMultipleDataStreams encodes multiple streams of metadata as an MRX.
It can be run with the following demo code, ensuring the channel is closed after writing to finish the mrx file.
// set up some channels bfChannel := make(chan []byte, 5) tfChannel := make(chan []byte, 10) // set up the streams streams := []encode.SingleStream{ {Key: encode.BinaryFrame, MdStream: bfChannel}, {Key: encode.TextFrame, MdStream: tfChannel}} // set up your data data := [][]string{ {`{"test":"binary"}`, `{"test":"binary"}`, `{"test":"binary"}`, `{"test":"binary"}`, `{"test":"binary"}`, `{"test":"binary"}`}, {`{"test":"text"}`, `{"test":"text"}`, `{"test":"text"}`, `{"test":"text"}`, `{"test":"text"}`, `{"test":"text"}`}} f, err := os.Create("./testdata/demo.mrx") if err != nil { return err } go func() { for i, stream := range streams { pos := i go func() { for _, d := range data[pos] { stream.MdStream <- []byte(d) } // close the stream when the buisness is done close(stream.MdStream) }() } }() // set up some default properties demoConfig := manifest.Configuration{Version: "pre alpha", Default: manifest.StreamProperties{StreamType: "some data to track", FrameRate: "24/1", NameSpace: "https://metarex.media/reg/MRX.123.456.789.gps"}, StreamProperties: map[int]manifest.StreamProperties{0: {NameSpace: "MRX.123.456.789.gps"}}, } // run the encoder err = encode.EncodeMultipleDataStreams(f, streams, demoConfig, nil)
Types ¶
type ChannelPackets ¶
type ChannelPackets struct { OverViewData manifest.GroupProperties Packets chan *DataCarriage }
ChannelPackets contains the user metadata for a metadata stream and the channel that is fed the metadata stream.
type DataCarriage ¶
type DataCarriage struct { Data *[]byte MetaData *manifest.EssenceProperties }
DataCarriage contains the metadata bytes and any metametadata associated with it.
type Encoder ¶
type Encoder interface { // GetEssenceKeys gives the array of the essence Keys // to be used in this mrx file. // The essence keys are given in the order their // metadata channels are handled in the EssenceChannels // function. GetStreamInformation() (StreamInformation, error) // The essence Pipe returns streams of KLV and their associated metadata // Each channel represents a separate stream. These streams // are written to MRX following the MRX file rules. EssenceChannels(chan *ChannelPackets) error // RoundTrip gets the RoundTrip data associated with the metadata // stream, this is an optional piece of metadata. GetRoundTrip() (*manifest.RoundTrip, error) }
The Encoder interface is a way to plug in the essence generator into an MRX file to save the essence, in an generic way without having to deal with the MRX file internal layout and data, such as headers.
type EssenceKey ¶
type EssenceKey uint64
EssenceKey is the id for the metadata keys
const ( // TextFrame is for clocked text metadata TextFrame EssenceKey = iota + 1 // TextClip is for embedded text metadata TextClip // TextFrame is for clocked binary metadata BinaryFrame // TextClip is for embedded binary metadata BinaryClip )
type ExampleMultipleStream ¶
type ExampleMultipleStream struct { // The roundtrip associated with the streams RoundTrip *manifest.RoundTrip // The array of essence keys for the metadata streams StreamInfo *StreamInformation // The metadata data stream channels to handle Contents []SingleStream }
ExampleFileStream contains the bare minimum to get multiple data streams saved as an MRX.
func GetMultiStream ¶
func GetMultiStream(streams []SingleStream, roundTrip *manifest.RoundTrip) (*ExampleMultipleStream, error)
GetMultiStream returns a multistream encode object. This can then be used to update teh encoder properties of an *MRXWriter object. Like so:
mw.UpdateEncoder(writer)
func (*ExampleMultipleStream) EssenceChannels ¶
func (st *ExampleMultipleStream) EssenceChannels(essChan chan *ChannelPackets) error
EssenceChannels is a pipe that concurrently runs all the metadata streams at once.
func (ExampleMultipleStream) GetRoundTrip ¶
func (st ExampleMultipleStream) GetRoundTrip() (*manifest.RoundTrip, error)
GetRoundTrip returns the roundtrip file
func (ExampleMultipleStream) GetStreamInformation ¶
func (st ExampleMultipleStream) GetStreamInformation() (StreamInformation, error)
GetStreamInformation tells the mrx writer the channel keys for the metadata. The number of keys is the number of channels.
type MrxEncodeOptions ¶
type MrxEncodeOptions struct { // ManifestHistoryCount is // the number of previous manifest files to be inlcuded (if possible) ManifestHistoryCount int // ConfigOverwrite overwrites any fields in the base configuration // of the mrx file. e.g from previous manifests ConfigOverWrite manifest.Configuration // is the manifest file to be used // default is to include it DisableManifest bool }
MrxEncodeOptions are the encoding parameters.
type MrxWriter ¶
type MrxWriter struct {
// contains filtered or unexported fields
}
MrxWriter is the encoding engine for MRX files
func NewMRXWriter ¶
func NewMRXWriter() *MrxWriter
NewMRXWriter generates a new MRX body for writing files.
func NewMRXWriterFR ¶
NewMRXWriterFR creates a Metarex file writer with the base frame rate. The frame rate string follows the format of %v/%v.
func (*MrxWriter) Encode ¶
func (mw *MrxWriter) Encode(w io.Writer, encodeOptions *MrxEncodeOptions) error
Encode writes the data to an mrx file, default options are used if MrxEncodeOptions is nil
func (*MrxWriter) UpdateEncoder ¶
UpdateEncoder sets the write handler for the mrx file. Example writers include the EncodeSingleDataStream() function in the example folders.
type RIPLayout ¶
type RIPLayout struct { SID uint32 // contains filtered or unexported fields }
RIP Layout is the simple layout of a partition in an mrx file
type SingleStream ¶
type SingleStream struct { Key EssenceKey MdStream chan []byte }
SingleStream contains a singe metadata channel for a data stream
type StreamInformation ¶
type StreamInformation struct { // Essence Keys are the essence keys of each data type // in the order they are to be streamed to the encoder // It also is the total number of channels expected EssenceKeys []EssenceKey }
StreamInformation contains the information about the complete metadata stream.