sergey-dryabzhinsky / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
1.02k stars 214 forks source link

Drop ngx-local-relay client through control submodule #96

Open salemgolemugoo opened 8 years ago

salemgolemugoo commented 8 years ago

Hi, guys. I'm trying to avoid using external applications like FFmpeg. My config:

rtmp {
    server {
        listen 1935;

        live on;
        record off;

        application live {
            push rtmp://127.0.0.1/one;
            push rtmp://127.0.0.1/two;
        }

        application one {
                on_publish http://php_app/rtmp/publish;
        }

        application two {
                on_publish http://php_app/rtmp/publish;
        }
    }
}

When I start streaming by OBS, i see: http://prntscr.com/aj7rs0 At http://php_app/rtmp/publish - there is some kind of redirecting logic to external streaming services.

When I drop connection by sending a request to http://rtmphost/control/drop/publisher?app=youtube&name=re_admin_8e2218e4ffb0fdf9c41c362580b3c5d6 or http://rtmphost/control/drop/client?app=live&name=re_admin_8e2218e4ffb0fdf9c41c362580b3c5d6&clientid=41, connection drops, but after 3 seconds it appears again.

Can I drop connection permanently?

sergey-dryabzhinsky commented 8 years ago

You can't prevent client from connect by that. You need to process on_connect <url> event handler, or on_play <url>. If someone unwanted connecting to unwanted app, or trying to play unplayable - just return 404/500 by <url>.

salemgolemugoo commented 8 years ago

I think there is a misunderstanding between us. See, I'm trying to reach something like that: The client has access to stream to 2 external services. Rtmp module initially redirects the client to all available services (for example 5), then I drop unnecessary services, and leave only 2 of them. So I can't drop initial connection from the client (on_connect or on_play), because it drops all of them.

                                               |----- youtube      -> continue play
client ->  Initial app --> (internal redirect) |----- twitch          -> continue play
                                               |----- goodgame  -> drop connection to this external service only
sergey-dryabzhinsky commented 8 years ago

Ah, something like dynamic publish-relay.

There is no way except constantly drop publishing via on_publish handler. Or you can try to redirect stream to null app via 301 location answer via handler:

Location /null/<stream-name>

Which deny play for all.

salemgolemugoo commented 8 years ago

Hm, I'll try, thx.