Expand my Community achievements bar.

SOLVED

Determine the type of connection & set webcam width/height

Avatar

Level 2

Hi, two quick questions:

1. Is there a way in ActionScript to determine what type of connection is being used (e.g. P2P or FMS)?

2. Is there a way to set the width/height of the webcam picture? I currently extend the WebcamPublisher class to access the _camera instance and use the Camera.setMode() method, but it looks like that doesn't have any effect whatsoever.

Thanks in advance,

Michiel

PS: I'm aware of the captureWidthHeightFactor method, but I really don't like that approach, as it's not really clear what dimensions are being used for the video. I would like to set the dimensions myself, like when using the Camera.setMode() method.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

For you height/width part, you can use resolutionFactor API in webcamPublisher as captureWidthHeight API is deprecated. The default width and height gets multiplied.

And still if you want to set your own native width/height , since you are already subclassing WebcamPublisher, just subclass the function createMyStream and add your native width and height. See that function in the player 9 source code of WebcamPublisher provided.

One thing I forgot to mention in last mail, you can only have P2P with player 10 and you need to use player 10 swc for any verification of P2P. Player 9 will be always FMS.

Hope this helps.

Thanks

Hironmay Basu

View solution in original post

12 Replies

Avatar

Level 4

For number 2 try setting WebcamPublisher.captureWidthHeightFactor (I set

mine to 5). That will change the size of the image the camera captures. I

can't remember about number 1 someone else will know though.

-Eric

Avatar

Level 2

Hi esteimle, thanks for your reply.

As I stated, using captureWidthHeightFactor is not really an option for me as this does not provide me with the functionality I need (setting the width/height myself).

Avatar

Level 4

Ah ok then pretty sure what you want to do is not an option as I asked about

this a few weeks back.

Avatar

Former Community Member

Hi,

When you connect, if your protocol is rtmfp , then only P2P is possible. So, if you are having a rtmps connection ( the default one unless you set the protocol to 'rtmfp' in authenticator). You can see this in the logs when you connect.

Once you are in a rtmfp connection, you can verify whether P2P is actually working or not, by streamManager's isP2P property and can track changes to it using by listening to StreamEvent.CONNECTION_TYPE_CHANGE thrown by subscribers.

All these are shown partially in the PeerToPeerRtmfp example in the examples folder.

Thanks

Hironmay Basu

Avatar

Correct answer by
Former Community Member

For you height/width part, you can use resolutionFactor API in webcamPublisher as captureWidthHeight API is deprecated. The default width and height gets multiplied.

And still if you want to set your own native width/height , since you are already subclassing WebcamPublisher, just subclass the function createMyStream and add your native width and height. See that function in the player 9 source code of WebcamPublisher provided.

One thing I forgot to mention in last mail, you can only have P2P with player 10 and you need to use player 10 swc for any verification of P2P. Player 9 will be always FMS.

Hope this helps.

Thanks

Hironmay Basu

Avatar

Employee

This is not completely true, because if for any reason the rtmfp connection doesn't go through we try rtmps, so even if you do connect specifingy "rtmfp" you may endup with an "rtmps" connection.

Somewhere deep in the connection logic stuff there is an isRTMPS flag, but I am not sure it's exposed. The NetConnection URL is also around there, but again it's not exposed at the very high levels. Maybe we should make these info more readily available.

Anyway, if the isP2P flag is true you are definitively using "rtmfp", if false you may or may not be using rtmfp.

Avatar

Level 2

Ok, I'm using resolutionFactor now, but I'm not sure what the difference is. captureWidthHeightFactor is not really documented (it's there, but pretty unexplained), but the resolutionFactor uses multiples of the default width/height. I assume it does the exact same thing? (By the way: the resolutionFactor is not documenten on livedocs, only in the local documentation received as part of the zipped SDK.)

I'll look into that, for now resolutionFactor will have to do. (For testing purposes all video parameters have to be adjustable on the fly, and I unfortunately am already very short on time.)

You may have just saved my life! I was indeed using the player 9 swc, and tried the isP2P property, but didn't get it to work. And since it's not documented I labeled this as "deprecated" and dropped it. Great to see that it really is in there.

Also, the difference between the player 9 and player 10 swc you just explained answers another question I had (but totally forgot about). When connecting, the console always showed:

This gave me the idea that the P2P service was unavailable. I'm glad to see that this isn't the case.

Thanks for your rapid replies everyone, I really appreciate it!

Michiel

Avatar

Level 2

Another quick question: when will the source be made available for the player 10 swc? There seem to be some differences between player9 and player 10, so the player 10 swc source would really come in handy.

Thanks,

Michiel

Avatar

Former Community Member

Hi,

The source of player 10 as well as the docs will be released in near future. This has been requested many times. We are in line for finishing the work on releasing it. You can expect it in coming months.

Only the player 9 source is available till now. Have patience for some time.

You are right that there are lot of differences between player 9 and 10 especially in audio/video components due to all the P2P implementations and sound codecs.

Thanks

Regards

Hironmay Basu

Avatar

Level 2

I finally got it to work! It's weird though, we're experiencing a weird, unpredictable thing when testing the application.

I've made a small logger that checks whether the connection is P2P or not (using StreamManager's isP2P property), and sometimes, when sending out video, it switches from true to false and vice versa. But only sometimes, not all the time. Furthermore, this morning I didn't get the P2P connection up, I've tried several times over the course of several hours.

Later this day it worked every single time, but as I mentioned, it switched while testing with video. Later on it stopped switching, but it still has me worried. Can you give me an insight on that?

Thanks,

Michiel

Avatar

Former Community Member

Hi,

The switching happens on a number of factors , depending on your player version, number of streams , number of users connected,firewalls and so on. When the number of streams is more than a limit, it gets switched to hub-spoke from p2p. The switching back and forth happens dynamically based on the requirements. So, you need to specify me the exact sequence of events resulting in switching and I can then throw some light.

When you mean you didn't get P2P connection, is the connection itself rtmps or even with rtmfp connection, you were not getting P2P ? Exact details will be fruitful.

Thanks

Hironmay Basu

Avatar

Level 2

Hi Hironmay, thanks for your reply. Here's the exact sequence:

  1. Both clients started and connected. (Both are on the same local network and are using my developer account.) Checked and verified (through a frequent isP2P-check) to have an RTMFP connection for P2P.
  2. Client 1 fires up his webcam. It takes some time (in this case it was about 10 seconds) before Client 2 sees the image. Right before the image is shown, both sides automatically switch to RTMPS (isP2P == false).
  3. Client 2 fires up his webcam. Still RTMPS.
  4. Both sides switch on audio. Still RTMPS.
  5. Both sides stop their webcam stream. Still RTMPS.
  6. Both sides stop their audio stream, so now there's no communication at all. Still RTMPS.
  7. Client 2 closes the connection. At this point, Client 1 automatically gets switched back to RTMFP (isP2P == true).

This is the only testsession I recall exactly though, other testsessions gave results somewhat comparable but not the same as above.

After a couple of tries (and closing/opening the application), we got a stable RTMFP connection and we tested it for about 30 minutes, using P2P. If I recall correctly, the connection remained P2P throughout this last testsession.

When I say we didn't get a P2P connection, I mean we were forwarded to an RTMPS connection after logging in. The console reads:

#FMSConnector# Wed Jan 6 10:52:11 GMT+0100 2010 is using RTMPS? true

Also, when running the application through the generated .air file, the isP2P flag was false.

If you need more information, please don't hesitate to ask!

Thanks,

Michiel

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----