winlin

Merge branch '2.0release' into develop

@@ -19,9 +19,6 @@ echo "SRS_JOBS: ${SRS_JOBS}" @@ -19,9 +19,6 @@ echo "SRS_JOBS: ${SRS_JOBS}"
19 mkdir -p ${ff_build_dir} 19 mkdir -p ${ff_build_dir}
20 mkdir -p ${ff_release_dir} 20 mkdir -p ${ff_release_dir}
21 21
22 -# for ubuntu14, donot compile libaacplus.  
23 -UBUNTU14=NO;grep -in "Ubuntu 14." /etc/issue >/dev/null 2>&1; if [[ $? -eq 0 ]]; then UBUNTU14=YES; fi  
24 -  
25 # yasm for libx264 22 # yasm for libx264
26 ff_yasm_bin=${ff_release_dir}/bin/yasm 23 ff_yasm_bin=${ff_release_dir}/bin/yasm
27 if [[ -f ${ff_yasm_bin} ]]; then 24 if [[ -f ${ff_yasm_bin} ]]; then
@@ -138,7 +138,7 @@ if [ $SRS_MIPS_UBUNTU12 = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh @@ -138,7 +138,7 @@ if [ $SRS_MIPS_UBUNTU12 = YES ]; then SrsLinkOptions="${SrsLinkOptions} -lgcc_eh
138 MODULE_ID="CORE" 138 MODULE_ID="CORE"
139 MODULE_DEPENDS=() 139 MODULE_DEPENDS=()
140 ModuleLibIncs=(${SRS_OBJS_DIR}) 140 ModuleLibIncs=(${SRS_OBJS_DIR})
141 -MODULE_FILES=("srs_core" "srs_core_autofree" "srs_core_performance") 141 +MODULE_FILES=("srs_core" "srs_core_autofree" "srs_core_performance" "srs_core_mem_watch")
142 CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh 142 CORE_INCS="src/core"; MODULE_DIR=${CORE_INCS} . auto/modules.sh
143 CORE_OBJS="${MODULE_OBJS[@]}" 143 CORE_OBJS="${MODULE_OBJS[@]}"
144 # 144 #
@@ -16,6 +16,8 @@ file @@ -16,6 +16,8 @@ file
16 ../../src/core/srs_core.cpp, 16 ../../src/core/srs_core.cpp,
17 ../../src/core/srs_core_autofree.hpp, 17 ../../src/core/srs_core_autofree.hpp,
18 ../../src/core/srs_core_autofree.cpp, 18 ../../src/core/srs_core_autofree.cpp,
  19 + ../../src/core/srs_core_mem_watch.hpp,
  20 + ../../src/core/srs_core_mem_watch.cpp,
19 ../../src/core/srs_core_performance.hpp, 21 ../../src/core/srs_core_performance.hpp,
20 ../../src/core/srs_core_performance.cpp, 22 ../../src/core/srs_core_performance.cpp,
21 kernel readonly separator, 23 kernel readonly separator,
@@ -100,6 +100,7 @@ @@ -100,6 +100,7 @@
100 <ClInclude Include="..\..\src\app\srs_app_utility.hpp" /> 100 <ClInclude Include="..\..\src\app\srs_app_utility.hpp" />
101 <ClInclude Include="..\..\src\core\srs_core.hpp" /> 101 <ClInclude Include="..\..\src\core\srs_core.hpp" />
102 <ClInclude Include="..\..\src\core\srs_core_autofree.hpp" /> 102 <ClInclude Include="..\..\src\core\srs_core_autofree.hpp" />
  103 + <ClInclude Include="..\..\src\core\srs_core_mem_watch.hpp" />
103 <ClInclude Include="..\..\src\core\srs_core_performance.hpp" /> 104 <ClInclude Include="..\..\src\core\srs_core_performance.hpp" />
104 <ClInclude Include="..\..\src\kernel\srs_kernel_aac.hpp" /> 105 <ClInclude Include="..\..\src\kernel\srs_kernel_aac.hpp" />
105 <ClInclude Include="..\..\src\kernel\srs_kernel_avc.hpp" /> 106 <ClInclude Include="..\..\src\kernel\srs_kernel_avc.hpp" />
@@ -181,6 +182,7 @@ @@ -181,6 +182,7 @@
181 <ClCompile Include="..\..\src\app\srs_app_utility.cpp" /> 182 <ClCompile Include="..\..\src\app\srs_app_utility.cpp" />
182 <ClCompile Include="..\..\src\core\srs_core.cpp" /> 183 <ClCompile Include="..\..\src\core\srs_core.cpp" />
183 <ClCompile Include="..\..\src\core\srs_core_autofree.cpp" /> 184 <ClCompile Include="..\..\src\core\srs_core_autofree.cpp" />
  185 + <ClCompile Include="..\..\src\core\srs_core_mem_watch.cpp" />
184 <ClCompile Include="..\..\src\core\srs_core_performance.cpp" /> 186 <ClCompile Include="..\..\src\core\srs_core_performance.cpp" />
185 <ClCompile Include="..\..\src\kernel\srs_kernel_aac.cpp" /> 187 <ClCompile Include="..\..\src\kernel\srs_kernel_aac.cpp" />
186 <ClCompile Include="..\..\src\kernel\srs_kernel_avc.cpp" /> 188 <ClCompile Include="..\..\src\kernel\srs_kernel_avc.cpp" />
@@ -79,6 +79,7 @@ @@ -79,6 +79,7 @@
79 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 */; };
80 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 */; };
81 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 */; };
  82 + 3C5265B41B241BF0009CA186 /* srs_core_mem_watch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C5265B21B241BF0009CA186 /* srs_core_mem_watch.cpp */; };
