Expand my Community achievements bar.

SOLVED

video chat delay

Avatar

Former Community Member

Hi,

I'm using WebCam Publisher/Subscriber components to have a user publish his webcam feed and another user subscribe to it.

However I'm seeing a delay of over 4-5 seconds for the webcam feed. On the publisher side I'm checking the connection to the LCCS chat room and the UserManager's isP2P and isRTMFP properties are both true.

The subscriber being on the same network I would obviously assume that it also is connected via RTMFP.

My question is, is when we have the publish/subscribe model for WebCam feed sharing is the feed P2P between the Publisher and the Subscriber??

Looks like it isn't.

Thanks,

Soumik

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi Soumik,

I got a chance to look and run your Publisher/Subscriber. I ran against your room. There is a fix I did on my side, you can put that on your source code , link your project to source and let me know if you still face the issue. I will put the fix in the next release coming in next few weeks so that you don’t need to link to source in future and can directly use the swc.

But there are some changes I want to suggest to your code also, specially the subscriber.

In the playPubStream function, you don't need to do

webCamSub.publisherIDs = [];

audioSub.publisherIDs = [];

as whenever you set the this property later in your function, it automatically will clean the previous streams.

Instead, you should do something like

var array:Array = new Array();

array.push(pubID);

webCamSub.publisherIDs = array ;

Also when you declare your rtc:WebcamSubscriber in mxml, it is automatically subscribed, you don't need to call webCamSub.subscribe() unless you are creating it in actionscript. Similarly for audioSub.subscribe().

Lastly if there are only two users in room, and one publishes and other subscribes, you don't need to set the publisherIDs property because by default, the stream goes to everyone in room who has a WebcamSubscriber.

My fix goes like this. You should modify your WebcamSubscriber's onPeerTimeout function to be the one below

protected function onPeerTimeout(p_evt:TimerEvent):void

{

// Peer to peer connection fails , and hence we switch back to the hub and spoke connection...

var userDesc:UserDescriptor = userManager.getUserDescriptor(userManager.myUserID) ;

for (var id:String in _peerTimeoutTable ) {

if ( peerTimeoutTable[id] == pevt.currentTarget ) {

_peerTimeoutTable[id].stop();

peerTimeoutTable[id].removeEventListener(TimerEvent.TIMERCOMPLETE,onPeerTimeout);

_peerTimeoutTable[id] = null ;

DebugUtil.debugTrace(" Peer to peer connection failed and timed out in Camera for user " + userManager.getUserDescriptor(userManager.myUserID).displayName);

if ( userDesc.isPeer ) {

userManager.setPeer(userManager.myUserID,false);

}

break ;

}

}

}

Make similar change in your AudioSubscriber.as too.

Hope this will help to fix your problem. Thanks for pointing this out and your patience. Let me know if you are still having any issue with your peer to peer streaming.

Thanks

Hironmay Basu

View solution in original post

32 Replies

Avatar

Former Community Member

Hi,

If both of your users are on player 10 or above, and you are having an RTMFP connection without any firewall, the p2p is the default streaming. However, if you want to keep your streams as hub-spoke instead of p2p irrespective of everything mentioned above, you can set streamManager. maxP2PStreamPublish = 0 .

Which player version you are using ? 10 or 10.1 and can you tell us whether setting everything to hub-spoke solves your delay problem ?

Thanks

Regards

Hironmay Basu

Avatar

Former Community Member

Hi Hironmoy,

I'm using Flash Player 10.1.

I'll give the hub-n-spoke thing a try by setting the maxP2PStreamPublish as 0. But I've a another swf(FP 10.1) where I've used Stratus and the NetGroup API for P2P. That one really gives a good performance, as in I see less than a second of lag.

So I am wondering if both are indeed P2P between publisher and subscriber, how come the lag in this case of LCCS so much.

Thanks,

Soumik

Avatar

Former Community Member

Hi,

You can try setting up a lower multicastWindowDuration for the streams by setting a lower value in webcamPublisher ? This reduces the latency for multicast but may compromise some quality but its worth giving a try

The docs are here http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/net/NetStream.html#mul...

Thanks

Regards

Hironmay Basu

Avatar

Former Community Member

Hi,

I tried setting the multicastWindowDuration for WebcamPublisher to 0 and 1 and though the delay came down a bit, its still around 2-3 seconds at worst.

