getDvrRecorder returns null for a stream

I am seeing the value null returned when I call getDvrRecorder on an IMediaStream object. This happens as soon as the stream is published from onPublish. I am using the stream object to get the default dvr recorder (’IDvrConstants.DVR_DEFAULT_RECORDER_ID). It’s always returning null. I also have nDVR enabled in my streaming engine. However, I noticed that if I delay the call to getDvrRecorder, the dvr recorder is available which makes me think that the dvr recorder for a stream is not available as soon as the the stream is publish. My question is what is the correct event hook I need to be waiting for to guarantee that the dvr recorder is initialized and available for a stream.

Welcome to the forums! I’m looking into this for you…

Per our technical support team:

ApplicationInstance has an addDvrRecorderListener() method.

Register a ILiveStreamDvrRecorderActionNotify listener on this and then listen for onLiveStreamDvrRecorderInit() calls

If you’d like some assistance with it, you can have an engineer work with you in a support ticket.

(I’m gathering a code sample for you…be back shortly.)

Update:
Re:the reference to the dvr recorder may be too soon as it may not be available yet. After some packets are in- A different way to accommodate this would be to utilize the ILiveStreamDvrRecorderActionNotify and ILiveStreamDvrRecorderControl interfaces where you’ll just need to specify the new recording name within the onLiveStreamDvrRecorderCreate event. Please see the following:


class DVRManualControl extends ModuleBase{
public void onAppStart(IApplicationInstance appInstance) {
appInstance.setLiveStreamDvrRecorderControl(new DVRController());
appInstance.addDvrRecorderListener(new DVRActionNotify());
}

class DVRActionNotify implements ILiveStreamDvrRecorderActionNotify{

/// Set the recording name in this event

@Override
public void onLiveStreamDvrRecorderCreate(
ILiveStreamDvrRecorder recorder, String streamName) {
recorder.setRecordingName(streamName+"_recorder");
WMSLoggerFactory.getLogger(getClass()).info("Set recording name as "+streamName+"_recorder");
}

@Override
public void onLiveStreamDvrRecorderDestroy(
ILiveStreamDvrRecorder recorder) {

}

@Override
public void onLiveStreamDvrRecorderInit(
ILiveStreamDvrRecorder recorder, String streamName) {

}
}

/// Tell DVR recorder to record
class DVRController implements ILiveStreamDvrRecorderControl{
@Override
public boolean shouldDvrRecord(String recorderName, IMediaStream stream) {
WMSLoggerFactory.getLogger(getClass()).info("Should DVR the following stream "+recorderName);
return true;
}
}
}
1 Like