82 3C663F0F1AB0155100286D8B /* srs_aac_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */; }; 83 3C663F0F1AB0155100286D8B /* srs_aac_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */; };
83 3C663F101AB0155100286D8B /* srs_audio_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */; }; 84 3C663F101AB0155100286D8B /* srs_audio_raw_publish.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */; };
84 3C663F111AB0155100286D8B /* srs_bandwidth_check.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */; }; 85 3C663F111AB0155100286D8B /* srs_bandwidth_check.c in Sources */ = {isa = PBXBuildFile; fileRef = 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */; };
@@ -327,6 +328,8 @@ @@ -327,6 +328,8 @@
327 3C36DB581ABD1CB90066CCAF /* srs_lib_simple_socket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_lib_simple_socket.hpp; path = ../../../src/libs/srs_lib_simple_socket.hpp; sourceTree = "<group>"; }; 328 3C36DB581ABD1CB90066CCAF /* srs_lib_simple_socket.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_lib_simple_socket.hpp; path = ../../../src/libs/srs_lib_simple_socket.hpp; sourceTree = "<group>"; };
328 3C36DB591ABD1CB90066CCAF /* srs_librtmp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_librtmp.cpp; path = ../../../src/libs/srs_librtmp.cpp; sourceTree = "<group>"; }; 329 3C36DB591ABD1CB90066CCAF /* srs_librtmp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_librtmp.cpp; path = ../../../src/libs/srs_librtmp.cpp; sourceTree = "<group>"; };
329 3C36DB5A1ABD1CB90066CCAF /* srs_librtmp.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_librtmp.hpp; path = ../../../src/libs/srs_librtmp.hpp; sourceTree = "<group>"; }; 330 3C36DB5A1ABD1CB90066CCAF /* srs_librtmp.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_librtmp.hpp; path = ../../../src/libs/srs_librtmp.hpp; sourceTree = "<group>"; };
  331 + 3C5265B21B241BF0009CA186 /* srs_core_mem_watch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = srs_core_mem_watch.cpp; path = ../../../src/core/srs_core_mem_watch.cpp; sourceTree = "<group>"; };
  332 + 3C5265B31B241BF0009CA186 /* srs_core_mem_watch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = srs_core_mem_watch.hpp; path = ../../../src/core/srs_core_mem_watch.hpp; sourceTree = "<group>"; };
330 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_aac_raw_publish.c; path = ../../../research/librtmp/srs_aac_raw_publish.c; sourceTree = "<group>"; }; 333 3C663F021AB0155100286D8B /* srs_aac_raw_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_aac_raw_publish.c; path = ../../../research/librtmp/srs_aac_raw_publish.c; sourceTree = "<group>"; };
331 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_audio_raw_publish.c; path = ../../../research/librtmp/srs_audio_raw_publish.c; sourceTree = "<group>"; }; 334 3C663F031AB0155100286D8B /* srs_audio_raw_publish.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_audio_raw_publish.c; path = ../../../research/librtmp/srs_audio_raw_publish.c; sourceTree = "<group>"; };
332 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_bandwidth_check.c; path = ../../../research/librtmp/srs_bandwidth_check.c; sourceTree = "<group>"; }; 335 3C663F041AB0155100286D8B /* srs_bandwidth_check.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = srs_bandwidth_check.c; path = ../../../research/librtmp/srs_bandwidth_check.c; sourceTree = "<group>"; };
@@ -428,6 +431,8 @@ @@ -428,6 +431,8 @@
428 children = ( 431 children = (
429 3C1231F01AAE652C00CE8F6C /* srs_core_autofree.cpp */, 432 3C1231F01AAE652C00CE8F6C /* srs_core_autofree.cpp */,
430 3C1231F11AAE652C00CE8F6C /* srs_core_autofree.hpp */, 433 3C1231F11AAE652C00CE8F6C /* srs_core_autofree.hpp */,
  434 + 3C5265B21B241BF0009CA186 /* srs_core_mem_watch.cpp */,
  435 + 3C5265B31B241BF0009CA186 /* srs_core_mem_watch.hpp */,
431 3C1231F21AAE652C00CE8F6C /* srs_core_performance.cpp */, 436 3C1231F21AAE652C00CE8F6C /* srs_core_performance.cpp */,
432 3C1231F31AAE652C00CE8F6C /* srs_core_performance.hpp */, 437 3C1231F31AAE652C00CE8F6C /* srs_core_performance.hpp */,
433 3C1231F41AAE652D00CE8F6C /* srs_core.cpp */, 438 3C1231F41AAE652D00CE8F6C /* srs_core.cpp */,
@@ -882,6 +887,7 @@ @@ -882,6 +887,7 @@
882 3CC52DDC1ACE4023006FEB01 /* srs_utest_protocol.cpp in Sources */, 887 3CC52DDC1ACE4023006FEB01 /* srs_utest_protocol.cpp in Sources */,
883 3C663F151AB0155100286D8B /* srs_h264_raw_publish.c in Sources */, 888 3C663F151AB0155100286D8B /* srs_h264_raw_publish.c in Sources */,
884 3C1231F61AAE652D00CE8F6C /* srs_core_autofree.cpp in Sources */, 889 3C1231F61AAE652D00CE8F6C /* srs_core_autofree.cpp in Sources */,
  890 + 3C5265B41B241BF0009CA186 /* srs_core_mem_watch.cpp in Sources */,
