Windows7上用AS编译MIPS架构的live555(一)

本文链接:http://www.jianshu.com/p/d65bda8713f7

环境

系统:Windows7 SP1 64位

编辑器:Android Studio 3.0

Live555:2018-01-24

NDK:r10e

下载源码

地址 http://www.live555.com/liveMedia/public/

live555 download.png

下载live555-latest.tar.gz

我下载的是2018-01-24版本,度盘

新建工程

用AS新建工程TestLive555,把live目录解压到app目录下, 并将目录名从live改成jni

工程结构.png

在jni目录下新建一个文件 Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# NDK 7d支持硬浮点的直接编译
#APP_ABI := armeabi-v7a-hard

LOCAL_MODULE := liblive555

LOCAL_ARM_MODE := arm

LOCAL_PRELINK_MODULE := false

LOCAL_CPPFLAGS := \
	-DNULL=0 -DSOCKLEN_T=socklen_t -DNO_SSTREAM -DBSD=1 -DNO_SSTREAM -fexceptions -DANDROID -DXLOCALE_NOT_USED

LOCAL_C_INCLUDES := \
	$(LOCAL_PATH) \
	$(LOCAL_PATH)/BasicUsageEnvironment/include \
	$(LOCAL_PATH)/BasicUsageEnvironment \
	$(LOCAL_PATH)/UsageEnvironment/include \
	$(LOCAL_PATH)/UsageEnvironment \
	$(LOCAL_PATH)/groupsock/include \
	$(LOCAL_PATH)/groupsock \
	$(LOCAL_PATH)/liveMedia/include \
	$(LOCAL_PATH)/liveMedia \

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := \
groupsock/IOHandlers.cpp                                       \
groupsock/Groupsock.cpp                                        \
groupsock/NetAddress.cpp                                       \
groupsock/GroupsockHelper.cpp                                  \
groupsock/NetInterface.cpp                                     \
groupsock/GroupEId.cpp                                         \
groupsock/inet.c                                               \
liveMedia/rtcp_from_spec.c                                     \
liveMedia/MPEG4GenericRTPSource.cpp                            \
liveMedia/MatroskaFileServerMediaSubsession.cpp                \
liveMedia/DVVideoRTPSink.cpp                                   \
liveMedia/H265VideoFileServerMediaSubsession.cpp               \
liveMedia/OggFile.cpp                                          \
liveMedia/MP3Transcoder.cpp                                    \
liveMedia/VorbisAudioRTPSink.cpp                               \
liveMedia/H265VideoStreamDiscreteFramer.cpp                    \
liveMedia/MPEG2TransportStreamFromESSource.cpp                 \
liveMedia/MPEG2TransportStreamIndexFile.cpp                    \
liveMedia/MediaSink.cpp                                        \
liveMedia/MPEG1or2Demux.cpp                                    \
liveMedia/QuickTimeFileSink.cpp                                \
liveMedia/MPEG1or2DemuxedServerMediaSubsession.cpp             \
liveMedia/MatroskaFileParser.cpp                               \
liveMedia/JPEGVideoSource.cpp                                  \
liveMedia/H264VideoStreamDiscreteFramer.cpp                    \
liveMedia/MP3ADURTPSink.cpp                                    \
liveMedia/MPEG4VideoStreamFramer.cpp                           \
liveMedia/MP3ADURTPSource.cpp                                  \
liveMedia/MP3InternalsHuffmanTable.cpp                         \
liveMedia/FramedFileSource.cpp                                 \
liveMedia/MPEG4GenericRTPSink.cpp                              \
liveMedia/MP3ADUTranscoder.cpp                                 \
liveMedia/FramedFilter.cpp                                     \
liveMedia/StreamParser.cpp                                     \
liveMedia/H265VideoRTPSink.cpp                                 \
liveMedia/TCPStreamSink.cpp                                    \
liveMedia/BasicUDPSource.cpp                                   \
liveMedia/MPEG1or2VideoFileServerMediaSubsession.cpp           \
liveMedia/MPEG4ESVideoRTPSource.cpp                            \
liveMedia/MatroskaFile.cpp                                     \
liveMedia/OggFileSink.cpp                                      \
liveMedia/MPEG1or2VideoRTPSource.cpp                           \
liveMedia/InputFile.cpp                                        \
liveMedia/BitVector.cpp                                        \
liveMedia/StreamReplicator.cpp                                 \
liveMedia/H264or5VideoStreamDiscreteFramer.cpp                 \
liveMedia/MP3FileSource.cpp                                    \
liveMedia/OggFileParser.cpp                                    \
liveMedia/EBMLNumber.cpp                                       \
liveMedia/H263plusVideoStreamParser.cpp                        \
liveMedia/VP8VideoRTPSink.cpp                                  \
liveMedia/VideoRTPSink.cpp                                     \
liveMedia/VorbisAudioRTPSource.cpp                             \
liveMedia/H263plusVideoStreamFramer.cpp                        \
liveMedia/DVVideoStreamFramer.cpp                              \
liveMedia/Base64.cpp                                           \
liveMedia/MPEG1or2AudioRTPSink.cpp                             \
liveMedia/ByteStreamFileSource.cpp                             \
liveMedia/H265VideoRTPSource.cpp                               \
liveMedia/AMRAudioFileServerMediaSubsession.cpp                \
liveMedia/H261VideoRTPSource.cpp                               \
liveMedia/RTSPRegisterSender.cpp                               \
liveMedia/MPEG1or2VideoRTPSink.cpp                             \
liveMedia/RTSPClient.cpp                                       \
liveMedia/RTPSource.cpp                                        \
liveMedia/MPEG2IndexFromTransportStream.cpp                    \
liveMedia/AMRAudioFileSink.cpp                                 \
liveMedia/AudioRTPSink.cpp                                     \
liveMedia/H264VideoFileSink.cpp                                \
liveMedia/AudioInputDevice.cpp                                 \
liveMedia/MPEG4VideoStreamDiscreteFramer.cpp                   \
liveMedia/H264or5VideoFileSink.cpp                             \
liveMedia/MP3ADUinterleaving.cpp                               \
liveMedia/AC3AudioStreamFramer.cpp                             \
liveMedia/MPEG2TransportStreamTrickModeFilter.cpp              \
liveMedia/MPEG1or2DemuxedElementaryStream.cpp                  \
liveMedia/MPEG4ESVideoRTPSink.cpp                              \
liveMedia/H264VideoFileServerMediaSubsession.cpp               \
liveMedia/OnDemandServerMediaSubsession.cpp                    \
liveMedia/OutputFile.cpp                                       \
liveMedia/FileSink.cpp                                         \
liveMedia/FileServerMediaSubsession.cpp                        \
liveMedia/MP3InternalsHuffman.cpp                              \
liveMedia/AMRAudioRTPSource.cpp                                \
liveMedia/MatroskaFileServerDemux.cpp                          \
liveMedia/ADTSAudioFileServerMediaSubsession.cpp               \
liveMedia/BasicUDPSink.cpp                                     \
liveMedia/MP3AudioMatroskaFileServerMediaSubsession.cpp        \
liveMedia/MPEG2TransportStreamFramer.cpp                       \
liveMedia/uLawAudioFilter.cpp                                  \
liveMedia/RTSPServer.cpp                                       \
liveMedia/DVVideoFileServerMediaSubsession.cpp                 \
liveMedia/H263plusVideoRTPSink.cpp                             \
liveMedia/H263plusVideoFileServerMediaSubsession.cpp           \
liveMedia/H265VideoStreamFramer.cpp                            \
liveMedia/JPEGVideoRTPSink.cpp                                 \
liveMedia/WAVAudioFileServerMediaSubsession.cpp                \
liveMedia/ByteStreamMultiFileSource.cpp                        \
liveMedia/TheoraVideoRTPSink.cpp                               \
liveMedia/ByteStreamMemoryBufferSource.cpp                     \
liveMedia/ourMD5.cpp                                           \
liveMedia/MPEG2TransportFileServerMediaSubsession.cpp          \
liveMedia/MPEG2TransportStreamMultiplexor.cpp                  \
liveMedia/MPEGVideoStreamParser.cpp                            \
liveMedia/MPEG1or2VideoStreamDiscreteFramer.cpp                \
liveMedia/VP8VideoRTPSource.cpp                                \
liveMedia/H264or5VideoStreamFramer.cpp                         \
liveMedia/AMRAudioRTPSink.cpp                                  \
liveMedia/RTPInterface.cpp                                     \
liveMedia/TheoraVideoRTPSource.cpp                             \
liveMedia/Locale.cpp                                           \
liveMedia/MPEGVideoStreamFramer.cpp                            \
liveMedia/QCELPAudioRTPSource.cpp                              \
liveMedia/ADTSAudioFileSource.cpp                              \
liveMedia/MediaSource.cpp                                      \
liveMedia/AC3AudioRTPSource.cpp                                \
liveMedia/WAVAudioFileSource.cpp                               \
liveMedia/MPEG4LATMAudioRTPSink.cpp                            \
liveMedia/MPEG1or2AudioRTPSource.cpp                           \
liveMedia/GSMAudioRTPSink.cpp                                  \
liveMedia/DigestAuthentication.cpp                             \
liveMedia/RTSPCommon.cpp                                       \
liveMedia/MP3ADU.cpp                                           \
liveMedia/Media.cpp                                            \
liveMedia/MPEG4VideoFileServerMediaSubsession.cpp              \
liveMedia/H264or5VideoRTPSink.cpp                              \
liveMedia/MPEG4LATMAudioRTPSource.cpp                          \
liveMedia/H264VideoRTPSink.cpp                                 \
liveMedia/MPEG1or2AudioStreamFramer.cpp                        \
liveMedia/AC3AudioRTPSink.cpp                                  \
liveMedia/H264VideoStreamFramer.cpp                            \
liveMedia/H265VideoFileSink.cpp                                \
liveMedia/T140TextRTPSink.cpp                                  \
liveMedia/OggFileServerMediaSubsession.cpp                     \
liveMedia/MP3Internals.cpp                                     \
liveMedia/MPEG1or2FileServerDemux.cpp                          \
liveMedia/RTPSink.cpp                                          \
liveMedia/AC3AudioFileServerMediaSubsession.cpp                \
liveMedia/H264VideoRTPSource.cpp                               \
liveMedia/ProxyServerMediaSession.cpp                          \
liveMedia/SimpleRTPSink.cpp                                    \
liveMedia/MultiFramedRTPSink.cpp                               \
liveMedia/H263plusVideoRTPSource.cpp                           \
liveMedia/RTCP.cpp                                             \
liveMedia/JPEGVideoRTPSource.cpp                               \
liveMedia/AMRAudioFileSource.cpp                               \
liveMedia/MultiFramedRTPSource.cpp                             \
liveMedia/AVIFileSink.cpp                                      \
liveMedia/TextRTPSink.cpp                                      \
liveMedia/AMRAudioSource.cpp                                   \
liveMedia/MatroskaDemuxedTrack.cpp                             \
liveMedia/MP3ADUdescriptor.cpp                                 \
liveMedia/QuickTimeGenericRTPSource.cpp                        \
liveMedia/ServerMediaSession.cpp                               \
liveMedia/FramedSource.cpp                                     \
liveMedia/MP3AudioFileServerMediaSubsession.cpp                \
liveMedia/SimpleRTPSource.cpp                                  \
liveMedia/OggDemuxedTrack.cpp                                  \
liveMedia/OggFileServerDemux.cpp                               \
liveMedia/MP3StreamState.cpp                                   \
liveMedia/MPEG1or2VideoStreamFramer.cpp                        \
liveMedia/MPEG2TransportStreamFromPESSource.cpp                \
liveMedia/PassiveServerMediaSubsession.cpp                     \
liveMedia/DeviceSource.cpp                                     \
liveMedia/RTSPServerSupportingHTTPStreaming.cpp                \
liveMedia/MediaSession.cpp                                     \
liveMedia/MPEG2TransportUDPServerMediaSubsession.cpp           \
liveMedia/DVVideoRTPSource.cpp                                 \
liveMedia/SIPClient.cpp                                        \
liveMedia/VP9VideoRTPSink.cpp                                  \
liveMedia/VP9VideoRTPSource.cpp                                \
liveMedia/GenericMediaServer.cpp                               \
liveMedia/RTSPServerRegister.cpp                               \
BasicUsageEnvironment/DelayQueue.cpp                           \
BasicUsageEnvironment/BasicTaskScheduler.cpp                   \
BasicUsageEnvironment/BasicUsageEnvironment0.cpp               \
BasicUsageEnvironment/BasicHashTable.cpp                       \
BasicUsageEnvironment/BasicUsageEnvironment.cpp                \
BasicUsageEnvironment/BasicTaskScheduler0.cpp                  \
UsageEnvironment/HashTable.cpp                                 \
UsageEnvironment/strDup.cpp                                    \
UsageEnvironment/UsageEnvironment.cpp                          

