Solved

Flash peer-to-peer video chat

Posted on 2007-03-22
22
6,034 Views
Last Modified: 2013-11-13
Does anyone know if Flash peer-to-peer video chat is a possibility?--and if so, any source code to get me started.
0
Comment
Question by:John Account
  • 8
  • 7
  • 5
  • +2
22 Comments
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
0
 

Author Comment

by:John Account
Comment Utility
By the way, I'm asking as a developer--to develop an application utiliizing Flash Peer-To-Peer chat.
0
 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
I don't think it is possible to do the p2p with Flash...  You will need a server to connect two clients...

CyanBlue
0
 
LVL 4

Accepted Solution

by:
teddysetiawan earned 250 total points
Comment Utility
FMS (Flash Media Serever ) will do the job , lots of sample about video chat using flash and FMS
If you want open source server try use Red5

here is what FMS can do , http://www.influxis.com/

its a web hosting ( FMS hosting ) with build in ready to use video  web chat .
( its just a sample what FMS can do )
0
 

Author Comment

by:John Account
Comment Utility
I'm slightly confused as to your reply, Teddy. My question asks if I can do peer-to-peer video chat with Flash; you reply to use a server. Maybe there is something I don't understand...like, are you saying that, while using the FMS or Red5, I can set up the clients to do peer-to-peer video chat? And if that's the case, then why the hell must I use one of these servers?--merely to establish the connections? More info, please.
Many Kind Thanks,
John
0
 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
No, basically you cannot do the peer to peer if you are using Flash...  Teddy is just suggesting alternative that can do the video chat but that won't be peer to peer...

CyanBlue
0
 

Author Comment

by:John Account
Comment Utility
Well, that's too bad....sigh...and it's not that I don't doubt the word of either of you, but I'm going to leave this open a bit longer in hopes that you are wrong, and that there is a way to do peer-to-peer video chat with Flash. Thanks.
0
 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
Just out of curiosity, are you talking about the web app or a desktop app???

CyanBlue
0
 

Author Comment

by:John Account
Comment Utility
Web app
0
 
LVL 37

Assisted Solution

by:CyanBlue
CyanBlue earned 250 total points
Comment Utility
You definitely have no way of doing the peer to peer if that is the case as far as I am aware of...
I was going to suggest looking up the third party projector tools such as Zinc or mProjector or create your own wrapper if it is for the desktop app...

CyanBlue
0
 

Author Comment

by:John Account
Comment Utility
hmmmmmmmmmnnn...how bout if it was for a desktop app--could that be Flash peer-to-peer?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
Um...  Please check line 2 of what I have posted earlier...  ;)

CyanBlue
0
 
LVL 4

Expert Comment

by:teddysetiawan
Comment Utility
Security is a big concern in flash ,Like Cyan said , you can't do P2P in flash ( as far as  know ).
In the next generation of flash (Apollo) , they added alot of things that might be able P2P  ( just don't have time to play for doing P2P thing)

you can read the article in here
http://www.onflex.org/ted/2006/10/web-20-is-distributed-internet.php

and here's the comment from Ted Patrick
"P2P in Apollo? Hmmmm....

Flash Player supports:
flash.net.Socket, AKA Binary Socket for 2 way data exchange of binary data.

Code here is hypothetical!!!

import apollo.net.Server
myServer:Server = new Server();
myServer.addEventListener( Server.CONNECT, connectHandler );
myServer.addEventListener( Server.DATA, dataHandler );
myServer.addEventListener( Server.DISCONNECT, disconnectHandler );
myServer.ports = [80,8080,1492,1976];
myServer.listen();

Technically its feasable. Security and Legal will be the barriers on this one.

Ted :) "


 


0
 

Author Comment

by:John Account
Comment Utility
I don't know which way I'm going to go at this point, but you both convinced me P2P via Flash is a no go. Previously, I"ve used the avphone activex from www.banasoft.net, but I can't make a wrapper for it to work with asp.net. Sigh.
0
 
LVL 4

Expert Comment

by:teddysetiawan
Comment Utility
Since the apollo have been release ( alpha ) a lot of thing may change in the security issue,
I'm not suprise if in the future flash/Apollo/Flex  will change the way user interact each other over the net.

AS 3.0 have socket class , and there are alot  sample how to use it , from SMTP,POP3, but have'nt seen any P2P sample.

But still the main issue is the security.

I've been asking your question to the flex/apollo comunity , I will share the knowledge in here

Regards


Teddy
0
 

Author Comment

