mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 09:37:36 -05:00
Note: Shoutcast V1 streaming to a Shoutcast V2.5.x server seems to be problematic. The newer server tracks MP3 boundaries in order to insert advertising and this appears to have problems keeping sync with the MP3 stream. I spent significant time eliminating MP3 framing errors in my code. You can see these 'Bad frame' errors in the sc_serv.log and the shoutcast server will eventually reset the connection after a period of time or after a number of framing errors occur. I anticipate that streaming to a Shoutcast V2 server using the ultravox (ie V2.x) protocol may resolve this issue.
96 lines
2.8 KiB
Java
96 lines
2.8 KiB
Java
/*******************************************************************************
|
|
* sdrtrunk
|
|
* Copyright (C) 2014-2016 Dennis Sheirer
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
*
|
|
******************************************************************************/
|
|
package audio.broadcast.shoutcast.v1;
|
|
|
|
import audio.broadcast.BroadcastFormat;
|
|
|
|
public enum ShoutcastMetadata
|
|
{
|
|
AIM("icy-aim:"),
|
|
AUDIO_BIT_RATE("icy-br:"),
|
|
CHANNELS("icy-channels:"),
|
|
CONTENT_TYPE("Content-Type:"),
|
|
DESCRIPTION("icy-description:"),
|
|
GENRE("icy-genre:"),
|
|
ICE_AUDIO_INFO("ice-audio-info:"),
|
|
ICQ("icy-icq:"),
|
|
INTERNET_RELAY_CHAT("icy-irc:"),
|
|
METADATA_INTERVAL("icy-metaint:"),
|
|
METADATA_REQUEST("icy-metadata:"),
|
|
PRE_BUFFER("icy-prebuffer:"),
|
|
PUBLIC("icy-pub:"),
|
|
RESET("icy-reset:"),
|
|
SERVER("server:"),
|
|
STREAM_NAME("icy-name:"),
|
|
SONG_TITLE("icy-title:"),
|
|
URL("icy-url:"),
|
|
USER_AGENT("User-Agent:"),
|
|
UNKNOWN("Unknown");
|
|
|
|
private String mTag;
|
|
|
|
private ShoutcastMetadata(String tag)
|
|
{
|
|
mTag = tag;
|
|
}
|
|
|
|
public static final String COMMAND_TERMINATOR = "\n";
|
|
|
|
public String toString()
|
|
{
|
|
return mTag;
|
|
}
|
|
|
|
/**
|
|
* Encodes the metadata tag and value with an end-of-line character, appropriate for sending over the network.
|
|
*/
|
|
public String encode(String value)
|
|
{
|
|
if(value != null && !value.isEmpty())
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(mTag).append(value).append(COMMAND_TERMINATOR);
|
|
return sb.toString();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public String encode(boolean value)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(mTag).append(value ? "1" : "0").append(COMMAND_TERMINATOR);
|
|
return sb.toString();
|
|
}
|
|
|
|
public String encode(BroadcastFormat broadcastFormat)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(mTag).append(broadcastFormat.getValue()).append(COMMAND_TERMINATOR);
|
|
return sb.toString();
|
|
}
|
|
|
|
public String encode(int value)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(mTag).append(String.valueOf(value)).append(COMMAND_TERMINATOR);
|
|
return sb.toString();
|
|
}
|
|
}
|