コード例 #1
0
ファイル: libshout.go プロジェクト: boedy/go-libshout
func (s *Shout) LazyInit() {
	if s.struc != nil {
		return
	}

	s.struc = C.shout_new()
	s.updateParameters()

	s.stream = make(chan []byte)
}
コード例 #2
0
ファイル: shout.go プロジェクト: Bevinsky/icecast-proxy-go
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
}