Exemplo n.º 1
0
func (s *Shout) SetDescription(description string) int {
	ptr1 := C.CString(description)
	success := int(C.shout_set_description(s.struc, ptr1))
	fmt.Println("Set description success: ", success)
	C.free(unsafe.Pointer(ptr1))
	return success
}
Exemplo n.º 2
0
func (self *Shout) ApplyOptions(options map[string]string) error {
	for key, value := range options {
		option := C.CString(value)
		defer C.free(unsafe.Pointer(option))

		switch key {
		case "host":
			C.shout_set_host(self.shout, option)
		case "port":
			temp, err := strconv.Atoi(value)
			if err != nil {
				continue
			}

			port := (C.ushort)(temp)
			C.shout_set_port(self.shout, port)
		case "user":
			C.shout_set_user(self.shout, option)
		case "passwd":
			C.shout_set_password(self.shout, option)
		case "protocol":
			proto := Protocols[value]
			C.shout_set_protocol(self.shout, proto)
		case "format":
			format := Formats[value]
			C.shout_set_format(self.shout, format)
		case "mount":
			C.shout_set_mount(self.shout, option)
		case "dumpfile":
			C.shout_set_dumpfile(self.shout, option)
		case "agent":
			C.shout_set_agent(self.shout, option)
		case "public":
			public := (C.uint)(0)
			if value == "true" || value == "1" {
				public = (C.uint)(1)
			}
			C.shout_set_public(self.shout, public)
		case "name":
			C.shout_set_name(self.shout, option)
		case "url":
			C.shout_set_url(self.shout, option)
		case "genre":
			C.shout_set_genre(self.shout, option)
		case "description":
			C.shout_set_description(self.shout, option)
		case "bitrate", "samplerate", "channels", "quality":
			param := AudioParams[value]
			ctype := C.CString(param)
			C.shout_set_audio_info(self.shout, ctype,
				option)
		}
	}
	return nil
}