基于移动平台的多媒体框架——移植Live555到Android上

基于移动平台的多媒体框架——移植Live555到Android上



live555是一个处理流媒体传输对c++库,再Mplayer与vlc中都有用到。我们计划将其加入到自己编写对Android上的播放器中作为流媒体模块,首先就需要将这个库移植到Android上。

1. 首先在官网下载live555对源码并解压。
2. 新建一个Android工程,将源码文件放到一个该工程的jni目录下,如:jni/live。
3. 新建jni/Android.mk文件作为Makefile。将需要编译对源文件加入到LOCAL_SRC_FILES变量,将需要引用对头文件加入到LOCAL_C_INCLUDES,编译过程中会提示需要参数:-fexceptions,于是加入参数LOCAL_CPPFLAGS += -fexceptions。

内容如下:

4. 新建jni/Application.mk文件。由于live555需要引用stl,所以加入:
APP_STL := gnustl_shared

5. 运行ndk-build就可以得到live555.so文件啦。


后记:

至今为止,我们已经向Android上移植了三个c/c++的库了(ffmpeg、sdl、live555)。如果有按着步骤一步步的做过,相信大家已经很熟悉如何向Android上移植一个c/c++库里。举一反三,融会贯通,相信以后遇到一个新的c/c++工程,你也会觉得轻而易举手到擒来啦!


补充:

本来打算把自己移植好的src发给在回复中留言的几位朋友的,但查了一下发现硬盘坑爹地被我格过几次,东西早就没有了。鉴于这个工作不那么复杂,我索性再做一遍,顺便把移植的过程写的详细点,便于他人参考。

1. 下载了最新的live555源码,日期是12/04/04,用的ndk版本是r7b。

2.预备工作,先用标准的方法make一下,确定你的源码是可以编译过的。

./genMakefiles linux
make
马上就看到成功的结果了,这时不要急得移植。移植是交叉编译了,咱们先不用交叉编译,用gcc编译看看会不会。

了解live555的基本结构之后就可以执行:

g++ BasicUsageEnvironment/*.cpp liveMedia/*.cpp mediaServer/*.cpp UsageEnvironment/*.cpp ./groupsock/*cpp -IBasicUsageEnvironment/include -IliveMedia/include -IBasicUsageEnvironment/include -Igroupsock/include/ -IUsageEnvironment/include -DSOCKLEN_T=socklen_t -shared -o live555.so
这样在本地就生成一个so了。

3. 跟本地一样,如果你了解了ndk的用法,写个简单的mk文件就可以移植了。建工程什么的在上面说了,我就把mk文件贴出来给大家参考一下好了。为了省事,我就建了一个Android.mk文件。写的过程就是碰到什么问题,就改改加加什么参数。(这次连Application.mk都没有加就过了。。。)

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := live555

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


LOCAL_C_INCLUDES := \
./live/BasicUsageEnvironment/include \
./live/liveMedia/include \
./live/BasicUsageEnvironment/include \
./live/groupsock/include \
./live/UsageEnvironment/include

LOCAL_CPPFLAGS += -fexceptions -DXLOCALE_NOT_USED=1 -DNULL=0 -DNO_SSTREAM=1 -UIP_ADD_SOURCE_MEMBERSHIP

include $(BUILD_SHARED_LIBRARY)


(有关in_addr的地方编译不过的,稍微修改下源码,去掉s_addr即可。

你可能感兴趣的:(基于移动平台的多媒体框架——移植Live555到Android上)