This is really not the same quality I get in the same setup when I use the stratus service.

Could you perhaps suggest some ideal settings for a the WebCamPublisher and AudioPublisher?? I'm having a 2mbps download and 600kb/s upload speed. And here's the settings i'm supplying to the webcam and audio publisher:

<rtc:WebcamPublisher id="webCamPub" width="10" height="10" resolutionFactor="5" multicastWindowDuration="0" quality="80"/>

<rtc:AudioPublisher id="audioPub" width="10" height="10" /> (Also, i'm setting the Audio codec to SPEEX with no additional params).

And there's only one stream being published out from my system.

Thanks,

Soumik

Avatar

Former Community Member

One more thing, while I was trying to debug my subscriber on the console I see the following output when the subscriber is streaming the webcam output:

Peer to peer connection failed and timed out in Camera for user guestsub

Peer to peer connection failed and timed out in Audio for user guestsub

Does this mean that the WebcamSubscriber and AudioSubscriber has fallen back to RTMP instead of RTMFP??

Thanks,

Soumik

Avatar

Former Community Member

Hi Soumik,

This is odd - it seems as though you're not really going peer-to-peer here.

I'm curious - could you send us some client logs showing connecting and

publishing?

thanks!

nigel

Avatar

Former Community Member

Bingo - seems like you aren't able to establish peer to peer connections.

This is pretty strange - are the 2 clients on the same network? Maybe Basu

can help you hack at the timeout for P2P and see what happens if there isn't

any timeout for establishing P2P connections?

thanks

nigel

Avatar

Former Community Member

Hi Nigel,

Yes, both of my clients are on the same network. Infact, since I'm currently debugging the issue of video chat latency I'm using the same machine to publish and then subscribe to the feed.

I would like to know how we can change timeouts for P2P connection.

If it helps I'll also paste the debug output for the subscriber swf.

Thanks,

Soumik

Avatar

Former Community Member

Here's the subscriber output in debug mode:

AFCS Beta Build # : 1.1.1

requestInfo http://connectnow.acrobat.com/soumikb/testroom?guk=ZzpndWVzdHN1Yjo=&mode=xml&x=0.781349497847259

#TicketService# ticket received: 18ln9obp9i4wb

Getting FMS at https://na2.connectnow.acrobat.com/fms?ticket=18ln9obp9i4wb&proto=rtmfp, attempt #1/3

result: <fms>

  <origin>fms2.acrobat.com</origin>

  <proto_ports>rtmfp:1935,rtmps:443</proto_ports>

  <retry_attempts>2</retry_attempts>

</fms>

#FMSConnector# Wed Jul 14 02:40:47 GMT+0530 2010 protocols: [object ProtocolPortPair],[object ProtocolPortPair]

#FMSConnector# Wed Jul 14 02:40:47 GMT+0530 2010 [attempt 1 of 2] Connecting to 0/1: rtmfp://fms2.acrobat.com/cocomo/na2-sdk-08ecda94-fe8e-4a42-a7fd-20abf15aec73/testroom #startProtosConnect#

#FMSConnector# Wed Jul 14 02:40:49 GMT+0530 2010 tempNetStatusHandler 0/2,NetConnection.Connect.Success

#FMSConnector# Wed Jul 14 02:40:49 GMT+0530 2010 isTunneling? false

#FMSConnector# Wed Jul 14 02:40:49 GMT+0530 2010 is using RTMPS? false

RECEIVED LOGIN AT SESSION

  .user descriptor from server [object]

    \\

    .role [number]= 50

    .displayName [string]= guestsub

    .affiliation [number]= 5

    .userID [string]= GUEST-CAB928C4-2646-4712-8B69-CF08A46DBF2C

RECEIVENODES UserManager

receiveAllSynchData UserManager

RECEIVENODES FileManager

receiveAllSynchData FileManager

checkManagerSync:[object FileManager]

RECEIVENODES AVManager

receiveAllSynchData AVManager

checkManagerSync:[object StreamManager]

RECEIVENODES RoomManager

receiveAllSynchData RoomManager

checkManagerSync:[object RoomManager]

checkManagerSync:[object UserManager]

Peer to peer connection failed and timed out in Camera for user guestsub

Peer to peer connection failed and timed out in Audio for user guestsub

Peer to peer connection failed and timed out in Camera for user guestsub

Peer to peer connection failed and timed out in Audio for user guestsub

[Unload SWF] soumik:smiktest:bin-debug:LiveDiscussSub.swf

Avatar

Former Community Member

Hi Soumik,

I can tell you the way of how you can increase your timeout but You need the source files for that. Since we do not distribute 10.1source ,I will say try the same thing with our 10 swc and if you can't connect or your p2p connection is timed out, I will tell you where to modify. Even though I believe increasing timeout will not help as I feel there is something going in your network that is stopping the p2p connection and causing timeout. Anyways, you first try with 10 swc and let me know.

Thanks

Hironmay Basu

Avatar

Former Community Member

Hironmoy,

Flash 10 is not really an option for us to deploy, since we've requirements for hardware acceleration which is fulfilled by 10.1.

Nevertheless, I'll try to test the same on FP 10 and let you know the result.

But if there's anything else you need which might need to debug this issue with FP 10.1, please let me know.

As I had mentioned to you before, I'm able to use Stratus service for RTMFP P2P chat with FP 10.1 within the same network, without any issues.

Thanks,

Soumik

Avatar

Former Community Member

Hironmoy,

I'm copy-pasting the publisher and subscriber flex code for your inspection. Please have a look and also if possible try out the publish/subscribe.

Publisher:

-------------------------------

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

   xmlns:s="library://ns.adobe.com/flex/spark"

   xmlns:mx="library://ns.adobe.com/flex/mx"

   xmlns:rtc="AfcsNameSpace" creationComplete="initVars()">

<fx:Style source="LiveDiscussPub.css"/>

<fx:Declarations>

<rtc:AdobeHSAuthenticator

id="auth" userName="someone@somewhere.com"/>

</fx:Declarations>

<fx:Script>

<![CDATA[

import com.adobe.rtc.events.CollectionNodeEvent;

import com.adobe.rtc.events.SharedObjectEvent;

import com.adobe.rtc.sharedManagers.descriptors.UserDescriptor;

import com.adobe.rtc.sharedModel.SharedObject;

import flash.external.ExternalInterface;

import mx.core.FlexGlobals;

[Bindable]

public var myDispName: String;

private function initVars(): void

{

myDispName = FlexGlobals.topLevelApplication.parameters.publishlabel;

//auth.userName = myDispName;

cSession.login();

}

/*****

* Handler for the stop and start buttons.

*******/

private function onBtnClick(p_evt:MouseEvent):void

{

if ( p_evt.currentTarget.label == "Start Webcam" ) {

webCamPub.publish();

p_evt.currentTarget.label = "Stop Webcam" ;

audioPub.codec = SoundCodec.SPEEX;

audioPub.publish();

}else if (p_evt.currentTarget.label == "Stop Webcam" ){

webCamPub.stop();

p_evt.currentTarget.label = "Start Webcam" ;

audioPub.stop();

}

}

private function onInit(): void

{

webCamPub.publish();

webCamButton.label = "Stop Webcam";

audioPub.codec = SoundCodec.SPEEX;

audioPub.publish();

var myUserDesc: UserDescriptor = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID);

myUserId.text = "UID:" + cSession.userManager.myUserID + " Display Name: " + myUserDesc.displayName + " flashvar: " + myDispName + " isP2P: " + myUserDesc.isPeer + " isRTMFP: " + myUserDesc.isRTMFP;

}

]]>

