See the sample code below:
When streaming to
IceCast, performing an
_broadCast.UpdateTitle just works, whereas setting the
iceCast.StreamDescription or
iceCast.StreamName needs a reconnect.
Since a reconnect cycle takes somwehere between 300 and 1000 milliseconds it seems expensive.
So:
- Can I do this without a reconnect? (if so: how?)
- If not: why is the reconnect needed?
DOES NOT WORK:
public void UpdateStreamDescription(string streamDescription)
{
if (_broadCast != null)
{
IStreamingServer streamingServer = _broadCast.Server;
ICEcast iceCast = streamingServer as ICEcast;
if (null != iceCast)
iceCast.StreamDescription = streamDescription;
Logger.WriteVerbose(null, "UpdateStreamDescription", this, streamDescription);
}
}
public void UpdateStreamName(string streamName)
{
if (_broadCast != null)
{
IStreamingServer streamingServer = _broadCast.Server;
ICEcast iceCast = streamingServer as ICEcast;
if (null != iceCast)
iceCast.StreamName = streamName;
Logger.WriteVerbose(null, "UpdateStreamName", this, streamName);
}
}
WORKS:
public void UpdateSongTitle(string songTitle)
{
if (_broadCast != null)
{
string url = "http://IcecastUrl";
_broadCast.UpdateTitle(songTitle, url);
Logger.WriteVerbose(null, "UpdateSongTitle", this, songTitle, url);
}
}
public void UpdateStreamDescription(string streamDescription)
{
if (_broadCast != null)
{
IStreamingServer streamingServer = _broadCast.Server;
ICEcast iceCast = streamingServer as ICEcast;
if (null != iceCast)
if (iceCast.StreamDescription != streamDescription)
{
iceCast.StreamDescription = streamDescription;
Reconnect();
Logger.WriteVerbose(null, "UpdateStreamDescription", this, streamDescription);
}
}
}
public void UpdateStreamName(string streamName)
{
if (_broadCast != null)
{
IStreamingServer streamingServer = _broadCast.Server;
ICEcast iceCast = streamingServer as ICEcast;
if (null != iceCast)
{
iceCast.StreamName = streamName;
Reconnect();
Logger.WriteVerbose(null, "UpdateStreamName", this, streamName);
}
}
}
public virtual void Reconnect()
{
if (_broadCast.IsConnected)
{
_broadCast.Disconnect();
}
if (!_broadCast.AutoConnect())
{
Logger.WriteVerbose(null, "Reconnect", this, "Not connected!");
}
}