示例#1
0
文件: codec.go 项目: Dim0N22/gmf
func FindDecoder(i interface{}) (*Codec, error) {
	var avc *C.AVCodec

	switch t := i.(type) {
	case string:
		cname := C.CString(i.(string))
		defer C.free(unsafe.Pointer(cname))

		avc = C.avcodec_find_decoder_by_name(cname)
		break

	case int:
		avc = C.avcodec_find_decoder(uint32(i.(int)))
		break

	default:
		return nil, errors.New(fmt.Sprintf("Unable to find codec, unexpected arguments type '%v'", t))
	}

	if avc == nil {
		return nil, errors.New(fmt.Sprintf("Unable to find codec by value '%v'", i))
	}

	return &Codec{avCodec: avc}, nil
}
示例#2
0
func avcodec_find_decoder_by_name(name string) _Codec {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	return _Codec{codec: C.avcodec_find_decoder_by_name(cname)}
}
示例#3
0
文件: avcodec.go 项目: hbdlb/goav
//Find a registered decoder with the specified name.
func AvcodecFindDecoderByName(n string) *Codec {
	return (*Codec)(C.avcodec_find_decoder_by_name(C.CString(n)))
}
示例#4
0
//Find a registered decoder with the specified name.
//AVCodec *avcodec_find_decoder_by_name (const char *name)
func Avcodec_find_decoder_by_name(n string) *AVCodec {
	return (*AVCodec)(C.avcodec_find_decoder_by_name(C.CString(n)))
}