winlin

add library

  1 +#!/bin/bash
  2 +# genereate the library header file.
  3 +
  4 +objs=$1
  1 +# generate the library for static link.
  2 +#
  3 +# params:
  4 +# $SRS_OBJS the objs directory. ie. objs
  5 +# $SRS_MAKEFILE the makefile name. ie. Makefile
  6 +#
  7 +# $BUILD_KEY a string indicates the build key for Makefile. ie. dump
  8 +# $LIB_NAME the app name to output. ie. smart_server
  9 +# $MODULE_OBJS array, the objects to compile the app.
  10 +# $LINK_OPTIONS the linker options to generate the so(shared library).
  11 +
  12 +FILE=${SRS_OBJS}/${SRS_MAKEFILE}
  13 +
  14 +LIB_TARGET="${SRS_OBJS}/${LIB_NAME}"
  15 +LIB_TAGET_STATIC="${LIB_TARGET}.a"
  16 +LIB_TAGET_SHARED="${LIB_TARGET}.so"
  17 +
  18 +echo "generate lib ${LIB_NAME} depends..."
  19 +
  20 +echo "" >> ${FILE}
  21 +echo "# archive library ${LIB_TAGET_STATIC}" >> ${FILE}
  22 +echo "${BUILD_KEY}: ${LIB_TAGET_SHARED}" >> ${FILE}
  23 +
  24 +# build depends
  25 +echo -n "${LIB_TAGET_SHARED}: " >> ${FILE}
  26 +for item in ${MODULE_OBJS[*]}; do
  27 + FILE_NAME=`basename $item`
  28 + FILE_NAME=${FILE_NAME%.*}
  29 +
  30 + if [ ! -f ${item} ]; then
  31 + continue;
  32 + fi
  33 +
  34 + OBJ_FILE=${SRS_OBJS}/$item
  35 + OBJ_FILE="${OBJ_FILE%.*}.o"
  36 + echo -n "${OBJ_FILE} " >> ${FILE}
  37 +done
  38 +echo "" >> ${FILE}
  39 +
  40 +# build header file
  41 +echo -n " @bash auto/generate_header.sh ${SRS_OBJS}" >> ${FILE}
  42 +echo "" >> ${FILE}
  43 +
  44 +# archive librtmp.a
  45 +echo -n " \$(AR) -rs ${LIB_TAGET_STATIC} " >> ${FILE}
  46 +for item in ${MODULE_OBJS[*]}; do
  47 + FILE_NAME=`basename $item`
  48 + FILE_NAME=${FILE_NAME%.*}
  49 +
  50 + if [ ! -f ${item} ]; then
  51 + continue;
  52 + fi
  53 +
  54 + OBJ_FILE=${SRS_OBJS}/$item
  55 + OBJ_FILE="${OBJ_FILE%.*}.o"
  56 + echo -n "${OBJ_FILE} " >> ${FILE}
  57 +done
  58 +echo "" >> ${FILE}
  59 +
  60 +echo "generate lib ${LIB_NAME} link...";
  61 +
  62 +# archive librtmp.so
  63 +echo -n " \$(GCC) -shared -o ${LIB_TAGET_SHARED} " >> ${FILE}
  64 +for item in ${MODULE_OBJS[*]}; do
  65 + FILE_NAME=`basename $item`
  66 + FILE_NAME=${FILE_NAME%.*}
  67 +
  68 + if [ ! -f ${item} ]; then
  69 + continue;
  70 + fi
  71 +
  72 + OBJ_FILE=${SRS_OBJS}/$item
  73 + OBJ_FILE="${OBJ_FILE%.*}.o"
  74 + echo -n "${OBJ_FILE} " >> ${FILE}
  75 +done
  76 +echo -n "${LINK_OPTIONS} " >> ${FILE}
  77 +echo "" >> ${FILE}
  78 +
  79 +echo -n "generate lib ${LIB_NAME} ok"; echo '!';
@@ -42,15 +42,16 @@ echo "" >> $SRS_AUTO_HEADERS_H @@ -42,15 +42,16 @@ echo "" >> $SRS_AUTO_HEADERS_H
42 echo "generate Makefile" 42 echo "generate Makefile"
43 SRS_MAKEFILE="Makefile" 43 SRS_MAKEFILE="Makefile"
44 cat << END > ${SRS_MAKEFILE} 44 cat << END > ${SRS_MAKEFILE}
45 -.PHONY: default help clean server bandwidth _prepare_dir  
46 -default: server bandwidth 45 +.PHONY: default help clean server bandwidth librtmp _prepare_dir
  46 +default: server bandwidth librtmp
