on demand external stream

270 views
Skip to first unread message

changosurf

unread,
Sep 7, 2011, 5:02:36 PM9/7/11
to C++ RTMP Server
Hi,
Im trying to setup a set of 'on demand' live external streams, and I
need to know if it can be done using one of the default applications
and/or the default functionality of crtmpserver...

i.e., i want to be able to setup a bunch of live external streams that
use rtmpd as a proxy (I also need to configure the proxy/swf
verification parameters for each live stream; swfUrl, pageUrl,
emulateUserAgent,etc. ). However, I need for rtmpd to connect to each
of the streams 'on demand', only when a user connects to rtmpd and
requests a given external stream.

I managed to configure a working external stream using the default
'FLV Playback Sample' application, but the problem is that crtmpserver
will automatically connect to & start receiving the stream on start-up
(regardless of whether a user has requested the stream or not). This
is inefficient since it robs the server of bandwidth & resources. What
I'd like is for crtmpserver to connect & receive the external stream
*only* once it has been requested, and then disconnect/stop receiving
the stream once there are no longer any users requesting it.

Is this currently possible using the default functionality
(proxypublish?) ???
If so, how would I go about configuring this???
if its not possible, what would need to be done to achieve it?

Please help, thanks,
cs

changosurf

unread,
Sep 15, 2011, 4:07:06 PM9/15/11
to C++ RTMP Server
bump...
It doesnt seem that there is very much active support for rtmpd; no
one has replied to my help requests...are the main developers still
actively supporting this project?
please help,
thanks,
cs


On Sep 7, 2:02 pm, changosurf <changos...@gmail.com> wrote:
> Hi,
> Im trying to setup a set of 'ondemand' liveexternalstreams, and I
> need to know if it can be done using one of the default applications
> and/or the default functionality of crtmpserver...
>
> i.e., i want to be able to setup a bunch of liveexternalstreams that
> use rtmpd as a proxy (I also need to configure the proxy/swf
> verification parameters for each live stream; swfUrl, pageUrl,
> emulateUserAgent,etc. ). However, I need for rtmpd to connect to each
> of the streams 'ondemand', only when a user connects to rtmpd and
> requests a givenexternalstream.
>
> I managed to configure a workingexternalstream using the default

Kevin Ross

unread,
Sep 15, 2011, 11:09:01 PM9/15/11
to c-rtmp...@googlegroups.com
I created a patch that auto-reconnects when the external stream gets disconnected for whatever reason. My next task is to look into the "on-demand" functionality like you mention.  Wowza does this, and works quite well, but I want a free program that does it. :)  If you need a solution now, have a look at Wowza.  They have a free developer edition that allows up to 10 concurrent connections.

BTW, I'm not one of the crtmpd developers, just a user adding the functionality that I need.

-- Kevin

Max Lapshin

unread,
Sep 16, 2011, 1:06:44 AM9/16/11
to c-rtmp...@googlegroups.com
On Fri, Sep 16, 2011 at 7:09 AM, Kevin Ross <kvnr...@gmail.com> wrote:
> I created a patch that auto-reconnects when the external stream gets
> disconnected for whatever reason.

Do you realize, that it is rather hard task to do it really right? =))

RTSP camera change timestamps on each reconnect, so you need to change
it properly.

cs

unread,
Sep 16, 2011, 2:21:30 AM9/16/11
to c-rtmp...@googlegroups.com

Kevin,

Thanks for the feedback; its great to hear that someone else finds this idea as being worthwhile.

BTW, where’s your patch? Id like to check it out if you don’t mind.

 

Ive managed to make some changes to the ‘flvplayback’ app so that external streams aren’t pulled at server startup, but are instead pulled right before stream initialization when a client requests a stream (assuming a given stream name has been defined as an external stream). More specifically, Ive over-ridden some of the functions that handle the ‘external stream’ routines, so that the streams aren’t automatically pulled when the app initializes. This seems to work fine so far for the rtmp streams Im working with; the first client to request an externally-defined stream will initiate the stream pull, all subsequent requests for that same external stream will be ignored (since there’s already built-in logic to disable duplicate stream creation by name).  Right now, its not very elegant, but it seems to do the job. I can share what Ive done so far if anyone is interested in helping…

 

The problem now is ‘how to disconnect an idle/unused external stream once there are no longer any clients subscribing to that stream?’

