raopd

package module
v0.0.0-...-3b56c24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2016 License: LGPL-3.0 Imports: 31 Imported by: 0

README

RAOP Daemon. Implements AirTunes functionality.

Install

$ go install github.com/maghul/go.raopd

Dependencies

"github.com/guelfey/go.dbus"
"github.com/maghul/go.alac"
"github.com/maghul/go.dnssd"
"github.com/maghul/go.slf"
"github.com/miekg/dns"

"github.com/stretchr/testify/assert"

License

The raopd package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details.

Documentation

Reference API documentation can be generated using godoc. The documentation can alse be found at https://godoc.org/github.com/maghul/go.raopd

Usage

The package defines Sources and Sinks.

A Source is an AirPlay source which will be named and published and can be connected to from an AirPlay client.

A Sink is an interface that needs to be implemented to handle the audio and from the AirPlay client.

For more specific needs the API exposes CreateRecordRegistrar for registering arbitrary entries.

Examples

func main() { keyfilename := "/tmp/airport.key" airplayers, err = raopd.NewSinkCollection(keyfilename) if err != nil { panic(err) }

sc := make(chan os.Signal)
signal.Notify(sc)
go func() {
	for {
		s := <-sc
		slog.Info("Received Signal: ", s)
		if s == os.Interrupt || s == os.Kill || s == syscall.SIGTERM {
			shutdownAll()
		}
	}
}()

	si := &raopd.SinkInfo{
		SupportsCoverArt: true,
		SupportsMetaData: "JSON",
		Name:             name,
		HardwareAddress:  hwaddr,
		Port:             0,
	}

	sp := &SqueezePlayer{nil, si, nil, nil, nil, "", h, name}
	sp.initPlayer()

	sp.apService, err = airplayers.Register(sp)
	if err != nil {
		return nil, err
	}

airplayers.Close()

Documentation

Overview

The raop package implements a server library for AirPlay. It allows creating multiple AirPlay endpoints on a single machine for proxying sound to other systems and environments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(name string, value interface{}) error

Types

type Sink

type Sink interface {
	// Get the service info for the service.
	Info() *SinkInfo

	// Called when a source has connected
	Connected(name string)

	// SetCoverArt will set the cover art of the currently playing track.
	// May be ignored and can be disables by setting SupportsCoverArt to
	// false in AirplaySinkInfo.
	SetCoverArt(mimetype string, content []byte)

	// SetMetadata will set the metadata of the currently playing track.
	// The data is DMAP data in a JSON or XML representation. This is controlled
	// by setting SupportsMetadata in AirplaySinkInfo to "JSON" or "XML"
	SetMetadata(content string)

	// Set the volume of the output device. The volume value may be an absolute
	// value from 0 - 100, or it may be up down values using UP=1000 and DOWN=-1000
	SetVolume(volume float32)

	// Shows the progress of the track in milliseconds.
	// pos is the current position, length is the total length of the current track
	SetProgress(pos, length int)

	// Called when the stream is started.
	Play()

	// Called when the stream is paused
	Pause()

	// Called when the connection to source is terminated
	Stopped()

	// Called when the sink has been closed and removed
	Closed()
}

AirplaySink is the interface necessary to implement to act as an Airplay output device. This interface should be registered with the AirplaySinkCollection and will then be available as an airplay output.

type SinkCollection

type SinkCollection struct {
	// contains filtered or unexported fields
}

AirplaySinkCollection is is used to register AirplayerSink instances

func NewSinkCollection

func NewSinkCollection(keyfilename string) (*SinkCollection, error)

NewAirplaySinkCollection creates a new collection to register services.

func (*SinkCollection) Close

func (sc *SinkCollection) Close()

Close all services created in this registry

func (*SinkCollection) Register

func (sc *SinkCollection) Register(sink Sink) (*Source, error)

Register will create and publish a new Airplay output.

func (*SinkCollection) Unregister

func (sc *SinkCollection) Unregister(sink Sink)

Register will create and publish a new Airplay output.

type SinkInfo

type SinkInfo struct {
	// If the sink wants coverart. See SetCoverArt in AirplaySink
	SupportsCoverArt bool

	// If the client wants metadata, song info, artist and track name.
	// Should be "XML" or "JSON", if it is "" then no metadata will be supplied.
	SupportsMetaData string

	// The name of the sink
	Name string

	// The hardware address of the sink. This is used as an identifier to avoid
	// identity collision and does not need to use a real hardware address. If it is
	// set to nil the server hardware address will be used.
	HardwareAddress net.HardwareAddr

	// The port the RAOP server should start at. Set to 0 to get an ephemeral port selected at random.
	Port uint16
}

AirplaySinkInfo contains data about the AirplaySink instance.

type Source

type Source struct {
	// contains filtered or unexported fields
}

AirplaySource can be used by the audio output to emit commands back to the source.

func (*Source) Command

func (source *Source) Command(cmd string)

Command will send a DACP command to the connected source.

beginff			begin fast forward

beginrew			begin rewind

mutetoggle		toggle mute status

nextitem			play next item in playlist

previtem			play previous item in playlist

pause			pause playback

playpause		toggle between play and pauses

play			start playback

stop			stop playback

playresume		play after fast forward or rewind

shuffle_songs		shuffle playlist

volumedown		turn audio volume down (*)

volumeup			turn audio volume up (*)

(*) Do not use these, this will only affect the display and the volume sent to AirplaySink. Volume control is maintained by setting the displayed volume using the Volume and VolumeMode functions of AirplaySource.

func (*Source) NewAudioStream

func (source *Source) NewAudioStream(ctx context.Context, w io.Writer)

NewAudioStream will start a new audio output stream for the source. Only raw PCM with two channel 16-bit depth at 44100 samples/second is currently supported. The parameter ctx is a context used to close the audio output. The streamed data is sent to the writer w.

func (*Source) Port

func (source *Source) Port() uint16

Returns the port of the RAOP server. This is useful if the service was created with an ephemeral port, i.e. port==0.

func (*Source) String

func (source *Source) String() string

String returns a brief description of the service. Useful for logging and debugging.

func (*Source) Volume

func (source *Source) Volume(vol float32)

Volume will set the displayed volume on the source device if it is in AbsoluteMode. The vol parameters can be in range -30 to 0

func (*Source) VolumeMode

func (source *Source) VolumeMode(absolute bool)

VolumeMode will set the volume mode of the source device. If absolute is false then the volume changes sent to SetVolume of the AirplaySink interface will be relative, i.e. up and down volume commands. This is done by setting the volume slider on the source device to middle position and check if it is dragged right (volume up) or dragged left (volume down). Also the volume up/down buttons on the source device will send volume up/down commands to SetVolume.

If absolute is true then the volume sent to SetVolume will be in the range 0..100. and the volume slider will reflect the volume send using the Volume function in AirplaySource.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL