• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Where do you start in getting an iPad to use two-way video chat through RTMP and an AMS without using AIR Mobile?

Explorer ,
Jul 28, 2015 Jul 28, 2015

Copy link to clipboard

Copied

Take the following two programs, which are almost identical:

1. HelloChatWeb (Flash Player)

package

{

    import flash.display.Sprite;

    import flash.events.Event;

    import flash.events.NetStatusEvent;

    import flash.events.TimerEvent;

    import flash.media.Camera;

    import flash.media.Microphone;

    import flash.media.SoundTransform;

    import flash.media.Video;

    import flash.net.NetConnection;

    import flash.net.NetStream;

    import flash.utils.Timer;

    public final class HelloChatWeb extends Sprite

    {

        private const CONNECTION_STRING:String = "rtmp://someIP/HelloChat/0";

    

        private var m_cam:Camera;

        private var m_tmr:Timer;

    

        private var m_nc:NetConnection = new NetConnection();

        private var m_ns:NetStream;

    

        public function HelloChatWeb()

        {

            stage ? init() : addEventListener(Event.ADDED_TO_STAGE, init);

            function init(pEvent:Event = null):void {

                removeEventListener(Event.ADDED_TO_STAGE, init);

                m_nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

            

                if (m_cam = Camera.getCamera())

                {

                    m_nc.connect(CONNECTION_STRING);

                }

                else

                {

                    m_tmr = new Timer(1000);

                    m_tmr.addEventListener(TimerEvent.TIMER, onTimer);

                    m_tmr.start();

                }

            }

        }

    

        private function onTimer(pEvent:TimerEvent):void

        {

            if (m_cam = Camera.getCamera())

            {

                m_tmr.removeEventListener(TimerEvent.TIMER, onTimer);

                m_tmr.stop();

                m_nc.connect(CONNECTION_STRING);

            }

        }

    

        private function onNetStatus(pEvent:NetStatusEvent):void

        {

            if (pEvent.info.code == "NetConnection.Connect.Success")

            {

                m_cam.setMode(320, 240, 15, false);

                m_cam.setQuality(65535, 0);

                m_cam.setKeyFrameInterval(8);

            

                var mic:Microphone = Microphone.getEnhancedMicrophone();

                if (mic)

                {

                    mic.enhancedOptions.echoPath = 256;

                    mic.enhancedOptions.nonLinearProcessing = false;

                }

                else

                {

                    mic = Microphone.getMicrophone();

                }

            

                mic.setUseEchoSuppression(true);

                mic.rate = 44;

                mic.gain = 20;

                mic.setSilenceLevel(0, 5000);

                mic.soundTransform = new SoundTransform(1);

            

                m_ns = new NetStream(m_nc);

                m_ns.attachCamera(m_cam);

                m_ns.attachAudio(mic);

                m_ns.bufferTime = 0;

                m_ns.publish("web", "live");

            

                var ns:NetStream = new NetStream(m_nc);

                ns.soundTransform = new SoundTransform();

                ns.play("mobile", "live");

            

                var vid:Video = new Video(320, 240);

                vid.attachNetStream(ns);

                addChild(vid);

            }

        }

    }

}

2. HelloChatMobile (AIR Mobile)

package

{

    import flash.display.Sprite;

    import flash.events.Event;

    import flash.events.NetStatusEvent;

    import flash.events.TimerEvent;

    import flash.media.Camera;

    import flash.media.Microphone;

    import flash.media.SoundTransform;

    import flash.media.Video;

    import flash.net.NetConnection;

    import flash.net.NetStream;

    import flash.utils.Timer;

    public final class HelloChatMobile extends Sprite

    {

        private const CONNECTION_STRING:String = "rtmp://someIP/HelloChat/0";

    

        private var m_cam:Camera;

        private var m_tmr:Timer;

    

        private var m_nc:NetConnection = new NetConnection();

        private var m_ns:NetStream;

    

        public function HelloChatMobile()

        {

            m_nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

            if (m_cam = Camera.getCamera("1"))

            {

                m_nc.connect(CONNECTION_STRING);

            }

            else

            {

                m_tmr = new Timer(1000);

                m_tmr.addEventListener(TimerEvent.TIMER, onTimer);

                m_tmr.start();

            }

        }

    

        private function onTimer(pEvent:TimerEvent):void

        {

            if (m_cam = Camera.getCamera("1"))

            {

                m_tmr.removeEventListener(TimerEvent.TIMER, onTimer);

                m_tmr.stop();

                m_nc.connect(CONNECTION_STRING);

            }

        }

    

        private function onNetStatus(pEvent:NetStatusEvent):void

        {

            if (pEvent.info.code == "NetConnection.Connect.Success")

            {

                m_cam.setMode(320, 240, 15, false);

                m_cam.setQuality(65535, 0);

                m_cam.setKeyFrameInterval(8);

            

                var mic:Microphone = Microphone.getEnhancedMicrophone();

                if (mic)

                {

                    mic.enhancedOptions.echoPath = 256;

                    mic.enhancedOptions.nonLinearProcessing = false;

                }

                else

                {

                    mic = Microphone.getMicrophone();

                }

            

                mic.setUseEchoSuppression(true);

                mic.rate = 44;

                mic.gain = 20;

                mic.setSilenceLevel(0, 5000);

                mic.soundTransform = new SoundTransform(1);

            

                m_ns = new NetStream(m_nc);

                m_ns.attachCamera(m_cam);

                m_ns.attachAudio(mic);

                m_ns.bufferTime = 0;

                m_ns.publish("mobile", "live");

            

                var ns:NetStream = new NetStream(m_nc);

                ns.soundTransform = new SoundTransform();

                ns.play("web", "live");

            

                var vid:Video = new Video(320, 240);

                vid.attachNetStream(ns);

                addChild(vid);

            }

        }

    }

}

There is no server-side code in the AMS app.

Try running the mobile one on an iPad mini 2 and the web-based one through your favorite browser on a desktop machine, and you'll quickly notice a problem: When using AIR Mobile on an iPad (at least an iPad mini), you simply cannot get the performance needed to fully support two-way communication like this.  Both sides connect fine.  Both sides hear each other fine.  The web client sees the mobile client's video fine.  The problem is solely with the mobile client receiving the web client's video, as an iPad mini will freeze the web client's video on and off throughout the conversation.  Changing the render mode does not seem to fully fix this problem.

That being said, I'm trying to research writing Objective-C code for the iOS side of something like this, and what I'm hearing and seeing suggests that this is done...but any starting point in learning how to do this seems to be obscured by other search results in Google.  It's not that I haven't looked; it's that I keep seeing things that'll skim the surface or appear to refer to this or something, but a good, basic description of how to Hello World this seems to be particularly difficult to come by.

Ideally we're trying to write in Flash for desktop clients, Objective-C for iPad clients, and then have them use hub-and-spoke RTMP through Adobe Media Server to facilitate live communication.  Not file-streaming, not HTML5 (for certain reasons).  It sounds like this is possible and is done, but if so, where do you start to learn this?  Alternatively if there were some particular trick to get the above program to animate the web-client's video a little faster, that might be another solution.  Thank you.

Views

419

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines