Ejemplo n.º 1
0
func (s *Shout) updateParameters() {
	// set hostname
	p := C.CString(s.Host)
	C.shout_set_host(s.struc, p)
	C.free(unsafe.Pointer(p))

	// set port
	C.shout_set_port(s.struc, C.ushort(s.Port))

	// set username
	p = C.CString(s.User)
	C.shout_set_user(s.struc, p)
	C.free(unsafe.Pointer(p))

	// set password
	p = C.CString(s.Password)
	C.shout_set_password(s.struc, p)
	C.free(unsafe.Pointer(p))

	// set mount point
	p = C.CString(s.Mount)
	C.shout_set_mount(s.struc, p)
	C.free(unsafe.Pointer(p))

	// set format
	C.shout_set_format(s.struc, C.uint(s.Format))

	// set protocol
	C.shout_set_protocol(s.struc, C.uint(s.Protocol))
}
Ejemplo 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
}