How do I stream to a specific application instance?

I’m trying to programmatically republish a VOD stream to the “live” application of the same server.

I have this:

public void republishStream(String streamName) {
		getLogger().info("Republishing stream " + streamName + " "+ appInstance.getName());
		IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
		vhost.startApplicationInstance("live", appInstance.getName());
		streamCopy = Stream.createInstance(vhost, "live/"+appInstance.getName(), "audio");
        if(streamCopy.play(streamName,delay,-1,false)){...

If I change this line:

Stream.createInstance(vhost, "live/"+appInstance.getName(), "audio");

To

Stream.createInstance(vhost, "live", "audio");

It’ll work, but I’d like to stream to something other than the “definst” channel.

How can I do this?

Oh, got it:

IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
vhost.startApplicationInstance("live", appInstance.getName());
IApplication app = vhost.getApplication("live");
IApplicationInstance instance = app.getAppInstance(appInstance.getName());
streamCopy = Stream.createInstance(instance, "audio");

I hope this helps someone else in the future

Thank you for the update and for posting a solution. Glad you were able to sort this out.

Regards,

Salvadore