1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine code, extract the http protocol sdk to module.

This commit is contained in:
winlin 2015-05-22 20:47:27 +08:00
parent d645411392
commit e2955da78f
9 changed files with 83 additions and 16 deletions

2
trunk/configure vendored
View file

@ -159,7 +159,7 @@ MODULE_DEPENDS=("CORE" "KERNEL")
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
MODULE_FILES=("srs_rtmp_amf0" "srs_rtmp_io" "srs_rtmp_stack" "srs_rtmp_sdk"
"srs_rtmp_handshake" "srs_rtmp_utility" "srs_rtmp_msg_array" "srs_rtmp_buffer"
"srs_raw_avc" "srs_rtsp_stack")
"srs_raw_avc" "srs_rtsp_stack" "srs_http_stack")
RTMP_INCS="src/protocol"; MODULE_DIR=${RTMP_INCS} . auto/modules.sh
RTMP_OBJS="${MODULE_OBJS[@]}"
#

View file

@ -46,6 +46,8 @@ file
../../src/kernel/srs_kernel_utility.hpp,
../../src/kernel/srs_kernel_utility.cpp,
protocol readonly separator,
../../src/protocol/srs_http_stack.hpp,
../../src/protocol/srs_http_stack.cpp,
../../src/protocol/srs_raw_avc.hpp,
../../src/protocol/srs_raw_avc.cpp,
../../src/protocol/srs_rtmp_amf0.hpp,

View file

@ -119,6 +119,7 @@
<ClInclude Include="..\..\src\libs\srs_librtmp.hpp" />
<ClInclude Include="..\..\src\libs\srs_lib_bandwidth.hpp" />
<ClInclude Include="..\..\src\libs\srs_lib_simple_socket.hpp" />
<ClInclude Include="..\..\src\protocol\srs_http_stack.hpp" />
<ClInclude Include="..\..\src\protocol\srs_raw_avc.hpp" />
<ClInclude Include="..\..\src\protocol\srs_rtmp_amf0.hpp" />
<ClInclude Include="..\..\src\protocol\srs_rtmp_buffer.hpp" />
@ -201,6 +202,7 @@
<ClCompile Include="..\..\src\libs\srs_lib_bandwidth.cpp" />
<ClCompile Include="..\..\src\libs\srs_lib_simple_socket.cpp" />
<ClCompile Include="..\..\src\main\srs_main_server.cpp" />
<ClCompile Include="..\..\src\protocol\srs_http_stack.cpp" />
<ClCompile Include="..\..\src\protocol\srs_raw_avc.cpp" />
<ClCompile Include="..\..\src\protocol\srs_rtmp_amf0.cpp" />
<ClCompile Include="..\..\src\protocol\srs_rtmp_buffer.cpp" />

