Esempio n. 1
0
func (this *Option) Set(ctx interface{}) {
	ckey := C.CString(this.Key)
	defer C.free(unsafe.Pointer(ckey))

	var ret int = 0

	switch t := this.Val.(type) {
	case int:
		ret = int(C.av_opt_set_int(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, C.int64_t(this.Val.(int)), 0))

	case SampleFmt:
		ret = int(C.av_opt_set_sample_fmt(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, (int32)(this.Val.(SampleFmt)), 0))

	case float64:
		ret = int(C.av_opt_set_double(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, (C.double)(this.Val.(float64)), 0))

	case AVR:
		ret = int(C.av_opt_set_q(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, C.AVRational(this.Val.(AVR).AVRational()), 0))

	case []byte:
		ret = int(C.av_opt_set_bin(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), ckey, (*C.uint8_t)(unsafe.Pointer(&this.Val.([]byte)[0])), C.int(len(ctx.([]byte))), 0))

	case *Dict:
		ret = int(C.av_opt_set_dict(unsafe.Pointer(reflect.ValueOf(ctx).Pointer()), &this.Val.(*Dict).avDict))

	default:
		log.Println("unsupported type:", t)
	}

	if ret < 0 {
		log.Printf("unable to set key '%s' value '%d', error: %s\n", this.Key, this.Val.(int), AvError(int(ret)))
	}
}
Esempio n. 2
0
func (oa *OptionAccessor) SetInt64OptionWithFlags(name string, value int64, flags OptionSearchFlags) error {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))
	searchFlags := oa.searchFlags(flags)
	code := C.av_opt_set_int(oa.obj, cName, (C.int64_t)(value), searchFlags)
	if code < 0 {
		return NewErrorFromCode(ErrorCode(code))
	}
	return nil
}
Esempio n. 3
0
File: codecCtx.go Progetto: tvib/gmf
// @todo
func (this *CodecCtx) SetOpt() {
	// mock
	C.av_opt_set_int(unsafe.Pointer(this.avCodecCtx), C.CString("refcounted_frames"), 1, 0)
}