live555 window下编译运行以及Android平台的移植
live555是一个开源的多媒体直播框架,代码是用c++写的,主要用到的直播协议是RTSP,在以下地址中可以直接下载到源码http://www.live555.com/liveMedia/public/
1.window平台的编译
参考地址:http://blog.csdn.net/hjl240/article/details/48159243
在编译的过程中遇到了两个问题,一个是以上博客中提到的,以下单独摘出:
错误 1
error C4996: ‘_snprintf’:This function or variable may be unsafe. Consider using _snprintf_s instead. Todisable deprecation, use _CRT_SECURE_NO_WARNINGS.错误是说 使用这个_snprintf函数不安全。
解决这个错误的方法是更改预处理定义:
项目->属性->配置属性->C/C++ ->预处理器 -> 预处理器定义
增加: _CRT_SECURE_NO_DEPRECATE
错误 2
说是一些方法过时了,编译不通过,我用的是一个相对简单的方法:
项目->属性->配置属性->C/C++ ->常规->SDL检查
改为‘否’就好了
2.Android平台的移植
熟悉在Androidstudio下jni开发就知道首先在main目录下建一个jni目录,将live555源码中的BaseUsageEnvironment,groupsock,liveMedia,mediaServer和UsageEnvironment文件夹分别拷贝到里面,然后再文件夹下建立一个Android.mk文件
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
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 := \
BasicUsageEnvironment/BasicHashTable.cpp \
BasicUsageEnvironment/BasicTaskScheduler.cpp \
BasicUsageEnvironment/BasicTaskScheduler0.cpp \
BasicUsageEnvironment/BasicUsageEnvironment.cpp \
BasicUsageEnvironment/BasicUsageEnvironment0.cpp \
BasicUsageEnvironment/DelayQueue.cpp \
groupsock/GroupEId.cpp \
groupsock/Groupsock.cpp \
groupsock/GroupsockHelper.cpp \
groupsock/inet.c \
groupsock/IOHandlers.cpp \
groupsock/NetAddress.cpp \
groupsock/NetInterface.cpp \
liveMedia/AC3AudioFileServerMediaSubsession.cpp \
liveMedia/AC3AudioRTPSink.cpp \
liveMedia/AC3AudioRTPSource.cpp \
liveMedia/AC3AudioStreamFramer.cpp \
liveMedia/ADTSAudioFileServerMediaSubsession.cpp \
liveMedia/ADTSAudioFileSource.cpp \
liveMedia/AMRAudioFileServerMediaSubsession.cpp \
liveMedia/AMRAudioFileSink.cpp \
liveMedia/AMRAudioFileSource.cpp \
liveMedia/AMRAudioRTPSink.cpp \
liveMedia/AMRAudioRTPSource.cpp \
liveMedia/AMRAudioSource.cpp \
liveMedia/AudioInputDevice.cpp \
liveMedia/AudioRTPSink.cpp \
liveMedia/AVIFileSink.cpp \
liveMedia/Base64.cpp \
liveMedia/BasicUDPSink.cpp \
liveMedia/BasicUDPSource.cpp \
liveMedia/BitVector.cpp \
liveMedia/ByteStreamFileSource.cpp \
liveMedia/ByteStreamMemoryBufferSource.cpp \
liveMedia/ByteStreamMultiFileSource.cpp \
liveMedia/DeviceSource.cpp \
liveMedia/DigestAuthentication.cpp \
liveMedia/DVVideoFileServerMediaSubsession.cpp \
liveMedia/DVVideoRTPSink.cpp \
liveMedia/DVVideoRTPSource.cpp \
liveMedia/DVVideoStreamFramer.cpp \
liveMedia/EBMLNumber.cpp \
liveMedia/FileServerMediaSubsession.cpp \
liveMedia/FileSink.cpp \
liveMedia/FramedFileSource.cpp \
liveMedia/FramedFilter.cpp \
liveMedia/FramedSource.cpp \
liveMedia/GenericMediaServer.cpp \
liveMedia/GSMAudioRTPSink.cpp \
liveMedia/H261VideoRTPSource.cpp \
liveMedia/H263plusVideoFileServerMediaSubsession.cpp \
liveMedia/H263plusVideoRTPSink.cpp \
liveMedia/H263plusVideoRTPSource.cpp \
liveMedia/H263plusVideoStreamFramer.cpp \
liveMedia/H263plusVideoStreamParser.cpp \
liveMedia/H264or5VideoFileSink.cpp \
liveMedia/H264or5VideoRTPSink.cpp \
liveMedia/H264or5VideoStreamDiscreteFramer.cpp \
liveMedia/H264or5VideoStreamFramer.cpp \
liveMedia/H264VideoFileServerMediaSubsession.cpp \
liveMedia/H264VideoFileSink.cpp \
liveMedia/H264VideoRTPSink.cpp \
liveMedia/H264VideoRTPSource.cpp \
liveMedia/H264VideoStreamDiscreteFramer.cpp \
liveMedia/H264VideoStreamFramer.cpp \
liveMedia/H265VideoFileServerMediaSubsession.cpp \
liveMedia/H265VideoFileSink.cpp \
liveMedia/H265VideoRTPSink.cpp \
liveMedia/H265VideoRTPSource.cpp \
liveMedia/H265VideoStreamDiscreteFramer.cpp \
liveMedia/H265VideoStreamFramer.cpp \
liveMedia/InputFile.cpp \
liveMedia/JPEGVideoRTPSink.cpp \
liveMedia/JPEGVideoRTPSource.cpp \
liveMedia/JPEGVideoSource.cpp \
liveMedia/Locale.cpp \
liveMedia/MatroskaDemuxedTrack.cpp \
liveMedia/MatroskaFile.cpp \
liveMedia/MatroskaFileParser.cpp \
liveMedia/MatroskaFileServerDemux.cpp \
liveMedia/MatroskaFileServerMediaSubsession.cpp \
liveMedia/Media.cpp \
liveMedia/MediaSession.cpp \
liveMedia/MediaSink.cpp \
liveMedia/MediaSource.cpp \
liveMedia/MP3ADU.cpp \
liveMedia/MP3ADUdescriptor.cpp \
liveMedia/MP3ADUinterleaving.cpp \
liveMedia/MP3ADURTPSink.cpp \
liveMedia/MP3ADURTPSource.cpp \
liveMedia/MP3ADUTranscoder.cpp \
liveMedia/MP3AudioFileServerMediaSubsession.cpp \
liveMedia/MP3AudioMatroskaFileServerMediaSubsession.cpp \
liveMedia/MP3FileSource.cpp \
liveMedia/MP3Internals.cpp \
liveMedia/MP3InternalsHuffman.cpp \
liveMedia/MP3InternalsHuffmanTable.cpp \
liveMedia/MP3StreamState.cpp \
liveMedia/MP3Transcoder.cpp \
liveMedia/MPEG1or2AudioRTPSink.cpp \
liveMedia/MPEG1or2AudioRTPSource.cpp \
liveMedia/MPEG1or2AudioStreamFramer.cpp \
liveMedia/MPEG1or2Demux.cpp \
liveMedia/MPEG1or2DemuxedElementaryStream.cpp \
liveMedia/MPEG1or2DemuxedServerMediaSubsession.cpp \
liveMedia/MPEG1or2FileServerDemux.cpp \
liveMedia/MPEG1or2VideoFileServerMediaSubsession.cpp \
liveMedia/MPEG1or2VideoRTPSink.cpp \
liveMedia/MPEG1or2VideoRTPSource.cpp \
liveMedia/MPEG1or2VideoStreamDiscreteFramer.cpp \
liveMedia/MPEG1or2VideoStreamFramer.cpp \
liveMedia/MPEG2IndexFromTransportStream.cpp \
liveMedia/MPEG2TransportFileServerMediaSubsession.cpp \
liveMedia/MPEG2TransportStreamAccumulator.cpp \
liveMedia/MPEG2TransportStreamFramer.cpp \
liveMedia/MPEG2TransportStreamFromESSource.cpp \
liveMedia/MPEG2TransportStreamFromPESSource.cpp \
liveMedia/MPEG2TransportStreamIndexFile.cpp \
liveMedia/MPEG2TransportStreamMultiplexor.cpp \
liveMedia/MPEG2TransportStreamTrickModeFilter.cpp \
liveMedia/MPEG2TransportUDPServerMediaSubsession.cpp \
liveMedia/MPEG4ESVideoRTPSink.cpp \
liveMedia/MPEG4ESVideoRTPSource.cpp \
liveMedia/MPEG4GenericRTPSink.cpp \
liveMedia/MPEG4GenericRTPSource.cpp \
liveMedia/MPEG4LATMAudioRTPSink.cpp \
liveMedia/MPEG4LATMAudioRTPSource.cpp \
liveMedia/MPEG4VideoFileServerMediaSubsession.cpp \
liveMedia/MPEG4VideoStreamDiscreteFramer.cpp \
liveMedia/MPEG4VideoStreamFramer.cpp \
liveMedia/MPEGVideoStreamFramer.cpp \
liveMedia/MPEGVideoStreamParser.cpp \
liveMedia/MultiFramedRTPSink.cpp \
liveMedia/MultiFramedRTPSource.cpp \
liveMedia/OggDemuxedTrack.cpp \
liveMedia/OggFile.cpp \
liveMedia/OggFileParser.cpp \
liveMedia/OggFileServerDemux.cpp \
liveMedia/OggFileServerMediaSubsession.cpp \
liveMedia/OggFileSink.cpp \
liveMedia/OnDemandServerMediaSubsession.cpp \
liveMedia/ourMD5.cpp \
liveMedia/OutputFile.cpp \
liveMedia/PassiveServerMediaSubsession.cpp \
liveMedia/ProxyServerMediaSession.cpp \
liveMedia/QCELPAudioRTPSource.cpp \
liveMedia/QuickTimeFileSink.cpp \
liveMedia/QuickTimeGenericRTPSource.cpp \
liveMedia/RTCP.cpp \
liveMedia/rtcp_from_spec.c \
liveMedia/RTPInterface.cpp \
liveMedia/RTPSink.cpp \
liveMedia/RTPSource.cpp \
liveMedia/RTSPClient.cpp \
liveMedia/RTSPCommon.cpp \
liveMedia/RTSPRegisterSender.cpp \
liveMedia/RTSPServer.cpp \
liveMedia/RTSPServerRegister.cpp \
liveMedia/RTSPServerSupportingHTTPStreaming.cpp \
liveMedia/ServerMediaSession.cpp \
liveMedia/SimpleRTPSink.cpp \
liveMedia/SimpleRTPSource.cpp \
liveMedia/SIPClient.cpp \
liveMedia/StreamParser.cpp \
liveMedia/StreamReplicator.cpp \
liveMedia/T140TextRTPSink.cpp \
liveMedia/TCPStreamSink.cpp \
liveMedia/TextRTPSink.cpp \
liveMedia/TheoraVideoRTPSink.cpp \
liveMedia/TheoraVideoRTPSource.cpp \
liveMedia/uLawAudioFilter.cpp \
liveMedia/VideoRTPSink.cpp \
liveMedia/VorbisAudioRTPSink.cpp \
liveMedia/VorbisAudioRTPSource.cpp \
liveMedia/VP8VideoRTPSink.cpp \
liveMedia/VP8VideoRTPSource.cpp \
liveMedia/VP9VideoRTPSink.cpp \
liveMedia/VP9VideoRTPSource.cpp \
liveMedia/WAVAudioFileServerMediaSubsession.cpp \
liveMedia/WAVAudioFileSource.cpp \
mediaServer/DynamicRTSPServer.cpp \
mediaServer/live555MediaServer.cpp \
UsageEnvironment/HashTable.cpp \
UsageEnvironment/strDup.cpp \
UsageEnvironment/UsageEnvironment.cpp \
include $(BUILD_SHARED_LIBRARY)
其中LOCAL_SRC_FILES的下面的一堆值可能会有问题,根据版本的不同类名也会有增删变化,所以如果不行,可以用下面代码自己生成,然后将生成的文件内容替换LOCAL_SRC_FILES的值:
public class CreateLive555Index {
public static void main(String[] args) {
File file = new File("D:/project/AndroidSDL/app/src/main/jni");
File outFile = new File("D:/project/AndroidSDL/app/src/main/jni/output.txt");
try {
PrintStream ps = new PrintStream(outFile);
createDirIndex(file,ps,"");
ps.flush();
ps.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private static void createDirIndex(File file,PrintStream ps,String outputPath){
File[] files = file.listFiles();
for(File f : files){
if(f.isDirectory()){
System.out.println(outputPath+f.getName()+"/---------------------------");
createDirIndex(f,ps,outputPath+f.getName()+"/");
}else{
if(f.getName().endsWith(".cpp") || f.getName().endsWith(".c")){
System.out.println(outputPath);
ps.append(outputPath + f.getName() + " \\\r\n");
}
}
}
}
}
然后只需要在jni目录下执行ndk-build即可编译