by:John Account
Comment Utility
Thanks, Teddy. Your kindness and thoughtfulness is appreciated very much.
0
 
LVL 4

Expert Comment

by:teddysetiawan
Comment Utility
Sorry , I can't help you a lot with these , you should try and moving to AS 3.0 using flex/apollo
and try to build your own P2P app or you can wait until someone build it  ^_^.

I have ask around about this P2P thing , they all said it can be done , but there's no sample that I can give it to you, and still the main problem is the security thing.

In the mean time here's what I found
http://code.google.com/p/as3corelib/

lots of interesting classes in there including extended socket class.
remember this is AS 3.0 actionscript
before you jump in to try these class I suggest you learn AS 3.0 first and how to use it.


/*
      Adobe Systems Incorporated(r) Source Code License Agreement
      Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
      
      Please read this Source Code License Agreement carefully before using
      the source code.
      
      Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
      no-charge, royalty-free, irrevocable copyright license, to reproduce,
      prepare derivative works of, publicly display, publicly perform, and
      distribute this source code and such derivative works in source or
      object code form without any attribution requirements.  
      
      The name "Adobe Systems Incorporated" must not be used to endorse or promote products
      derived from the source code without prior written permission.
      
      You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
      against any loss, damage, claims or lawsuits, including attorney's
      fees that arise or result from your use or distribution of the source
      code.
      
      THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
      ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
      BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
      FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ALSO, THERE IS NO WARRANTY OF
      NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT.  IN NO EVENT SHALL MACROMEDIA
      OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
      EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
      PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
      OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
      WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
      ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.adobe.net.proxies
{
      import flash.events.Event;
      import flash.events.IOErrorEvent;
      import flash.events.ProgressEvent;
      import flash.net.Socket;

      /**
       * This class allows TCP socket connections through HTTP proxies in accordance with
       * RFC 2817:
       *
       * ftp://ftp.rfc-editor.org/in-notes/rfc2817.txt
       *
       * It can also be used to make direct connections to a destination, as well. If you
       * pass the host and port into the constructor, no proxy will be used. You can also
       * call connect, passing in the host and the port, and if you didn't set the proxy
       * info, a direct connection will be made. A proxy is only used after you have called
       * the setProxyInfo function.
       *
       * The connection to and negotiation with the proxy is completely hidden. All the
       * same events are thrown whether you are using a proxy or not, and the data you
       * receive from the target server will look exact as it would if you were connected
       * to it directly rather than through a proxy.
       *
       * @author Christian Cantrell
       *
       **/
      public class RFC2817Socket
            extends Socket
      {
            private var proxyHost:String = null;
            private var host:String = null;
            private var proxyPort:int = 0;
            private var port:int = 0;
            private var deferredEventHandlers:Object = new Object();
            private var buffer:String = new String();

            /**
             * Construct a new RFC2817Socket object. If you pass in the host and the port,
             * no proxy will be used. If you want to use a proxy, instantiate with no
             * arguments, call setProxyInfo, then call connect.
             **/
            public function RFC2817Socket(host:String = null, port:int = 0)
            {
                  if (host != null && port != 0)
                  {
                        super(host, port);
                  }
            }
            
            /**
             * Set the proxy host and port number. Your connection will only proxied if
             * this function has been called.
             **/
            public function setProxyInfo(host:String, port:int):void
            {
                  this.proxyHost = host;
                  this.proxyPort = port;

                  var deferredSocketDataHandler:Object = this.deferredEventHandlers[ProgressEvent.SOCKET_DATA];
                  var deferredConnectHandler:Object = this.deferredEventHandlers[Event.CONNECT];

                  if (deferredSocketDataHandler != null)
                  {
                        super.removeEventListener(ProgressEvent.SOCKET_DATA, deferredSocketDataHandler.listener, deferredSocketDataHandler.useCapture);
                  }

                  if (deferredConnectHandler != null)
                  {
                        super.removeEventListener(Event.CONNECT, deferredConnectHandler.listener, deferredConnectHandler.useCapture);
                  }
            }
            
            /**
             * Connect to the specified host over the specified port. If you want your
             * connection proxied, call the setProxyInfo function first.
             **/
            public override function connect(host:String, port:int):void
            {
                  if (this.proxyHost == null)
                  {
                        this.redirectConnectEvent();
                        this.redirectSocketDataEvent();
                        super.connect(host, port);
                  }
                  else
                  {
                        this.host = host;
                        this.port = port;
                        super.addEventListener(Event.CONNECT, this.onConnect);
                        super.addEventListener(ProgressEvent.SOCKET_DATA, this.onSocketData);
                        super.connect(this.proxyHost, this.proxyPort);
                  }
            }

            private function onConnect(event:Event):void
            {
                  this.writeUTFBytes("CONNECT "+this.host+":"+this.port+" HTTP/1.1\n\n");
                  this.flush();
                  this.redirectConnectEvent();
            }
            
            private function onSocketData(event:ProgressEvent):void
            {
                  while (this.bytesAvailable != 0)
                  {
                        this.buffer += this.readUTFBytes(1);
                        if (this.buffer.search(/\r?\n\r?\n$/) != -1)
                        {
                              this.checkResponse(event);
                              break;
                        }
                  }
            }
            
            private function checkResponse(event:ProgressEvent):void
            {
                  var responseCode:String = this.buffer.substr(this.buffer.indexOf(" ")+1, 3);

                  if (responseCode.search(/^2/) == -1)
                  {
                        var ioError:IOErrorEvent = new IOErrorEvent(IOErrorEvent.IO_ERROR);
                        ioError.text = "Error connecting to the proxy ["+this.proxyHost+"] on port ["+this.proxyPort+"]: " + this.buffer;
                        this.dispatchEvent(ioError);
                  }
                  else
                  {
                        this.redirectSocketDataEvent();
                        this.dispatchEvent(new Event(Event.CONNECT));
                        if (this.bytesAvailable > 0)
                        {
                              this.dispatchEvent(event);
                        }
                  }
                  this.buffer = null;
            }
            
            private function redirectConnectEvent():void
            {
                  super.removeEventListener(Event.CONNECT, onConnect);
                  var deferredEventHandler:Object = this.deferredEventHandlers[Event.CONNECT];
                  if (deferredEventHandler != null)
                  {
                        super.addEventListener(Event.CONNECT, deferredEventHandler.listener, deferredEventHandler.useCapture, deferredEventHandler.priority, deferredEventHandler.useWeakReference);                  
                  }
            }
            
            private function redirectSocketDataEvent():void
            {
                  super.removeEventListener(ProgressEvent.SOCKET_DATA, onSocketData);
                  var deferredEventHandler:Object = this.deferredEventHandlers[ProgressEvent.SOCKET_DATA];
                  if (deferredEventHandler != null)
                  {
                        super.addEventListener(ProgressEvent.SOCKET_DATA, deferredEventHandler.listener, deferredEventHandler.useCapture, deferredEventHandler.priority, deferredEventHandler.useWeakReference);                  
                  }
            }
            
            public override function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int=0.0, useWeakReference:Boolean=false):void
            {
                  if (type == Event.CONNECT || type == ProgressEvent.SOCKET_DATA)
                  {
                        this.deferredEventHandlers[type] = {listener:listener,useCapture:useCapture, priority:priority, useWeakReference:useWeakReference};
                  }
                  else
                  {
                        super.addEventListener(type, listener, useCapture, priority, useWeakReference);
                  }
            }
      }
}

