Skip to content

Commit

Permalink
For #820, modules use service only.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 26, 2017
1 parent ff822b5 commit e3526c0
Show file tree
Hide file tree
Showing 34 changed files with 3,061 additions and 2,620 deletions.
5 changes: 3 additions & 2 deletions trunk/auto/modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ echo -n "${INCS_NAME} = -I${MODULE_DIR} " >> ${FILE}
for item in ${MODULE_DEPENDS[*]}; do
DEP_INCS_NAME="${item}_INCS"do
DEP_INCS_NAME="${item}_MODULE_INCS"
echo -n "\$(${DEP_INCS_NAME}) " >> ${FILE}
echo -n "\$(${DEP_INCS_NAME})" >> ${FILE}
done
#
# depends library header files
Expand Down Expand Up @@ -79,7 +79,8 @@ for item in ${MODULE_FILES[*]}; do
MODULE_OBJS="${MODULE_OBJS[@]} ${CPP_FILE}"
if [ -f ${CPP_FILE} ]; then
echo "${OBJ_FILE}: \$(${DEPS_NAME}) ${CPP_FILE} " >> ${FILE}
echo " \$(CXX) -c \$(CXXFLAGS) ${DEFINES} \$(${INCS_NAME})\\" >> ${FILE}
echo " \$(CXX) -c \$(CXXFLAGS) ${DEFINES}\\" >> ${FILE}
echo " \$(${INCS_NAME})\\" >> ${FILE}
echo " -o ${OBJ_FILE} ${CPP_FILE}" >> ${FILE}
fi
done
Expand Down
40 changes: 27 additions & 13 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ PROTOCOL_OBJS="${MODULE_OBJS[@]}"
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
MODULE_ID="SERVICE"
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL")
ModuleLibIncs=(${LibSTRoot} ${LibSSLRoot} ${SRS_OBJS_DIR})
MODULE_FILES=("srs_service_log" "srs_service_st")
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR})
MODULE_FILES=("srs_service_log" "srs_service_st" "srs_service_http_client"
"srs_service_http_conn" "srs_service_rtmp_conn" "srs_service_utility"
"srs_service_conn")
DEFINES=""
SERVICE_INCS="src/service"; MODULE_DIR=${SERVICE_INCS} . auto/modules.sh
SERVICE_OBJS="${MODULE_OBJS[@]}"
Expand All @@ -188,7 +190,7 @@ fi
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
MODULE_ID="APP"
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE")
ModuleLibIncs=(${LibSTRoot} ${LibSSLRoot} ${SRS_OBJS_DIR})
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR})
MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source"
"srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream"
"srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
Expand Down Expand Up @@ -218,37 +220,46 @@ MODULE_FILES=("srs_librtmp" "srs_lib_simple_socket" "srs_lib_bandwidth")
LIBS_INCS="src/libs"; MODULE_DIR=${LIBS_INCS} . auto/modules.sh
LIBS_OBJS="${MODULE_OBJS[@]}"
#
#Main Module
#Main Module, for SRS.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
MODULE_ID="MAIN"
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP")
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot})
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot})
MODULE_FILES=("srs_main_server")
MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@]}"
fi
#
#Main Module, for app from modules.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
MODULE_ID="MAIN2"
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE")
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot})
MODULE_FILES=()
DEFINES=""
# add each modules for main
for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config
MODULE_FILES+=("${SRS_MODULE_MAIN[*]}")
DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}"
done
MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@]}"
MAIN2_INCS="src/main"; MODULE_DIR=${MAIN2_INCS} . auto/modules.sh
MAIN2_OBJS="${MODULE_OBJS[@]}"
fi