</fx:Script>

<rtc:ConnectSessionContainer id="cSession" authenticator="{auth}" width="100%"

height="100%" roomURL="http://connectnow.acrobat.com/soumikb/testroom"  autoLogin="false" backgroundColor="#040404">

<s:VGroup height="100%" width="100%" horizontalAlign="center" verticalAlign="middle" creationComplete="onInit()">

<s:HGroup height="20%" width="100%" verticalAlign="middle" horizontalAlign="center" contentBackgroundColor="#161313">

<rtc:WebcamPublisher id="webCamPub" width="10" height="10" resolutionFactor="2" quality="0"/>

<mx:Button id="webCamButton" label="Start Webcam" click="onBtnClick(event)" fontSize="24" width="60%" height="90%"/>

<rtc:AudioPublisher id="audioPub" width="10" height="10" />

</s:HGroup>

<s:TextArea id="myUserId" text="None" height="70%" width="100%" contentBackgroundColor="#030303" symbolColor="#FCFAFA" color="#FAF6F6"/>

</s:VGroup>

</rtc:ConnectSessionContainer>

</s:Application>

-------------------------------

And the Subscriber:

--------------------------------

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

   xmlns:s="library://ns.adobe.com/flex/spark"

   xmlns:mx="library://ns.adobe.com/flex/mx"

   xmlns:rtc="AfcsNameSpace" creationComplete="initVars()">

