Following up on this, the release notes for 4.0.4 state that:
-
Added support to Apple HLS (cupertino) live stream packetizer to provide a IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler class to control how chunks are numbered
-
LiveStreamPacketizerCupertino.setChunkIdHandler(IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHan dler chunkIdHandler)
-
Added LiveStreamPacketizers/Properties string property cupertinoChunkIdHandlerClass to specify full Java path to a class that implements IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler to control how cupertino chunks are numbered
-
Added IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler interface to control how cupertino chunks are numbered
-
void init(LiveStreamPacketizerCupertino liveStreamPacketizer);
-
long onAssignChunkId(HTTPStreamerCupertinoLiveStreamPacketizerChunkIdContext chunkIdContext);
This in turn is a way of saying that there’s now an interface to handle which number is assigned to an HLS chunk (which were previously just number sequentially). Matt notes that this can be controlled by a property in settings, but it’s also fairly easy to do programatically (and I wanted to keep my module structure).
My code to number chunks by the epoch time in milliseconds of their creation looks like this:
import com.wowza.wms.module.*;
import com.wowza.wms.application.*;
import com.wowza.wms.httpstreamer.cupertinostreaming.livestreampacketizer.*;
import com.wowza.wms.stream.livepacketizer.*;
public class MyWowzaModule extends ModuleBase {
public void onAppStart(IApplicationInstance appInstance) {
// We want to set chunk numbers for cupertino streaming; this is done first by listening to the live stream packetizers
appInstance.addLiveStreamPacketizerListener(new LiveActionNotify(appInstance));
}
/*** CHUNK NUMBER HANDLING
Set chunk numbers by the epoch time (in milliseconds) of their creation
***/
class CupertinoChunkIdHandler implements IHTTPStreamerCupertinoLiveStreamPacketizerChunkIdHandler {
public void init(LiveStreamPacketizerCupertino liveStreamPacketizer) {}
public long onAssignChunkId(HTTPStreamerCupertinoLiveStreamPacketizerChunkIdContext chunkIdContext) {
return System.currentTimeMillis();
}
}
class LiveActionNotify implements ILiveStreamPacketizerActionNotify {
public LiveActionNotify(IApplicationInstance appInstance) {}
public void onLiveStreamPacketizerCreate(ILiveStreamPacketizer liveStreamPacketizer, String streamName) {}
public void onLiveStreamPacketizerDestroy(ILiveStreamPacketizer liveStreamPacketizer) {}
public void onLiveStreamPacketizerInit(ILiveStreamPacketizer liveStreamPacketizer, String streamName) {
while(true) {
if (!(liveStreamPacketizer instanceof LiveStreamPacketizerCupertino)) break;
LiveStreamPacketizerCupertino cupertinoPacketizer = (LiveStreamPacketizerCupertino)liveStreamPacketizer;
cupertinoPacketizer.setChunkIdHandler(new CupertinoChunkIdHandler());
break;
}
}
}
}
This is awesome. It really is.
More wants more though: Is there any ways to do the same thing for DVR chunks?