Frozen video streams on Air for iOS

Post your questions and bug-reports about the audio/video streaming add-on based on Red5 Media Server.

Moderators: Lapo, Bax

darrenortiz
Posts: 9
Joined: 06 Jan 2012, 22:38

Frozen video streams on Air for iOS

Postby darrenortiz » 14 Jan 2012, 18:52

I'm building an app that runs on Air 3.1 for iOS (particularly the iPad2). I very frequently experience frozen video streams when using the AVCastManager. The only way to fix it so far is to disconnect from Smartfox and restart the app.

Anyone else experience anything like this?
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Postby A51Integrated » 14 Jan 2012, 19:29

Are you seeing any errors in the logs? SFS or Red5?
A51 Integrated
http://a51integrated.com / +1 416-703-2300
darrenortiz
Posts: 9
Joined: 06 Jan 2012, 22:38

Postby darrenortiz » 15 Jan 2012, 16:37

Actually yes. It seems like it's not actually a frozen video stream. It's that RedBox is disconnecting a user due to too much inactivity. I don't know how that can be the case because there's definitely activity going on on the stream.

I tried bumping up the "MaxUserIdleTime" in the config xml to something like 100000, but it's still dropping connections.

'Sup with that?!
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Postby A51Integrated » 15 Jan 2012, 16:44

In that case, it's probably inactivity on the SFS side. Create a keep alive message to the room the gets sent on a timer. The easiest is a simple ObjectMessage with a single boolean value. So check if the video is playing from the client, and if so, send the keep alive every 15 seconds or so.
A51 Integrated

http://a51integrated.com / +1 416-703-2300
darrenortiz
Posts: 9
Joined: 06 Jan 2012, 22:38

Postby darrenortiz » 15 Jan 2012, 16:49

Thanks for responding so quickly. By "sending an ObjectMessage" do you mean I should have all users sendPublicMessage on an interval?

Like "sendPublicMessage('keep alive');"? So that SFS just feels like there's always something going on?

If that works, that's great. But shouldn't the fact that there's a video stream be enough for SFS to think there's activity?
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Postby A51Integrated » 15 Jan 2012, 17:05

You have to remember that RedBox is simply a bridge between the two servers and Red5 runs somewhat independently of SFS.

Not a public message, an Object Message. Check the docs for yor client API. You first create an SFSObect and pass that to an object message request. So the smallest object you can send would simply contain a single Boolean value.
A51 Integrated

http://a51integrated.com / +1 416-703-2300
darrenortiz
Posts: 9
Joined: 06 Jan 2012, 22:38

Postby darrenortiz » 15 Jan 2012, 17:17

Thanks. I don't see anything in the AS3 docs about SFSObjects, but I do see the sendObject method.

So would I not just do:
_smartfox.sendObject(true);
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Postby A51Integrated » 15 Jan 2012, 18:02

For SFS1.x:

Code: Select all

var obj:Object = new Object();
obj.keepAlive = true;
smartFox.sendObject(obj);

For SFS2X:

Code: Select all

var obj:ISFSObject = new SFSObject();
obj.putBool("keepAlive", true);
sfs.send(new ObjectMessageRequest(obj));

Make sure you're reading the right documentation for your API.

1.6: http://www.smartfoxserver.com/docs/
2X: http://docs2x.smartfoxserver.com/
A51 Integrated

http://a51integrated.com / +1 416-703-2300
darrenortiz
Posts: 9
Joined: 06 Jan 2012, 22:38

Postby darrenortiz » 15 Jan 2012, 21:01

Thanks so much for your help. The problem actually turned out to be a couple of things, but we're using your method as further insurance that the connection never gets dropped.

You've been super helpful and shockingly quick in your responses.

To anyone else who might have the same problem, it's a very specific problem and your cause would probably not be the same as ours, but I'll describe it anyways just in case I can help.

This project was unlike other standard video conferencing projects in that it was for an art installation where a few iPads were going to be spread throughout the city all connected via a three-way video stream. If there was no motion in front of a camera for a set period of time, then we would stop publishing video on that iPad, and the other iPads would just show some canned footage. As soon as someone would come near the camera again it would have to start publishing again. The problem was the user kept getting removed from the SmartFox server due to inactivity.

Normally, when you stop publishing a stream, you'll most likely be closing the camera as well, but in our case we needed the camera to keep running even though we stopped publishing. That way we could track the camera's activity level and then start publishing again automatically based on movement. The problem here was that when you call the unpublishLiveCast method, it would then have the odd result of making it so the camera's activity level would never update itself. The camera was still connected and displaying fine on screen, but camera activity never changed and so we never restarted publishing again which lead to a dropped connection on SmartFox. The solution was to disconnect and reconnect the camera right after stopping publishing.

Also, the solution mentioned above regarding having each user send an object on an interval (once every 5 seconds in our case) further insures that a user is never kicked due to inactivity.
Annabellen
Posts: 1
Joined: 10 Apr 2012, 07:13
Contact:

Re: Frozen video streams on Air for iOS

Postby Annabellen » 10 Apr 2012, 07:15

hanks for responding so quickly. By "sending an ObjectMessage" do you mean I should have all users sendPublicMessage on an interval?

Like "sendPublicMessage('keep alive');"? So that SFS just feels like there's always something going on?

If that works, that's great. But shouldn't the fact that there's a video stream be enough for SFS to think there's activity?
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Re: Frozen video streams on Air for iOS

Postby A51Integrated » 10 Apr 2012, 13:37

Not a PublicMessage, an ObjectMessage - see: http://docs2x.smartfoxserver.com/api-do ... quest.html

An object message is the smallest message you can send to the server (if the abject being sent is also small) and in this case it can be a very small. The ObjectMessageRequest takes an SFSObject (http://docs2x.smartfoxserver.com/api-do ... bject.html) and passes that to the server. You can create an SFSObject with as little as a single boolean or a byte.

Code: Select all

    SFSObject *obj = [[SFSObject newInstance] autorelease];
    [obj putBool:@"t" value:YES];
    [client send:[ObjectMessageRequest requestWithObject:obj]];

This way, the SFS server is aware of the client's existence.

Just because a stream is playing does not mean that the SFS server is aware of activity. You have to remember that we are using two distinct servers here and when streaming video, you're going through Red5 which is on a different port than SFS and does not communicate connectivity status to SFS.
A51 Integrated

http://a51integrated.com / +1 416-703-2300

Return to “RedBox”

Who is online

Users browsing this forum: No registered users and 11 guests