winlin

refine the macro.

@@ -528,9 +528,9 @@ else @@ -528,9 +528,9 @@ else
528 fi 528 fi
529 529
530 if [ $SRS_INGEST = YES ]; then 530 if [ $SRS_INGEST = YES ]; then
531 - echo "#define SRS_INGEST" >> $SRS_AUTO_HEADERS_H 531 + echo "#define SRS_RTMP_INGEST" >> $SRS_AUTO_HEADERS_H
532 else 532 else
533 - echo "#undef SRS_INGEST" >> $SRS_AUTO_HEADERS_H 533 + echo "#undef SRS_RTMP_INGEST" >> $SRS_AUTO_HEADERS_H
534 fi 534 fi
535 535
536 ##################################################################################### 536 #####################################################################################
@@ -2128,13 +2128,13 @@ string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest) @@ -2128,13 +2128,13 @@ string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest)
2128 SrsConfDirective* conf = ingest->get("input"); 2128 SrsConfDirective* conf = ingest->get("input");
2129 2129
2130 if (!conf) { 2130 if (!conf) {
2131 - return SRS_INGEST_TYPE_FILE; 2131 + return SRS_RTMP_INGEST_TYPE_FILE;
2132 } 2132 }
2133 2133
2134 conf = conf->get("type"); 2134 conf = conf->get("type");
2135 2135
2136 if (!conf) { 2136 if (!conf) {
2137 - return SRS_INGEST_TYPE_FILE; 2137 + return SRS_RTMP_INGEST_TYPE_FILE;
2138 } 2138 }
2139 2139
2140 return conf->arg0(); 2140 return conf->arg0();
@@ -70,8 +70,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -70,8 +70,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 #define SRS_STAGE_INGESTER_INTERVAL_MS 2000 70 #define SRS_STAGE_INGESTER_INTERVAL_MS 2000
71 #define SRS_STAGE_HLS_INTERVAL_MS 2000 71 #define SRS_STAGE_HLS_INTERVAL_MS 2000
72 72
73 -#define SRS_INGEST_TYPE_FILE "file"  
74 -#define SRS_INGEST_TYPE_STREAM "stream" 73 +#define SRS_RTMP_INGEST_TYPE_FILE "file"
  74 +#define SRS_RTMP_INGEST_TYPE_STREAM "stream"
75 75
76 class SrsFileBuffer; 76 class SrsFileBuffer;
77 77
@@ -37,14 +37,14 @@ using namespace std; @@ -37,14 +37,14 @@ using namespace std;
37 #ifdef SRS_RTMP_TRANSCODE 37 #ifdef SRS_RTMP_TRANSCODE
38 38
39 // when error, encoder sleep for a while and retry. 39 // when error, encoder sleep for a while and retry.
40 -#define SRS_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL) 40 +#define SRS_RTMP_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL)
41 41
42 // for encoder to detect the dead loop 42 // for encoder to detect the dead loop
43 static std::vector<std::string> _transcoded_url; 43 static std::vector<std::string> _transcoded_url;
44 44
45 SrsEncoder::SrsEncoder() 45 SrsEncoder::SrsEncoder()
46 { 46 {
47 - pthread = new SrsThread(this, SRS_ENCODER_SLEEP_US); 47 + pthread = new SrsThread(this, SRS_RTMP_ENCODER_SLEEP_US);
48 pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER); 48 pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER);
49 } 49 }
50 50
@@ -112,7 +112,7 @@ int SrsEncoder::cycle() @@ -112,7 +112,7 @@ int SrsEncoder::cycle()
112 112
113 // pithy print 113 // pithy print
114 encoder(); 114 encoder();
115 - pithy_print->elapse(SRS_ENCODER_SLEEP_US / 1000); 115 + pithy_print->elapse(SRS_RTMP_ENCODER_SLEEP_US / 1000);
116 116
117 return ret; 117 return ret;
118 } 118 }
@@ -41,14 +41,14 @@ using namespace std; @@ -41,14 +41,14 @@ using namespace std;
41 41
42 #ifdef SRS_FFMPEG_STUB 42 #ifdef SRS_FFMPEG_STUB
43 43
44 -#define SRS_ENCODER_COPY "copy"  
45 -#define SRS_ENCODER_NO_VIDEO "vn"  
46 -#define SRS_ENCODER_NO_AUDIO "an" 44 +#define SRS_RTMP_ENCODER_COPY "copy"
  45 +#define SRS_RTMP_ENCODER_NO_VIDEO "vn"
  46 +#define SRS_RTMP_ENCODER_NO_AUDIO "an"
