Question

I try to build module for wowza 3.6.2. My module needs to get instance of an IApplicationIdstance, all samples I found do it in onAppStart method, however it is not called when I access wowza application.

I have following:

public class TestModule extends ModuleBase {

    public void onAppStart(IApplicationInstance appInstance) {
        String fullname = appInstance.getApplication().getName() + "/"
                + appInstance.getName();
        getLogger().info("onAppStart: " + fullname);
    }

    public void onAppStop(IApplicationInstance appInstance) {
        String fullname = appInstance.getApplication().getName() + "/"
                + appInstance.getName();
        getLogger().info("onAppStop: " + fullname);
    }
....
}

Application configuration:

    <Module>
        <Name>TestModule</Name>
        <Description>MyTestModule</Description>
        <Class>mnesterenko.TestModule</Class>
    </Module> 

Also I have applications/myapp and conf/myapp/Application.xml.

I open http://wowza_ip:1935/myapp in browser, but onAppStart is not called, what am I missing?

Était-ce utile?

La solution

the reason is that your HTTP link is catched by wowza HTTPProviders. Wowza modules are used when you access "streaming" features of wowza (in general). so if you'll do RTMP connect to specific app instance then it will work. also, you can work with application "via HTTP", however that will require you to request specific HTTP streaming URL like http://example.com/path/to/file.ext/playlist.m3u8

so wowza combines streaming server and web server inside it.

read more about HTTPProviders if you want to catch such requests. https://www.wowza.com/docs/http-providers

Autres conseils

Here you can extend the HTTProvider2Base class of wowza streaming engine overide the onHTTPRequest. Make you jar and put in Wowza-install directoy/lib/ and add the same to server.xml of wowza streaming engine.

Below is a small code for the same :

public class httpProvider extends HTTProvider2Base {

    public void onBind(IVHost vhost, HostPort hostPort) {
        super.onBind(vhost, hostPort);
        // Called when the HTTP Provider is added to the VHost it is configured for.
    }

    public void onUnbind(IVHost vhost, HostPort hostPort) {
        // Called when the VHost is shutting down for the hostPort configured
    }

    public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
        // If you omit this no authentication is checked regardless of the configuration
        if (!doHTTPAuthentication(vhost, req, resp))
            return;

        String retStr = "Hello Wowza";

        try {
            OutputStream out = resp.getOutputStream();
            byte[] outBytes = retStr.getBytes();
            out.write(outBytes);
            WMSLoggerFactory.getLogger(MyhttpProvider.class).info("HTTPHelloWowza " + resp);
        } catch (Exception e) {
            WMSLoggerFactory.getLogger(MyhttpProvider.class).error("HTTPHelloWowza ", e);
        }
    }

    @Override
    public void addDateHeader(IHTTPResponse resp) {
        // TODO Auto-generated method stub
        super.addDateHeader(resp);
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top