mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
#30 - WIP Streaming audio support
This commit is contained in:
55
src/audio/stream/Stream.java
Normal file
55
src/audio/stream/Stream.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream;
|
||||
|
||||
import audio.AudioPacket;
|
||||
import audio.stream.shout.channel.IShoutChannel;
|
||||
import audio.stream.shout.server.IShoutServer;
|
||||
import sample.Listener;
|
||||
|
||||
/**
|
||||
* Streaming channel encapsulates communication with a specific server and channel.
|
||||
*/
|
||||
public class Stream implements Listener<AudioPacket>
|
||||
{
|
||||
private IShoutServer mServer;
|
||||
private IShoutChannel mChannel;
|
||||
|
||||
public Stream(IShoutServer server, IShoutChannel channel)
|
||||
{
|
||||
mServer = server;
|
||||
mChannel = channel;
|
||||
}
|
||||
|
||||
public IShoutServer getServer()
|
||||
{
|
||||
return mServer;
|
||||
}
|
||||
|
||||
public IShoutChannel getChannel()
|
||||
{
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(AudioPacket audioPacket)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
46
src/audio/stream/StreamManager.java
Normal file
46
src/audio/stream/StreamManager.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream;
|
||||
|
||||
import audio.AudioPacket;
|
||||
import audio.IAudioPacketListener;
|
||||
import controller.ThreadPoolManager;
|
||||
import sample.Listener;
|
||||
|
||||
public class StreamManager implements IAudioPacketListener, Listener<AudioPacket>
|
||||
{
|
||||
private ThreadPoolManager mThreadPoolManager;
|
||||
|
||||
public StreamManager(ThreadPoolManager threadPoolManager)
|
||||
{
|
||||
mThreadPoolManager = threadPoolManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(AudioPacket audioPacket)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<AudioPacket> getAudioPacketListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
86
src/audio/stream/StreamModel.java
Normal file
86
src/audio/stream/StreamModel.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StreamModel extends AbstractTableModel
|
||||
{
|
||||
private static final int COLUMN_CHANNEL_NAME = 0;
|
||||
private static final int COLUMN_CHANNEL_FORMAT = 1;
|
||||
private static final int COLUMN_SERVER_NAME = 2;
|
||||
|
||||
private List<Stream> mStreams = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mStreams.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
if( rowIndex <= mStreams.size())
|
||||
{
|
||||
Stream stream = mStreams.get(rowIndex);
|
||||
|
||||
if(stream != null)
|
||||
{
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_CHANNEL_NAME:
|
||||
return stream.getChannel().getName();
|
||||
case COLUMN_CHANNEL_FORMAT:
|
||||
return stream.getChannel().getSourceFormat().name();
|
||||
case COLUMN_SERVER_NAME:
|
||||
return stream.getServer().getName();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column)
|
||||
{
|
||||
switch(column)
|
||||
{
|
||||
case COLUMN_CHANNEL_NAME:
|
||||
return "Channel";
|
||||
case COLUMN_CHANNEL_FORMAT:
|
||||
return "Format";
|
||||
case COLUMN_SERVER_NAME:
|
||||
return "Server";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
27
src/audio/stream/shout/channel/IShoutChannel.java
Normal file
27
src/audio/stream/shout/channel/IShoutChannel.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.channel;
|
||||
|
||||
import audio.stream.shout.source.ShoutSourceFormat;
|
||||
|
||||
public interface IShoutChannel
|
||||
{
|
||||
public String getName();
|
||||
public ShoutSourceFormat getSourceFormat();
|
||||
}
|
||||
38
src/audio/stream/shout/channel/ShoutChannel.java
Normal file
38
src/audio/stream/shout/channel/ShoutChannel.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.channel;
|
||||
|
||||
import audio.stream.shout.source.IShoutSource;
|
||||
|
||||
public class ShoutChannel
|
||||
{
|
||||
private String mName;
|
||||
private IShoutSource mShoutSource;
|
||||
|
||||
public ShoutChannel(String name, IShoutSource shoutSource)
|
||||
{
|
||||
mName = name;
|
||||
mShoutSource = shoutSource;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
24
src/audio/stream/shout/server/IShoutServer.java
Normal file
24
src/audio/stream/shout/server/IShoutServer.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.server;
|
||||
|
||||
public interface IShoutServer
|
||||
{
|
||||
public String getName();
|
||||
}
|
||||
35
src/audio/stream/shout/server/ShoutServer.java
Normal file
35
src/audio/stream/shout/server/ShoutServer.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.server;
|
||||
|
||||
public abstract class ShoutServer implements IShoutServer
|
||||
{
|
||||
private String mName;
|
||||
|
||||
public ShoutServer(String name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
24
src/audio/stream/shout/source/IShoutSource.java
Normal file
24
src/audio/stream/shout/source/IShoutSource.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.source;
|
||||
|
||||
public interface IShoutSource
|
||||
{
|
||||
public ShoutSourceFormat getFormat();
|
||||
}
|
||||
27
src/audio/stream/shout/source/MP3ShoutSource.java
Normal file
27
src/audio/stream/shout/source/MP3ShoutSource.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.source;
|
||||
|
||||
public class MP3ShoutSource extends ShoutSource
|
||||
{
|
||||
public MP3ShoutSource()
|
||||
{
|
||||
super(ShoutSourceFormat.MP3);
|
||||
}
|
||||
}
|
||||
34
src/audio/stream/shout/source/ShoutSource.java
Normal file
34
src/audio/stream/shout/source/ShoutSource.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.source;
|
||||
|
||||
public abstract class ShoutSource implements IShoutSource
|
||||
{
|
||||
private ShoutSourceFormat mFormat;
|
||||
|
||||
public ShoutSource(ShoutSourceFormat format)
|
||||
{
|
||||
mFormat = format;
|
||||
}
|
||||
@Override
|
||||
public ShoutSourceFormat getFormat()
|
||||
{
|
||||
return mFormat;
|
||||
}
|
||||
}
|
||||
24
src/audio/stream/shout/source/ShoutSourceFormat.java
Normal file
24
src/audio/stream/shout/source/ShoutSourceFormat.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* 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.stream.shout.source;
|
||||
|
||||
public enum ShoutSourceFormat
|
||||
{
|
||||
MP3;
|
||||
}
|
||||
Reference in New Issue
Block a user