#####################################################################################
# Binaries, main entrances, link the module and its depends modules,
# then link to a binary, for example, objs/srs
#
# disable all app when export librtmp
# Disable SRS application for exporting librtmp.
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
# all main entrances
MAIN_ENTRANCES=("srs_main_server")
# add each modules for main
for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config
MAIN_ENTRANCES+=("${SRS_MODULE_MAIN[*]}")
done
#
#
# all depends libraries
ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile})
# all depends objects
Expand All @@ -257,12 +268,15 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
#
# srs: srs(simple rtmp server) over st(state-threads)
BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
# add each modules for application
#
# For modules, without the app module.
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${MAIN2_OBJS[@]}"
#
for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config
# no SRS_MODULE_MAIN
# no SRS_MODULE_MAIN
if [[ 0 -eq ${#SRS_MODULE_MAIN[@]} ]]; then continue; fi
BUILD_KEY="$SRS_MODULE_NAME" APP_MAIN="$SRS_MODULE_MAIN" APP_NAME="$SRS_MODULE_NAME" . auto/apps.sh
BUILD_KEY="$SRS_MODULE_NAME" APP_MAIN="${SRS_MODULE_MAIN[0]}" APP_NAME="$SRS_MODULE_NAME" . auto/apps.sh
done
fi
# srs librtmp
Expand Down
32 changes: 31 additions & 1 deletion trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
3CE893B51E87508D000B742D /* srs_app_dvr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893B31E87508D000B742D /* srs_app_dvr.cpp */; };
3CE893B91E8750A9000B742D /* srs_service_log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893B71E8750A9000B742D /* srs_service_log.cpp */; };
3CE893BC1E875108000B742D /* srs_service_st.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893BA1E875108000B742D /* srs_service_st.cpp */; };
3CE893BF1E876A97000B742D /* srs_service_http_client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893BD1E876A97000B742D /* srs_service_http_client.cpp */; };
3CE893C21E876B9E000B742D /* srs_service_http_conn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893C01E876B9E000B742D /* srs_service_http_conn.cpp */; };
3CE893C51E876C39000B742D /* srs_service_rtmp_conn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893C31E876C39000B742D /* srs_service_rtmp_conn.cpp */; };
3CE893C81E876D04000B742D /* srs_service_utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893C61E876D04000B742D /* srs_service_utility.cpp */; };
3CE893CB1E8770E2000B742D /* srs_service_conn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CE893C91E8770E2000B742D /* srs_service_conn.cpp */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -431,6 +436,16 @@
3CE893B81E8750A9000B742D /* srs_service_log.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_service_log.hpp; path = ../../../src/service/srs_service_log.hpp; sourceTree = "<group>"; };
3CE893BA1E875108000B742D /* srs_service_st.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_service_st.cpp; path = ../../../src/service/srs_service_st.cpp; sourceTree = "<group>"; };
3CE893BB1E875108000B742D /* srs_service_st.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_service_st.hpp; path = ../../../src/service/srs_service_st.hpp; sourceTree = "<group>"; };
3CE893BD1E876A97000B742D /* srs_service_http_client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_service_http_client.cpp; path = ../../../src/service/srs_service_http_client.cpp; sourceTree = "<group>"; };
3CE893BE1E876A97000B742D /* srs_service_http_client.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_service_http_client.hpp; path = ../../../src/service/srs_service_http_client.hpp; sourceTree = "<group>"; };
3CE893C01E876B9E000B742D /* srs_service_http_conn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_service_http_conn.cpp; path = ../../../src/service/srs_service_http_conn.cpp; sourceTree = "<group>"; };
3CE893C11E876B9E000B742D /* srs_service_http_conn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_service_http_conn.hpp; path = ../../../src/service/srs_service_http_conn.hpp; sourceTree = "<group>"; };
3CE893C31E876C39000B742D /* srs_service_rtmp_conn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_service_rtmp_conn.cpp; path = ../../../src/service/srs_service_rtmp_conn.cpp; sourceTree = "<group>"; };
3CE893C41E876C39000B742D /* srs_service_rtmp_conn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_service_rtmp_conn.hpp; path = ../../../src/service/srs_service_rtmp_conn.hpp; sourceTree = "<group>"; };
3CE893C61E876D04000B742D /* srs_service_utility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_service_utility.cpp; path = ../../../src/service/srs_service_utility.cpp; sourceTree = "<group>"; };
3CE893C71E876D04000B742D /* srs_service_utility.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_service_utility.hpp; path = ../../../src/service/srs_service_utility.hpp; sourceTree = "<group>"; };
3CE893C91E8770E2000B742D /* srs_service_conn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_service_conn.cpp; path = ../../../src/service/srs_service_conn.cpp; sourceTree = "<group>"; };
3CE893CA1E8770E2000B742D /* srs_service_conn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_service_conn.hpp; path = ../../../src/service/srs_service_conn.hpp; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -475,9 +490,9 @@
3C1231EF1AAE651100CE8F6C /* core */,
3C1232071AAE814200CE8F6C /* kernel */,
3C12322C1AAE819900CE8F6C /* protocol */,
3CE893B61E875095000B742D /* service */,
3C12324B1AAE81CE00CE8F6C /* app */,
3C96ADC41B00A71000885304 /* modules */,
3CE893B61E875095000B742D /* service */,
3C1232041AAE80CB00CE8F6C /* main */,
3C36DB541ABD1CA70066CCAF /* libs */,
3C1231F91AAE670E00CE8F6C /* objs */,
Expand Down Expand Up @@ -919,10 +934,20 @@
3CE893B61E875095000B742D /* service */ = {
isa = PBXGroup;
children = (
3CE893C91E8770E2000B742D /* srs_service_conn.cpp */,
3CE893CA1E8770E2000B742D /* srs_service_conn.hpp */,
3CE893BD1E876A97000B742D /* srs_service_http_client.cpp */,
3CE893BE1E876A97000B742D /* srs_service_http_client.hpp */,
3CE893C01E876B9E000B742D /* srs_service_http_conn.cpp */,
3CE893C11E876B9E000B742D /* srs_service_http_conn.hpp */,
3CE893B71E8750A9000B742D /* srs_service_log.cpp */,
3CE893B81E8750A9000B742D /* srs_service_log.hpp */,
3CE893C31E876C39000B742D /* srs_service_rtmp_conn.cpp */,
3CE893C41E876C39000B742D /* srs_service_rtmp_conn.hpp */,
3CE893BA1E875108000B742D /* srs_service_st.cpp */,
3CE893BB1E875108000B742D /* srs_service_st.hpp */,
3CE893C61E876D04000B742D /* srs_service_utility.cpp */,
3CE893C71E876D04000B742D /* srs_service_utility.hpp */,
);
name = service;
sourceTree = "<group>";
Expand Down Expand Up @@ -1008,6 +1033,7 @@
3C12322B1AAE814D00CE8F6C /* srs_kernel_utility.cpp in Sources */,
3CA5F1411E65543700E442C7 /* event.c in Sources */,
3C12324A1AAE81A400CE8F6C /* srs_rtsp_stack.cpp in Sources */,
3CE893BF1E876A97000B742D /* srs_service_http_client.cpp in Sources */,
3C36DB5D1ABD1CB90066CCAF /* srs_librtmp.cpp in Sources */,
3CA5F1421E65543700E442C7 /* io.c in Sources */,
3C12329F1AAE81D900CE8F6C /* srs_app_http_api.cpp in Sources */,
Expand All @@ -1027,6 +1053,7 @@
3C1232221AAE814D00CE8F6C /* srs_kernel_codec.cpp in Sources */,
3C1232B71AAE81D900CE8F6C /* srs_app_utility.cpp in Sources */,
3C1232AB1AAE81D900CE8F6C /* srs_app_recv_thread.cpp in Sources */,
3CE893C51E876C39000B742D /* srs_service_rtmp_conn.cpp in Sources */,
3CC52DDC1ACE4023006FEB01 /* srs_utest_protocol.cpp in Sources */,
3C663F151AB0155100286D8B /* srs_h264_raw_publish.c in Sources */,
3C1231F61AAE652D00CE8F6C /* srs_core_autofree.cpp in Sources */,
Expand All @@ -1048,9 +1075,11 @@
3C12329C1AAE81D900CE8F6C /* srs_app_forward.cpp in Sources */,
3C1232251AAE814D00CE8F6C /* srs_kernel_file.cpp in Sources */,
3C1232AD1AAE81D900CE8F6C /* srs_app_reload.cpp in Sources */,
3CE893C81E876D04000B742D /* srs_service_utility.cpp in Sources */,
3C1231F81AAE652D00CE8F6C /* srs_core.cpp in Sources */,
3C1232A21AAE81D900CE8F6C /* srs_app_http_hooks.cpp in Sources */,
3C663F121AB0155100286D8B /* srs_detect_rtmp.c in Sources */,
3CE893CB1E8770E2000B742D /* srs_service_conn.cpp in Sources */,
3C1232B11AAE81D900CE8F6C /* srs_app_server.cpp in Sources */,
3C1232061AAE812C00CE8F6C /* srs_main_server.cpp in Sources */,
3C1232281AAE814D00CE8F6C /* srs_kernel_mp3.cpp in Sources */,
Expand All @@ -1076,6 +1105,7 @@
3C28EDDF1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp in Sources */,
3C1232241AAE814D00CE8F6C /* srs_kernel_error.cpp in Sources */,
3C036B561B2D0AC10078E2E0 /* srs_app_http_stream.cpp in Sources */,
3CE893C21E876B9E000B742D /* srs_service_http_conn.cpp in Sources */,
3C068D6D1B10175500AA722C /* srs_protocol_stream.cpp in Sources */,
3CB25C2A1BB269FD00C97A63 /* jmp_sp.cpp in Sources */,
3C068D6D1B10175500AA722C /* srs_protocol_stream.cpp in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion trunk/modules/readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SRS Module Ruler(SRS模块规则)
SRS Module Rules(SRS模块规则)
1. Each module in its seperate home directory(一个模块一个目录).
2. There is a config file in home(目录下放一个config文件).
3. All variables in configure are available(所有的configure中的变量模块中可以使用).
Expand Down
6 changes: 4 additions & 2 deletions trunk/src/app/srs_app_caster_flv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ int SrsAppCasterFlv::on_tcp_client(st_netfd_t stfd)
return ret;
}

void SrsAppCasterFlv::remove(SrsConnection* c)
void SrsAppCasterFlv::remove(ISrsConnection* c)
{
SrsConnection* conn = dynamic_cast<SrsConnection*>(c);

std::vector<SrsHttpConn*>::iterator it;
if ((it = std::find(conns.begin(), conns.end(), c)) != conns.end()) {
if ((it = std::find(conns.begin(), conns.end(), conn)) != conns.end()) {
conns.erase(it);
}
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_caster_flv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SrsAppCasterFlv : virtual public ISrsTcpHandler
virtual int on_tcp_client(st_netfd_t stfd);
// IConnectionManager
public:
virtual void remove(SrsConnection* c);
virtual void remove(ISrsConnection* c);
// ISrsHttpHandler
public:
virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
Expand Down
8 changes: 0 additions & 8 deletions trunk/src/app/srs_app_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ using namespace std;
#include <srs_app_utility.hpp>
#include <srs_kernel_utility.hpp>

IConnectionManager::IConnectionManager()
{
}

IConnectionManager::~IConnectionManager()
{
}

SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c, string cip)
{
id = 0;
Expand Down
21 changes: 3 additions & 18 deletions trunk/src/app/srs_app_conn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,15 @@
#include <srs_app_thread.hpp>
#include <srs_protocol_kbps.hpp>
#include <srs_app_reload.hpp>

class SrsConnection;

/**
* the manager for connection.
*/
class IConnectionManager
{
public:
IConnectionManager();
virtual ~IConnectionManager();
public:
/**
* remove the specified connection.
*/
virtual void remove(SrsConnection* c) = 0;
};
#include <srs_service_conn.hpp>

/**
* the basic connection of SRS,
* all connections accept from listener must extends from this base class,
* server will add the connection to manager, and delete it when remove.
*/
class SrsConnection : virtual public ISrsOneCycleThreadHandler, virtual public IKbpsDelta, virtual public ISrsReloadHandler
class SrsConnection : virtual public ISrsConnection, virtual public ISrsOneCycleThreadHandler
, virtual public IKbpsDelta, virtual public ISrsReloadHandler
{
private:
/**
Expand Down
Loading

0 comments on commit e3526c0

Please sign in to comment.