func (ctx *Context) ReadFrame(pkt *avcodec.Packet) (bool, error) { cPkt := (*C.AVPacket)(unsafe.Pointer(&pkt.CAVPacket)) code := C.av_read_frame(ctx.CAVFormatContext, cPkt) if code < 0 { if avutil.ErrorCode(code) == avutil.ErrorCodeEOF { return false, nil } return false, avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return true, nil }
func (g *Graph) Config() error { code := C.avfilter_graph_config(g.CAVFilterGraph, nil) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) WriteTrailer() error { code := C.av_write_trailer(ctx.CAVFormatContext) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) GetFrame(frame *avutil.Frame) (bool, error) { var cFrame *C.AVFrame if frame != nil { cFrame = (*C.AVFrame)(unsafe.Pointer(frame.CAVFrame)) } code := C.av_buffersink_get_frame(ctx.CAVFilterContext, cFrame) if code < 0 { switch avutil.ErrorCode(code) { case avutil.ErrorCode(C.GO_AVERROR(C.EAGAIN)): return false, nil case avutil.ErrorCodeEOF: return false, nil } return false, avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return true, nil }
func NewContextForOutput(output *Output) (*Context, error) { var cCtx *C.AVFormatContext code := C.avformat_alloc_output_context2(&cCtx, output.CAVOutputFormat, nil, nil) if code < 0 { return nil, avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return NewContextFromC(unsafe.Pointer(cCtx)), nil }
func (ctx *Context) Link(srcPad uint, dst *Context, dstPad uint) error { cSrc := ctx.CAVFilterContext cDst := dst.CAVFilterContext code := C.avfilter_link(cSrc, C.uint(srcPad), cDst, C.uint(dstPad)) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) InitWithString(args string) error { cArgs := C.CString(args) defer C.free(unsafe.Pointer(cArgs)) code := C.avfilter_init_str(ctx.CAVFilterContext, cArgs) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (g *Graph) Parse(filters string, input, output *InOut) error { cFilters := C.CString(filters) defer C.free(unsafe.Pointer(cFilters)) cInput := &input.CAVFilterInOut cOutput := &output.CAVFilterInOut code := C.avfilter_graph_parse_ptr(g.CAVFilterGraph, cFilters, cInput, cOutput, nil) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) WriteFrame(frame *avutil.Frame) error { var cFrame *C.AVFrame if frame != nil { cFrame = (*C.AVFrame)(unsafe.Pointer(frame.CAVFrame)) } code := C.av_buffersrc_write_frame(ctx.CAVFilterContext, cFrame) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) AddFrameWithFlags(frame *avutil.Frame, flags BufferSrcFlags) error { var cFrame *C.AVFrame if frame != nil { cFrame = (*C.AVFrame)(unsafe.Pointer(frame.CAVFrame)) } code := C.av_buffersrc_add_frame_flags(ctx.CAVFilterContext, cFrame, (C.int)(flags)) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) InitWithDictionary(options *avutil.Dictionary) error { var cOptions **C.AVDictionary if options != nil { cOptions = (**C.AVDictionary)(unsafe.Pointer(&options.CAVDictionary)) } code := C.avfilter_init_dict(ctx.CAVFilterContext, cOptions) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) InterleavedWriteFrame(pkt *avcodec.Packet) error { var cPkt *C.AVPacket if pkt != nil { cPkt = (*C.AVPacket)(unsafe.Pointer(&pkt.CAVPacket)) } code := C.av_interleaved_write_frame(ctx.CAVFormatContext, cPkt) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) WriteHeader(options *avutil.Dictionary) error { var cOptions **C.AVDictionary if options != nil { cOptions = (**C.AVDictionary)(unsafe.Pointer(&options.CAVDictionary)) } code := C.avformat_write_header(ctx.CAVFormatContext, cOptions) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) FindStreamInfo(options []*avutil.Dictionary) error { var cOptions **C.AVDictionary count := ctx.NumberOfStreams() if count > 0 && options != nil { if uint(len(options)) < count { return ErrInvalidArgumentSize } cOptions = newCAVDictionaryArrayFromDictionarySlice(options[:count]) defer freeCAVDictionaryArray(cOptions) } code := C.avformat_find_stream_info(ctx.CAVFormatContext, cOptions) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func (ctx *Context) OpenInput(fileName string, input *Input, options *avutil.Dictionary) error { cFileName := C.CString(fileName) defer C.free(unsafe.Pointer(cFileName)) var cInput *C.AVInputFormat if input != nil { cInput = input.CAVInputFormat } var cOptions **C.AVDictionary if options != nil { cOptions = (**C.AVDictionary)(unsafe.Pointer(&options.CAVDictionary)) } code := C.avformat_open_input(&ctx.CAVFormatContext, cFileName, cInput, cOptions) if code < 0 { return avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return nil }
func OpenIOContext(url string, flags IOFlags, cb *IOInterruptCallback, options *avutil.Dictionary) (*IOContext, error) { cURL := C.CString(url) defer C.free(unsafe.Pointer(cURL)) var cCb *C.AVIOInterruptCB if cb != nil { cCb = cb.CAVIOInterruptCB } var cOptions **C.AVDictionary if options != nil { cOptions = (**C.AVDictionary)(unsafe.Pointer(&options.CAVDictionary)) } var cCtx *C.AVIOContext code := C.avio_open2(&cCtx, cURL, (C.int)(flags), cCb, cOptions) if code < 0 { return nil, avutil.NewErrorFromCode(avutil.ErrorCode(code)) } return NewIOContextFromC(unsafe.Pointer(cCtx)), nil }