Пример #1
0
func (s *Shout) UpdateMetadata(mname string, mvalue string) {
	md := C.shout_metadata_new()
	ptr1 := C.CString(mname)
	ptr2 := C.CString(mvalue)
	C.shout_metadata_add(md, ptr1, ptr2)
	C.free(unsafe.Pointer(ptr1))
	C.free(unsafe.Pointer(ptr2))
	C.shout_set_metadata(s.struc, md)
	C.shout_metadata_free(md)
}
Пример #2
0
func (self *Shout) SendMetadata(meta string) error {
	/* Updates the metadata. This is only supported for MP3 streams */
	new_string := C.CString(meta)
	song_string := C.CString("song")
	// Make sure we call free at the end
	defer C.free(unsafe.Pointer(new_string))
	defer C.free(unsafe.Pointer(song_string))

	i := C.shout_metadata_add(self.shout_metadata, song_string, new_string)
	if i != C.SHOUTERR_SUCCESS {
		return self.createShoutError()
	}

	i = C.shout_set_metadata(self.shout, self.shout_metadata)
	if i != C.SHOUTERR_SUCCESS {
		return self.createShoutError()
	}

	return nil
}
Пример #3
0
func NewShout(options map[string]string) *Shout {
	/* Creates a new Shout instance

	   options is a mapping of settings to pass to the new Shout instance
	   on creation. The following settings are supported.

	   All settings should be strings, they are converted accordingly when
	   being set.

	   metadata: The initial metadata to send to the server.
	   host: The server hostname or IP. Default is localhost
	   port: The server port. Default is 8000
	   user: The user to authenticate as. The default is source
	   passwd: The password to authenticate with. No default
	   protocol: The protocol to use (Listed above). Default is HTTP
	   format: The format to use (Listed above). Default is VORBIS
	   mount: The mountpoint for this stream. No default
	          (Only available if protocol supports it)
	   dumpfile: If the server supports it, you can request that
	             your stream be archived on the server under the
	             name dumpfile. This can quickly eat a lot of disk
	             space, so think twice before setting it.
	   agent: The useragent that is send to the server on connecting.
	           (Defaults to libshout/version)

	   Optional directory parameters:

	   public: bool indicating if the stream should be published on any
	           directories the server knows about.
	   name: The name of the stream.
	   url: An URL for the stream.
	   genre: A genre for the stream.
	   description: A description for the stream.

	   Audio parameters:

	   bitrate: Sets the audio bitrate.
	   samplerate: Sets the audio sample rate.
	   channels: The amount of channels in the audio.
	   quality: A quality setting of the audio.
	*/

	charset := C.CString("charset")
	charset_option := C.CString("UTF8")

	// FREE THEM, libshout copies them over anyway.
	defer C.free(unsafe.Pointer(charset))
	defer C.free(unsafe.Pointer(charset_option))

	// Create new C libshout struct
	shout_t := C.shout_new()

	shout_metadata_t := C.shout_metadata_new()
	C.shout_metadata_add(shout_metadata_t, charset, charset_option)

	new := Shout{shout_t, shout_metadata_t}
	// Set the options we got passed
	new.ApplyOptions(options)

	return &new
}