wanglava 2015-03-26 16:12
浏览 1471

flex rtmp wowza不能发布视频

请教个问题。我用flex + rtmp + wowza想实现视频的推送和接收。我使用如下的代码推送视频,但是在wowza服务器上却直接停止了我的推送操作,请问这是什么原因呢?

 <?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" minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[

            private var connection:NetConnection; 
            private var stream:NetStream; 
            private var m_camera:Camera;


            public function VideoExample():void 
            { 
                connection = new NetConnection(); 
                connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
                connection.connect(txtURL.text);
            } 

            private function netStatusHandler(event:NetStatusEvent):void { 
                switch (event.info.code)
                {
                    case "NetConnection.Connect.Success":
                        trace("成功连接FMS服务器!");
                        publishStreamVideo(); // 接收视频
                        break;
                    case "NetConnection.Connect.Rejected":
                        trace ("访问FMS服务器权限不足,连接被拒绝!");
                        break;
                    case "NetConnection.Connect.InvalidApp":
                        trace("指定的应用程序名称没有找到");
                        break;
                    case "NetConnection.Connect.Failed":
                        trace("连接失败!");
                        break;
                    case "NetConnection.Connect.AppShutDown":
                        trace("服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭!");
                        break;
                    case "NetConnection.Connect.Closed":
                        trace("与FMS的连接中断!");
                        break;
                }
            } 

            // 发布视频
            private function publishStreamVideo():void 
            { 
                var stream:NetStream = new NetStream(connection); 

                var microPhone:Microphone = Microphone.getMicrophone();

                stream.attachAudio(microPhone);
                stream.attachCamera(m_camera);
                stream.client = this;
                stream.publish(txtID.text);
            } 

            private function securityErrorHandler(event:SecurityErrorEvent):void 
            {
                trace("securityErrorHandler: " + event); 
            } 

            private function asyncErrorHandler(event:AsyncErrorEvent):void 
            { 
                trace("securityErrorHandler: " + event); 
            } 

            // 推送视频
            protected function button1_clickHandler(event:MouseEvent):void
            {
                VideoExample();
            }

            // 连接摄像头
            protected function btnOpenCamera_clickHandler(event:MouseEvent):void
            {
                m_camera = Camera.getCamera();

                var m_video:Video = new Video(m_camera.width * 2, m_camera.height * 2);
                m_video.attachCamera(m_camera);
                sprct.addChild(m_video);
            }

        ]]>
    </fx:Script>

    <s:TextInput id="txtURL" x="78" y="49" width="244" text="rtmp://localhost/videochat"/>
    <s:TextInput id="txtID" x="78" y="79" width="244" text="testing"/>
    <s:Button x="351" y="76" label="推送视频" click="button1_clickHandler(event)" />
    <s:VideoDisplay id="sprct" x="79" y="101" width="351" height="238"/>
    <s:Button id="btnOpenCamera" x="351" y="48" label="打开摄像头" click="btnOpenCamera_clickHandler(event)"/>
</s:Application>

publish - unpublish - destory!为什么会这样呢?

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 一道python难题
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度