The following line needs to be added to all existing handlers to fix compilation for binary cases.
HandleBinary(id ElementID, r io.Reader, info ElementInfo) error {
data, _ := ioutil.ReadAll(r)
// use data as before. should be safe to ignore errors (the parser will handle these)
}
To make it more convenient, consider adding a convenience function:
HandleBinary(id ElementID, r io.Reader, info ElementInfo) error {
data := mkvparse.ReadBytes(r)
// use data as before
}
Because reading strings require more code, a convenience function for strings is useful:
HandleString(id ElementID, r io.Reader, info ElementInfo) error {
str := mkvparse.ReadString(r)
// use str as before
}
The Read* functions probably need a parameter to limit the size of the read (with -1 to mean 'Unlimited')
Another alternative is to add an UnsafeHandler interface, and adapt it to the new handler interface:
Change the following methods on the Handler interface:
to
This allows handlers to only read part of the data (in case it is too much for them to process). Alternatively, change the signature to
where
BytesType
isString
orBinary
.The following line needs to be added to all existing handlers to fix compilation for binary cases.
To make it more convenient, consider adding a convenience function:
Because reading strings require more code, a convenience function for strings is useful:
The
Read*
functions probably need a parameter to limit the size of the read (with -1 to mean 'Unlimited')Another alternative is to add an
UnsafeHandler
interface, and adapt it to the new handler interface: