Hey guys,
I’m using an overloaded version of serviceMsg() to modify HLS playlists a they’re delivered; specifically for adding program timing and for adding CORS headers. In essence I have this:
public class ModuleVisualplatformStreamCupertinoPlaylistHandler extends HTTPStreamerAdapterCupertinoStreamer {
public void serviceMsg(long timestamp, IoSession ioSession, RtmpRequestMessage req, RtmpResponseMessage resp) {
super.serviceMsg(timestamp, ioSession, req, resp);
// Add CORS header
resp.setHeader(“Access-Control-Allow-Origin”, “*”);
// Modify playlist
decorateWithProgramDate()
}
}
To read out the playlist from the response, I’m doing this to decode the response body:
List bufferlist = resp.getBodyList();
Charset charset = Charset.forName(“UTF-8”);
CharsetDecoder decoder = charset.newDecoder();
StringBuffer originalData = new StringBuffer();
int i = 0;
for (ByteBuffer buffer : bufferlist) {
try {
originalData.append(buffer.getString(decoder));
i++;
} catch (Exception e){
log("Could not append buffer.getString(decoder) to originalData for stream, " + i + “/” + bufferlist.size());
e.printStackTrace();
}
}
This however results in an exception in a limited set of cases:
-
It always works for non-DVR request.
-
When a new stream start, it works well for DVR requests as well.
-
After “a while” (say, 30 minutes, but this is not consistent) DVR requests fire an exception (see below).
-
If I restart the same stream, requests return without exception.
Crucially, the requests themselves return data to the client even if there’s an exception on the way (a full list of all relevant chunks, though of course without the lines I’m trying to add).
The exception is:
2014-08-18_15:21:27.21809 INFO server comment - Playlist Handler: Could not append buffer.getString(decoder) to originalData for stream, 0/1
2014-08-18_15:21:27.21847 java.nio.charset.MalformedInputException: Input length = 1
2014-08-18_15:21:27.21876 at java.nio.charset.CoderResult.throwException(CoderResult.java:277)
2014-08-18_15:21:27.21893 at org.apache.mina.common.ByteBuffer.getString(ByteBuffer.java:1022)
2014-08-18_15:21:27.21909 at com.wowza.wms.plugin.visualplatform.ModuleVisualplatformStreamCupertinoPlaylistHandler.decorateWithProgramDate(ModuleVisualplatformStreamCupertinoPlaylistHandler.java:77)
2014-08-18_15:21:27.21925 at com.wowza.wms.plugin.visualplatform.ModuleVisualplatformStreamCupertinoPlaylistHandler.serviceMsg(ModuleVisualplatformStreamCupertinoPlaylistHandler.java:57)
2014-08-18_15:21:27.21942 at com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.HTTPStreamerAdapterCupertinoStreamer.service(HTTPStreamerAdapterCupertinoStreamer.java:422)
2014-08-18_15:21:27.21958 at com.wowza.wms.server.ServerHandler.a(ServerHandler.java:636)
2014-08-18_15:21:27.21974 at com.wowza.wms.server.ServerHandler.a(ServerHandler.java:375)
2014-08-18_15:21:27.21991 at com.wowza.wms.server.ServerHandler.messageReceived(ServerHandler.java:487)
2014-08-18_15:21:27.22007 at com.wowza.wms.server.ServerHandlerThreaded.messageReceived(ServerHandlerThreaded.java:78)
2014-08-18_15:21:27.22023 at org.apache.mina.common.support.AbstractIoFilterChain$2.messageReceived(AbstractIoFilterChain.java:181)
2014-08-18_15:21:27.22039 at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:511)
2014-08-18_15:21:27.22055 at org.apache.mina.common.support.AbstractIoFilterChain.access$900(AbstractIoFilterChain.java:42)
2014-08-18_15:21:27.22071 at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:786)
2014-08-18_15:21:27.22087 at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProtocolDecoderOutput.java:60)
2014-08-18_15:21:27.22104 at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:177)
2014-08-18_15:21:27.22120 at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:511)
2014-08-18_15:21:27.22137 at org.apache.mina.common.support.AbstractIoFilterChain.access$900(AbstractIoFilterChain.java:42)
2014-08-18_15:21:27.22153 at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:786)
2014-08-18_15:21:27.22173 at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:247)
2014-08-18_15:21:27.22189 at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:323)
2014-08-18_15:21:27.22205 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
2014-08-18_15:21:27.22222 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
2014-08-18_15:21:27.22239 at java.lang.Thread.run(Thread.java:679)
Hopefully, the above is enough of a description to trigger good ideas. I really do appreciate the help.