<fx:Style source="LiveDiscussSub.css"/>

<fx:Declarations>

<rtc:AdobeHSAuthenticator

id="auth"

userName="guestsub" />

</fx:Declarations>

<fx:Script>

<![CDATA[

import com.adobe.rtc.sharedManagers.descriptors.UserDescriptor;

import com.adobe.rtc.sharedModel.SharedObject;

import com.adobe.rtc.events.CollectionNodeEvent;

import mx.collections.ArrayCollection;

import mx.core.FlexGlobals;

[Bindable]

public var publisherDispName: String;

[Bindable]

public var chatPeerId:String = null;

private function initVars(): void

{

publisherDispName = FlexGlobals.topLevelApplication.parameters.stream;

chatPeerId = FlexGlobals.topLevelApplication.parameters.peerid;

}

private function playPubStream(): void

{

var currUsers:ArrayCollection = cSession.userManager.userCollection;

var pubId: String = null;

webCamSub.publisherIDs = [];

audioSub.publisherIDs = [];

var pubWithDispNames: String = null;

for( var i:int=0; i < currUsers.length; i++)

{

pubWithDispNames = pubWithDispNames + "User: " + (currUsers[i] as UserDescriptor).userID + ", name: " + (currUsers[i] as UserDescriptor).displayName + ";";

if((currUsers[i] as UserDescriptor).displayName == "someone@somewhere.com")

{

pubId = (currUsers[i] as UserDescriptor).userID;

}

}

if(pubId != null)

{

mySubStatus.text = "Subscribing to: " + pubId;

var publishers: Array = new Array(pubId);

webCamSub.subscribe();

webCamSub.publisherIDs = publishers;

audioSub.subscribe();

audioSub.publisherIDs = publishers;

audioSub.setLocalVolume(1);

}

else

{

mySubStatus.text = "Error: failed to subscribe to " + publisherDispName;

}

}

private function sliderVolSet():void

{

var volToSet: Number = (volSlider.value / 100);

audioSub.setLocalVolume(volToSet);

}

]]>

</fx:Script>

<rtc:ConnectSessionContainer id="cSession" authenticator="{auth}" width="100%"

height="100%" roomURL="http://connectnow.acrobat.com/soumikb/testroom"  contentBackgroundColor="#040404" symbolColor="#FAF6F6" color="#FBF8F8">

<s:VGroup height="100%" width="100%" creationComplete="playPubStream()" x="0" y="0" verticalAlign="top" horizontalAlign="justify" clipAndEnableScrolling="true" includeInLayout="false">

<rtc:WebcamSubscriber width="100%" height="90%" displayUserBars="false" id="webCamSub" chromeColor="#040404" left="0"/>

<s:HGroup height="10%" width="100%" horizontalAlign="center" verticalAlign="middle">

<s:TextArea id="mySubStatus" text="None" height="100%" width="80%" />

<rtc:AudioSubscriber id="audioSub" width="10%" height="100%" chromeColor="#040404"/>

<s:HSlider id="volSlider" height="10%" width="10%" dataTipPrecision="0" minimum="0" maximum="100" thumbRelease="sliderVolSet()" value="100" toolTip="Volume" showDataTip="true" />

</s:HGroup>

</s:VGroup>

</rtc:ConnectSessionContainer>

</s:Application>

--------------------------------

If you feel that there's any error in the code above please let me know.

Thanks,

Soumik

Avatar

Former Community Member

Hi,

I just tried running the same publisher/subscriber application in FP 10(10.0.45.2) with Flex 4.

I got the same error on the subscriber side.

AFCS Beta Build # : 1.1.1

requestInfo http://connectnow.acrobat.com/soumikb/testroom?guk=ZzpndWVzdHN1Yjo=&mode=xml&x=0.3174786879681051

#TicketService# ticket received: 1rg5zmeictooh

Getting FMS at https://na2.connectnow.acrobat.com/fms?ticket=1rg5zmeictooh&proto=rtmfp, attempt #1/3

result: <fms>

<origin>fms2.acrobat.com</origin>

