mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #191: configure --export-librtmp-project and --export-librtmp-single. 2.0.11.
This commit is contained in:
parent
e62c3a4e0e
commit
3405f35d06
9 changed files with 329 additions and 162 deletions
|
@ -126,7 +126,7 @@ function Ubuntu_prepare()
|
|||
return 0
|
||||
}
|
||||
# donot prepare tools, for srs-librtmp depends only gcc and g++.
|
||||
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
Ubuntu_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Ubuntu prepare failed, ret=$ret"; exit $ret; fi
|
||||
fi
|
||||
#####################################################################################
|
||||
|
@ -217,14 +217,14 @@ function Centos_prepare()
|
|||
return 0
|
||||
}
|
||||
# donot prepare tools, for srs-librtmp depends only gcc and g++.
|
||||
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
Centos_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "CentOS prepare failed, ret=$ret"; exit $ret; fi
|
||||
fi
|
||||
|
||||
#####################################################################################
|
||||
# st-1.9
|
||||
#####################################################################################
|
||||
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
# check the arm flag file, if flag changed, need to rebuild the st.
|
||||
_ST_MAKE=linux-debug
|
||||
if [ $SRS_EMBEDED_CPU = YES ]; then
|
||||
|
@ -343,7 +343,7 @@ function write_nginx_html5()
|
|||
END
|
||||
}
|
||||
# create the nginx dir, for http-server if not build nginx
|
||||
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
mkdir -p ${SRS_OBJS}/nginx
|
||||
fi
|
||||
# make nginx
|
||||
|
@ -372,7 +372,7 @@ if [ $__SRS_BUILD_NGINX = YES ]; then
|
|||
fi
|
||||
|
||||
# the demo dir.
|
||||
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
# create forward dir
|
||||
mkdir -p ${SRS_OBJS}/nginx/html/live &&
|
||||
mkdir -p ${SRS_OBJS}/nginx/html/forward/live
|
||||
|
@ -595,7 +595,7 @@ fi
|
|||
#####################################################################################
|
||||
# build research code, librtmp
|
||||
#####################################################################################
|
||||
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
if [ $SRS_RESEARCH = YES ]; then
|
||||
mkdir -p ${SRS_OBJS}/research
|
||||
|
||||
|
|
30
trunk/auto/generate-srs-librtmp-project.sh
Executable file
30
trunk/auto/generate-srs-librtmp-project.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# when export srs-librtmp project
|
||||
# set the SRS_WORKDIR and SRS_OBJS,
|
||||
# then copy the srs-librtmp needed files.
|
||||
#
|
||||
# params:
|
||||
# $SRS_WORKDIR the work dir. ie. .
|
||||
# $SRS_OBJS the objs directory to store the Makefile. ie. ./objs
|
||||
# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
|
||||
# $SRS_EXPORT_LIBRTMP_PROJECT the export srs-librtmp project path. ie. srs-librtmp
|
||||
#
|
||||
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
|
||||
if [[ -d ${SRS_EXPORT_LIBRTMP_PROJECT} ]]; then
|
||||
echo -e "${RED}srs-librtmp target dir exists: ${SRS_EXPORT_LIBRTMP_PROJECT}. ${BLACK}"
|
||||
exit 1
|
||||
fi
|
||||
# create target
|
||||
SRS_WORKDIR=${SRS_EXPORT_LIBRTMP_PROJECT} && SRS_OBJS=${SRS_WORKDIR}/${SRS_OBJS_DIR} && mkdir -p ${SRS_OBJS} &&
|
||||
# copy src to target
|
||||
_CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/research/librtmp && mkdir -p ${_CPT} && cp research/librtmp/*.c research/librtmp/Makefile ${_CPT} &&
|
||||
_CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/auto && mkdir -p ${_CPT} && cp auto/generate_header.sh auto/generate-srs-librtmp-single.sh ${_CPT} &&
|
||||
_CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/core && mkdir -p ${_CPT} && cp src/core/* ${_CPT} &&
|
||||
_CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/kernel && mkdir -p ${_CPT} && cp src/kernel/* ${_CPT} &&
|
||||
_CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/rtmp && mkdir -p ${_CPT} && cp src/rtmp/* ${_CPT} &&
|
||||
_CPT=${SRS_EXPORT_LIBRTMP_PROJECT}/src/libs && mkdir -p ${_CPT} && cp src/libs/* ${_CPT}
|
||||
# check ret
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then echo "export src failed, ret=$ret"; exit $ret; fi
|
||||
fi
|
130
trunk/auto/generate-srs-librtmp-single.sh
Executable file
130
trunk/auto/generate-srs-librtmp-single.sh
Executable file
|
@ -0,0 +1,130 @@
|
|||
#!/bin/bash
|
||||
|
||||
# when export srs-librtmp single files
|
||||
# package the whole project to srs_librtmp.h and srs_librtmp.cpp
|
||||
#
|
||||
# params:
|
||||
# $SRS_OBJS_DIR the objs directory for Makefile. ie. objs
|
||||
# $SRS_EXPORT_LIBRTMP_SINGLE the export srs-librtmp single path. ie. srs-librtmp
|
||||
#
|
||||
|
||||
# the target dir must created
|
||||
if [[ ! -d $SRS_EXPORT_LIBRTMP_SINGLE ]]; then
|
||||
echo -e "${RED}error, target dir not created: $SRS_EXPORT_LIBRTMP_SINGLE${BLACK}"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# generate the srs_librtmp.h
|
||||
cp $SRS_EXPORT_LIBRTMP_SINGLE/src/libs/srs_librtmp.hpp $SRS_EXPORT_LIBRTMP_SINGLE/srs_librtmp.h
|
||||
|
||||
# create srs_librtmp.cpp
|
||||
FILE=$SRS_EXPORT_LIBRTMP_SINGLE/srs_librtmp.cpp
|
||||
cat << END >$FILE
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "srs_librtmp.h"
|
||||
|
||||
END
|
||||
# build objs auto files to cpp
|
||||
cat $SRS_EXPORT_LIBRTMP_SINGLE/$SRS_OBJS_DIR/srs_auto_headers.hpp >>$FILE
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then
|
||||
echo -e "${RED}failed to generate the srs_librtmp.cpp${BLACK}"
|
||||
exit $ret
|
||||
fi
|
||||
# module to cpp files.
|
||||
function build_module_hpp()
|
||||
{
|
||||
echo "build files ${SRS_LIBRTMP_OBJS} to $FILE"
|
||||
for item in ${SRS_LIBRTMP_OBJS[*]}; do
|
||||
FILE_NAME="${item%.*}"
|
||||
echo "// following is generated by ${FILE_NAME}.hpp" >> $FILE &&
|
||||
sed -i "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp &&
|
||||
cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.hpp >>$FILE
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then
|
||||
echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.hpp. {${BLACK}"
|
||||
exit $ret
|
||||
fi
|
||||
done
|
||||
}
|
||||
SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_hpp
|
||||
SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_hpp
|
||||
SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_hpp
|
||||
SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_hpp
|
||||
# module to cpp files.
|
||||
function build_module_cpp()
|
||||
{
|
||||
echo "build files ${SRS_LIBRTMP_OBJS} to $FILE"
|
||||
for item in ${SRS_LIBRTMP_OBJS[*]}; do
|
||||
FILE_NAME="${item%.*}"
|
||||
echo "// following is generated by ${FILE_NAME}.cpp" >> $FILE &&
|
||||
sed -i "s|#include <srs_|//#include <srs_|g" $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp &&
|
||||
cat $SRS_EXPORT_LIBRTMP_SINGLE/${FILE_NAME}.cpp >>$FILE
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then
|
||||
echo -e "${RED}failed to generate the srs_librtmp.cpp by ${FILE_NAME}.cpp. {${BLACK}"
|
||||
exit $ret
|
||||
fi
|
||||
done
|
||||
}
|
||||
SRS_LIBRTMP_OBJS="${CORE_OBJS[@]}" && build_module_cpp
|
||||
SRS_LIBRTMP_OBJS="${KERNEL_OBJS[@]}" && build_module_cpp
|
||||
SRS_LIBRTMP_OBJS="${RTMP_OBJS[@]}" && build_module_cpp
|
||||
SRS_LIBRTMP_OBJS="${LIBS_OBJS[@]}" && build_module_cpp
|
||||
|
||||
# create example.cpp
|
||||
FILE=$SRS_EXPORT_LIBRTMP_SINGLE/example.c
|
||||
COMPILE='gcc example.c srs_librtmp.cpp -g -O0 -lstdc++ -o example'
|
||||
cat << END >$FILE
|
||||
/**
|
||||
# Example to use srs-librtmp
|
||||
# see: https://github.com/winlinvip/simple-rtmp-server/wiki/v2_CN_SrsLibrtmp
|
||||
${COMPILE}
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "srs_librtmp.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
printf("Example for srs-librtmp\n");
|
||||
printf("SRS(simple-rtmp-server) client librtmp library.\n");
|
||||
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||
|
||||
srs_rtmp_t rtmp = srs_rtmp_create("rtmp://ossrs.net/live/livestream");
|
||||
srs_trace("create rtmp success");
|
||||
srs_rtmp_destroy(rtmp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
END
|
||||
|
||||
# compile the example
|
||||
(cd $SRS_EXPORT_LIBRTMP_SINGLE && `${COMPILE}` && ./example && rm -f example)
|
||||
ret=$?; if [[ $ret -ne 0 ]]; then
|
||||
echo "(cd $SRS_EXPORT_LIBRTMP_SINGLE && ${COMPILE} && ./example && rm -f example)"
|
||||
echo -e "${RED}failed to compile example.${BLACK}"
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
# clear the files for srs-librtmp project, generated by generate-srs-librtmp-project.sh
|
||||
(cd $SRS_EXPORT_LIBRTMP_SINGLE && rm -rf auto $SRS_OBJS_DIR research src Makefile)
|
|
@ -58,8 +58,10 @@ SRS_LOG_TRACE=RESERVED
|
|||
# experts
|
||||
# donot compile ssl, use system ssl(-lssl) if required.
|
||||
SRS_USE_SYS_SSL=NO
|
||||
# export the srs-librtmp to specified path, NO to disable it.
|
||||
SRS_EXPORT_LIBRTMP=NO
|
||||
# export the srs-librtmp to specified project, NO to disable it.
|
||||
SRS_EXPORT_LIBRTMP_PROJECT=NO
|
||||
# export the srs-librtmp to a single .h and .c, NO to disable it.
|
||||
SRS_EXPORT_LIBRTMP_SINGLE=NO
|
||||
#
|
||||
################################################################
|
||||
# presets
|
||||
|
@ -183,8 +185,9 @@ Conflicts:
|
|||
the complex tools not available for arm.
|
||||
|
||||
Experts:
|
||||
--use-sys-ssl donot compile ssl, use system ssl(-lssl) if required.
|
||||
--export-librtmp=<path> export srs-librtmp to specified path.
|
||||
--use-sys-ssl donot compile ssl, use system ssl(-lssl) if required.
|
||||
--export-librtmp-project=<path> export srs-librtmp to specified project in path.
|
||||
--export-librtmp-single=<path> export srs-librtmp to a single file(.h+.cpp) in path.
|
||||
|
||||
Workflow:
|
||||
1. apply "Presets". if not specified, use default preset.
|
||||
|
@ -266,7 +269,8 @@ function parse_user_option() {
|
|||
--full) SRS_ENABLE_ALL=YES ;;
|
||||
|
||||
--use-sys-ssl) SRS_USE_SYS_SSL=YES ;;
|
||||
--export-librtmp) SRS_EXPORT_LIBRTMP=${value} ;;
|
||||
--export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;;
|
||||
--export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;;
|
||||
|
||||
*)
|
||||
echo "$0: error: invalid option \"$option\""
|
||||
|
@ -701,8 +705,13 @@ function apply_user_detail_options() {
|
|||
export SRS_JOBS="--jobs=${SRS_JOBS}"
|
||||
fi
|
||||
|
||||
# if specified export single file, export project first.
|
||||
if [ $SRS_EXPORT_LIBRTMP_SINGLE != NO ]; then
|
||||
SRS_EXPORT_LIBRTMP_PROJECT=$SRS_EXPORT_LIBRTMP_SINGLE
|
||||
fi
|
||||
|
||||
# disable almost all features for export srs-librtmp.
|
||||
if [ $SRS_EXPORT_LIBRTMP != NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
|
||||
SRS_HLS=NO
|
||||
SRS_DVR=NO
|
||||
SRS_NGINX=NO
|
||||
|
|
|
@ -21,7 +21,7 @@ SrsGperfMPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_MP = YES ]; then
|
|||
SrsGperfCPSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPERF_CP = YES ]; then SrsGperfCPSummaryColor="\${YELLOW}"; fi
|
||||
SrsGprofSummaryColor="\${GREEN}{disabled} "; if [ $SRS_GPROF = YES ]; then SrsGprofSummaryColor="\${YELLOW}"; fi
|
||||
|
||||
if [ $SRS_EXPORT_LIBRTMP = NO ]; then
|
||||
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||
cat <<END > ${SRS_OBJS}/${SRS_BUILD_SUMMARY}
|
||||
#!/bin/bash
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue