Exemplo n.º 1
0
//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));
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
func av_find_stream_info(ctx *FormatContext) int {
	return int(C.av_find_stream_info(ctx.ctx))
}