885 3C1EE6D71AB1367D00576EE9 /* README.md in Sources */, 891 3C1EE6D71AB1367D00576EE9 /* README.md in Sources */,
886 3C1232411AAE81A400CE8F6C /* srs_raw_avc.cpp in Sources */, 892 3C1232411AAE81A400CE8F6C /* srs_raw_avc.cpp in Sources */,
887 3C1232491AAE81A400CE8F6C /* srs_rtmp_utility.cpp in Sources */, 893 3C1232491AAE81A400CE8F6C /* srs_rtmp_utility.cpp in Sources */,
@@ -2860,13 +2860,15 @@ vector<string> SrsConfig::get_engine_vfilter(SrsConfDirective* engine) @@ -2860,13 +2860,15 @@ vector<string> SrsConfig::get_engine_vfilter(SrsConfDirective* engine)
2860 2860
2861 string SrsConfig::get_engine_vcodec(SrsConfDirective* engine) 2861 string SrsConfig::get_engine_vcodec(SrsConfDirective* engine)
2862 { 2862 {
  2863 + static string DEFAULT = "";
  2864 +
2863 if (!engine) { 2865 if (!engine) {
2864 - return ""; 2866 + return DEFAULT;
2865 } 2867 }
2866 2868
2867 SrsConfDirective* conf = engine->get("vcodec"); 2869 SrsConfDirective* conf = engine->get("vcodec");
2868 if (!conf) { 2870 if (!conf) {
2869 - return ""; 2871 + return DEFAULT;
2870 } 2872 }
2871 2873
2872 return conf->arg0(); 2874 return conf->arg0();
@@ -2998,13 +3000,15 @@ vector<string> SrsConfig::get_engine_vparams(SrsConfDirective* engine) @@ -2998,13 +3000,15 @@ vector<string> SrsConfig::get_engine_vparams(SrsConfDirective* engine)
2998 3000
2999 string SrsConfig::get_engine_acodec(SrsConfDirective* engine) 3001 string SrsConfig::get_engine_acodec(SrsConfDirective* engine)
3000 { 3002 {
  3003 + static string DEFAULT = "";
  3004 +
3001 if (!engine) { 3005 if (!engine) {
3002 - return ""; 3006 + return DEFAULT;
3003 } 3007 }
3004 3008
3005 SrsConfDirective* conf = engine->get("acodec"); 3009 SrsConfDirective* conf = engine->get("acodec");
3006 if (!conf) { 3010 if (!conf) {
3007 - return ""; 3011 + return DEFAULT;
3008 } 3012 }
3009 3013
3010 return conf->arg0(); 3014 return conf->arg0();
@@ -783,7 +783,7 @@ public: @@ -783,7 +783,7 @@ public:
783 virtual std::vector<std::string> get_engine_vfilter(SrsConfDirective* engine); 783 virtual std::vector<std::string> get_engine_vfilter(SrsConfDirective* engine);
784 /** 784 /**
785 * get the vcodec of engine, 785 * get the vcodec of engine,
786 - * the codec of video, copy or libx264 786 + * the codec of video, can be vn, copy or libx264
787 */ 787 */
788 virtual std::string get_engine_vcodec(SrsConfDirective* engine); 788 virtual std::string get_engine_vcodec(SrsConfDirective* engine);
789 /** 789 /**
@@ -827,7 +827,7 @@ public: @@ -827,7 +827,7 @@ public:
827 virtual std::vector<std::string> get_engine_vparams(SrsConfDirective* engine); 827 virtual std::vector<std::string> get_engine_vparams(SrsConfDirective* engine);
828 /** 828 /**
829 * get the acodec of engine, 829 * get the acodec of engine,
830 - * the audio codec can be copy or libaacplus 830 + * the audio codec can be an, copy or libfdk_aac
831 */ 831 */
832 virtual std::string get_engine_acodec(SrsConfDirective* engine); 832 virtual std::string get_engine_acodec(SrsConfDirective* engine);
833 /** 833 /**
@@ -40,6 +40,7 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c) @@ -40,6 +40,7 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c)
40 id = 0; 40 id = 0;
41 manager = cm; 41 manager = cm;
42 stfd = c; 42 stfd = c;
  43 + disposed = false;
43 44
44 // the client thread should reap itself, 45 // the client thread should reap itself,
45 // so we never use joinable. 46 // so we never use joinable.
@@ -50,12 +51,24 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c) @@ -50,12 +51,24 @@ SrsConnection::SrsConnection(IConnectionManager* cm, st_netfd_t c)
50 51
51 SrsConnection::~SrsConnection() 52 SrsConnection::~SrsConnection()
52 { 53 {
  54 + dispose();
  55 +
  56 + srs_freep(pthread);
  57 +}
  58 +
  59 +void SrsConnection::dispose()
  60 +{
  61 + if (disposed) {
  62 + return;
  63 + }
  64 +
  65 + disposed = true;
  66 +
53 /** 67 /**
54 * when delete the connection, stop the connection, 68 * when delete the connection, stop the connection,
55 * close the underlayer socket, delete the thread. 69 * close the underlayer socket, delete the thread.
56 */ 70 */
57 srs_close_stfd(stfd); 71 srs_close_stfd(stfd);
58 - srs_freep(pthread);  
59 } 72 }
60 73
61 int SrsConnection::start() 74 int SrsConnection::start()
@@ -83,11 +83,20 @@ protected: @@ -83,11 +83,20 @@ protected:
83 * the ip of client. 83 * the ip of client.
84 */ 84 */
85 std::string ip; 85 std::string ip;
  86 + /**
  87 + * whether the connection is disposed,
  88 + * when disposed, connection should stop cycle and cleanup itself.
  89 + */;
  90 + bool disposed;
86 public: 91 public:
87 SrsConnection(IConnectionManager* cm, st_netfd_t c); 92 SrsConnection(IConnectionManager* cm, st_netfd_t c);
88 virtual ~SrsConnection(); 93 virtual ~SrsConnection();
89 public: 94 public:
90 /** 95 /**
  96 + * to dipose the connection.
  97 + */
  98 + virtual void dispose();
  99 + /**
91 * start the client green thread. 100 * start the client green thread.
92 * when server get a client from listener, 101 * when server get a client from listener,
93 * 1. server will create an concrete connection(for instance, RTMP connection), 102 * 1. server will create an concrete connection(for instance, RTMP connection),
@@ -48,6 +48,7 @@ using namespace std; @@ -48,6 +48,7 @@ using namespace std;
48 // for example, libaacplus, aac, fdkaac 48 // for example, libaacplus, aac, fdkaac
49 #define SRS_RTMP_ENCODER_ACODEC "aac" 49 #define SRS_RTMP_ENCODER_ACODEC "aac"
50 #define SRS_RTMP_ENCODER_LIBAACPLUS "libaacplus" 50 #define SRS_RTMP_ENCODER_LIBAACPLUS "libaacplus"
  51 +#define SRS_RTMP_ENCODER_LIBFDKAAC "libfdk_aac"
51 52
52 SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin) 53 SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
53 { 54 {
@@ -174,7 +175,7 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine) @@ -174,7 +175,7 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
174 } 175 }
175 176
176 // @see, https://github.com/simple-rtmp-server/srs/issues/145 177 // @see, https://github.com/simple-rtmp-server/srs/issues/145
177 - if (acodec == SRS_RTMP_ENCODER_LIBAACPLUS) { 178 + if (acodec == SRS_RTMP_ENCODER_LIBAACPLUS && acodec != SRS_RTMP_ENCODER_LIBFDKAAC) {
178 if (abitrate < 16 || abitrate > 72) { 179 if (abitrate < 16 || abitrate > 72) {
179 ret = ERROR_ENCODER_ABITRATE; 180 ret = ERROR_ENCODER_ABITRATE;
180 srs_error("invalid abitrate for aac: %d, must in [16, 72], ret=%d", abitrate, ret); 181 srs_error("invalid abitrate for aac: %d, must in [16, 72], ret=%d", abitrate, ret);
@@ -529,7 +529,7 @@ int SrsHttpApi::do_cycle() @@ -529,7 +529,7 @@ int SrsHttpApi::do_cycle()
529 skt.set_recv_timeout(SRS_HTTP_RECV_TIMEOUT_US); 529 skt.set_recv_timeout(SRS_HTTP_RECV_TIMEOUT_US);
530 530
531 // process http messages. 531 // process http messages.
532 - for (;;) { 532 + while(!disposed) {
533 ISrsHttpMessage* req = NULL; 533 ISrsHttpMessage* req = NULL;
534 534
535 // get a http message 535 // get a http message
@@ -2533,7 +2533,7 @@ int SrsHttpConn::do_cycle() @@ -2533,7 +2533,7 @@ int SrsHttpConn::do_cycle()
2533 skt.set_recv_timeout(SRS_HTTP_RECV_TIMEOUT_US); 2533 skt.set_recv_timeout(SRS_HTTP_RECV_TIMEOUT_US);
2534 2534
2535 // process http messages. 2535 // process http messages.
2536 - for (;;) { 2536 + while (!disposed) {
2537 ISrsHttpMessage* req = NULL; 2537 ISrsHttpMessage* req = NULL;
2538 2538
2539 // get a http message 2539 // get a http message
@@ -320,11 +320,14 @@ int SrsRtmpConn::service_cycle() @@ -320,11 +320,14 @@ int SrsRtmpConn::service_cycle()
320 } 320 }
321 srs_verbose("on_bw_done success"); 321 srs_verbose("on_bw_done success");
322 322
323 - while (true) { 323 + while (!disposed) {
324 ret = stream_service_cycle(); 324 ret = stream_service_cycle();
325 325
326 // stream service must terminated with error, never success. 326 // stream service must terminated with error, never success.
327 - srs_assert(ret != ERROR_SUCCESS); 327 + // when terminated with success, it's user required to stop.
  328 + if (ret == ERROR_SUCCESS) {
  329 + continue;
  330 + }
328 331
329 // when not system control error, fatal error, return. 332 // when not system control error, fatal error, return.
330 if (!srs_is_system_control_error(ret)) { 333 if (!srs_is_system_control_error(ret)) {
@@ -361,6 +364,8 @@ int SrsRtmpConn::service_cycle() @@ -361,6 +364,8 @@ int SrsRtmpConn::service_cycle()
361 srs_error("control message(%d) reject as error. ret=%d", ret, ret); 364 srs_error("control message(%d) reject as error. ret=%d", ret, ret);
362 return ret; 365 return ret;
363 } 366 }
  367 +
  368 + return ret;
364 } 369 }
365 370
366 int SrsRtmpConn::stream_service_cycle() 371 int SrsRtmpConn::stream_service_cycle()
@@ -635,7 +640,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe @@ -635,7 +640,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
635 // set the sock options. 640 // set the sock options.
636 play_set_sock_options(); 641 play_set_sock_options();
637 642
638 - while (true) { 643 + while (!disposed) {
639 // collect elapse for pithy print. 644 // collect elapse for pithy print.
640 pprint->elapse(); 645 pprint->elapse();
641 646
@@ -865,7 +870,7 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) @@ -865,7 +870,7 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
865 } 870 }
866 871
867 int64_t nb_msgs = 0; 872 int64_t nb_msgs = 0;
868 - while (true) { 873 + while (!disposed) {
869 pprint->elapse(); 874 pprint->elapse();
870 875
871 // cond wait for error. 876 // cond wait for error.
@@ -47,6 +47,7 @@ using namespace std; @@ -47,6 +47,7 @@ using namespace std;
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 #include <srs_app_caster_flv.hpp>
  50 +#include <srs_core_mem_watch.hpp>
50 51
51 // signal defines. 52 // signal defines.
52 #define SIGNAL_RELOAD SIGHUP 53 #define SIGNAL_RELOAD SIGHUP
@@ -513,15 +514,7 @@ void SrsServer::destroy() @@ -513,15 +514,7 @@ void SrsServer::destroy()
513 { 514 {
514 srs_warn("start destroy server"); 515 srs_warn("start destroy server");
515 516
516 - _srs_config->unsubscribe(this);  
517 -  
518 - close_listeners(SrsListenerRtmpStream);  
519 - close_listeners(SrsListenerHttpApi);  
520 - close_listeners(SrsListenerHttpStream);  
521 -  
522 -#ifdef SRS_AUTO_INGEST  
523 - ingester->dispose();  
524 -#endif 517 + dispose();
525 518
526 #ifdef SRS_AUTO_HTTP_API 519 #ifdef SRS_AUTO_HTTP_API
527 srs_freep(http_api_mux); 520 srs_freep(http_api_mux);
@@ -547,28 +540,39 @@ void SrsServer::destroy() @@ -547,28 +540,39 @@ void SrsServer::destroy()
547 srs_freep(signal_manager); 540 srs_freep(signal_manager);
548 541
549 srs_freep(handler); 542 srs_freep(handler);
550 -  
551 - // @remark never destroy the connections,  
552 - // for it's still alive.  
553 -  
554 - // @remark never destroy the source,  
555 - // when we free all sources, the fmle publish may retry  
556 - // and segment fault.  
557 } 543 }
558 544
559 void SrsServer::dispose() 545 void SrsServer::dispose()
560 { 546 {
561 _srs_config->unsubscribe(this); 547 _srs_config->unsubscribe(this);
562 548
  549 + // prevent fresh clients.
  550 + close_listeners(SrsListenerRtmpStream);
  551 + close_listeners(SrsListenerHttpApi);
  552 + close_listeners(SrsListenerHttpStream);
  553 + close_listeners(SrsListenerMpegTsOverUdp);
  554 + close_listeners(SrsListenerRtsp);
  555 + close_listeners(SrsListenerFlv);
  556 +
563 #ifdef SRS_AUTO_INGEST 557 #ifdef SRS_AUTO_INGEST
564 ingester->dispose(); 558 ingester->dispose();
565 - srs_trace("gracefully dispose ingesters");  
566 #endif 559 #endif
567 560
568 SrsSource::dispose_all(); 561 SrsSource::dispose_all();
569 - srs_trace("gracefully dispose sources");  
570 562
571 - srs_trace("terminate server"); 563 + while (!conns.empty()) {
  564 + std::vector<SrsConnection*>::iterator it;
  565 + for (it = conns.begin(); it != conns.end(); ++it) {
  566 + SrsConnection* conn = *it;
  567 + conn->dispose();
  568 + }
  569 +
  570 + st_usleep(100 * 1000);
  571 + }
  572 +
  573 +#ifdef SRS_MEM_WATCH
  574 + srs_memory_report();
  575 +#endif
572 } 576 }
573 577
574 int SrsServer::initialize(ISrsServerCycle* cycle_handler) 578 int SrsServer::initialize(ISrsServerCycle* cycle_handler)
@@ -889,6 +893,9 @@ void SrsServer::on_signal(int signo) @@ -889,6 +893,9 @@ void SrsServer::on_signal(int signo)
889 signal_gmc_stop = true; 893 signal_gmc_stop = true;
890 #else 894 #else
891 srs_trace("user terminate program"); 895 srs_trace("user terminate program");
  896 +#ifdef SRS_MEM_WATCH
  897 + srs_memory_report();
  898 +#endif
892 exit(0); 899 exit(0);
893 #endif 900 #endif
894 return; 901 return;
@@ -583,6 +583,11 @@ SrsGopCache::~SrsGopCache() @@ -583,6 +583,11 @@ SrsGopCache::~SrsGopCache()
583 clear(); 583 clear();
584 } 584 }
585 585
  586 +void SrsGopCache::dispose()
  587 +{
  588 + clear();
  589 +}
  590 +
586 void SrsGopCache::set(bool enabled) 591 void SrsGopCache::set(bool enabled)
587 { 592 {
588 enable_gop_cache = enabled; 593 enable_gop_cache = enabled;
@@ -955,6 +960,14 @@ void SrsSource::dispose() @@ -955,6 +960,14 @@ void SrsSource::dispose()
955 #ifdef SRS_AUTO_HLS 960 #ifdef SRS_AUTO_HLS
956 hls->dispose(); 961 hls->dispose();
957 #endif 962 #endif
  963 +
  964 + // cleaup the cached packets.
  965 + srs_freep(cache_metadata);
  966 + srs_freep(cache_sh_video);
  967 + srs_freep(cache_sh_audio);
  968 +
  969 + // cleanup the gop cache.
  970 + gop_cache->dispose();
958 } 971 }
959 972
960 int SrsSource::cycle() 973 int SrsSource::cycle()
@@ -310,6 +310,10 @@ public: @@ -310,6 +310,10 @@ public:
310 virtual ~SrsGopCache(); 310 virtual ~SrsGopCache();
311 public: 311 public:
312 /** 312 /**
  313 + * cleanup when system quit.
  314 + */
  315 + virtual void dispose();
  316 + /**
313 * to enable or disable the gop cache. 317 * to enable or disable the gop cache.
314 */ 318 */
315 virtual void set(bool enabled); 319 virtual void set(bool enabled);
  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_core_mem_watch.hpp>
  25 +
  26 +#ifdef SRS_MEM_WATCH
  27 +
  28 +#include <map>
  29 +#include <stdio.h>
  30 +using namespace std;
  31 +
  32 +struct SrsMemoryObject
  33 +{
  34 + void* ptr;
  35 + std::string category;
  36 + int size;
  37 +};
  38 +
  39 +std::map<void*, SrsMemoryObject*> _srs_ptrs;
  40 +
  41 +void srs_memory_watch(void* ptr, string category, int size)
  42 +{
  43 + SrsMemoryObject* obj = NULL;
  44 +
  45 + std::map<void*, SrsMemoryObject*>::iterator it;
  46 + if ((it = _srs_ptrs.find(ptr)) != _srs_ptrs.end()) {
  47 + obj = it->second;
  48 + } else {
  49 + obj = new SrsMemoryObject();
  50 + _srs_ptrs[ptr] = obj;
  51 + }
  52 +
  53 + obj->ptr = ptr;
  54 + obj->category = category;
  55 + obj->size = size;
  56 +}
  57 +
  58 +void srs_memory_unwatch(void* ptr)
  59 +{
  60 + std::map<void*, SrsMemoryObject*>::iterator it;
  61 + if ((it = _srs_ptrs.find(ptr)) != _srs_ptrs.end()) {
  62 + SrsMemoryObject* obj = it->second;
  63 + srs_freep(obj);
  64 +
  65 + _srs_ptrs.erase(it);
  66 + }
  67 +}
  68 +
  69 +void srs_memory_report()
  70 +{
  71 + printf("srs memory leak report:\n");
  72 +
  73 + int total = 0;
  74 + std::map<void*, SrsMemoryObject*>::iterator it;
  75 + for (it = _srs_ptrs.begin(); it != _srs_ptrs.end(); ++it) {
  76 + SrsMemoryObject* obj = it->second;
  77 + printf(" %s: %#"PRIx64", %dB\n", obj->category.c_str(), (int64_t)obj->ptr, obj->size);
  78 + total += obj->size;
  79 + }
  80 +
  81 + printf("%d objects leak %dKB.\n", (int)_srs_ptrs.size(), total / 1024);
  82 +}
  83 +
  84 +#endif
  85 +
  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_CORE_MEM_WATCH_HPP
  25 +#define SRS_CORE_MEM_WATCH_HPP
  26 +
  27 +/*
  28 +#include <srs_core_mem_watch.hpp>
  29 +*/
  30 +
  31 +#include <srs_core.hpp>
  32 +
  33 +#ifdef SRS_MEM_WATCH
  34 +
  35 +#include <string>
  36 +
  37 +// watch the specified memory.
  38 +extern void srs_memory_watch(void* ptr, std::string category, int size);
  39 +
  40 +// unwatch the specified memory.
  41 +extern void srs_memory_unwatch(void* ptr);
  42 +
  43 +// report the memory watch.
  44 +extern void srs_memory_report();
  45 +
  46 +#endif
  47 +
  48 +#endif
  49 +
@@ -188,5 +188,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -188,5 +188,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
188 #undef SRS_PERF_FAST_FLV_ENCODER 188 #undef SRS_PERF_FAST_FLV_ENCODER
189 #define SRS_PERF_FAST_FLV_ENCODER 189 #define SRS_PERF_FAST_FLV_ENCODER
190 190
  191 +/**
  192 + * whether enable the special memory watcher.
  193 + * which used for memory leak debug and hurts performance.
  194 + */
  195 +#define SRS_MEM_WATCH
  196 +#undef SRS_MEM_WATCH
  197 +
191 #endif 198 #endif
192 199
@@ -38,6 +38,7 @@ using namespace std; @@ -38,6 +38,7 @@ using namespace std;
38 #include <srs_kernel_file.hpp> 38 #include <srs_kernel_file.hpp>
39 #include <srs_kernel_codec.hpp> 39 #include <srs_kernel_codec.hpp>
40 #include <srs_kernel_utility.hpp> 40 #include <srs_kernel_utility.hpp>
  41 +#include <srs_core_mem_watch.hpp>
41 42
42 SrsMessageHeader::SrsMessageHeader() 43 SrsMessageHeader::SrsMessageHeader()
43 { 44 {
@@ -159,6 +160,9 @@ SrsCommonMessage::SrsCommonMessage() @@ -159,6 +160,9 @@ SrsCommonMessage::SrsCommonMessage()
159 160
160 SrsCommonMessage::~SrsCommonMessage() 161 SrsCommonMessage::~SrsCommonMessage()
161 { 162 {
  163 +#ifdef SRS_MEM_WATCH
  164 + srs_memory_unwatch(payload);
  165 +#endif
162 srs_freep(payload); 166 srs_freep(payload);
163 } 167 }
164 168
@@ -171,6 +175,9 @@ SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload() @@ -171,6 +175,9 @@ SrsSharedPtrMessage::SrsSharedPtrPayload::SrsSharedPtrPayload()
171 175
172 SrsSharedPtrMessage::SrsSharedPtrPayload::~SrsSharedPtrPayload() 176 SrsSharedPtrMessage::SrsSharedPtrPayload::~SrsSharedPtrPayload()
173 { 177 {
  178 +#ifdef SRS_MEM_WATCH
  179 + srs_memory_unwatch(payload);
  180 +#endif
174 srs_freep(payload); 181 srs_freep(payload);
175 } 182 }
176 183
@@ -211,6 +211,11 @@ void check_macro_features() @@ -211,6 +211,11 @@ void check_macro_features()
211 #warning "current branch is not stable, please use stable branch instead." 211 #warning "current branch is not stable, please use stable branch instead."
212 srs_warn("SRS %s is not stable, please use stable branch %s instead", RTMP_SIG_SRS_VERSION, VERSION_STABLE_BRANCH); 212 srs_warn("SRS %s is not stable, please use stable branch %s instead", RTMP_SIG_SRS_VERSION, VERSION_STABLE_BRANCH);
213 #endif 213 #endif
  214 +
  215 +#ifdef SRS_MEM_WATCH
  216 + #warning "srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script."
  217 + srs_warn("srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script.");
  218 +#endif
214 219
215 #if defined(SRS_AUTO_STREAM_CASTER) 220 #if defined(SRS_AUTO_STREAM_CASTER)
216 #warning "stream caster is experiment feature." 221 #warning "stream caster is experiment feature."
@@ -72,7 +72,7 @@ SrsFastBuffer::~SrsFastBuffer() @@ -72,7 +72,7 @@ SrsFastBuffer::~SrsFastBuffer()
72 72
73 int SrsFastBuffer::size() 73 int SrsFastBuffer::size()
74 { 74 {
75 - return end - p; 75 + return (int)(end - p);
76 } 76 }
77 77
78 char* SrsFastBuffer::bytes() 78 char* SrsFastBuffer::bytes()
@@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #include <srs_kernel_utility.hpp> 30 #include <srs_kernel_utility.hpp>
31 #include <srs_protocol_buffer.hpp> 31 #include <srs_protocol_buffer.hpp>
32 #include <srs_rtmp_utility.hpp> 32 #include <srs_rtmp_utility.hpp>
  33 +#include <srs_core_mem_watch.hpp>
33 34
34 // for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213 35 // for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213
35 #ifndef _WIN32 36 #ifndef _WIN32
@@ -364,6 +365,7 @@ int SrsProtocol::recv_message(SrsCommonMessage** pmsg) @@ -364,6 +365,7 @@ int SrsProtocol::recv_message(SrsCommonMessage** pmsg)
364 srs_verbose("entire msg received"); 365 srs_verbose("entire msg received");
365 366
366 if (!msg) { 367 if (!msg) {
  368 + srs_info("got empty message without error.");
367 continue; 369 continue;
368 } 370 }
369 371
@@ -467,7 +469,7 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) @@ -467,7 +469,7 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs)
467 iovs[0].iov_len = nbh; 469 iovs[0].iov_len = nbh;
468 470
469 // payload iov 471 // payload iov
470 - int payload_size = srs_min(out_chunk_size, pend - p); 472 + int payload_size = srs_min(out_chunk_size, (int)(pend - p));
471 iovs[1].iov_base = p; 473 iovs[1].iov_base = p;
472 iovs[1].iov_len = payload_size; 474 iovs[1].iov_len = payload_size;
473 475
@@ -1411,6 +1413,9 @@ int SrsProtocol::read_message_payload(SrsChunkStream* chunk, SrsCommonMessage** @@ -1411,6 +1413,9 @@ int SrsProtocol::read_message_payload(SrsChunkStream* chunk, SrsCommonMessage**
1411 if (!chunk->msg->payload) { 1413 if (!chunk->msg->payload) {
1412 chunk->msg->payload = new char[chunk->header.payload_length]; 1414 chunk->msg->payload = new char[chunk->header.payload_length];
1413 srs_verbose("create payload for RTMP message. size=%d", chunk->header.payload_length); 1415 srs_verbose("create payload for RTMP message. size=%d", chunk->header.payload_length);
  1416 +#ifdef SRS_MEM_WATCH
  1417 + srs_memory_watch(chunk->msg->payload, "msg.payload", chunk->header.payload_length);
  1418 +#endif
1414 } 1419 }
1415 1420
1416 // read payload to buffer 1421 // read payload to buffer
@@ -289,7 +289,7 @@ std::string _full_conf = "" @@ -289,7 +289,7 @@ std::string _full_conf = ""
289 " bf 3; \n " 289 " bf 3; \n "
290 " refs 10; \n " 290 " refs 10; \n "
291 " } \n " 291 " } \n "
292 -" acodec libaacplus; \n " 292 +" acodec libfdk_aac; \n "
293 " abitrate 70; \n " 293 " abitrate 70; \n "
294 " asample_rate 44100; \n " 294 " asample_rate 44100; \n "
295 " achannels 2; \n " 295 " achannels 2; \n "
@@ -320,7 +320,7 @@ std::string _full_conf = "" @@ -320,7 +320,7 @@ std::string _full_conf = ""
320 " vpreset superfast; \n " 320 " vpreset superfast; \n "
321 " vparams { \n " 321 " vparams { \n "
322 " } \n " 322 " } \n "
323 -" acodec libaacplus; \n " 323 +" acodec libfdk_aac; \n "
324 " abitrate 45; \n " 324 " abitrate 45; \n "
325 " asample_rate 44100; \n " 325 " asample_rate 44100; \n "
326 " achannels 2; \n " 326 " achannels 2; \n "
@@ -349,7 +349,7 @@ std::string _full_conf = "" @@ -349,7 +349,7 @@ std::string _full_conf = ""
349 " vpreset superfast; \n " 349 " vpreset superfast; \n "
350 " vparams { \n " 350 " vparams { \n "
351 " } \n " 351 " } \n "
352 -" acodec libaacplus; \n " 352 +" acodec libfdk_aac; \n "
353 " abitrate 45; \n " 353 " abitrate 45; \n "
354 " asample_rate 44100; \n " 354 " asample_rate 44100; \n "
355 " achannels 2; \n " 355 " achannels 2; \n "
@@ -379,7 +379,7 @@ std::string _full_conf = "" @@ -379,7 +379,7 @@ std::string _full_conf = ""
379 " vpreset superfast; \n " 379 " vpreset superfast; \n "
380 " vparams { \n " 380 " vparams { \n "
381 " } \n " 381 " } \n "
382 -" acodec libaacplus; \n " 382 +" acodec libfdk_aac; \n "
383 " abitrate 45; \n " 383 " abitrate 45; \n "
384 " asample_rate 44100; \n " 384 " asample_rate 44100; \n "
385 " achannels 2; \n " 385 " achannels 2; \n "
@@ -396,7 +396,7 @@ std::string _full_conf = "" @@ -396,7 +396,7 @@ std::string _full_conf = ""
396 " engine acodec { \n " 396 " engine acodec { \n "
397 " enabled on; \n " 397 " enabled on; \n "
398 " vcodec copy; \n " 398 " vcodec copy; \n "
399 -" acodec libaacplus; \n " 399 +" acodec libfdk_aac; \n "
400 " abitrate 45; \n " 400 " abitrate 45; \n "
401 " asample_rate 44100; \n " 401 " asample_rate 44100; \n "
402 " achannels 2; \n " 402 " achannels 2; \n "
@@ -413,7 +413,7 @@ std::string _full_conf = "" @@ -413,7 +413,7 @@ std::string _full_conf = ""
413 " engine vn { \n " 413 " engine vn { \n "
414 " enabled on; \n " 414 " enabled on; \n "
415 " vcodec vn; \n " 415 " vcodec vn; \n "
416 -" acodec libaacplus; \n " 416 +" acodec libfdk_aac; \n "
417 " abitrate 45; \n " 417 " abitrate 45; \n "
418 " asample_rate 44100; \n " 418 " asample_rate 44100; \n "
419 " achannels 2; \n " 419 " achannels 2; \n "
@@ -461,7 +461,7 @@ std::string _full_conf = "" @@ -461,7 +461,7 @@ std::string _full_conf = ""
461 " bf 3; \n " 461 " bf 3; \n "
462 " refs 10; \n " 462 " refs 10; \n "
463 " } \n " 463 " } \n "
464 -" acodec libaacplus; \n " 464 +" acodec libfdk_aac; \n "
465 " abitrate 70; \n " 465 " abitrate 70; \n "
466 " asample_rate 44100; \n " 466 " asample_rate 44100; \n "
467 " achannels 2; \n " 467 " achannels 2; \n "
@@ -483,7 +483,7 @@ std::string _full_conf = "" @@ -483,7 +483,7 @@ std::string _full_conf = ""
483 " vpreset medium; \n " 483 " vpreset medium; \n "
484 " vparams { \n " 484 " vparams { \n "
485 " } \n " 485 " } \n "
486 -" acodec libaacplus; \n " 486 +" acodec libfdk_aac; \n "
487 " abitrate 70; \n " 487 " abitrate 70; \n "
488 " asample_rate 44100; \n " 488 " asample_rate 44100; \n "
489 " achannels 2; \n " 489 " achannels 2; \n "
@@ -503,7 +503,7 @@ std::string _full_conf = "" @@ -503,7 +503,7 @@ std::string _full_conf = ""
503 " vpreset fast; \n " 503 " vpreset fast; \n "
504 " vparams { \n " 504 " vparams { \n "
505 " } \n " 505 " } \n "
506 -" acodec libaacplus; \n " 506 +" acodec libfdk_aac; \n "
507 " abitrate 60; \n " 507 " abitrate 60; \n "
508 " asample_rate 44100; \n " 508 " asample_rate 44100; \n "
509 " achannels 2; \n " 509 " achannels 2; \n "
@@ -523,7 +523,7 @@ std::string _full_conf = "" @@ -523,7 +523,7 @@ std::string _full_conf = ""
523 " vpreset superfast; \n " 523 " vpreset superfast; \n "
524 " vparams { \n " 524 " vparams { \n "
525 " } \n " 525 " } \n "
526 -" acodec libaacplus; \n " 526 +" acodec libfdk_aac; \n "
527 " abitrate 45; \n " 527 " abitrate 45; \n "
528 " asample_rate 44100; \n " 528 " asample_rate 44100; \n "
529 " achannels 2; \n " 529 " achannels 2; \n "
@@ -534,7 +534,7 @@ std::string _full_conf = "" @@ -534,7 +534,7 @@ std::string _full_conf = ""
534 " engine vcopy { \n " 534 " engine vcopy { \n "
535 " enabled on; \n " 535 " enabled on; \n "
536 " vcodec copy; \n " 536 " vcodec copy; \n "
537 -" acodec libaacplus; \n " 537 +" acodec libfdk_aac; \n "
538 " abitrate 45; \n " 538 " abitrate 45; \n "
539 " asample_rate 44100; \n " 539 " asample_rate 44100; \n "
540 " achannels 2; \n " 540 " achannels 2; \n "
@@ -581,7 +581,7 @@ std::string _full_conf = "" @@ -581,7 +581,7 @@ std::string _full_conf = ""
581 " vpreset superfast; \n " 581 " vpreset superfast; \n "
582 " vparams { \n " 582 " vparams { \n "
583 " } \n " 583 " } \n "
584 -" acodec libaacplus; \n " 584 +" acodec libfdk_aac; \n "
585 " abitrate 45; \n " 585 " abitrate 45; \n "
586 " asample_rate 44100; \n " 586 " asample_rate 44100; \n "
587 " achannels 2; \n " 587 " achannels 2; \n "
@@ -2586,7 +2586,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_mirror) @@ -2586,7 +2586,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_mirror)
2586 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str()); 2586 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str());
2587 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str()); 2587 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str());
2588 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0); 2588 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0);
2589 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 2589 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
2590 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 2590 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
2591 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 2591 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
2592 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 2592 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -2676,7 +2676,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_crop) @@ -2676,7 +2676,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_crop)
2676 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str()); 2676 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str());
2677 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str()); 2677 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str());
2678 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0); 2678 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0);
2679 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 2679 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
2680 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 2680 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
2681 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 2681 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
2682 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 2682 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -2766,7 +2766,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_logo) @@ -2766,7 +2766,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_logo)
2766 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str()); 2766 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str());
2767 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str()); 2767 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str());
2768 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0); 2768 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0);
2769 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 2769 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
2770 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 2770 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
2771 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 2771 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
2772 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 2772 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -2849,7 +2849,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_audio) @@ -2849,7 +2849,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_audio)
2849 EXPECT_STREQ("flv", conf.get_engine_iformat(engine).c_str()); 2849 EXPECT_STREQ("flv", conf.get_engine_iformat(engine).c_str());
2850 EXPECT_TRUE((int)conf.get_engine_vfilter(engine).size() == 0); 2850 EXPECT_TRUE((int)conf.get_engine_vfilter(engine).size() == 0);
2851 EXPECT_STREQ("copy", conf.get_engine_vcodec(engine).c_str()); 2851 EXPECT_STREQ("copy", conf.get_engine_vcodec(engine).c_str());
2852 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 2852 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
2853 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 2853 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
2854 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 2854 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
2855 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 2855 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -2933,7 +2933,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_vn) @@ -2933,7 +2933,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_vn)
2933 EXPECT_STREQ("flv", conf.get_engine_iformat(engine).c_str()); 2933 EXPECT_STREQ("flv", conf.get_engine_iformat(engine).c_str());
2934 EXPECT_TRUE((int)conf.get_engine_vfilter(engine).size() == 0); 2934 EXPECT_TRUE((int)conf.get_engine_vfilter(engine).size() == 0);
2935 EXPECT_STREQ("vn", conf.get_engine_vcodec(engine).c_str()); 2935 EXPECT_STREQ("vn", conf.get_engine_vcodec(engine).c_str());
2936 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 2936 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
2937 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 2937 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
2938 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 2938 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
2939 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 2939 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -3105,7 +3105,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all) @@ -3105,7 +3105,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all)
3105 EXPECT_STREQ("main", conf.get_engine_vprofile(engine).c_str()); 3105 EXPECT_STREQ("main", conf.get_engine_vprofile(engine).c_str());
3106 EXPECT_STREQ("medium", conf.get_engine_vpreset(engine).c_str()); 3106 EXPECT_STREQ("medium", conf.get_engine_vpreset(engine).c_str());
3107 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() > 0); 3107 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() > 0);
3108 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 3108 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
3109 EXPECT_EQ(70, conf.get_engine_abitrate(engine)); 3109 EXPECT_EQ(70, conf.get_engine_abitrate(engine));
3110 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 3110 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
3111 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 3111 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -3130,7 +3130,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all) @@ -3130,7 +3130,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all)
3130 EXPECT_STREQ("main", conf.get_engine_vprofile(engine).c_str()); 3130 EXPECT_STREQ("main", conf.get_engine_vprofile(engine).c_str());
3131 EXPECT_STREQ("medium", conf.get_engine_vpreset(engine).c_str()); 3131 EXPECT_STREQ("medium", conf.get_engine_vpreset(engine).c_str());
3132 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0); 3132 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0);
3133 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 3133 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
3134 EXPECT_EQ(70, conf.get_engine_abitrate(engine)); 3134 EXPECT_EQ(70, conf.get_engine_abitrate(engine));
3135 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 3135 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
3136 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 3136 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -3155,7 +3155,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all) @@ -3155,7 +3155,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all)
3155 EXPECT_STREQ("main", conf.get_engine_vprofile(engine).c_str()); 3155 EXPECT_STREQ("main", conf.get_engine_vprofile(engine).c_str());
3156 EXPECT_STREQ("fast", conf.get_engine_vpreset(engine).c_str()); 3156 EXPECT_STREQ("fast", conf.get_engine_vpreset(engine).c_str());
3157 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0); 3157 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0);
3158 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 3158 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
3159 EXPECT_EQ(60, conf.get_engine_abitrate(engine)); 3159 EXPECT_EQ(60, conf.get_engine_abitrate(engine));
3160 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 3160 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
3161 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 3161 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -3180,7 +3180,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all) @@ -3180,7 +3180,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all)
3180 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str()); 3180 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str());
3181 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str()); 3181 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str());
3182 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0); 3182 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0);
3183 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 3183 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
3184 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 3184 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
3185 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 3185 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
3186 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 3186 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -3197,7 +3197,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all) @@ -3197,7 +3197,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_all)
3197 EXPECT_STREQ("flv", conf.get_engine_iformat(engine).c_str()); 3197 EXPECT_STREQ("flv", conf.get_engine_iformat(engine).c_str());
3198 EXPECT_TRUE((int)conf.get_engine_vfilter(engine).size() == 0); 3198 EXPECT_TRUE((int)conf.get_engine_vfilter(engine).size() == 0);
3199 EXPECT_STREQ("copy", conf.get_engine_vcodec(engine).c_str()); 3199 EXPECT_STREQ("copy", conf.get_engine_vcodec(engine).c_str());
3200 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 3200 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
3201 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 3201 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
3202 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 3202 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
3203 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 3203 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -3322,7 +3322,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_ffempty) @@ -3322,7 +3322,7 @@ VOID TEST(ConfigMainTest, ParseFullConf_transcode_ffempty)
3322 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str()); 3322 EXPECT_STREQ("baseline", conf.get_engine_vprofile(engine).c_str());
3323 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str()); 3323 EXPECT_STREQ("superfast", conf.get_engine_vpreset(engine).c_str());
3324 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0); 3324 EXPECT_TRUE((int)conf.get_engine_vparams(engine).size() == 0);
3325 - EXPECT_STREQ("libaacplus", conf.get_engine_acodec(engine).c_str()); 3325 + EXPECT_STREQ("libfdk_aac", conf.get_engine_acodec(engine).c_str());
3326 EXPECT_EQ(45, conf.get_engine_abitrate(engine)); 3326 EXPECT_EQ(45, conf.get_engine_abitrate(engine));
3327 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine)); 3327 EXPECT_EQ(44100, conf.get_engine_asample_rate(engine));
3328 EXPECT_EQ(2, conf.get_engine_achannels(engine)); 3328 EXPECT_EQ(2, conf.get_engine_achannels(engine));
@@ -4837,12 +4837,12 @@ VOID TEST(ConfigMainTest, CheckConf_transcode) @@ -4837,12 +4837,12 @@ VOID TEST(ConfigMainTest, CheckConf_transcode)
4837 4837
4838 if (true) { 4838 if (true) {
4839 MockSrsConfig conf; 4839 MockSrsConfig conf;
4840 - EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{transcode{engine {acodec libaacplus;}}}")); 4840 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{transcode{engine {acodec libfdk_aac;}}}"));
4841 } 4841 }
4842 4842
4843 if (true) { 4843 if (true) {
4844 MockSrsConfig conf; 4844 MockSrsConfig conf;
4845 - EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"vhost v{transcode{engine {acodecs libaacplus;}}}")); 4845 + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"vhost v{transcode{engine {acodecs libfdk_aac;}}}"));
4846 } 4846 }
4847 4847
4848 if (true) { 4848 if (true) {