Switch to unified view

a b/doc/scmulti.txt
1
= Managing multiroom audio with Linn Songcast and upmpdcli
2
3
== What is Linn Songcast
4
5
*Songcast* is a protocol for transporting audio streams across the network,
6
developped by link:http://oss.linn.co.uk/trac/wiki/Songcast[Linn] as a
7
series of open-source libraries and applications.
8
9
There are two types of entities involved in the protocol:
10
11
 - A *Songcast* _Sender_ generates an audio stream.
12
 - A *Songcast* _Receiver_, which typically runs on an OpenHome Renderer,
13
   receives the stream and plays it.
14
15
The streams transported by *Songcast* are actual real-time audio data, which
16
can go straight to an audio card for playing.
17
18
Controlling the streams (connecting, starting, stopping) is
19
done through an UPnP service named OpenHome __Receiver__, which runs on an
20
UPnP Media Renderer implementing the OpenHome services.
21
22
The typical use of *Songcast* is to have an audio driver on a Windows or OS X
23
desktop capture and forward the audio stream to a remote *Songcast* device
24
(this is the main purpose of the *Songcast* Mac and Windows applications,
25
apart from actually controlling the audio destination).
26
27
Any application on the desktop will (be compelled to) transparently play to
28
the remote device, without need to know anything about *Songcast*.
29
30
== Multiple Receivers
31
32
Multiple _Receiver_ hosts can connect to the same _Sender_, so that they
33
will all be playing the same audio.
34
35
The Mac and Windows *Songcast* apps only let you connect the _Sender_ to one
36
Receiver though.
37
38
*upmpdcli* now includes a small application which can list the state of
39
the local *Songcast* Receivers, make a Receiver play from the same URI as
40
another one (for building multiroom groups), or return a Media Renderer
41
from Receiver to normal operation.
42
43
The functions can be accessed either from the *scctl* command line utility,
44
or from a local Web application (as Songcast is mostly used from a Windows
45
or Mac PC, it would be inconvenient to have to access the Linux command
46
line to control the multiroom groups).
47
48
This has only be tested with *upmpdcli* and its link:sc2mpd.html[sc2mpd]
49
*Songcast* auxiliary process as Receiver implementation, but I'd guess that
50
there is a good chance it would work with others.
51
52
This is very preliminary for now and there are a number of issues, I hope
53
to improve them, but for now, this is definitely an _early adopters_ system:
54
55
  - The initial synchronisation when forming the group is very bad. To
56
    resynchronize everything, stop or pause the playing on the PC (from the
57
    player, e.g. Media Player, not from the Songcast utility), wait for the
58
    audio to drain, and a few seconds more, then restart playing.
59
60
  - It's quite easy to put the system in a confused state where nothing
61
    seems to work any more. Stopping all Receivers (with *scctl* or the Web
62
    interface) and restarting the PC will normally get things back to
63
    sanity, but it will sometimes be necessary to restart everything.
64
    *Always give the commands a little time to take effect*. Especially,
65
    it's quite common that the audio will not begin to play for around
66
    10 S after activation from the *Songcast* PC interface. Clicking on
67
    stuff too early is the surest way to get into bad states, always give
68
    10 S to the system when things seem to not be happening.
69
70
  - _The following problem seems to be gone from the latest *Songcast*
71
    code_ (which is used by the current `ohbuild.sh` script).  Songcast can
72
    be transported by either unicast or multicast IP. multicast is of
73
    course much better for the network load, but I seem to have seen random
74
    *sc2mpd* crashes with it. I am not sure of the cause (may be not linked
75
    to multicast at all), but if you experience random *sc2mpd* crashes,
76
    switch *Songcast* to unicast (in the PC Songcast app advanced
77
    configuration panel. Unicast is the default).
78
79
80
== Setting things up
81
82
The following seems to work for me:
83
84
 - Remove libupnpp and upmpdcli packages from the system to avoid confusion
85
 - Clone the libupnpp, upmpdcli and sc2mpd repositories from
86
   link:https://github.com/[GitHub]
87
 - Follow the usual procedure to build. This should just be the usual for
88
   libupnpp and upmpdcli:
89
    
90
    sh autogen.sh
91
    ./configure --prefix=/usr
92
    make
93
    sudo make install
94
95
 - For sc2mpd, things are a small bit more complicated, see the _Building
96
   sc2mpd_ section in link:sc2mpd.html[this document].
97
 - Repeat the above steps on all the machines which you want to be Receivers.
98
 - Activate a Receiver from the PC *Songcast* interface. Play something and
99
   leave it playing.
100
 - Use either *scctl* (`scctl -h` prints a simple help message), or the Web
101
   interface (see further) to associate other Receivers to the same Sender.
102
 - Stop or Pause the music. Wait 10 S, restart. *_Multiroom !_*
103
104
Once the slave Receivers are associated with the Sender, they should stay
105
in this state until you change it. So you can stop/start Songcast on the
106
PC, and they will usually just follow.
107
108
An "associated" Receiver is just one which plays from the same URI, it
109
keeps no other relation to the "Master". Only one Receiver is a bit special
110
because it is the one known from the PC, but there is no specific reason to
111
use it as Master, the Master is only used to get the URI. Avoid changing
112
the state of the "PC"l Receiver from outside the PC *Songcast* interface,
113
this can only confuse things.
114
115
Every time you change the group configuration, you need to resynchronize
116
the audio by pausing, waiting, restarting.
117
118
I do know that the whole thing is not very solid, this is a prototype and I
119
hope to improve some of the issues in the future: constructive problem
120
reports are more than welcome, but no flaming (for now) please :)
121
122
123
== Controlling the Songcast groups from the Web interface
124
125
To avoid having to access the command line interface to control the
126
*Songcast* groups, *upmpdcli* comes with a small Web server which uses
127
*scctl* to actually do the work. This is found inside the `web/`
128
subdirectory inside the *upmpdcli* source tree.
129
130
The server is based on the 
131
link:http://bottlepy.org/docs/dev/index.html[Bottle Python Web Framework]
132
and it only depends on Python (version 2 and 3 are supported by *Bottle*,
133
but the current app only works with Python 2).
134
135
I'll find ways to autostart the server in the future, but for now, 
136
use the `scweb-standalone.py` script to manually start it:
137
    
138
    python2 ./scweb-standalone.py
139
140
This will start a server on localhost, on port 8777 which is good for
141
testing, but not very useful. Use the -a 0.0.0.0 option to let the server
142
answer on all local addresses (or specify the address to use a specific
143
interface):
144
145
    python2 ./scweb-standalone.py -a 0.0.0.0
146
147
-p can be used to specify a port.
148
149
Once started, connecting to the server from any browser should hopefully
150
display a reasonably self-explanatory interface.
151