0
 

Author Comment

by:John Account
Comment Utility
Wow, Teddy. Thanks! I think I'm going to move to AS 3.0 using flex/apollo, as you've suggested. The information you provided certainly sounds very promising.

Do you have a website?
0
 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
Interesting find, Teddy...  Something to investigate further...  Nice...  :)

CyanBlue
0
 
LVL 4

Expert Comment

by:teddysetiawan
Comment Utility
John,

Must understand that it will be completely different from AS 2.0, and especially who never or less doing coding in actrionscript, no frame , no timeline in flex/apollo.

For you who familiar with flash environment I believe Adobe CS 3.0 will be coming out around April, and you can pre order it right now.
One thing that amaze me is that you can convert your timeline animation into AS 3.0 in just single click.

I think its around $600 and $200 for upgrade.

btw sorry john , no website at the moment ,
you can contact me at teddysetiawan@ hotmail. com

or you can always ask in here , at the experts-exchange ,
as I believe more brain are better than one.


Cyan, it will be very  interesting if you can share your knowledge after your investigation  ;)
0
 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
Well...  Don't expect that to be happening any time soon cuz I am just trying to dive into that can of worms, uh I mean AS3...  But I'll get back to you if I ever can get this thing any further...  ;)

CyanBlue
0
 

Expert Comment

by:yarekGmail
Comment Utility
stratus can be used.

this is called RTMPF and popular sites wuch as: www.chatroulette.com (adn other clones www.visioroulette.com) do use it !
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now