include $(BUILD_SHARED_LIBRARY)

新建文件 Application.mk

APP_ABI := armeabi-v7a mips

添加native方法和loadLibrary

test.png

尝试自动生成c函数报错

Cannot resolve corresponding JNI function Java_cn_eagleview_testlive555_MainActivity_test less... (Ctrl+F1) 
Reports native method declarations in Java where no corresponding JNI function is found in the project

jni函数报错.png

解决办法是点击菜单栏File->Link C++ Project with Gradle,选ndk-build,找到Android.mk,点OK

link c++.png

select Android.mk.png

在native方法用快速修复自动生成C函数

生成C函数.png

设置返回字符串

live555.c.png

native test.png

提示需要同步

Sync now.png

在Android.mk加入live555.c,重新同步

添加live555.c.png

引用静态库

    static {
        System.loadLibrary("live555");
    }

编译运行

运行在手机上,有输出

log test.png

但是打开apk发现,lib里面有x86和armeabi-v7a,没有mips

apk1.png

修改app/build.gradle,添加

        ndk {
            abiFilters "armeabi-v7a", "mips"
        }

修改后

build.gradle.png

clean和rebuild一下

运行成功,apk的lib也对了

apk2.png

复制视频文件到手机SD卡,运行TestLive555

获取文件路径

Environment.getExternalStorageDirectory()

打开VLC,输入URL

vlc url.png

播放

vlc play.png

由于MIPS虚拟机的IP是10.0.2.15,无法访问,所以暂不测试。

结束。

参考

http://www.live555.com/mediaServer/

http://wendal.net/2014/04/29.html

最纯粹的直播技术实战01-FFmpeg的编译与运行 - CSDN博客
http://blog.csdn.net/u011485531/article/details/55804380

https://github.com/googlesamples/android-ndk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值