Hello,
I’ve been trying to access setVideoSource public method of ModuleAVMix but without any success. How can I load module dynamically during runtime and change video source based on query string parameters provided to custom HTTP provider? I want to send stream name with query param and set video/audio source based on provided parameter from HTTP provider using this public method.
IApplication applicationLoc = vhost.getApplication(applicationName);
String appInstanceStr = IApplicationInstance.DEFAULT_APPINSTANCE_NAME;
IApplicationInstance appInstance = applicationLoc.getAppInstance(appInstanceStr);
// get AVMix module instance
String className = "ModuleAVMix";
ModuleAVMix avMixModuleInstance = (ModuleAVMix)appInstance.getModuleInstance(className);
if(avMixModuleInstance != null) {
// query string parameter
String queryStr = req.getQueryString();
if (queryStr == null)
{
WMSLoggerFactory.getLogger(CLASS).warn(CLASSNAME+".onHTTPRequest: Query string missing");
return;
}
Map queryMap = HTTPUtils.splitQueryStr(queryStr);
String streamName = (String) queryMap.get("stream");
// set stream source
try {
avMixModuleInstance.setVideoSource("stream1", streamName);
avMixModuleInstance.setAudioSource("stream1", streamName);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Here is the snippet of code I’ve been trying to use. In the logs I see NullPointerException on the line where I try to get module instance ModuleAVMix avMixModuleInstance = (ModuleAVMix)appInstance.getModuleInstance(className);
Any help or suggestions would be appreciated.