View file

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
3C0E1B8D1B0F5ADF003ADEF7 /* srs_http_stack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C0E1B8B1B0F5ADF003ADEF7 /* srs_http_stack.cpp */; };
3C1231F61AAE652D00CE8F6C /* srs_core_autofree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C1231F01AAE652C00CE8F6C /* srs_core_autofree.cpp */; };
3C1231F71AAE652D00CE8F6C /* srs_core_performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C1231F21AAE652C00CE8F6C /* srs_core_performance.cpp */; };
3C1231F81AAE652D00CE8F6C /* srs_core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C1231F41AAE652D00CE8F6C /* srs_core.cpp */; };
@ -122,6 +123,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
3C0E1B8B1B0F5ADF003ADEF7 /* srs_http_stack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_http_stack.cpp; path = ../../../src/protocol/srs_http_stack.cpp; sourceTree = "<group>"; };
3C0E1B8C1B0F5ADF003ADEF7 /* srs_http_stack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_http_stack.hpp; path = ../../../src/protocol/srs_http_stack.hpp; sourceTree = "<group>"; };
3C1231E51AAE64A400CE8F6C /* srs_xcode */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = srs_xcode; sourceTree = BUILT_PRODUCTS_DIR; };
3C1231F01AAE652C00CE8F6C /* srs_core_autofree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_core_autofree.cpp; path = ../../../src/core/srs_core_autofree.cpp; sourceTree = "<group>"; };
3C1231F11AAE652C00CE8F6C /* srs_core_autofree.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_core_autofree.hpp; path = ../../../src/core/srs_core_autofree.hpp; sourceTree = "<group>"; };
@ -487,6 +490,8 @@
3C12322C1AAE819900CE8F6C /* protocol */ = {
isa = PBXGroup;
children = (
3C0E1B8B1B0F5ADF003ADEF7 /* srs_http_stack.cpp */,
3C0E1B8C1B0F5ADF003ADEF7 /* srs_http_stack.hpp */,
3C12322D1AAE81A400CE8F6C /* srs_raw_avc.cpp */,
3C12322E1AAE81A400CE8F6C /* srs_raw_avc.hpp */,
3C12322F1AAE81A400CE8F6C /* srs_rtmp_amf0.cpp */,
@ -886,6 +891,7 @@
3C1232411AAE81A400CE8F6C /* srs_raw_avc.cpp in Sources */,
3C1232491AAE81A400CE8F6C /* srs_rtmp_utility.cpp in Sources */,
3C663F191AB0155100286D8B /* srs_publish.c in Sources */,
3C0E1B8D1B0F5ADF003ADEF7 /* srs_http_stack.cpp in Sources */,
3C1232A01AAE81D900CE8F6C /* srs_app_http_client.cpp in Sources */,
3C689F981AB6AAAC00C9CEEE /* key.c in Sources */,
3C12329B1AAE81D900CE8F6C /* srs_app_ffmpeg.cpp in Sources */,

View file

@ -58,7 +58,7 @@ using namespace std;
#define SRS_HTTP_DEFAULT_PAGE "index.html"
int srs_go_http_response_json(ISrsHttpResponseWriter* w, string data)
int srs_http_response_json(ISrsHttpResponseWriter* w, string data)
{
w->header()->set_content_length(data.length());
w->header()->set_content_type("application/json");

View file

@ -40,6 +40,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_st.hpp>
#include <srs_kernel_consts.hpp>
#include <srs_http_stack.hpp>
class SrsRequest;
class SrsStSocket;
@ -72,7 +73,7 @@ class SrsConnection;
#define SRS_HTTP_TS_SEND_BUFFER_SIZE 4096
// helper function: response in json format.
extern int srs_go_http_response_json(ISrsHttpResponseWriter* w, std::string data);
extern int srs_http_response_json(ISrsHttpResponseWriter* w, std::string data);
// state of message
enum SrsHttpParseState {

View file

@ -59,7 +59,7 @@ int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiApi::SrsGoApiApi()
@ -81,7 +81,7 @@ int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiV1::SrsGoApiV1()
@ -112,7 +112,7 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiVersion::SrsGoApiVersion()
@ -137,7 +137,7 @@ int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiSummaries::SrsGoApiSummaries()
@ -152,7 +152,7 @@ int SrsGoApiSummaries::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
{
std::stringstream ss;
srs_api_dump_summaries(ss);
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiRusages::SrsGoApiRusages()
@ -193,7 +193,7 @@ int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* req)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiSelfProcStats::SrsGoApiSelfProcStats()
@ -263,7 +263,7 @@ int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage*
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiSystemProcStats::SrsGoApiSystemProcStats()
@ -298,7 +298,7 @@ int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessag
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiMemInfos::SrsGoApiMemInfos()
@ -334,7 +334,7 @@ int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiAuthors::SrsGoApiAuthors()
@ -359,7 +359,7 @@ int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiRequests::SrsGoApiRequests()
@ -420,7 +420,7 @@ int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JOBJECT_END
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiVhosts::SrsGoApiVhosts()
@ -445,7 +445,7 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JFIELD_ORG("vhosts", data.str())
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsGoApiStreams::SrsGoApiStreams()
@ -470,7 +470,7 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
<< SRS_JFIELD_ORG("streams", data.str())
<< SRS_JOBJECT_END;
return srs_go_http_response_json(w, ss.str());
return srs_http_response_json(w, ss.str());
}
SrsHttpApi::SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m)

View file

@ -0,0 +1,24 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2015 SRS(simple-rtmp-server)
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_http_stack.hpp>

View file

@ -0,0 +1,32 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2015 SRS(simple-rtmp-server)
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.
*/
#ifndef SRS_PROTOCOL_HTTP_HPP
#define SRS_PROTOCOL_HTTP_HPP
/*
#include <srs_http_stack.hpp>
*/
#include <srs_core.hpp>
#endif