Stream Manager MediaCaster API

Previously I have used the MediaCaster API to reset the active streams.

Using the knowledge of this threads

https://www.wowza.com/docs/how-to-use-the-wowza-streaming-engine-java-api-to-start-and-stop-mediacaster-streams - How to use the MediaCaster API

https://www.wowza.com/forums/showthread.php?9999-Coding-the-Stream-Manager - using the Richard’s post

Now I’m trying to create method to start the stream and I encounter the following issue.

First using the Engine Manager an application is created.

When I call my method for starting the stream

[INDENT]IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
IApplication app = vhost.getApplication(appName);
try[/INDENT]
[INDENT][/INDENT]
[INDENT]{[/INDENT]
		IApplicationInstance applicationInstance = application.getAppInstance(application.getAppInstanceNames().get(0));
		applicationInstance.startMediaCasterStream(streamName, mediaCasterType);
	}
	catch (Exception e) 
	{
		//
	}

A null pointer exception happens where I try to get the appInstance (application.getAppInstance(application.getAppInstanceNames().get(0));), same happens with (app.getAppInstance(“definst”);), because the instance hasn’t been created yet.

If I manually start the stream from stream manager it does start and after using my method can start second stream without problem after the instance is created, but I can’t use this because if I have to manually start the instance then I won’t need this method.

How is the stream started using the stream manager, how it can start it without the instance (definst) being already created?

Regards,

Hello.

Please take a look at this HTTPProvider. The second example shows how to do this:

How to parse post or get variables in an HTTPProvider

Kind regards,

Salvadore

That’s great news. Thanks for the update and glad you got this sorted out.

Kind regards,

Salvadore

Hi Salvadore,

Thank you for replying to the thread.

I’m already using HTTPProvider to call the API method, that part of the configuration is already working. In the example choosing the app instance is again done with (app.getAppInstance(“definst”):wink: which also does not work if the instance is not active.

I fixed the problem with starting the application prior to selecting the app instance and the null pointer exception is gone.

Current code is:

IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
vHost.startApplicationInstance(appName);

IApplication app = vhost.getApplication(appName);

IApplicationInstance applicationInstance = application.getAppInstance(application.getAppInstanceNames().get(0));
applicationInstance.startMediaCasterStream(streamName, mediaCasterType);

Regards,