0

I'm working on a video chat application and I'm building a feature where someone who starts a call can switch the call to an audio call. Now the receiver gets a link for the call and when they join the call the application gets their camera and microphone and attach it to the netstream. What I want is if the initiator if the call turns his camera off when starting the call when the receiver who joins the call, the application shouldn't get the Camera because their is no video attached to the netstream. Now I have used netstream.info.Videobytespersecond but since the opposing video and audio doesn't start immediately when the receiver joins the call (There is like a 3-4 second delay) the function keeps returning 0 at the start of the call whether or not the netstream has a video attached to it or not.

This is what I did

public function checkVideo():Number        {

        hey=_incomingStream.info.videoByteCount;
        return hey;
    }

if(_outgoingStream && _incomingStream!=null ){
                if(checkVideo()>0)
                _outgoingStream.attachCamera(camera);
                else
                    _outgoingStream.attachCamera(null);  

It didn't work.

Next I read about the netstream.send() function and so my idea was that when a user initiates a call he/she will send at message in the netstream which will basically flag true if the user initiated a video call or false if the user initiated an audio call. Then when the receiver joins if the flag is false their camera won't be initiated but if the flag is true the camera would be initiated.

When I implemented it, it didn't work. I don't know if there is something I did wrong while implementing.

 if(camera && !muteCam )
        {//Initate call
            camera = setCameraQuality(camera);
            yourVidHolder.attachCamera(camera);

            if(_outgoingStream && _incomingStream==null){
                _outgoingStream.attachCamera(camera);
 _outgoingStream.send("flagVideo", true);

----------------------------------------------------------------------------------
public function flagV():Boolean
    {

        _incomingStream.client.flagVideo=function(flag:Boolean):void{
            check=flag;
        }



            return check;
    }


if(_outgoingStream && _incomingStream!=null ){
                if(checkVideo()>0)
                _outgoingStream.attachCamera(camera);
                else
                    _outgoingStream.attachCamera(null);    
            } 

But I can't get it to work. Can anyone help me out please? Also maybe there is a better way I could check if the netstream has a video attached to it?

Michael Nana
  • 1,969
  • 4
  • 24
  • 36

1 Answers1

0

I got it to work. I used netstreaminfo.videobytecount property to get it to work. I check the videobytes coming in after the incoming stream was loaded on the receiver's end. If the bytes were equal to zero, then the receiver's camera won't turn on.

Michael Nana
  • 1,969
  • 4
  • 24
  • 36