Im figuring that the next step is to dig into the stream-management code and find a relatively simple, unobtrusive way to keep track of connected users (on a per-stream basis, via stream name or stream ID?), and then find an effective point in to code to hook into in order to run a ‘check_if_any_clients_are_still_connected_to_any_running_external_streams()’ routine: if an external stream is running without any clients, its time to shut it down (obviously, I need help figuring out how to implement the above two items; the activeClient count and the active check routine).

 

Anymore feedback would be greatly appreciated.

Thanks,

cs

You received this message because you are subscribed to "C++ RTMP Server" mailing list.
To post to this group, send email to c-rtmp...@googlegroups.com
To unsubscribe from this group, send email to
c-rtmp-serve...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/c-rtmp-server?hl=en

Kevin Ross

unread,
Sep 19, 2011, 11:59:17 PM9/19/11
to c-rtmp...@googlegroups.com
I posted the patch in the auto reconnect thread.

My plan is to hook the SignalStreamRegistered and SignalStreamUnRegistered notifications in FLVPlaybackApplication, and keep my own ref counts for the streams.  These notifications are called both for incoming and outgoing streams.  I'll only be interested in outgoing (clients).  When an outgoing stream connects, the callback includes the stream name.  I'll use that to maintain my own ref counts.  When the ref count goes to zero, I'll call EnqueueForDelete on the stream.  When the ref count increases again, I'll call PullExternalStream for the desired stream.

-- Kevin

Kevin Ross

unread,
Sep 20, 2011, 12:02:49 AM9/20/11
to c-rtmp...@googlegroups.com
On Monday, September 19, 2011 8:59:17 PM UTC-7, Kevin Ross wrote:
When the ref count goes to zero, I'll call EnqueueForDelete on the stream.

I meant I'll call EnqueueForDelete on the corresponding incoming stream, not the outgoing (client) stream.

cs

unread,
Sep 20, 2011, 2:19:06 AM9/20/11
to c-rtmp...@googlegroups.com

Kevin,

I think we ended up having the same concept.

Ive attached my source files.

I’ve managed to put something together that’s working so far…

Take a look, give it a try and let me know how it goes.

 

Basically, what happens is that the external stream config data is loaded on app. initialization, but the streams aren’t actually pulled at that point.

The pulling starts only once a new stream is registered that matches an external stream by name.

I overrode the stream pull/reg/unreg functions and added logic to launch the external streams, keep track of them, and then kill them once no clients are left.

 

Im still not comfortable working with the variant/maps that are common in the rtmpd source, so my book keeping methods are probably really ugly & inefficient (see the _external* class variables Ive added).

The stream killing method that I used is pretty ‘brute force’; there’s probably a better, cleaner way to do it, but for now it works…

If you can help come up with a more elegant, more efficient way to keep track of the streams, please share…

 

Thanks,

cs

You received this message because you are subscribed to "C++ RTMP Server" mailing list.

on_demand.zip

cs

unread,
Sep 20, 2011, 2:29:21 AM9/20/11
to c-rtmp...@googlegroups.com

I Forgot to mention, I performed a pretty ugly ‘cludge’ to distinguish which types of streams I was interested in.

