1 Reply Latest reply on May 25, 2011 5:16 PM by Michael Thornburgh

    What is Best Practice for Publishing and Subscribing to Multicast Video P2P

      Please, could someone help with an issue I am having in developing a peer to peer video chatting application?  My application uses  multicast to publish and subscribe to video streams of NetGroup members.  I'm listening for the  NetGroup.Neighbor.Connect event, and I'm calling the following function:


      protected function onPeerConnect(event:NetStatusEvent):void{
                      var peerID:String = event.info.peerID;

                      // create user vo here
                      // user Value Object for incoming stream
                      userVO = new User();
                      userVO.peerID = peerID;


      protected function receiveStream(userVO:User):void{
                      // init netstream
                      var stream:NetStream = new NetStream(nc,groupspec.groupspecWithAuthorizations());
                      // init panel
                      // alter to use custom component instead
                      var panel:Panel = new Panel();
                      panel.id = "panel" + panel_seq;
                      panel.title = "Panel" + panel_seq;
                      panel.x = 50 * panel_seq + 200;
                      panel.y = 25 * panel_seq + 200;
                      var cpanelContent:Array = new Array();
                      // init video
                      var video:Video = new Video();
                      // init videoWrapper
                      var videoWrapper:UIComponent = new UIComponent();
                      videoWrapper.id = "wrapper" + panel_seq;
                      // add to display list
                      // drag and drop panel
                      panel_seq++;// used for unique panel id
                      userVO.panel = panel;// reference to the panel
                      userVO.stream = stream;
                      userVO.video = video;


      I am confused on this:


      var stream:NetStream = new NetStream(nc,groupspec.groupspecWithAuthorizations());


      What  should I pass as the second parameter to establish an incoming  NetStream with the publishing peer?  I've seen people put in the farID  but I haven't figured out how to access it.  What is the difference  between event.info.peerID and event.info.neighbor?  And since I'm  multicasting to the group do I need to pass in the groupspec or the  farID?  I would love some clarification on this.


      What is happening is this:


      When  I join the group, and there are two members in the group already, I'll  get three panels with videos.  However, duplicate video streams are  being attached.  When I inspect the peerStreams array I'm seeing a  length of 0, so does that mean that no one is subscribing to my  published netstream?  If so, how do I specifically subscribe to each  published stream in the group?  Sometimes if I step through in debug  mode, I get three separate camera feeds in their prospective panels, but  if I run it will have duplicates.  I thought at first that this was a  referencing error because all of the NetGroup.Neighbor.Connect events  where happening all at the same time and perhaps that is the reason for  the duplicates?


      My only other thought is that maybe I'm  multicasting one guys stream to the whole group, but I'm getting varying  results so I want to know what is the correct way to grab, in sequence,  a NetGroup members' published netstream and be sure that all other  members are subscribing to my NetStream as well?


      Also, I  am using Value Objects to keep track of who my group members are, is  that data shared with the group or is it not accessible to all members?   or should I use another method of keeping track of my group members?


      Please help!  Thank you in advance!