<proto_ports>rtmfp:1935,rtmps:443</proto_ports>

<retry_attempts>2</retry_attempts>

</fms>

#FMSConnector# Thu Jul 15 18:49:20 GMT+0530 2010 protocols: [object ProtocolPortPair],[object ProtocolPortPair]

#FMSConnector# Thu Jul 15 18:49:20 GMT+0530 2010 [attempt 1 of 2] Connecting to 0/1: rtmfp://fms2.acrobat.com/cocomo/na2-sdk-08ecda94-fe8e-4a42-a7fd-20abf15aec73/testroom #startProtosConnect#

#FMSConnector# Thu Jul 15 18:49:21 GMT+0530 2010 tempNetStatusHandler 0/2,NetConnection.Connect.Success

#FMSConnector# Thu Jul 15 18:49:21 GMT+0530 2010 isTunneling? false

#FMSConnector# Thu Jul 15 18:49:21 GMT+0530 2010 is using RTMPS? false

RECEIVED LOGIN AT SESSION

.user descriptor from server [object]

\\

.displayName [string]= guestsub

.userID [string]= GUEST-A69F5835-8BDD-4CCE-A8CF-2C04A7CCE500

.affiliation [number]= 5

.role [number]= 50

RECEIVENODES UserManager

receiveAllSynchData UserManager

RECEIVENODES FileManager

receiveAllSynchData FileManager

checkManagerSync:[object FileManager]

RECEIVENODES AVManager

receiveAllSynchData AVManager

checkManagerSync:[object StreamManager]

RECEIVENODES RoomManager

receiveAllSynchData RoomManager

checkManagerSync:[object RoomManager]

checkManagerSync:[object UserManager]

Peer to peer connection failed and timed out in Camera for user guestsub

Peer to peer connection failed and timed out in Audio for user guestsub

Peer to peer connection failed and timed out in Camera for user guestsub

Peer to peer connection failed and timed out in Audio for user guestsub

Please advise me on what to do next.

Thanks,

Soumik

Avatar

Former Community Member

Hi Soumik,

Firstly, You can use Player 10.1 but use our lccs.swc for player 10 SDK. That won't stop you from Hardware accelarations.

Now, in player 10, either in WebcamSubscriber.as or AudioSubscriber.as source, you can look for this line and modify the timeout

_peerTimeoutTable[streamDescriptor.id] = new Timer(8000,1);

Currently , its 8 secs but you can increase it and see if it makes a difference. My opinion is it won't. There is something going on with your connection but you can give it a try. Other users and enterprises have been using this and they don't face this issue.

Lastly, you need to be patient for responses. We are there to help but we can't be 24X7 replying to your queries.

Thanks

Regards

Hironmay Basu

Avatar

Former Community Member

Thanks for the update.

One question though regarding changing the .as file - How do I include the flah 10 LCCS source? I'm trying the following:

Project -> Properties ->  Add SWC folder -> Here I'm adding : Flash Builder 4\plugins\com.adobe.afcs\libs\player10\src.

This doesn't seem to work as the compilation of the Flex project gives me errors.

-Soumik

p.s. - I'm aware you're not here to answer my queries 24x7. I apologize if the multiple posts came across as a desperate attempt to get your attention, but my intention was to give you all the info I could before you replied.

Avatar

Former Community Member

You need to add to the source path by going to Project->Properties->Flex Build Path-> Source Path tab. There add player10/src path.

Hope this helps.

Thanks

Hironmay Basu

Avatar

Former Community Member

Ok, so I was able to change the WebcamSubscriber timeout and increased it to 80 seconds. And you were right, the error log still came after the increased timeout.

Btw, one observation is that the Webcam starts publishing immediately though the timeout has been increased. I was under the impression that the RTMFP stream was tried first, failing which it switched to RTMP. It seems that it already latches on to the RTMP stream even though the timer expires later on.

Thanks,

Soumik

Avatar

Former Community Member

Hmm.. interesting. I need to take a fresh look with time.. send me your room url and a small app which I can run. And then I can debug sometimes.

Thanks

Hironmay Basu

Avatar

Former Community Member

Hironmoy,

I've attached both the publisher and subscriber code few posts back. It'll also have the room URL in it.

Thanks,

Soumik

Avatar

Former Community Member

Ok I will get back with my findings next week.

Thanks

Hironmay Basu

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] ----