English 中文(简体)
RTMP 和机型顶部
原标题:RTMP android aftek

I am trying to implement the library from http://www.aftek.com/afteklab/aftek-RTMP-library.shtml to stream live video from a red5 server.

在服务器上,我正在使用简单的Broadcaster, 我想把它传送到手机和机器人手机上。

我的代码:

package com.cu.reader;

import java.nio.channels.FileChannel;
import java.util.Map;
import com.al.rtmp.client.RtmpClient;
import com.al.rtmp.client.RtmpStream;
import com.al.rtmp.client.RtmpStreamFactory;
import com.al.rtmp.client.data.MetaData;
import com.al.rtmp.client.data.RTMPData;
import com.al.rtmp.client.data.VideoCodec;
import com.al.rtmp.message.Metadata;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class StreamreaderActivity extends Activity implements RtmpClient {
     RtmpStream stream = null;
     Boolean connected = false;
 String server = "rtmp://216.224.181.197/oflaDemo/";
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    stream = RtmpStreamFactory.getRtmpStream();
    stream.setClient(this);
    stream.connect(server);
}
@Override
public void streamCreated() {
    Log.i("stream","Connected!");       

    connected = true;
    stream.setPlayName("red5StreamDemo");
    stream.play();

}
@Override
public byte[] getWriteData(int length) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public void invoke(String arg0, Object... arg1) {
    // TODO Auto-generated method stub
;   
}
@Override
public void onDataReceived(RTMPData rtmpData) {
    MetaData metaData = rtmpData.getMetaData();
    VideoCodec vc = metaData.getVideoCodec();
}
@Override
public void onError(Exception ex) {
    Log.e("ClientException", " Some exception occurred." + ex.getMessage());
    ex.printStackTrace();
}
@Override
public void onMetaDataReceived(Map map) {
    Log.i("code","METADATA:" + map);        

}
@Override
public void onResult(String method, Object... arg1) {
    Log.i("result","METADATA:" + method);       

}
@Override
public void onStatus(String code) {
    Log.i("code",code);     
}

}

我总是接收NetStream.Play. Stream NotFound on Status 函数上的网络Status。

谢谢

最佳回答

流并不存在, 正确 。 但原因为何? 可能是一两个原因 : 您没有创建直播流和 2, 因为您使用错误的范围 。 除非您手工配置不同( 不太可能), 否则使用直播范围, 即/ 实时 。

因此,发布到rtmp://216.224.181.197/live/red5StreamDemo, 并在此例中的rtmp://216.224.181.197/live/red5StreamDemo 中, 并订阅相同的 Mrl。 注意: 要做到这一点, 您需要创建一个活流, 并将其输入您的 RED5 服务器。 您可以使用 avconv (affmpeg) 来创建 rtmp 种子 。

问题回答

您可以获取 NetStream.Play.StreamNotFound 错误。 将这种流体在 red5 应用程序上不存在 。

我做了快速的As3测试来检查:

package {

import flash.display.Sprite;
import flash.events.AsyncErrorEvent;
import flash.events.IOErrorEvent;
import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;

public class LearnWowzaClient extends Sprite {

    private var nc:NetConnection;
    private var video:Video = new Video();

    public function LearnWowzaClient() {

        nc = new NetConnection();
        nc.client = this;
        nc.addEventListener(NetStatusEvent.NET_STATUS, onNet);
        nc.connect("rtmp://216.224.181.197/oflaDemo/");
    }

    private function onNet(event:NetStatusEvent):void {
        trace(event);
        trace(event.info.code);
        switch (event.info.code) {
            case "NetConnection.Connect.Success":
                tryPlayStream();
                break;
        }
    }

    private function tryPlayStream():void {
        trace("playStream");
        var ns:NetStream = new NetStream(nc);
        ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
        ns.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
        ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);

        ns.play("red5StreamDemo");
        video.attachNetStream(ns);
    }

    public function onBWCheck(parameter:Object = null):void {
        trace("onBWCheck p=" + parameter);
    }

    public function onBWDone(parameter:Object = null):void {
        trace("onBWDone p=" + parameter);
    }

    private function onIOError(event:IOErrorEvent):void {
        trace("onIOError");
    }

    private function onAsyncError(event:AsyncErrorEvent):void {
        trace("onAsyncError");
    }

    private function onNetStatus(event:NetStatusEvent):void {
        trace("onNetStatus   ", event.info.code);
    }
}
}

I also get NetStream.Play.StreamNotFound error. Can you show red5 application code?





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签