正在显示
10 个修改的文件
包含
202 行增加
和
2 行删除
| @@ -159,6 +159,7 @@ stream_caster { | @@ -159,6 +159,7 @@ stream_caster { | ||
| 159 | # the caster type of stream, the casters: | 159 | # the caster type of stream, the casters: |
| 160 | # mpegts_over_udp, MPEG-TS over UDP caster. | 160 | # mpegts_over_udp, MPEG-TS over UDP caster. |
| 161 | # rtsp, Real Time Streaming Protocol (RTSP). | 161 | # rtsp, Real Time Streaming Protocol (RTSP). |
| 162 | + # flv, FLV over HTTP POST. | ||
| 162 | caster mpegts_over_udp; | 163 | caster mpegts_over_udp; |
| 163 | # the output rtmp url. | 164 | # the output rtmp url. |
| 164 | # for mpegts_over_udp caster, the typically output url: | 165 | # for mpegts_over_udp caster, the typically output url: |
| @@ -195,6 +196,12 @@ stream_caster { | @@ -195,6 +196,12 @@ stream_caster { | ||
| 195 | rtp_port_min 57200; | 196 | rtp_port_min 57200; |
| 196 | rtp_port_max 57300; | 197 | rtp_port_max 57300; |
| 197 | } | 198 | } |
| 199 | +stream_caster { | ||
| 200 | + enabled off; | ||
| 201 | + caster flv; | ||
| 202 | + output rtmp://127.0.0.1/[app]/[stream]; | ||
| 203 | + listen 8936; | ||
| 204 | +} | ||
| 198 | 205 | ||
| 199 | ############################################################################################# | 206 | ############################################################################################# |
| 200 | # RTMP/HTTP VHOST sections | 207 | # RTMP/HTTP VHOST sections |
| @@ -175,7 +175,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | @@ -175,7 +175,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | ||
| 175 | "srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge" | 175 | "srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge" |
| 176 | "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" | 176 | "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" |
| 177 | "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds" | 177 | "srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds" |
| 178 | - "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call") | 178 | + "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call" |
| 179 | + "srs_app_caster_flv") | ||
| 179 | DEFINES="" | 180 | DEFINES="" |
| 180 | # add each modules for app | 181 | # add each modules for app |
| 181 | for SRS_MODULE in ${SRS_MODULES[*]}; do | 182 | for SRS_MODULE in ${SRS_MODULES[*]}; do |
| @@ -69,6 +69,8 @@ file | @@ -69,6 +69,8 @@ file | ||
| 69 | ../../src/app/srs_app_async_call.cpp, | 69 | ../../src/app/srs_app_async_call.cpp, |
| 70 | ../../src/app/srs_app_bandwidth.hpp, | 70 | ../../src/app/srs_app_bandwidth.hpp, |
| 71 | ../../src/app/srs_app_bandwidth.cpp, | 71 | ../../src/app/srs_app_bandwidth.cpp, |
| 72 | + ../../src/app/srs_app_caster_flv.hpp, | ||
| 73 | + ../../src/app/srs_app_caster_flv.cpp, | ||
| 72 | ../../src/app/srs_app_conn.hpp, | 74 | ../../src/app/srs_app_conn.hpp, |
| 73 | ../../src/app/srs_app_conn.cpp, | 75 | ../../src/app/srs_app_conn.cpp, |
| 74 | ../../src/app/srs_app_config.hpp, | 76 | ../../src/app/srs_app_config.hpp, |
| @@ -85,6 +85,7 @@ | @@ -85,6 +85,7 @@ | ||
| 85 | <ClInclude Include="..\..\src\app\srs_app_listener.hpp" /> | 85 | <ClInclude Include="..\..\src\app\srs_app_listener.hpp" /> |
| 86 | <ClInclude Include="..\..\src\app\srs_app_log.hpp" /> | 86 | <ClInclude Include="..\..\src\app\srs_app_log.hpp" /> |
| 87 | <ClInclude Include="..\..\src\app\srs_app_mpegts_udp.hpp" /> | 87 | <ClInclude Include="..\..\src\app\srs_app_mpegts_udp.hpp" /> |
| 88 | + <ClInclude Include="..\..\src\app\srs_app_caster_flv.hpp" /> | ||
| 88 | <ClInclude Include="..\..\src\app\srs_app_pithy_print.hpp" /> | 89 | <ClInclude Include="..\..\src\app\srs_app_pithy_print.hpp" /> |
| 89 | <ClInclude Include="..\..\src\app\srs_app_recv_thread.hpp" /> | 90 | <ClInclude Include="..\..\src\app\srs_app_recv_thread.hpp" /> |
| 90 | <ClInclude Include="..\..\src\app\srs_app_refer.hpp" /> | 91 | <ClInclude Include="..\..\src\app\srs_app_refer.hpp" /> |
| @@ -165,6 +166,7 @@ | @@ -165,6 +166,7 @@ | ||
| 165 | <ClCompile Include="..\..\src\app\srs_app_listener.cpp" /> | 166 | <ClCompile Include="..\..\src\app\srs_app_listener.cpp" /> |
| 166 | <ClCompile Include="..\..\src\app\srs_app_log.cpp" /> | 167 | <ClCompile Include="..\..\src\app\srs_app_log.cpp" /> |
| 167 | <ClCompile Include="..\..\src\app\srs_app_mpegts_udp.cpp" /> | 168 | <ClCompile Include="..\..\src\app\srs_app_mpegts_udp.cpp" /> |
| 169 | + <ClCompile Include="..\..\src\app\srs_app_caster_flv.cpp" /> | ||
| 168 | <ClCompile Include="..\..\src\app\srs_app_pithy_print.cpp" /> | 170 | <ClCompile Include="..\..\src\app\srs_app_pithy_print.cpp" /> |
| 169 | <ClCompile Include="..\..\src\app\srs_app_recv_thread.cpp" /> | 171 | <ClCompile Include="..\..\src\app\srs_app_recv_thread.cpp" /> |
| 170 | <ClCompile Include="..\..\src\app\srs_app_refer.cpp" /> | 172 | <ClCompile Include="..\..\src\app\srs_app_refer.cpp" /> |
| @@ -75,6 +75,7 @@ | @@ -75,6 +75,7 @@ | ||
| 75 | 3C1232ED1AAEA70F00CE8F6C /* libhttp_parser.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232EC1AAEA70F00CE8F6C /* libhttp_parser.a */; }; | 75 | 3C1232ED1AAEA70F00CE8F6C /* libhttp_parser.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C1232EC1AAEA70F00CE8F6C /* libhttp_parser.a */; }; |
| 76 | 3C1EE6AE1AB1055800576EE9 /* srs_app_hds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */; }; | 76 | 3C1EE6AE1AB1055800576EE9 /* srs_app_hds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6AC1AB1055800576EE9 /* srs_app_hds.cpp */; }; |
| 77 | 3C1EE6D71AB1367D00576EE9 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6D61AB1367D00576EE9 /* README.md */; }; | 77 | 3C1EE6D71AB1367D00576EE9 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 3C1EE6D61AB1367D00576EE9 /* README.md */; }; |
| 78 | + 3C28EDDF1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */; }; | ||
| 78 | 3C36DB5B1ABD1CB90066CCAF /* srs_lib_bandwidth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB551ABD1CB90066CCAF /* srs_lib_bandwidth.cpp */; }; | 79 | 3C36DB5B1ABD1CB90066CCAF /* srs_lib_bandwidth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB551ABD1CB90066CCAF /* srs_lib_bandwidth.cpp */; }; |
| 79 | 3C36DB5C1ABD1CB90066CCAF /* srs_lib_simple_socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB571ABD1CB90066CCAF /* srs_lib_simple_socket.cpp */; }; | 80 | 3C36DB5C1ABD1CB90066CCAF /* srs_lib_simple_socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB571ABD1CB90066CCAF /* srs_lib_simple_socket.cpp */; }; |
| 80 | 3C36DB5D1ABD1CB90066CCAF /* srs_librtmp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB591ABD1CB90066CCAF /* srs_librtmp.cpp */; }; | 81 | 3C36DB5D1ABD1CB90066CCAF /* srs_librtmp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C36DB591ABD1CB90066CCAF /* srs_librtmp.cpp */; }; |
| @@ -318,6 +319,8 @@ | @@ -318,6 +319,8 @@ | ||
| 318 | 3C1EE6D41AB1367D00576EE9 /* DONATIONS.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DONATIONS.txt; path = ../../../DONATIONS.txt; sourceTree = "<group>"; }; | 319 | 3C1EE6D41AB1367D00576EE9 /* DONATIONS.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DONATIONS.txt; path = ../../../DONATIONS.txt; sourceTree = "<group>"; }; |
| 319 | 3C1EE6D51AB1367D00576EE9 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../../../LICENSE; sourceTree = "<group>"; }; | 320 | 3C1EE6D51AB1367D00576EE9 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../../../LICENSE; sourceTree = "<group>"; }; |
| 320 | 3C1EE6D61AB1367D00576EE9 /* README.md */ = {isa = PBXFileReference; explicitFileType = net.daringfireball.markdown; fileEncoding = 4; name = README.md; path = ../../../README.md; sourceTree = "<group>"; wrapsLines = 0; }; | 321 | 3C1EE6D61AB1367D00576EE9 /* README.md */ = {isa = PBXFileReference; explicitFileType = net.daringfireball.markdown; fileEncoding = 4; name = README.md; path = ../../../README.md; sourceTree = "<group>"; wrapsLines = 0; }; |
| 322 | + 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_app_caster_flv.cpp; path = ../../../src/app/srs_app_caster_flv.cpp; sourceTree = "<group>"; }; | ||
| 323 | + 3C28EDDE1AF5C43F00A3AEAC /* srs_app_caster_flv.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_app_caster_flv.hpp; path = ../../../src/app/srs_app_caster_flv.hpp; sourceTree = "<group>"; }; | ||
| 321 | 3C36DB551ABD1CB90066CCAF /* srs_lib_bandwidth.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_lib_bandwidth.cpp; path = ../../../src/libs/srs_lib_bandwidth.cpp; sourceTree = "<group>"; }; | 324 | 3C36DB551ABD1CB90066CCAF /* srs_lib_bandwidth.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_lib_bandwidth.cpp; path = ../../../src/libs/srs_lib_bandwidth.cpp; sourceTree = "<group>"; }; |
| 322 | 3C36DB561ABD1CB90066CCAF /* srs_lib_bandwidth.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_lib_bandwidth.hpp; path = ../../../src/libs/srs_lib_bandwidth.hpp; sourceTree = "<group>"; }; | 325 | 3C36DB561ABD1CB90066CCAF /* srs_lib_bandwidth.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_lib_bandwidth.hpp; path = ../../../src/libs/srs_lib_bandwidth.hpp; sourceTree = "<group>"; }; |
| 323 | 3C36DB571ABD1CB90066CCAF /* srs_lib_simple_socket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_lib_simple_socket.cpp; path = ../../../src/libs/srs_lib_simple_socket.cpp; sourceTree = "<group>"; }; | 326 | 3C36DB571ABD1CB90066CCAF /* srs_lib_simple_socket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_lib_simple_socket.cpp; path = ../../../src/libs/srs_lib_simple_socket.cpp; sourceTree = "<group>"; }; |
| @@ -511,6 +514,8 @@ | @@ -511,6 +514,8 @@ | ||
| 511 | 3C12324B1AAE81CE00CE8F6C /* app */ = { | 514 | 3C12324B1AAE81CE00CE8F6C /* app */ = { |
| 512 | isa = PBXGroup; | 515 | isa = PBXGroup; |
| 513 | children = ( | 516 | children = ( |
| 517 | + 3C28EDDD1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp */, | ||
| 518 | + 3C28EDDE1AF5C43F00A3AEAC /* srs_app_caster_flv.hpp */, | ||
| 514 | 3CD88B3D1ACA9C58000359E0 /* srs_app_async_call.cpp */, | 519 | 3CD88B3D1ACA9C58000359E0 /* srs_app_async_call.cpp */, |
| 515 | 3CD88B3E1ACA9C58000359E0 /* srs_app_async_call.hpp */, | 520 | 3CD88B3E1ACA9C58000359E0 /* srs_app_async_call.hpp */, |
| 516 | 3C12324C1AAE81D900CE8F6C /* srs_app_bandwidth.cpp */, | 521 | 3C12324C1AAE81D900CE8F6C /* srs_app_bandwidth.cpp */, |
| @@ -908,6 +913,7 @@ | @@ -908,6 +913,7 @@ | ||
| 908 | 3C1232261AAE814D00CE8F6C /* srs_kernel_flv.cpp in Sources */, | 913 | 3C1232261AAE814D00CE8F6C /* srs_kernel_flv.cpp in Sources */, |
| 909 | 3C663F1A1AB0155100286D8B /* srs_rtmp_dump.c in Sources */, | 914 | 3C663F1A1AB0155100286D8B /* srs_rtmp_dump.c in Sources */, |
| 910 | 3CE6CD311AE4AFB800706E07 /* srs_main_ingest_hls.cpp in Sources */, | 915 | 3CE6CD311AE4AFB800706E07 /* srs_main_ingest_hls.cpp in Sources */, |
| 916 | + 3C28EDDF1AF5C43F00A3AEAC /* srs_app_caster_flv.cpp in Sources */, | ||
| 911 | 3C1232241AAE814D00CE8F6C /* srs_kernel_error.cpp in Sources */, | 917 | 3C1232241AAE814D00CE8F6C /* srs_kernel_error.cpp in Sources */, |
| 912 | 3C1232441AAE81A400CE8F6C /* srs_rtmp_handshake.cpp in Sources */, | 918 | 3C1232441AAE81A400CE8F6C /* srs_rtmp_handshake.cpp in Sources */, |
| 913 | 3C1232291AAE814D00CE8F6C /* srs_kernel_stream.cpp in Sources */, | 919 | 3C1232291AAE814D00CE8F6C /* srs_kernel_stream.cpp in Sources */, |
trunk/src/app/srs_app_caster_flv.cpp
0 → 100644
| 1 | +/* | ||
| 2 | +The MIT License (MIT) | ||
| 3 | + | ||
| 4 | +Copyright (c) 2013-2015 SRS(simple-rtmp-server) | ||
| 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_app_caster_flv.hpp> | ||
| 25 | + | ||
| 26 | +#ifdef SRS_AUTO_STREAM_CASTER | ||
| 27 | + | ||
| 28 | +#include <srs_app_config.hpp> | ||
| 29 | +#include <srs_kernel_error.hpp> | ||
| 30 | +#include <srs_kernel_log.hpp> | ||
| 31 | +#include <srs_app_config.hpp> | ||
| 32 | +#include <srs_app_pithy_print.hpp> | ||
| 33 | + | ||
| 34 | +SrsAppCasterFlv::SrsAppCasterFlv(SrsConfDirective* c) | ||
| 35 | +{ | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +SrsAppCasterFlv::~SrsAppCasterFlv() | ||
| 39 | +{ | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +int SrsAppCasterFlv::on_tcp_client(st_netfd_t stfd) | ||
| 43 | +{ | ||
| 44 | + int ret = ERROR_SUCCESS; | ||
| 45 | + return ret; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +#endif |
trunk/src/app/srs_app_caster_flv.hpp
0 → 100644
| 1 | +/* | ||
| 2 | +The MIT License (MIT) | ||
| 3 | + | ||
| 4 | +Copyright (c) 2013-2015 SRS(simple-rtmp-server) | ||
| 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_APP_CASTER_FLV_HPP | ||
| 25 | +#define SRS_APP_CASTER_FLV_HPP | ||
| 26 | + | ||
| 27 | +/* | ||
| 28 | +#include <srs_app_caster_flv.hpp> | ||
| 29 | +*/ | ||
| 30 | + | ||
| 31 | +#include <srs_core.hpp> | ||
| 32 | + | ||
| 33 | +#ifdef SRS_AUTO_STREAM_CASTER | ||
| 34 | + | ||
| 35 | +class SrsConfDirective; | ||
| 36 | + | ||
| 37 | +#include <srs_app_st.hpp> | ||
| 38 | +#include <srs_app_listener.hpp> | ||
| 39 | + | ||
| 40 | +class SrsAppCasterFlv : public ISrsTcpHandler | ||
| 41 | +{ | ||
| 42 | +public: | ||
| 43 | + SrsAppCasterFlv(SrsConfDirective* c); | ||
| 44 | + virtual ~SrsAppCasterFlv(); | ||
| 45 | +// ISrsTcpHandler | ||
| 46 | +public: | ||
| 47 | + virtual int on_tcp_client(st_netfd_t stfd); | ||
| 48 | +}; | ||
| 49 | + | ||
| 50 | +#endif | ||
| 51 | + | ||
| 52 | +#endif |
| @@ -100,6 +100,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -100,6 +100,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 100 | #define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false | 100 | #define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false |
| 101 | #define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp" | 101 | #define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp" |
| 102 | #define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp" | 102 | #define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp" |
| 103 | +#define SRS_CONF_DEFAULT_STREAM_CASTER_FLV "flv" | ||
| 103 | 104 | ||
| 104 | #define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0 | 105 | #define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0 |
| 105 | 106 |
| @@ -46,6 +46,7 @@ using namespace std; | @@ -46,6 +46,7 @@ using namespace std; | ||
| 46 | #include <srs_app_mpegts_udp.hpp> | 46 | #include <srs_app_mpegts_udp.hpp> |
| 47 | #include <srs_app_rtsp.hpp> | 47 | #include <srs_app_rtsp.hpp> |
| 48 | #include <srs_app_statistic.hpp> | 48 | #include <srs_app_statistic.hpp> |
| 49 | +#include <srs_app_caster_flv.hpp> | ||
| 49 | 50 | ||
| 50 | // signal defines. | 51 | // signal defines. |
| 51 | #define SIGNAL_RELOAD SIGHUP | 52 | #define SIGNAL_RELOAD SIGHUP |
| @@ -206,7 +207,7 @@ int SrsRtspListener::listen(string ip, int port) | @@ -206,7 +207,7 @@ int SrsRtspListener::listen(string ip, int port) | ||
| 206 | listener = new SrsTcpListener(this, ip, port); | 207 | listener = new SrsTcpListener(this, ip, port); |
| 207 | 208 | ||
| 208 | if ((ret = listener->listen()) != ERROR_SUCCESS) { | 209 | if ((ret = listener->listen()) != ERROR_SUCCESS) { |
| 209 | - srs_error("udp caster listen failed. ret=%d", ret); | 210 | + srs_error("rtsp caster listen failed. ret=%d", ret); |
| 210 | return ret; | 211 | return ret; |
| 211 | } | 212 | } |
| 212 | 213 | ||
| @@ -231,6 +232,64 @@ int SrsRtspListener::on_tcp_client(st_netfd_t stfd) | @@ -231,6 +232,64 @@ int SrsRtspListener::on_tcp_client(st_netfd_t stfd) | ||
| 231 | return ret; | 232 | return ret; |
| 232 | } | 233 | } |
| 233 | 234 | ||
| 235 | +SrsHttpFlvListener::SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type) | ||
| 236 | +{ | ||
| 237 | + listener = NULL; | ||
| 238 | + | ||
| 239 | + // the caller already ensure the type is ok, | ||
| 240 | + // we just assert here for unknown stream caster. | ||
| 241 | + srs_assert(_type == SrsListenerRtsp); | ||
| 242 | + if (_type == SrsListenerRtsp) { | ||
| 243 | + caster = new SrsAppCasterFlv(c); | ||
| 244 | + } | ||
| 245 | +} | ||
| 246 | + | ||
| 247 | +SrsHttpFlvListener::~SrsHttpFlvListener() | ||
| 248 | +{ | ||
| 249 | + srs_freep(caster); | ||
| 250 | + srs_freep(listener); | ||
| 251 | +} | ||
| 252 | + | ||
| 253 | +int SrsHttpFlvListener::listen(string ip, int port) | ||
| 254 | +{ | ||
| 255 | + int ret = ERROR_SUCCESS; | ||
| 256 | + | ||
| 257 | + // the caller already ensure the type is ok, | ||
| 258 | + // we just assert here for unknown stream caster. | ||
| 259 | + srs_assert(_type == SrsListenerRtsp); | ||
| 260 | + | ||
| 261 | + _ip = ip; | ||
| 262 | + _port = port; | ||
| 263 | + | ||
| 264 | + srs_freep(listener); | ||
| 265 | + listener = new SrsTcpListener(this, ip, port); | ||
| 266 | + | ||
| 267 | + if ((ret = listener->listen()) != ERROR_SUCCESS) { | ||
| 268 | + srs_error("flv caster listen failed. ret=%d", ret); | ||
| 269 | + return ret; | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + srs_info("listen thread cid=%d, current_cid=%d, " | ||
| 273 | + "listen at port=%d, type=%d, fd=%d started success, ep=%s:%d", | ||
| 274 | + pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port); | ||
| 275 | + | ||
| 276 | + srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(_type).c_str(), ip.c_str(), _port, listener->fd()); | ||
| 277 | + | ||
| 278 | + return ret; | ||
| 279 | +} | ||
| 280 | + | ||
| 281 | +int SrsHttpFlvListener::on_tcp_client(st_netfd_t stfd) | ||
| 282 | +{ | ||
| 283 | + int ret = ERROR_SUCCESS; | ||
| 284 | + | ||
| 285 | + if ((ret = caster->on_tcp_client(stfd)) != ERROR_SUCCESS) { | ||
| 286 | + srs_warn("accept client error. ret=%d", ret); | ||
| 287 | + return ret; | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + return ret; | ||
| 291 | +} | ||
| 292 | + | ||
| 234 | SrsUdpCasterListener::SrsUdpCasterListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type) | 293 | SrsUdpCasterListener::SrsUdpCasterListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c) : SrsListener(server, type) |
| 235 | { | 294 | { |
| 236 | _type = type; | 295 | _type = type; |
| @@ -1003,6 +1062,8 @@ int SrsServer::listen_stream_caster() | @@ -1003,6 +1062,8 @@ int SrsServer::listen_stream_caster() | ||
| 1003 | listener = new SrsUdpCasterListener(this, SrsListenerMpegTsOverUdp, stream_caster); | 1062 | listener = new SrsUdpCasterListener(this, SrsListenerMpegTsOverUdp, stream_caster); |
| 1004 | } else if (caster == SRS_CONF_DEFAULT_STREAM_CASTER_RTSP) { | 1063 | } else if (caster == SRS_CONF_DEFAULT_STREAM_CASTER_RTSP) { |
| 1005 | listener = new SrsRtspListener(this, SrsListenerRtsp, stream_caster); | 1064 | listener = new SrsRtspListener(this, SrsListenerRtsp, stream_caster); |
| 1065 | + } else if (caster == SRS_CONF_DEFAULT_STREAM_CASTER_FLV) { | ||
| 1066 | + listener = new SrsHttpFlvListener(this, SrsListenerFlv, stream_caster); | ||
| 1006 | } else { | 1067 | } else { |
| 1007 | ret = ERROR_STREAM_CASTER_ENGINE; | 1068 | ret = ERROR_STREAM_CASTER_ENGINE; |
| 1008 | srs_error("unsupported stream caster %s. ret=%d", caster.c_str(), ret); | 1069 | srs_error("unsupported stream caster %s. ret=%d", caster.c_str(), ret); |
| @@ -66,6 +66,8 @@ enum SrsListenerType | @@ -66,6 +66,8 @@ enum SrsListenerType | ||
| 66 | SrsListenerMpegTsOverUdp = 3, | 66 | SrsListenerMpegTsOverUdp = 3, |
| 67 | // TCP stream, RTSP stream. | 67 | // TCP stream, RTSP stream. |
| 68 | SrsListenerRtsp = 4, | 68 | SrsListenerRtsp = 4, |
| 69 | + // HTTP stream, FLV over HTTP POST. | ||
| 70 | + SrsListenerFlv = 5, | ||
| 69 | }; | 71 | }; |
| 70 | 72 | ||
| 71 | /** | 73 | /** |
| @@ -124,6 +126,24 @@ public: | @@ -124,6 +126,24 @@ public: | ||
| 124 | }; | 126 | }; |
| 125 | 127 | ||
| 126 | /** | 128 | /** |
| 129 | + * the tcp listener, for http flv server. | ||
| 130 | + */ | ||
| 131 | +class SrsHttpFlvListener : virtual public SrsListener, virtual public ISrsTcpHandler | ||
| 132 | +{ | ||
| 133 | +private: | ||
| 134 | + SrsTcpListener* listener; | ||
| 135 | + ISrsTcpHandler* caster; | ||
| 136 | +public: | ||
| 137 | + SrsHttpFlvListener(SrsServer* server, SrsListenerType type, SrsConfDirective* c); | ||
| 138 | + virtual ~SrsHttpFlvListener(); | ||
| 139 | +public: | ||
| 140 | + virtual int listen(std::string ip, int port); | ||
| 141 | +// ISrsTcpHandler | ||
| 142 | +public: | ||
| 143 | + virtual int on_tcp_client(st_netfd_t stfd); | ||
| 144 | +}; | ||
| 145 | + | ||
| 146 | +/** | ||
| 127 | * the udp listener, for udp server. | 147 | * the udp listener, for udp server. |
| 128 | */ | 148 | */ |
| 129 | class SrsUdpCasterListener : public SrsListener | 149 | class SrsUdpCasterListener : public SrsListener |
-
请 注册 或 登录 后发表评论