1

我尝试为wowza 3.6.2. 我的模块需要获取一个实例,IApplicationIdstance我发现的所有示例都是在onAppStart方法中完成的,但是当我访问 wowza 应用程序时它不会被调用。

我有以下内容:

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);
    }
....
}

应用配置:

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

我也有applications/myappconf/myapp/Application.xml

http://wowza_ip:1935/myapp在浏览器中打开,但onAppStart没有被调用,我错过了什么?

4

2 回答 2

1

原因是您的 HTTP 链接被 wowza HTTPProviders 捕获。当您访问 wowza 的“流式传输”功能(通常)时,会使用 Wowza 模块。因此,如果您将 RTMP 连接到特定的应用程序实例,那么它将起作用。此外,您可以“通过 HTTP”使用应用程序,但这需要您请求特定的 HTTP 流 URL,例如http://example.com/path/to/file.ext/playlist.m3u8

所以 wowza 在里面结合了流媒体服务器和网络服务器。

如果您想捕获此类请求,请阅读有关 HTTPProviders 的更多信息。 https://www.wowza.com/docs/http-providers

于 2013-08-09T13:18:07.793 回答
0

在这里,您可以扩展 wowza 流引擎的 HTTProvider2Base 类覆盖 onHTTPRequest。让你 jar 并放入 Wowza-install 目录/lib/ 并将其添加到 wowza 流引擎的 server.xml 中。

以下是相同的小代码:

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);
    }
}
于 2018-04-05T08:56:23.397 回答