//export OpenMediaFile func OpenMediaFile(filename string) { println("try openning the media file ") println(filename) cfilename := C.CString(filename) C.avcodec_register_all() C.av_register_all() ctx := C.avformat_alloc_context() result := C.av_open_input_file(&ctx, cfilename, nil, 0, nil) println(result) result = C.av_find_stream_info(ctx) C.free(unsafe.Pointer(cfilename)) C.av_close_input_file(ctx) //C.free(unsafe.Pointer(ctx)); }
func (src *DataSource) Connect() bool { src.Valid = false cfilename := C.CString(src.Locator.Filename) src.Ctx = C.avformat_alloc_context() result := C.av_open_input_file(&src.Ctx, cfilename, nil, 0, nil) C.free(unsafe.Pointer(cfilename)) if result != 0 { return src.Valid } result = C.av_find_stream_info(src.Ctx) if result < 0 { return src.Valid } src.Valid = true return src.Valid }
func av_find_stream_info(ctx *FormatContext) int { return int(C.av_find_stream_info(ctx.ctx)) }