47 47
48 help: 48 help:
49 - @echo "Usage: make <help>|<clean>|<server>|<bandwidth>" 49 + @echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>"
50 @echo " help display this help menu" 50 @echo " help display this help menu"
51 @echo " clean cleanup project" 51 @echo " clean cleanup project"
52 @echo " server build the srs(simple rtmp server) over st(state-threads)" 52 @echo " server build the srs(simple rtmp server) over st(state-threads)"
53 @echo " bandwidth build the bandwidth test client tool." 53 @echo " bandwidth build the bandwidth test client tool."
  54 + @echo " librtmp build the client publish/play library."
54 55
55 clean: 56 clean:
56 (rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs bandwidth Makefile *.hpp src st_*_load research) 57 (rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs bandwidth Makefile *.hpp src st_*_load research)
@@ -63,6 +64,10 @@ bandwidth: _prepare_dir @@ -63,6 +64,10 @@ bandwidth: _prepare_dir
63 @echo "build the bandwidth test client tool" 64 @echo "build the bandwidth test client tool"
64 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} bandwidth 65 \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} bandwidth
65 66
  67 +librtmp: _prepare_dir
  68 + @echo "build the client publish/play library."
  69 + \$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp
  70 +
66 # the ./configure will generate it. 71 # the ./configure will generate it.
67 _prepare_dir: 72 _prepare_dir:
68 @mkdir -p ${SRS_OBJS} 73 @mkdir -p ${SRS_OBJS}
@@ -158,6 +163,14 @@ MODULE_FILES=("srs_core_server" "srs_core_conn" "srs_core_client" "srs_core_sock @@ -158,6 +163,14 @@ MODULE_FILES=("srs_core_server" "srs_core_conn" "srs_core_client" "srs_core_sock
158 MODULE_DIR="src/app" . auto/modules.sh 163 MODULE_DIR="src/app" . auto/modules.sh
159 APP_OBJS="${MODULE_OBJS[@]}" 164 APP_OBJS="${MODULE_OBJS[@]}"
160 # 165 #
  166 +#LIBS Module, build libsrs.a for static link.
  167 +MODULE_ID="LIBS"
  168 +MODULE_DEPENDS=("CORE" "KERNEL" "RTMP")
  169 +ModuleLibIncs=()
  170 +MODULE_FILES=("srs_librtmp")
  171 +MODULE_DIR="src/libs" . auto/modules.sh
  172 +LIBS_OBJS="${MODULE_OBJS[@]}"
  173 +#
161 #Main Module 174 #Main Module
162 MODULE_ID="MAIN" 175 MODULE_ID="MAIN"
163 MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP") 176 MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
@@ -186,6 +199,10 @@ BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh @@ -186,6 +199,10 @@ BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
186 # bandwidth 199 # bandwidth
187 # bandwidth test tool, to test the bandwidth to server 200 # bandwidth test tool, to test the bandwidth to server
188 BUILD_KEY="bandwidth" APP_MAIN="srs_main_bandcheck" APP_NAME="bandwidth" . auto/apps.sh 201 BUILD_KEY="bandwidth" APP_MAIN="srs_main_bandcheck" APP_NAME="bandwidth" . auto/apps.sh
  202 +#
  203 +# srs librtmp
  204 +MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${RTMP_OBJS[@]} ${LIBS_OBJS[@]}"
  205 +BUILD_KEY="librtmp" LIB_NAME="srs_librtmp" LINK_OPTIONS="" . auto/libs.sh
189 206
190 echo 'configure ok! ' 207 echo 'configure ok! '
191 208
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#include <srs_librtmp.hpp>
  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2013-2014 winlin
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
  24 +#ifndef SRS_LIB_RTMP_HPP
  25 +#define SRS_LIB_RTMP_HPP
  26 +
  27 +/*
  28 +#include <srs_librtmp.hpp>
  29 +*/
  30 +
  31 +#endif
@@ -4,6 +4,9 @@ file @@ -4,6 +4,9 @@ file
4 ..\main\srs_main_bandcheck.cpp, 4 ..\main\srs_main_bandcheck.cpp,
5 auto readonly separator, 5 auto readonly separator,
6 ..\..\objs\srs_auto_headers.hpp, 6 ..\..\objs\srs_auto_headers.hpp,
  7 + libs readonly separator,
  8 + ..\libs\srs_librtmp.hpp,
  9 + ..\libs\srs_librtmp.cpp,
7 core readonly separator, 10 core readonly separator,
8 ..\core\srs_core.hpp, 11 ..\core\srs_core.hpp,
9 ..\core\srs_core.cpp, 12 ..\core\srs_core.cpp,