In my case, I was only concerned with the streams of type ‘ONR4R’, and Im kinda embarrassed about the way I went about it, it looks really bad.

                string target_type="ONR4R";

                string source_type=STR(tagToString(pStream->GetType()));

                if (target_type.compare(source_type)==0){

Anyway, it works, but I think it definitely could use help…

Thanks,

cs

 

From: c-rtmp...@googlegroups.com [mailto:c-rtmp...@googlegroups.com] On Behalf Of Kevin Ross


Sent: Monday, September 19, 2011 9:03 PM
To: c-rtmp...@googlegroups.com

You received this message because you are subscribed to "C++ RTMP Server" mailing list.

Kevin Ross

unread,
Sep 20, 2011, 2:53:48 AM9/20/11
to c-rtmp...@googlegroups.com
On Monday, September 19, 2011 11:29:21 PM UTC-7, changosurf wrote:

I Forgot to mention, I performed a pretty ugly ‘cludge’ to distinguish which types of streams I was interested in.

In my case, I was only concerned with the streams of type ‘ONR4R’, and Im kinda embarrassed about the way I went about it, it looks really bad.

                string target_type="ONR4R";

                string source_type=STR(tagToString(pStream->GetType()));

                if (target_type.compare(source_type)==0){

Anyway, it works, but I think it definitely could use help…

Thanks,

cs

 



Yeah, you probably want something like:

if(TAG_KIND_OF(pStream->GetType(), ST_OUT_NET)) // any output stream type
...

 or

if(TAG_KIND_OF(pStream->GetType(), ST_OUT_NET_RTMP)) // any RTMP output stream type
...

Anyway, I've been looking over your patch, and the approach is very similar to mine, only I can't get mine to work.  When the client connects and signals the registered stream event, I call PullExternalStream on the appropriate stream, and I can see in the logs it's connected to my IP camera, but the client (using Flowplayer) just sits there forever spinning.  I don't know if it's a client problem, or a problem with my code.  I'll try yours to see if it works.  Are you using Flowplayer, by chance?

-- Kevin

cs

unread,
Sep 20, 2011, 2:57:29 AM9/20/11
to c-rtmp...@googlegroups.com

Im using openvideoplayer, http://openvideoplayer.sourceforge.net/

I’ll try implementing your stream test, it looks good…

Let me know if you have any prob’s with my patch, or if it works.

Thanks,

cs

 

From: c-rtmp...@googlegroups.com [mailto:c-rtmp...@googlegroups.com] On Behalf Of Kevin Ross


Sent: Monday, September 19, 2011 11:54 PM
To: c-rtmp...@googlegroups.com

You received this message because you are subscribed to "C++ RTMP Server" mailing list.

Kevin Ross

unread,
Sep 20, 2011, 3:54:47 AM9/20/11
to c-rtmp...@googlegroups.com
Your patch isn't working for me either, it might be a Flowplayer problem.  I'll try another player, such as OVP or JW.

Kevin Ross

unread,
Sep 20, 2011, 4:09:35 AM9/20/11
to c-rtmp...@googlegroups.com
On 09/20/2011 12:54 AM, Kevin Ross wrote:
> Your patch isn't working for me either, it might be a Flowplayer
> problem. I'll try another player, such as OVP or JW.

JW Player does the same. I haven't tried OVP, it appears to be for Flex
applications, I'm not sure though.

What version of the source are you using? I'm using the tarball,
version 575. Are you using something newer from SVN?

-- Kevin

cs

unread,
Sep 20, 2011, 4:13:45 AM9/20/11
to c-rtmp...@googlegroups.com
Im also using 575; its working for me with no probs.

You can download the ovp player package without needing to compile it with
flex.
http://openvideoplayer.sourceforge.net/ovpfl/akamai_multi_player/akamai-mult
i-player-files.zip
give it a try, ovp seems to be pretty good at just 'waiting' for a stream to
come to life (or come back from the dead).
cs

-----Original Message-----
From: c-rtmp...@googlegroups.com [mailto:c-rtmp...@googlegroups.com]
On Behalf Of Kevin Ross
Sent: Tuesday, September 20, 2011 1:10 AM
To: c-rtmp...@googlegroups.com

-- Kevin

You received this message because you are subscribed to "C++ RTMP Server"

Kevin Ross

unread,
Sep 20, 2011, 4:51:57 AM9/20/11
to c-rtmp...@googlegroups.com
OVP isn't working any better than the others. Bummer. I wonder why
it's working for you and not me. :(

Oh well, I'll try again tomorrow. Bed time.

-- Kevin

cs

unread,
Sep 20, 2011, 6:16:44 PM9/20/11
to c-rtmp...@googlegroups.com
Ive been looking into the rtmpd source...
from what I can tell, it appears that rtmpd can't perform 'swf verification'
in the same way that librtmp/rtmpdump can.
Can anyone verify this?

I think it would be worthwhile to include this functionality into rtmpd.
Would anyone be willing to help me with implementing this into the source?
Thanks,
cs

cs

unread,
Sep 22, 2011, 3:51:30 AM9/22/11
to c-rtmp...@googlegroups.com
Did you get this to work?

Kevin Ross

unread,
Sep 22, 2011, 4:00:44 AM9/22/11
to c-rtmp...@googlegroups.com

On 09/22/2011 12:51 AM, cs wrote:
> Did you get this to work?
>

Unfortunately, I haven't had time to work on it again. I probably won't
have time again until this weekend.

-- Kevin

Jimmy

unread,
Jun 13, 2012, 11:29:29 AM6/13/12
to c-rtmp...@googlegroups.com
Does this patch work on the new 717 build?
Reply all
Reply to author
Forward
0 new messages