Exemplo 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)))
	}
}
Exemplo n.º 2
0
Arquivo: utils.go Projeto: Dim0N22/gmf
func CompareTimeStamp(aTimestamp int, aTimebase AVRational, bTimestamp int, bTimebase AVRational) int {
	return int(C.av_compare_ts(C.int64_t(aTimestamp), C.AVRational(aTimebase),
		C.int64_t(bTimestamp), C.AVRational(bTimebase)))
}
Exemplo n.º 3
0
Arquivo: utils.go Projeto: Dim0N22/gmf
func RescaleDelta(inTb AVRational, inTs int64, fsTb AVRational, duration int, last *int64, outTb AVRational) int64 {
	return int64(C.av_rescale_delta(C.AVRational(inTb), C.int64_t(inTs), C.AVRational(fsTb), C.int(duration), (*C.int64_t)(unsafe.Pointer(&last)), C.AVRational(outTb)))
}
Exemplo n.º 4
0
Arquivo: utils.go Projeto: Dim0N22/gmf
func RescaleQ(a int64, encBase AVRational, stBase AVRational) int64 {
	return int64(C.av_rescale_q(C.int64_t(a), C.AVRational(encBase), C.AVRational(stBase)))
}