Live555无法在Android上运行

时间:2015-01-16 23:52:50

标签: android android-ndk java-native-interface live555

我尝试使用Live555将视频文件(h264原始流)从Android设备流式传输到VLC。我的本机代码基于testh264streamer示例,它在Ubuntu上运行正常 但是,当我尝试在Android上启动流式传输时,它无效。视频文件成功打开,客户端收到一些软件包(我跟随Wireshark),但VLC没有显示任何内容。
我想问题是Java和C ++之间的联系,所以这里是我的Java代码,它调用本地流方法:

public class LiveStreamer implements Runnable {
    private static final String LOG_TAG = LiveStreamer.class.getSimpleName();

    private Context context;
    private String fileName;
    private FileDescriptor fileDescriptor;

    public LiveStreamer(Context context, String fileName) {
        this.context = context;
        this.fileName = fileName;
        this.prepare();
    }

    private void prepare() {
        try {
            fileDescriptor = prepareStream(fileName, fileDescriptor);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getFileName() {
        return fileName;
    }

    public FileDescriptor getFileDescriptor() {
        return fileDescriptor;
    }

    private native void stream(String ipAdress);

    private native FileDescriptor prepareStream(String file, FileDescriptor fd)
        throws IOException;

    @Override
    public void run() {
        Log.d(LOG_TAG, "Start streaming ...");
        String ipAddress = NetworkUtilities.getWifiIpAddress(context);
        if (fileDescriptor != null) {
            stream(ipAddress);
        }
        Log.d(LOG_TAG, "Stopp streaming ...");
    }
}

我的原生代码:

JNIEXPORT void JNICALL Java_[PACKAGE_NAME]_LiveStreamer_stream(
    JNIEnv *env, jobject obj, jstring ipAddress) {
    const char* c_ipaddress = env->GetStringUTFChars(ipAddress, false);

    jclass streamClazz = env->GetObjectClass(obj);
    jclass exceptionClazz = env->FindClass("java/lang/RuntimeException");

    if (streamClazz == NULL || exceptionClazz == NULL) {
        return;
    }

    if (videoFile == NULL) {
        return;
    }

    // setting up the usage environment
    TaskScheduler *scheduler = BasicTaskScheduler::createNew();
    uenv = BasicUsageEnvironment::createNew(*scheduler);

    // Creating groupsocks
    struct in_addr destinationAddress;
    destinationAddress.s_addr = chooseRandomIPv4SSMAddress(*uenv);

    const unsigned short rtpPortNum = 18888;
    const unsigned short rtcpPortNum = rtpPortNum + 1;
    const unsigned char ttl = 255;

    const Port rtpPort(rtpPortNum);
    const Port rtcpPort(rtcpPortNum);

    Groupsock rtpGroupsockVideo(*uenv, destinationAddress, rtpPort, ttl);
    Groupsock rtcpGroupsockVideo(*uenv, destinationAddress, rtcpPort, ttl);

    rtpGroupsockVideo.multicastSendOnly();
    rtcpGroupsockVideo.multicastSendOnly();

    // Create a 'H264 Video RTP' sink from the RTP 'groupsock':
    OutPacketBuffer::maxSize = 100000;
    rtpVideoSink = H264VideoRTPSink::createNew(*uenv, &rtpGroupsockVideo, 96);

    // Create (and start) a 'RTCP instance' for this RTP sink:
    logDebug("Starting RTSP server ...");
    const unsigned estimatedSessionBandwidth = 10000; // in kbps; for RTCP b/w share
    const unsigned maxCNAMElen = 100;
    unsigned char CNAME[maxCNAMElen + 1];
    gethostname((char*) CNAME, maxCNAMElen);
    CNAME[maxCNAMElen] = '\0'; // just in case

    RTCPInstance* rtcpVideo = RTCPInstance::createNew(*uenv,
        &rtcpGroupsockVideo, estimatedSessionBandwidth, CNAME, rtpVideoSink,
        NULL, True);

    RTSPServer *rtspServer = RTSPServer::createNew(*uenv, 8554);
    if (rtspServer == NULL) {
        logError("Failed to create RTSP Server");
        exit(1);
    }

    ServerMediaSession *session = ServerMediaSession::createNew(*uenv,
        "herosession", "video.sdp", "Session streamed by \"LiveCam\"",
        True);
    session->addSubsession(
        PassiveServerMediaSubsession::createNew(*rtpVideoSink));
    rtspServer->addServerMediaSession(session);
    logDebug("RTSP server started ...");

    logDebug("Beginning streaming ...");
    char* url = rtspServer->rtspURL(session);
    logDebug(url);

    play();
    uenv->taskScheduler().doEventLoop(); // does not return
}

你有什么建议吗?谢谢你的帮助!

编辑//

这是我的应用程序的logcat(看似不可思议的东西):

01-17 14:00:38.731: D/dalvikvm(32167): Trying to load lib /data/app-lib/de.[PACKAGE]-4/libliveCam.so 0x4252f570
01-17 14:00:38.731: D/dalvikvm(32167): Added shared lib /data/app-lib/de.[PACKAGE]-4/libliveCam.so 0x4252f570
01-17 14:00:38.731: D/dalvikvm(32167): No JNI_OnLoad found in /data/app-lib/de.[PACKAGE]-4/libliveCam.so 0x4252f570, skipping init
01-17 14:00:38.741: I/PersonaManager(32167): getPersonaService() name persona_policy
01-17 14:00:38.771: D/skia(32167): GFXPNG PNG bitmap created width:13 height:41 bitmap id is 180 
01-17 14:00:38.781: E/MoreInfoHPW_ViewGroup(32167): Parent view is not a TextView
01-17 14:00:38.801: D/skia(32167): GFXPNG PNG bitmap created width:78 height:96 bitmap id is 181 
01-17 14:00:38.811: D/skia(32167): GFXPNG PNG bitmap created width:78 height:96 bitmap id is 182 
01-17 14:00:38.811: D/skia(32167): GFXPNG PNG bitmap created width:144 height:144 bitmap id is 183 
01-17 14:00:38.821: D/Activity(32167): setTransGradationMode to true
01-17 14:00:38.961: I/Adreno-EGL(32167): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
01-17 14:00:38.961: I/Adreno-EGL(32167): OpenGL ES Shader Compiler Version: E031.24.00.08+13
01-17 14:00:38.961: I/Adreno-EGL(32167): Build Date: 03/20/14 Thu
01-17 14:00:38.961: I/Adreno-EGL(32167): Local Branch: 0320_AU200_patches
01-17 14:00:38.961: I/Adreno-EGL(32167): Remote Branch: 
01-17 14:00:38.961: I/Adreno-EGL(32167): Local Patches: 
01-17 14:00:38.961: I/Adreno-EGL(32167): Reconstruct Branch: 
01-17 14:00:38.991: D/OpenGLRenderer(32167): Enabling debug mode 0
01-17 14:00:42.611: D/LiveStreamer(32167): Start streaming ...
01-17 14:00:42.631: D/LiveCam(32167): Starting RTSP server ...
01-17 14:00:42.631: D/LiveCam(32167): RTSP server started ...
01-17 14:00:42.631: D/LiveCam(32167): Beginning streaming ...
01-17 14:00:42.631: D/LiveCam(32167): rtsp://141.24.13.60:8554/herosession
01-17 14:00:42.631: D/LiveCam(32167): Beginning to read from file ...
01-17 14:00:42.631: D/LiveCam(32167): ...done reading from file
01-17 14:00:42.631: D/LiveCam(32167): Beginning to read from file ...

这里是vlc的调试输出:

[000000000119b188] core playlist debug: adding item `rtsp://141.24.13.60:8554/herosession' ( rtsp://141.24.13.60:8554/herosession )
[000000000119b188] core playlist debug: meta ok for (null), need to fetch art
[000000000119b188] core playlist debug: processing request item: rtsp://141.24.13.60:8554/herosession, node: null, skip: 0
[000000000119b188] core playlist debug: rebuilding array of current - root Wiedergabeliste
[000000000119b188] core playlist debug: rebuild done - 1 items, index 0
[000000000119b188] core playlist debug: starting playback of the new playlist item
[000000000119b188] core playlist debug: resyncing on rtsp://141.24.13.60:8554/herosession
[000000000119b188] core playlist debug: rtsp://141.24.13.60:8554/herosession is at 0
[000000000119b188] core playlist debug: creating new input thread
[00007fb48c0009b8] core input debug: Creating an input for 'rtsp://141.24.13.60:8554/herosession'
[00007fb494000cf8] core art finder debug: looking for meta fetcher module matching "any": 1 candidates
[000000000119b188] core playlist debug: requesting art for rtsp://141.24.13.60:8554/herosession
[00007fb48c0009b8] core input debug: using timeshift granularity of 50 MiB, in path '/tmp'
[00007fb48c0009b8] core input debug: `rtsp://141.24.13.60:8554/herosession' gives access `rtsp' demux `' path `141.24.13.60:8554/herosession'
[00007fb48c0009b8] core input debug: specified demux `any'
[00007fb48c0009b8] core input debug: creating demux: access='rtsp' demux='any' location='141.24.13.60:8554/herosession' file='(null)'
[00007fb484000958] core art finder debug: looking for meta fetcher module matching "any": 1 candidates
[00007fb490000e38] core demux debug: looking for access_demux module matching "rtsp": 21 candidates
[00007fb490000e38] live555 demux debug: version 2014.01.13
[00000000011b57b8] qt4 interface debug: IM: Setting an input
Opening connection to 141.24.13.60, port 8554...
[00007fb484000958] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/fetcher
[00007fb484000958] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/fetcher
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/fetcher/tvrage.luac
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/fetcher
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/fetcher
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/fetcher/tvrage.luac
[00007fb494000cf8] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/fetcher/tvrage.luac
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /usr/share/vlc/lua/meta/fetcher
[00007fb494000cf8] core art finder debug: no meta fetcher modules matched
[00007fb484000958] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/fetcher/tvrage.luac
[00007fb484000958] lua art finder debug: Trying Lua scripts in /usr/share/vlc/lua/meta/fetcher
[00007fb484000958] core art finder debug: no meta fetcher modules matched
[0000000001187118] core libvlc debug: searching art for rtsp://141.24.13.60:8554/herosession
[00007fb484000958] core art finder debug: looking for art finder module matching "any": 2 candidates
[000000000119b188] core playlist debug: searching art for rtsp://141.24.13.60:8554/herosession
[00007fb494000cf8] core art finder debug: looking for art finder module matching "any": 2 candidates
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/art
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/art
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/00_musicbrainz.luac
[00007fb484000958] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/art
[00007fb484000958] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/art
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/00_musicbrainz.luac
[00007fb484000958] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/00_musicbrainz.luac
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/01_googleimage.luac
[00007fb494000cf8] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/00_musicbrainz.luac
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/01_googleimage.luac
...remote connection opened
Sending request: OPTIONS rtsp://141.24.13.60:8554/herosession RTSP/1.0
CSeq: 2
User-Agent: LibVLC/2.2.0-pre2 (LIVE555 Streaming Media v2014.01.13)


[00007fb484000958] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/01_googleimage.luac
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/02_frenchtv.luac
[00007fb494000cf8] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/01_googleimage.luac
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/02_frenchtv.luac
[00007fb484000958] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/02_frenchtv.luac
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/03_lastfm.luac
Received 152 new bytes of response data.
Received a complete OPTIONS response:
RTSP/1.0 200 OK
CSeq: 2
Date: Sat, Jan 17 2015 13:06:24 GMT
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER


Sending request: DESCRIBE rtsp://141.24.13.60:8554/herosession RTSP/1.0
CSeq: 3
User-Agent: LibVLC/2.2.0-pre2 (LIVE555 Streaming Media v2014.01.13)
Accept: application/sdp


[00007fb494000cf8] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/02_frenchtv.luac
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/03_lastfm.luac
Received 617 new bytes of response data.
[00007fb484000958] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/03_lastfm.luac
Received a complete DESCRIBE response:
RTSP/1.0 200 OK
CSeq: 3
Date: Sat, Jan 17 2015 13:06:24 GMT
Content-Base: rtsp://141.24.13.60:8554/herosession/
Content-Type: application/sdp
Content-Length: 447

v=0
o=- 1421499976435789 1 IN IP4 141.24.13.60
s=Session streamed by "LiveCam"
i=video.sdp
t=0 0
a=tool:LIVE555 Streaming Media v2015.01.04
a=type:broadcast
a=control:*
a=source-filter: incl IN IP4 * 141.24.13.60
a=rtcp-unicast: reflection
a=range:npt=0-
a=x-qt-text-nam:Session streamed by "LiveCam"
a=x-qt-text-inf:video.sdp
m=video 18888 RTP/AVP 96
c=IN IP4 232.240.223.192/255
b=AS:50
a=rtpmap:96 H264/90000
a=control:track1

[00007fb484000958] lua art finder debug: Trying Lua scripts in /usr/share/vlc/lua/meta/art
[00007fb484000958] core art finder debug: no art finder modules matched
[00007fb484000958] core art finder debug: looking for meta fetcher module matching "any": 1 candidates
[00007fb490000e38] live555 demux debug: RTP subsession 'video/H264'
Sending request: SETUP rtsp://141.24.13.60:8554/herosession/track1 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/2.2.0-pre2 (LIVE555 Streaming Media v2014.01.13)
Transport: RTP/AVP;multicast;client_port=18888-18889


[00007fb494000cf8] lua art finder debug: skipping script (unmatched scope) /usr/lib/vlc/lua/meta/art/03_lastfm.luac
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /usr/share/vlc/lua/meta/art
[00007fb494000cf8] core art finder debug: no art finder modules matched
[00007fb494000cf8] core art finder debug: looking for meta fetcher module matching "any": 1 candidates
[00007fb484000958] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/fetcher
[00007fb484000958] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/fetcher
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/fetcher/tvrage.luac
Received 194 new bytes of response data.
Received a complete SETUP response:
RTSP/1.0 200 OK
CSeq: 4
Date: Sat, Jan 17 2015 13:06:24 GMT
Transport: RTP/AVP;multicast;destination=232.240.223.192;source=141.24.13.60;port=18888-0;ttl=255
Session: 247BEDD2;timeout=65


[00007fb48c0009b8] core input debug: selecting program id=0
[00007fb490000e38] live555 demux debug: setup start: 0,000000 stop:0,000000
Sending request: PLAY rtsp://141.24.13.60:8554/herosession/ RTSP/1.0
CSeq: 5
User-Agent: LibVLC/2.2.0-pre2 (LIVE555 Streaming Media v2014.01.13)
Session: 247BEDD2
Range: npt=0.000-


[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/fetcher
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/fetcher
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/fetcher/tvrage.luac
[00007fb484000958] core art finder debug: using meta fetcher module "lua"
[00007fb484000958] core art finder debug: removing module "lua"
[0000000001187118] core libvlc debug: searching art for rtsp://141.24.13.60:8554/herosession
[00007fb484000958] core art finder debug: looking for art finder module matching "any": 2 candidates
Received 191 new bytes of response data.
Received a complete PLAY response:
RTSP/1.0 200 OK
CSeq: 5
Date: Sat, Jan 17 2015 13:06:24 GMT
Range: npt=0.000-
Session: 247BEDD2
RTP-Info: url=rtsp://141.24.13.60:8554/herosession/track1;seq=21427;rtptime=3001652764


[00007fb490000e38] live555 demux debug: We have a timeout of 65 seconds
[00007fb490000e38] live555 demux debug: spawned timeout thread
[00007fb490000e38] live555 demux debug: play start: 0,000000 stop:0,000000
[00007fb490000e38] core demux debug: using access_demux module "live555"
[00007fb49000c238] core decoder debug: looking for decoder module matching "any": 42 candidates
[00007fb494000cf8] core art finder debug: using meta fetcher module "lua"
[00007fb494000cf8] core art finder debug: removing module "lua"
[000000000119b188] core playlist debug: searching art for rtsp://141.24.13.60:8554/herosession
[00007fb494000cf8] core art finder debug: looking for art finder module matching "any": 2 candidates
[00007fb484000958] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/art
[00007fb484000958] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/art
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/00_musicbrainz.luac
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/01_googleimage.luac
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/art
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/art
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/00_musicbrainz.luac
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/02_frenchtv.luac
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/01_googleimage.luac
[00007fb49000c238] avcodec decoder debug: CPU flags: 0x000053db
[00007fb484000958] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/03_lastfm.luac
[00007fb49000c238] avcodec decoder debug: trying to use direct rendering
[00007fb49000c238] avcodec decoder debug: allowing 4 thread(s) for decoding
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/02_frenchtv.luac
[00007fb49000c238] avcodec decoder debug: avcodec codec (H264 - MPEG-4 AVC (part 10)) started
[00007fb49000c238] avcodec decoder debug: using frame thread mode with 4 threads
[00007fb49000c238] core decoder debug: using decoder module "avcodec"
[00007fb4901ad358] core packetizer debug: looking for packetizer module matching "any": 22 candidates
[00007fb4901ad358] core packetizer debug: using packetizer module "packetizer_h264"
[00007fb4901b33a8] core demux meta debug: looking for meta reader module matching "any": 2 candidates
[00007fb484000958] lua art finder debug: Trying Lua scripts in /usr/share/vlc/lua/meta/art
[00007fb484000958] core art finder debug: no art finder modules matched
[0000000001187118] core libvlc debug: art not found for rtsp://141.24.13.60:8554/herosession
[00007fb494000cf8] lua art finder debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/art/03_lastfm.luac
[00007fb4901b33a8] lua demux meta debug: Trying Lua scripts in /home/robin/.local/share/vlc/lua/meta/reader
[00007fb4901b33a8] lua demux meta debug: Trying Lua scripts in /usr/lib/vlc/lua/meta/reader
[00007fb4901b33a8] lua demux meta debug: Trying Lua playlist script /usr/lib/vlc/lua/meta/reader/filename.luac
[00007fb494000cf8] lua art finder debug: Trying Lua scripts in /usr/share/vlc/lua/meta/art
[00007fb494000cf8] core art finder debug: no art finder modules matched
[000000000119b188] core playlist debug: art not found for rtsp://141.24.13.60:8554/herosession
[00007fb4901b33a8] lua demux meta debug: Trying Lua scripts in /usr/share/vlc/lua/meta/reader
[00007fb4901b33a8] core demux meta debug: no meta reader modules matched
[00007fb48c0009b8] core input debug: `rtsp://141.24.13.60:8554/herosession' successfully opened
Sending request: GET_PARAMETER rtsp://141.24.13.60:8554/herosession/ RTSP/1.0
CSeq: 6
User-Agent: LibVLC/2.2.0-pre2 (LIVE555 Streaming Media v2014.01.13)
Session: 247BEDD2


Received 114 new bytes of response data.
Received a complete GET_PARAMETER response:
RTSP/1.0 200 OK
CSeq: 6
Date: Sat, Jan 17 2015 13:06:24 GMT
Session: 247BEDD2
Content-Length: 10

2015.01.04

0 个答案:

没有答案