47 // only support libx264 encoder. 47 // only support libx264 encoder.
48 -#define SRS_ENCODER_VCODEC "libx264" 48 +#define SRS_RTMP_ENCODER_VCODEC "libx264"
49 // any aac encoder is ok which contains the aac, 49 // any aac encoder is ok which contains the aac,
50 // for example, libaacplus, aac, fdkaac 50 // for example, libaacplus, aac, fdkaac
51 -#define SRS_ENCODER_ACODEC "aac" 51 +#define SRS_RTMP_ENCODER_ACODEC "aac"
52 52
53 SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin) 53 SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
54 { 54 {
@@ -118,17 +118,17 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine) @@ -118,17 +118,17 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
118 vwidth -= vwidth % 2; 118 vwidth -= vwidth % 2;
119 vheight -= vheight % 2; 119 vheight -= vheight % 2;
120 120
121 - if (vcodec == SRS_ENCODER_NO_VIDEO && acodec == SRS_ENCODER_NO_AUDIO) { 121 + if (vcodec == SRS_RTMP_ENCODER_NO_VIDEO && acodec == SRS_RTMP_ENCODER_NO_AUDIO) {
122 ret = ERROR_ENCODER_VCODEC; 122 ret = ERROR_ENCODER_VCODEC;
123 srs_warn("video and audio disabled. ret=%d", ret); 123 srs_warn("video and audio disabled. ret=%d", ret);
124 return ret; 124 return ret;
125 } 125 }
126 126
127 - if (vcodec != SRS_ENCODER_COPY && vcodec != SRS_ENCODER_NO_VIDEO) {  
128 - if (vcodec != SRS_ENCODER_VCODEC) { 127 + if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
  128 + if (vcodec != SRS_RTMP_ENCODER_VCODEC) {
129 ret = ERROR_ENCODER_VCODEC; 129 ret = ERROR_ENCODER_VCODEC;
130 srs_error("invalid vcodec, must be %s, actual %s, ret=%d", 130 srs_error("invalid vcodec, must be %s, actual %s, ret=%d",
131 - SRS_ENCODER_VCODEC, vcodec.c_str(), ret); 131 + SRS_RTMP_ENCODER_VCODEC, vcodec.c_str(), ret);
132 return ret; 132 return ret;
133 } 133 }
134 if (vbitrate <= 0) { 134 if (vbitrate <= 0) {
@@ -168,11 +168,11 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine) @@ -168,11 +168,11 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
168 } 168 }
169 } 169 }
170 170
171 - if (acodec != SRS_ENCODER_COPY && acodec != SRS_ENCODER_NO_AUDIO) {  
172 - if (acodec.find(SRS_ENCODER_ACODEC) == std::string::npos) { 171 + if (acodec != SRS_RTMP_ENCODER_COPY && acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
  172 + if (acodec.find(SRS_RTMP_ENCODER_ACODEC) == std::string::npos) {
173 ret = ERROR_ENCODER_ACODEC; 173 ret = ERROR_ENCODER_ACODEC;
174 srs_error("invalid acodec, must be %s, actual %s, ret=%d", 174 srs_error("invalid acodec, must be %s, actual %s, ret=%d",
175 - SRS_ENCODER_ACODEC, acodec.c_str(), ret); 175 + SRS_RTMP_ENCODER_ACODEC, acodec.c_str(), ret);
176 return ret; 176 return ret;
177 } 177 }
178 if (abitrate <= 0) { 178 if (abitrate <= 0) {
@@ -207,8 +207,8 @@ int SrsFFMPEG::initialize_copy() @@ -207,8 +207,8 @@ int SrsFFMPEG::initialize_copy()
207 { 207 {
208 int ret = ERROR_SUCCESS; 208 int ret = ERROR_SUCCESS;
209 209
210 - vcodec = SRS_ENCODER_COPY;  
211 - acodec = SRS_ENCODER_COPY; 210 + vcodec = SRS_RTMP_ENCODER_COPY;
  211 + acodec = SRS_RTMP_ENCODER_COPY;
212 212
213 if (_output.empty()) { 213 if (_output.empty()) {
214 ret = ERROR_ENCODER_OUTPUT; 214 ret = ERROR_ENCODER_OUTPUT;
@@ -261,7 +261,7 @@ int SrsFFMPEG::start() @@ -261,7 +261,7 @@ int SrsFFMPEG::start()
261 } 261 }
262 262
263 // video specified. 263 // video specified.
264 - if (vcodec != SRS_ENCODER_NO_VIDEO) { 264 + if (vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
265 params.push_back("-vcodec"); 265 params.push_back("-vcodec");
266 params.push_back(vcodec); 266 params.push_back(vcodec);
267 } else { 267 } else {
@@ -269,7 +269,7 @@ int SrsFFMPEG::start() @@ -269,7 +269,7 @@ int SrsFFMPEG::start()
269 } 269 }
270 270
271 // the codec params is disabled when copy 271 // the codec params is disabled when copy
272 - if (vcodec != SRS_ENCODER_COPY && vcodec != SRS_ENCODER_NO_VIDEO) { 272 + if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
273 params.push_back("-b:v"); 273 params.push_back("-b:v");
274 snprintf(tmp, sizeof(tmp), "%d", vbitrate * 1000); 274 snprintf(tmp, sizeof(tmp), "%d", vbitrate * 1000);
275 params.push_back(tmp); 275 params.push_back(tmp);
@@ -310,7 +310,7 @@ int SrsFFMPEG::start() @@ -310,7 +310,7 @@ int SrsFFMPEG::start()
310 } 310 }
311 311
312 // audio specified. 312 // audio specified.
313 - if (acodec != SRS_ENCODER_NO_AUDIO) { 313 + if (acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
314 params.push_back("-acodec"); 314 params.push_back("-acodec");
315 params.push_back(acodec); 315 params.push_back(acodec);
316 } else { 316 } else {
@@ -318,7 +318,7 @@ int SrsFFMPEG::start() @@ -318,7 +318,7 @@ int SrsFFMPEG::start()
318 } 318 }
319 319
320 // the codec params is disabled when copy 320 // the codec params is disabled when copy
321 - if (acodec != SRS_ENCODER_COPY && acodec != SRS_ENCODER_NO_AUDIO) { 321 + if (acodec != SRS_RTMP_ENCODER_COPY && acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
322 params.push_back("-b:a"); 322 params.push_back("-b:a");
323 snprintf(tmp, sizeof(tmp), "%d", abitrate * 1000); 323 snprintf(tmp, sizeof(tmp), "%d", abitrate * 1000);
324 params.push_back(tmp); 324 params.push_back(tmp);
@@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 23
24 #include <srs_app_ingest.hpp> 24 #include <srs_app_ingest.hpp>
25 25
26 -#ifdef SRS_INGEST 26 +#ifdef SRS_RTMP_INGEST
27 27
28 using namespace std; 28 using namespace std;
29 29
@@ -35,7 +35,7 @@ using namespace std; @@ -35,7 +35,7 @@ using namespace std;
35 35
36 // when error, ingester sleep for a while and retry. 36 // when error, ingester sleep for a while and retry.
37 // ingest never sleep a long time, for we must start the stream ASAP. 37 // ingest never sleep a long time, for we must start the stream ASAP.
38 -#define SRS_INGESTER_SLEEP_US (int64_t)(6*100*1000LL) 38 +#define SRS_RTMP_INGESTER_SLEEP_US (int64_t)(6*100*1000LL)
39 39
40 SrsIngesterFFMPEG::SrsIngesterFFMPEG(SrsFFMPEG* _ffmpeg, string _vhost, string _id) 40 SrsIngesterFFMPEG::SrsIngesterFFMPEG(SrsFFMPEG* _ffmpeg, string _vhost, string _id)
41 { 41 {
@@ -53,7 +53,7 @@ SrsIngester::SrsIngester() @@ -53,7 +53,7 @@ SrsIngester::SrsIngester()
53 { 53 {
54 _srs_config->subscribe(this); 54 _srs_config->subscribe(this);
55 55
56 - pthread = new SrsThread(this, SRS_INGESTER_SLEEP_US); 56 + pthread = new SrsThread(this, SRS_RTMP_INGESTER_SLEEP_US);
57 pithy_print = new SrsPithyPrint(SRS_STAGE_INGESTER); 57 pithy_print = new SrsPithyPrint(SRS_STAGE_INGESTER);
58 } 58 }
59 59
@@ -187,7 +187,7 @@ int SrsIngester::cycle() @@ -187,7 +187,7 @@ int SrsIngester::cycle()
187 187
188 // pithy print 188 // pithy print
189 ingester(); 189 ingester();
190 - pithy_print->elapse(SRS_INGESTER_SLEEP_US / 1000); 190 + pithy_print->elapse(SRS_RTMP_INGESTER_SLEEP_US / 1000);
191 191
192 return ret; 192 return ret;
193 } 193 }
@@ -282,7 +282,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S @@ -282,7 +282,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
282 return ret; 282 return ret;
283 } 283 }
284 284
285 - if (input_type == SRS_INGEST_TYPE_FILE) { 285 + if (input_type == SRS_RTMP_INGEST_TYPE_FILE) {
286 std::string input_url = _srs_config->get_ingest_input_url(ingest); 286 std::string input_url = _srs_config->get_ingest_input_url(ingest);
287 if (input_url.empty()) { 287 if (input_url.empty()) {
288 ret = ERROR_ENCODER_NO_INPUT; 288 ret = ERROR_ENCODER_NO_INPUT;
@@ -296,7 +296,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S @@ -296,7 +296,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
296 if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) { 296 if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) {
297 return ret; 297 return ret;
298 } 298 }
299 - } else if (input_type == SRS_INGEST_TYPE_STREAM) { 299 + } else if (input_type == SRS_RTMP_INGEST_TYPE_STREAM) {
300 std::string input_url = _srs_config->get_ingest_input_url(ingest); 300 std::string input_url = _srs_config->get_ingest_input_url(ingest);
301 if (input_url.empty()) { 301 if (input_url.empty()) {
302 ret = ERROR_ENCODER_NO_INPUT; 302 ret = ERROR_ENCODER_NO_INPUT;
@@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 */ 29 */
30 #include <srs_core.hpp> 30 #include <srs_core.hpp>
31 31
32 -#ifdef SRS_INGEST 32 +#ifdef SRS_RTMP_INGEST
33 33
34 #include <vector> 34 #include <vector>
35 35
@@ -41,12 +41,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -41,12 +41,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 #include <srs_app_http_api.hpp> 41 #include <srs_app_http_api.hpp>
42 #include <srs_app_http_conn.hpp> 42 #include <srs_app_http_conn.hpp>
43 #include <srs_app_http.hpp> 43 #include <srs_app_http.hpp>
44 -#ifdef SRS_INGEST 44 +#ifdef SRS_RTMP_INGEST
45 #include <srs_app_ingest.hpp> 45 #include <srs_app_ingest.hpp>
46 #endif 46 #endif
47 47
48 #define SERVER_LISTEN_BACKLOG 512 48 #define SERVER_LISTEN_BACKLOG 512
49 -#define SRS_TIME_RESOLUTION_MS 500 49 +#define SRS_SYS_TIME_RESOLUTION_MS 500
50 50
51 SrsListener::SrsListener(SrsServer* server, SrsListenerType type) 51 SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
52 { 52 {
@@ -175,7 +175,7 @@ SrsServer::SrsServer() @@ -175,7 +175,7 @@ SrsServer::SrsServer()
175 #ifdef SRS_HTTP_SERVER 175 #ifdef SRS_HTTP_SERVER
176 http_stream_handler = NULL; 176 http_stream_handler = NULL;
177 #endif 177 #endif
178 -#ifdef SRS_INGEST 178 +#ifdef SRS_RTMP_INGEST
179 ingester = NULL; 179 ingester = NULL;
180 #endif 180 #endif
181 } 181 }
@@ -209,7 +209,7 @@ SrsServer::~SrsServer() @@ -209,7 +209,7 @@ SrsServer::~SrsServer()
209 #ifdef SRS_HTTP_SERVER 209 #ifdef SRS_HTTP_SERVER
210 srs_freep(http_stream_handler); 210 srs_freep(http_stream_handler);
211 #endif 211 #endif
212 -#ifdef SRS_INGEST 212 +#ifdef SRS_RTMP_INGEST
213 srs_freep(ingester); 213 srs_freep(ingester);
214 #endif 214 #endif
215 } 215 }
@@ -232,7 +232,7 @@ int SrsServer::initialize() @@ -232,7 +232,7 @@ int SrsServer::initialize()
232 srs_assert(!http_stream_handler); 232 srs_assert(!http_stream_handler);
233 http_stream_handler = SrsHttpHandler::create_http_stream(); 233 http_stream_handler = SrsHttpHandler::create_http_stream();
234 #endif 234 #endif
235 -#ifdef SRS_INGEST 235 +#ifdef SRS_RTMP_INGEST
236 srs_assert(!ingester); 236 srs_assert(!ingester);
237 ingester = new SrsIngester(); 237 ingester = new SrsIngester();
238 #endif 238 #endif
@@ -377,7 +377,7 @@ int SrsServer::ingest() @@ -377,7 +377,7 @@ int SrsServer::ingest()
377 { 377 {
378 int ret = ERROR_SUCCESS; 378 int ret = ERROR_SUCCESS;
379 379
380 -#ifdef SRS_INGEST 380 +#ifdef SRS_RTMP_INGEST
381 if ((ret = ingester->start()) != ERROR_SUCCESS) { 381 if ((ret = ingester->start()) != ERROR_SUCCESS) {
382 srs_error("start ingest streams failed. ret=%d", ret); 382 srs_error("start ingest streams failed. ret=%d", ret);
383 return ret; 383 return ret;
@@ -393,7 +393,7 @@ int SrsServer::cycle() @@ -393,7 +393,7 @@ int SrsServer::cycle()
393 393
394 // the deamon thread, update the time cache 394 // the deamon thread, update the time cache
395 while (true) { 395 while (true) {
396 - st_usleep(SRS_TIME_RESOLUTION_MS * 1000); 396 + st_usleep(SRS_SYS_TIME_RESOLUTION_MS * 1000);
397 srs_update_system_time_ms(); 397 srs_update_system_time_ms();
398 398
399 // for gperf heap checker, 399 // for gperf heap checker,
@@ -419,7 +419,7 @@ int SrsServer::cycle() @@ -419,7 +419,7 @@ int SrsServer::cycle()
419 } 419 }
420 } 420 }
421 421
422 -#ifdef SRS_INGEST 422 +#ifdef SRS_RTMP_INGEST
423 ingester->stop(); 423 ingester->stop();
424 #endif 424 #endif
425 425
@@ -85,7 +85,7 @@ private: @@ -85,7 +85,7 @@ private:
85 #ifdef SRS_HTTP_SERVER 85 #ifdef SRS_HTTP_SERVER
86 SrsHttpHandler* http_stream_handler; 86 SrsHttpHandler* http_stream_handler;
87 #endif 87 #endif
88 -#ifdef SRS_INGEST 88 +#ifdef SRS_RTMP_INGEST
89 SrsIngester* ingester; 89 SrsIngester* ingester;
90 #endif 90 #endif
91 private: 91 private: