正在显示
13 个修改的文件
包含
216 行增加
和
56 行删除
@@ -6,6 +6,10 @@ listen 1935; | @@ -6,6 +6,10 @@ listen 1935; | ||
6 | # performance about 10%. | 6 | # performance about 10%. |
7 | # if not specified, set to 4096. | 7 | # if not specified, set to 4096. |
8 | chunk_size 65000; | 8 | chunk_size 65000; |
9 | +# the logs dir. | ||
10 | +# if enabled ffmpeg, each stracoding stream will create a log file. | ||
11 | +# default: ./objs/logs | ||
12 | +log_dir ./objs/logs; | ||
9 | # vhost list, the __defaultVhost__ is the default vhost | 13 | # vhost list, the __defaultVhost__ is the default vhost |
10 | # for which cannot identify the required vhost. | 14 | # for which cannot identify the required vhost. |
11 | # for default demo. | 15 | # for default demo. |
@@ -76,10 +80,10 @@ vhost dev { | @@ -76,10 +80,10 @@ vhost dev { | ||
76 | hls_path ./objs/nginx/html; | 80 | hls_path ./objs/nginx/html; |
77 | hls_fragment 5; | 81 | hls_fragment 5; |
78 | hls_window 30; | 82 | hls_window 30; |
79 | - #forward 127.0.0.1:19350; | 83 | + forward 127.0.0.1:19350; |
80 | #forward 127.0.0.1:1936; | 84 | #forward 127.0.0.1:1936; |
81 | transcode { | 85 | transcode { |
82 | - enabled off; | 86 | + enabled on; |
83 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 87 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
84 | engine dev { | 88 | engine dev { |
85 | enabled on; | 89 | enabled on; |
@@ -511,6 +515,12 @@ pithy_print { | @@ -511,6 +515,12 @@ pithy_print { | ||
511 | # shared print interval for all forwarders, in milliseconds. | 515 | # shared print interval for all forwarders, in milliseconds. |
512 | # if not specified, set to 2000. | 516 | # if not specified, set to 2000. |
513 | forwarder 3000; | 517 | forwarder 3000; |
518 | + # shared print interval for all encoders, in milliseconds. | ||
519 | + # if not specified, set to 2000. | ||
520 | + encoder 3000; | ||
521 | + # shared print interval for all hls, in milliseconds. | ||
522 | + # if not specified, set to 2000. | ||
523 | + hls 3000; | ||
514 | } | 524 | } |
515 | 525 | ||
516 | 526 |
@@ -144,6 +144,9 @@ else | @@ -144,6 +144,9 @@ else | ||
144 | echo -e "${YELLOW}warning: without live stream transcoding over FFMPEG support${BLACK}" | 144 | echo -e "${YELLOW}warning: without live stream transcoding over FFMPEG support${BLACK}" |
145 | fi | 145 | fi |
146 | 146 | ||
147 | +# mkdir dirs | ||
148 | +mkdir -p ${SRS_OBJS}/logs | ||
149 | + | ||
147 | # next step. | 150 | # next step. |
148 | echo "" | 151 | echo "" |
149 | echo "you can:" | 152 | echo "you can:" |
@@ -904,6 +904,17 @@ std::string SrsConfig::get_engine_output(SrsConfDirective* engine) | @@ -904,6 +904,17 @@ std::string SrsConfig::get_engine_output(SrsConfDirective* engine) | ||
904 | return conf->arg0(); | 904 | return conf->arg0(); |
905 | } | 905 | } |
906 | 906 | ||
907 | +std::string SrsConfig::get_log_dir() | ||
908 | +{ | ||
909 | + srs_assert(root); | ||
910 | + | ||
911 | + SrsConfDirective* conf = root->get("log_dir"); | ||
912 | + if (!conf || conf->arg0().empty()) { | ||
913 | + return "./objs/logs"; | ||
914 | + } | ||
915 | + | ||
916 | + return conf->arg0(); | ||
917 | +} | ||
907 | 918 | ||
908 | SrsConfDirective* SrsConfig::get_gop_cache(std::string vhost) | 919 | SrsConfDirective* SrsConfig::get_gop_cache(std::string vhost) |
909 | { | 920 | { |
@@ -1049,6 +1060,26 @@ SrsConfDirective* SrsConfig::get_pithy_print_forwarder() | @@ -1049,6 +1060,26 @@ SrsConfDirective* SrsConfig::get_pithy_print_forwarder() | ||
1049 | return pithy->get("forwarder"); | 1060 | return pithy->get("forwarder"); |
1050 | } | 1061 | } |
1051 | 1062 | ||
1063 | +SrsConfDirective* SrsConfig::get_pithy_print_hls() | ||
1064 | +{ | ||
1065 | + SrsConfDirective* pithy = root->get("pithy_print"); | ||
1066 | + if (!pithy) { | ||
1067 | + return NULL; | ||
1068 | + } | ||
1069 | + | ||
1070 | + return pithy->get("hls"); | ||
1071 | +} | ||
1072 | + | ||
1073 | +SrsConfDirective* SrsConfig::get_pithy_print_encoder() | ||
1074 | +{ | ||
1075 | + SrsConfDirective* pithy = root->get("encoder"); | ||
1076 | + if (!pithy) { | ||
1077 | + return NULL; | ||
1078 | + } | ||
1079 | + | ||
1080 | + return pithy->get("forwarder"); | ||
1081 | +} | ||
1082 | + | ||
1052 | SrsConfDirective* SrsConfig::get_pithy_print_play() | 1083 | SrsConfDirective* SrsConfig::get_pithy_print_play() |
1053 | { | 1084 | { |
1054 | SrsConfDirective* pithy = root->get("pithy_print"); | 1085 | SrsConfDirective* pithy = root->get("pithy_print"); |
@@ -140,6 +140,7 @@ public: | @@ -140,6 +140,7 @@ public: | ||
140 | virtual int get_engine_achannels(SrsConfDirective* engine); | 140 | virtual int get_engine_achannels(SrsConfDirective* engine); |
141 | virtual void get_engine_aparams(SrsConfDirective* engine, std::vector<std::string>& aparams); | 141 | virtual void get_engine_aparams(SrsConfDirective* engine, std::vector<std::string>& aparams); |
142 | virtual std::string get_engine_output(SrsConfDirective* engine); | 142 | virtual std::string get_engine_output(SrsConfDirective* engine); |
143 | + virtual std::string get_log_dir(); | ||
143 | virtual SrsConfDirective* get_gop_cache(std::string vhost); | 144 | virtual SrsConfDirective* get_gop_cache(std::string vhost); |
144 | virtual SrsConfDirective* get_forward(std::string vhost); | 145 | virtual SrsConfDirective* get_forward(std::string vhost); |
145 | virtual SrsConfDirective* get_hls(std::string vhost); | 146 | virtual SrsConfDirective* get_hls(std::string vhost); |
@@ -154,6 +155,8 @@ public: | @@ -154,6 +155,8 @@ public: | ||
154 | virtual SrsConfDirective* get_chunk_size(); | 155 | virtual SrsConfDirective* get_chunk_size(); |
155 | virtual SrsConfDirective* get_pithy_print_publish(); | 156 | virtual SrsConfDirective* get_pithy_print_publish(); |
156 | virtual SrsConfDirective* get_pithy_print_forwarder(); | 157 | virtual SrsConfDirective* get_pithy_print_forwarder(); |
158 | + virtual SrsConfDirective* get_pithy_print_encoder(); | ||
159 | + virtual SrsConfDirective* get_pithy_print_hls(); | ||
157 | virtual SrsConfDirective* get_pithy_print_play(); | 160 | virtual SrsConfDirective* get_pithy_print_play(); |
158 | private: | 161 | private: |
159 | virtual int parse_file(const char* filename); | 162 | virtual int parse_file(const char* filename); |
@@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <sys/wait.h> | 28 | #include <sys/wait.h> |
29 | +#include <fcntl.h> | ||
29 | 30 | ||
30 | #include <algorithm> | 31 | #include <algorithm> |
31 | 32 | ||
@@ -33,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -33,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
33 | #include <srs_core_log.hpp> | 34 | #include <srs_core_log.hpp> |
34 | #include <srs_core_config.hpp> | 35 | #include <srs_core_config.hpp> |
35 | #include <srs_core_rtmp.hpp> | 36 | #include <srs_core_rtmp.hpp> |
37 | +#include <srs_core_pithy_print.hpp> | ||
36 | 38 | ||
37 | #ifdef SRS_FFMPEG | 39 | #ifdef SRS_FFMPEG |
38 | 40 | ||
@@ -58,6 +60,8 @@ SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin) | @@ -58,6 +60,8 @@ SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin) | ||
58 | abitrate = 0; | 60 | abitrate = 0; |
59 | asample_rate = 0; | 61 | asample_rate = 0; |
60 | achannels = 0; | 62 | achannels = 0; |
63 | + | ||
64 | + log_fd = -1; | ||
61 | } | 65 | } |
62 | 66 | ||
63 | SrsFFMPEG::~SrsFFMPEG() | 67 | SrsFFMPEG::~SrsFFMPEG() |
@@ -108,6 +112,18 @@ int SrsFFMPEG::initialize(SrsRequest* req, SrsConfDirective* engine) | @@ -108,6 +112,18 @@ int SrsFFMPEG::initialize(SrsRequest* req, SrsConfDirective* engine) | ||
108 | output = srs_replace(output, "[app]", req->app); | 112 | output = srs_replace(output, "[app]", req->app); |
109 | output = srs_replace(output, "[stream]", req->stream); | 113 | output = srs_replace(output, "[stream]", req->stream); |
110 | output = srs_replace(output, "[engine]", engine->arg0()); | 114 | output = srs_replace(output, "[engine]", engine->arg0()); |
115 | + | ||
116 | + // write ffmpeg info to log file. | ||
117 | + log_file = config->get_log_dir(); | ||
118 | + log_file += "/"; | ||
119 | + log_file += "encoder"; | ||
120 | + log_file += "-"; | ||
121 | + log_file += req->vhost; | ||
122 | + log_file += "-"; | ||
123 | + log_file += req->app; | ||
124 | + log_file += "-"; | ||
125 | + log_file += req->stream; | ||
126 | + log_file += ".log"; | ||
111 | 127 | ||
112 | // important: loop check, donot transcode again. | 128 | // important: loop check, donot transcode again. |
113 | std::vector<std::string>::iterator it; | 129 | std::vector<std::string>::iterator it; |
@@ -316,7 +332,8 @@ int SrsFFMPEG::start() | @@ -316,7 +332,8 @@ int SrsFFMPEG::start() | ||
316 | snprintf(p, last - p, "%s ", ffp.c_str()); | 332 | snprintf(p, last - p, "%s ", ffp.c_str()); |
317 | p += ffp.length() + 1; | 333 | p += ffp.length() + 1; |
318 | } | 334 | } |
319 | - srs_trace("start transcoder: %s", pparam); | 335 | + srs_trace("start transcoder, log: %s, params: %s", |
336 | + log_file.c_str(), pparam); | ||
320 | srs_freepa(pparam); | 337 | srs_freepa(pparam); |
321 | } | 338 | } |
322 | 339 | ||
@@ -329,6 +346,30 @@ int SrsFFMPEG::start() | @@ -329,6 +346,30 @@ int SrsFFMPEG::start() | ||
329 | 346 | ||
330 | // child process: ffmpeg encoder engine. | 347 | // child process: ffmpeg encoder engine. |
331 | if (pid == 0) { | 348 | if (pid == 0) { |
349 | + // redirect logs to file. | ||
350 | + int flags = O_CREAT|O_WRONLY|O_APPEND; | ||
351 | + mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH; | ||
352 | + if ((log_fd = ::open(log_file.c_str(), flags, mode)) < 0) { | ||
353 | + ret = ERROR_ENCODER_OPEN; | ||
354 | + srs_error("open encoder file %s failed. ret=%d", log_file.c_str(), ret); | ||
355 | + return ret; | ||
356 | + } | ||
357 | + if (dup2(log_fd, STDOUT_FILENO) < 0) { | ||
358 | + ret = ERROR_ENCODER_DUP2; | ||
359 | + srs_error("dup2 encoder file failed. ret=%d", ret); | ||
360 | + return ret; | ||
361 | + } | ||
362 | + if (dup2(log_fd, STDERR_FILENO) < 0) { | ||
363 | + ret = ERROR_ENCODER_DUP2; | ||
364 | + srs_error("dup2 encoder file failed. ret=%d", ret); | ||
365 | + return ret; | ||
366 | + } | ||
367 | + // close other fds | ||
368 | + // TODO: do in right way. | ||
369 | + for (int i = 3; i < 1024; i++) { | ||
370 | + ::close(i); | ||
371 | + } | ||
372 | + | ||
332 | // memory leak in child process, it's ok. | 373 | // memory leak in child process, it's ok. |
333 | char** charpv_params = new char*[params.size() + 1]; | 374 | char** charpv_params = new char*[params.size() + 1]; |
334 | for (int i = 0; i < (int)params.size(); i++) { | 375 | for (int i = 0; i < (int)params.size(); i++) { |
@@ -389,6 +430,11 @@ int SrsFFMPEG::cycle() | @@ -389,6 +430,11 @@ int SrsFFMPEG::cycle() | ||
389 | 430 | ||
390 | void SrsFFMPEG::stop() | 431 | void SrsFFMPEG::stop() |
391 | { | 432 | { |
433 | + if (log_fd > 0) { | ||
434 | + ::close(log_fd); | ||
435 | + log_fd = -1; | ||
436 | + } | ||
437 | + | ||
392 | if (!started) { | 438 | if (!started) { |
393 | return; | 439 | return; |
394 | } | 440 | } |
@@ -598,6 +644,8 @@ void SrsEncoder::encoder_cycle() | @@ -598,6 +644,8 @@ void SrsEncoder::encoder_cycle() | ||
598 | log_context->generate_id(); | 644 | log_context->generate_id(); |
599 | srs_trace("encoder cycle start"); | 645 | srs_trace("encoder cycle start"); |
600 | 646 | ||
647 | + SrsPithyPrint pithy_print(SRS_STAGE_ENCODER); | ||
648 | + | ||
601 | while (loop) { | 649 | while (loop) { |
602 | if ((ret = cycle()) != ERROR_SUCCESS) { | 650 | if ((ret = cycle()) != ERROR_SUCCESS) { |
603 | srs_warn("encoder cycle failed, ignored and retry, ret=%d", ret); | 651 | srs_warn("encoder cycle failed, ignored and retry, ret=%d", ret); |
@@ -608,6 +656,9 @@ void SrsEncoder::encoder_cycle() | @@ -608,6 +656,9 @@ void SrsEncoder::encoder_cycle() | ||
608 | if (!loop) { | 656 | if (!loop) { |
609 | break; | 657 | break; |
610 | } | 658 | } |
659 | + | ||
660 | + encoder(&pithy_print); | ||
661 | + pithy_print.elapse(SRS_ENCODER_SLEEP_MS); | ||
611 | 662 | ||
612 | st_usleep(SRS_ENCODER_SLEEP_MS * 1000); | 663 | st_usleep(SRS_ENCODER_SLEEP_MS * 1000); |
613 | } | 664 | } |
@@ -622,6 +673,15 @@ void SrsEncoder::encoder_cycle() | @@ -622,6 +673,15 @@ void SrsEncoder::encoder_cycle() | ||
622 | srs_trace("encoder cycle finished"); | 673 | srs_trace("encoder cycle finished"); |
623 | } | 674 | } |
624 | 675 | ||
676 | +void SrsEncoder::encoder(SrsPithyPrint* pithy_print) | ||
677 | +{ | ||
678 | + // reportable | ||
679 | + if (pithy_print->can_print()) { | ||
680 | + srs_trace("-> time=%"PRId64", encoders=%d", | ||
681 | + pithy_print->get_age(), (int)ffmpegs.size()); | ||
682 | + } | ||
683 | +} | ||
684 | + | ||
625 | void* SrsEncoder::encoder_thread(void* arg) | 685 | void* SrsEncoder::encoder_thread(void* arg) |
626 | { | 686 | { |
627 | SrsEncoder* obj = (SrsEncoder*)arg; | 687 | SrsEncoder* obj = (SrsEncoder*)arg; |
@@ -36,6 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -36,6 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
36 | 36 | ||
37 | class SrsConfDirective; | 37 | class SrsConfDirective; |
38 | class SrsRequest; | 38 | class SrsRequest; |
39 | +class SrsPithyPrint; | ||
39 | 40 | ||
40 | #ifdef SRS_FFMPEG | 41 | #ifdef SRS_FFMPEG |
41 | 42 | ||
@@ -49,6 +50,9 @@ private: | @@ -49,6 +50,9 @@ private: | ||
49 | bool started; | 50 | bool started; |
50 | pid_t pid; | 51 | pid_t pid; |
51 | private: | 52 | private: |
53 | + std::string log_file; | ||
54 | + int log_fd; | ||
55 | +private: | ||
52 | std::string ffmpeg; | 56 | std::string ffmpeg; |
53 | std::vector<std::string> vfilter; | 57 | std::vector<std::string> vfilter; |
54 | std::string vcodec; | 58 | std::string vcodec; |
@@ -101,6 +105,7 @@ private: | @@ -101,6 +105,7 @@ private: | ||
101 | virtual int parse_transcode(SrsRequest* req, SrsConfDirective* conf); | 105 | virtual int parse_transcode(SrsRequest* req, SrsConfDirective* conf); |
102 | virtual int cycle(); | 106 | virtual int cycle(); |
103 | virtual void encoder_cycle(); | 107 | virtual void encoder_cycle(); |
108 | + virtual void encoder(SrsPithyPrint* pithy_print); | ||
104 | static void* encoder_thread(void* arg); | 109 | static void* encoder_thread(void* arg); |
105 | }; | 110 | }; |
106 | 111 |
@@ -139,5 +139,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -139,5 +139,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
139 | #define ERROR_ENCODER_VBITRATE 712 | 139 | #define ERROR_ENCODER_VBITRATE 712 |
140 | #define ERROR_ENCODER_FORK 713 | 140 | #define ERROR_ENCODER_FORK 713 |
141 | #define ERROR_ENCODER_LOOP 714 | 141 | #define ERROR_ENCODER_LOOP 714 |
142 | +#define ERROR_ENCODER_OPEN 715 | ||
143 | +#define ERROR_ENCODER_DUP2 716 | ||
142 | 144 | ||
143 | #endif | 145 | #endif |
@@ -41,6 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -41,6 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
41 | #include <srs_core_source.hpp> | 41 | #include <srs_core_source.hpp> |
42 | #include <srs_core_autofree.hpp> | 42 | #include <srs_core_autofree.hpp> |
43 | #include <srs_core_rtmp.hpp> | 43 | #include <srs_core_rtmp.hpp> |
44 | +#include <srs_core_pithy_print.hpp> | ||
44 | 45 | ||
45 | // max PES packets size to flush the video. | 46 | // max PES packets size to flush the video. |
46 | #define SRS_HLS_AUDIO_CACHE_SIZE 512 * 1024 | 47 | #define SRS_HLS_AUDIO_CACHE_SIZE 512 * 1024 |
@@ -1110,6 +1111,8 @@ SrsHls::SrsHls() | @@ -1110,6 +1111,8 @@ SrsHls::SrsHls() | ||
1110 | 1111 | ||
1111 | muxer = new SrsM3u8Muxer(); | 1112 | muxer = new SrsM3u8Muxer(); |
1112 | ts_cache = new SrsTSCache(); | 1113 | ts_cache = new SrsTSCache(); |
1114 | + | ||
1115 | + pithy_print = new SrsPithyPrint(SRS_STAGE_HLS); | ||
1113 | } | 1116 | } |
1114 | 1117 | ||
1115 | SrsHls::~SrsHls() | 1118 | SrsHls::~SrsHls() |
@@ -1120,6 +1123,8 @@ SrsHls::~SrsHls() | @@ -1120,6 +1123,8 @@ SrsHls::~SrsHls() | ||
1120 | 1123 | ||
1121 | srs_freep(muxer); | 1124 | srs_freep(muxer); |
1122 | srs_freep(ts_cache); | 1125 | srs_freep(ts_cache); |
1126 | + | ||
1127 | + srs_freep(pithy_print); | ||
1123 | } | 1128 | } |
1124 | 1129 | ||
1125 | int SrsHls::on_publish(SrsRequest* req) | 1130 | int SrsHls::on_publish(SrsRequest* req) |
@@ -1328,8 +1333,20 @@ int SrsHls::on_video(SrsSharedPtrMessage* video) | @@ -1328,8 +1333,20 @@ int SrsHls::on_video(SrsSharedPtrMessage* video) | ||
1328 | return ret; | 1333 | return ret; |
1329 | } | 1334 | } |
1330 | 1335 | ||
1336 | + _mpegts(); | ||
1337 | + | ||
1331 | return ret; | 1338 | return ret; |
1332 | } | 1339 | } |
1333 | 1340 | ||
1341 | +void SrsHls::_mpegts() | ||
1342 | +{ | ||
1343 | + // reportable | ||
1344 | + if (pithy_print->can_print()) { | ||
1345 | + srs_trace("-> time=%"PRId64"", pithy_print->get_age()); | ||
1346 | + } | ||
1347 | + | ||
1348 | + pithy_print->elapse(sample->cts); | ||
1349 | +} | ||
1350 | + | ||
1334 | #endif | 1351 | #endif |
1335 | 1352 |
@@ -43,6 +43,7 @@ class SrsRtmpJitter; | @@ -43,6 +43,7 @@ class SrsRtmpJitter; | ||
43 | class SrsTSMuxer; | 43 | class SrsTSMuxer; |
44 | class SrsCodec; | 44 | class SrsCodec; |
45 | class SrsRequest; | 45 | class SrsRequest; |
46 | +class SrsPithyPrint; | ||
46 | 47 | ||
47 | /** | 48 | /** |
48 | * jitter correct for audio, | 49 | * jitter correct for audio, |
@@ -211,6 +212,7 @@ private: | @@ -211,6 +212,7 @@ private: | ||
211 | SrsCodec* codec; | 212 | SrsCodec* codec; |
212 | SrsCodecSample* sample; | 213 | SrsCodecSample* sample; |
213 | SrsRtmpJitter* jitter; | 214 | SrsRtmpJitter* jitter; |
215 | + SrsPithyPrint* pithy_print; | ||
214 | public: | 216 | public: |
215 | SrsHls(); | 217 | SrsHls(); |
216 | virtual ~SrsHls(); | 218 | virtual ~SrsHls(); |
@@ -220,6 +222,8 @@ public: | @@ -220,6 +222,8 @@ public: | ||
220 | virtual int on_meta_data(SrsOnMetaDataPacket* metadata); | 222 | virtual int on_meta_data(SrsOnMetaDataPacket* metadata); |
221 | virtual int on_audio(SrsSharedPtrMessage* audio); | 223 | virtual int on_audio(SrsSharedPtrMessage* audio); |
222 | virtual int on_video(SrsSharedPtrMessage* video); | 224 | virtual int on_video(SrsSharedPtrMessage* video); |
225 | +private: | ||
226 | + virtual void _mpegts(); | ||
223 | }; | 227 | }; |
224 | 228 | ||
225 | #endif | 229 | #endif |
@@ -35,6 +35,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -35,6 +35,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
35 | #define SRS_STAGE_PLAY_USER_INTERVAL_MS 1300 | 35 | #define SRS_STAGE_PLAY_USER_INTERVAL_MS 1300 |
36 | #define SRS_STAGE_PUBLISH_USER_INTERVAL_MS 1100 | 36 | #define SRS_STAGE_PUBLISH_USER_INTERVAL_MS 1100 |
37 | #define SRS_STAGE_FORWARDER_INTERVAL_MS 2000 | 37 | #define SRS_STAGE_FORWARDER_INTERVAL_MS 2000 |
38 | +#define SRS_STAGE_ENCODER_INTERVAL_MS 2000 | ||
39 | +#define SRS_STAGE_HLS_INTERVAL_MS 2000 | ||
38 | 40 | ||
39 | struct SrsStageInfo : public SrsReloadHandler | 41 | struct SrsStageInfo : public SrsReloadHandler |
40 | { | 42 | { |
@@ -82,6 +84,22 @@ struct SrsStageInfo : public SrsReloadHandler | @@ -82,6 +84,22 @@ struct SrsStageInfo : public SrsReloadHandler | ||
82 | } | 84 | } |
83 | break; | 85 | break; |
84 | } | 86 | } |
87 | + case SRS_STAGE_ENCODER: { | ||
88 | + pithy_print_time_ms = SRS_STAGE_ENCODER_INTERVAL_MS; | ||
89 | + SrsConfDirective* conf = config->get_pithy_print_encoder(); | ||
90 | + if (conf && !conf->arg0().empty()) { | ||
91 | + pithy_print_time_ms = ::atoi(conf->arg0().c_str()); | ||
92 | + } | ||
93 | + break; | ||
94 | + } | ||
95 | + case SRS_STAGE_HLS: { | ||
96 | + pithy_print_time_ms = SRS_STAGE_HLS_INTERVAL_MS; | ||
97 | + SrsConfDirective* conf = config->get_pithy_print_hls(); | ||
98 | + if (conf && !conf->arg0().empty()) { | ||
99 | + pithy_print_time_ms = ::atoi(conf->arg0().c_str()); | ||
100 | + } | ||
101 | + break; | ||
102 | + } | ||
85 | default: { | 103 | default: { |
86 | pithy_print_time_ms = SRS_STAGE_DEFAULT_INTERVAL_MS; | 104 | pithy_print_time_ms = SRS_STAGE_DEFAULT_INTERVAL_MS; |
87 | break; | 105 | break; |
@@ -36,6 +36,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -36,6 +36,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
36 | #define SRS_STAGE_PUBLISH_USER 2 | 36 | #define SRS_STAGE_PUBLISH_USER 2 |
37 | // the pithy stage for all forward clients. | 37 | // the pithy stage for all forward clients. |
38 | #define SRS_STAGE_FORWARDER 3 | 38 | #define SRS_STAGE_FORWARDER 3 |
39 | +// the pithy stage for all encoders. | ||
40 | +#define SRS_STAGE_ENCODER 4 | ||
41 | +// the pithy stage for all hls. | ||
42 | +#define SRS_STAGE_HLS 5 | ||
39 | 43 | ||
40 | /** | 44 | /** |
41 | * the stage is used for a collection of object to do print, | 45 | * the stage is used for a collection of object to do print, |
@@ -48,6 +48,8 @@ int main(int argc, char** argv){ | @@ -48,6 +48,8 @@ int main(int argc, char** argv){ | ||
48 | return ret; | 48 | return ret; |
49 | } | 49 | } |
50 | 50 | ||
51 | + // TODO: create log dir in config->get_log_dir() | ||
52 | + | ||
51 | if ((ret = _server()->listen()) != ERROR_SUCCESS) { | 53 | if ((ret = _server()->listen()) != ERROR_SUCCESS) { |
52 | return ret; | 54 | return ret; |
53 | } | 55 | } |
trunk/src/srs/srs.upp
100644 → 100755
1 | file | 1 | file |
2 | - main readonly separator, | ||
3 | - ..\main\srs_main_server.cpp, | ||
4 | - auto readonly separator, | ||
5 | - ..\..\objs\srs_auto_headers.hpp, | ||
6 | - core readonly separator, | ||
7 | - ..\core\srs_core.hpp, | ||
8 | - ..\core\srs_core.cpp, | ||
9 | - ..\core\srs_core_error.hpp, | ||
10 | - ..\core\srs_core_error.cpp, | ||
11 | - ..\core\srs_core_autofree.hpp, | ||
12 | - ..\core\srs_core_autofree.cpp, | ||
13 | - ..\core\srs_core_server.hpp, | ||
14 | - ..\core\srs_core_server.cpp, | ||
15 | - ..\core\srs_core_reload.hpp, | ||
16 | - ..\core\srs_core_reload.cpp, | ||
17 | - ..\core\srs_core_config.hpp, | ||
18 | - ..\core\srs_core_config.cpp, | ||
19 | - ..\core\srs_core_refer.hpp, | ||
20 | - ..\core\srs_core_refer.cpp, | ||
21 | - ..\core\srs_core_conn.hpp, | ||
22 | - ..\core\srs_core_conn.cpp, | ||
23 | - ..\core\srs_core_client.hpp, | ||
24 | - ..\core\srs_core_client.cpp, | ||
25 | - ..\core\srs_core_source.hpp, | ||
26 | - ..\core\srs_core_source.cpp, | ||
27 | - ..\core\srs_core_forward.hpp, | ||
28 | - ..\core\srs_core_forward.cpp, | ||
29 | - ..\core\srs_core_encoder.hpp, | ||
30 | - ..\core\srs_core_encoder.cpp, | ||
31 | - ..\core\srs_core_hls.hpp, | ||
32 | - ..\core\srs_core_hls.cpp, | ||
33 | - ..\core\srs_core_codec.hpp, | ||
34 | - ..\core\srs_core_codec.cpp, | ||
35 | - ..\core\srs_core_rtmp.hpp, | ||
36 | - ..\core\srs_core_rtmp.cpp, | ||
37 | - ..\core\srs_core_handshake.hpp, | ||
38 | - ..\core\srs_core_handshake.cpp, | ||
39 | - ..\core\srs_core_protocol.hpp, | ||
40 | - ..\core\srs_core_protocol.cpp, | ||
41 | - ..\core\srs_core_amf0.hpp, | ||
42 | - ..\core\srs_core_amf0.cpp, | ||
43 | - ..\core\srs_core_stream.hpp, | ||
44 | - ..\core\srs_core_stream.cpp, | ||
45 | - ..\core\srs_core_socket.hpp, | ||
46 | - ..\core\srs_core_socket.cpp, | ||
47 | - ..\core\srs_core_buffer.hpp, | ||
48 | - ..\core\srs_core_buffer.cpp, | ||
49 | - ..\core\srs_core_pithy_print.hpp, | ||
50 | - ..\core\srs_core_pithy_print.cpp, | ||
51 | - ..\core\srs_core_log.hpp, | ||
52 | - ..\core\srs_core_log.cpp, | ||
53 | - research readonly separator, | ||
54 | - ..\..\research\ts_info.cc; | 2 | + main readonly separator, |
3 | + ..\main\srs_main_server.cpp, | ||
4 | + auto readonly separator, | ||
5 | + ..\..\objs\srs_auto_headers.hpp, | ||
6 | + core readonly separator, | ||
7 | + ..\core\srs_core.hpp, | ||
8 | + ..\core\srs_core.cpp, | ||
9 | + ..\core\srs_core_error.hpp, | ||
10 | + ..\core\srs_core_error.cpp, | ||
11 | + ..\core\srs_core_autofree.hpp, | ||
12 | + ..\core\srs_core_autofree.cpp, | ||
13 | + ..\core\srs_core_server.hpp, | ||
14 | + ..\core\srs_core_server.cpp, | ||
15 | + ..\core\srs_core_reload.hpp, | ||
16 | + ..\core\srs_core_reload.cpp, | ||
17 | + ..\core\srs_core_config.hpp, | ||
18 | + ..\core\srs_core_config.cpp, | ||
19 | + ..\core\srs_core_refer.hpp, | ||
20 | + ..\core\srs_core_refer.cpp, | ||
21 | + ..\core\srs_core_conn.hpp, | ||
22 | + ..\core\srs_core_conn.cpp, | ||
23 | + ..\core\srs_core_client.hpp, | ||
24 | + ..\core\srs_core_client.cpp, | ||
25 | + ..\core\srs_core_source.hpp, | ||
26 | + ..\core\srs_core_source.cpp, | ||
27 | + ..\core\srs_core_forward.hpp, | ||
28 | + ..\core\srs_core_forward.cpp, | ||
29 | + ..\core\srs_core_encoder.hpp, | ||
30 | + ..\core\srs_core_encoder.cpp, | ||
31 | + ..\core\srs_core_hls.hpp, | ||
32 | + ..\core\srs_core_hls.cpp, | ||
33 | + ..\core\srs_core_codec.hpp, | ||
34 | + ..\core\srs_core_codec.cpp, | ||
35 | + ..\core\srs_core_rtmp.hpp, | ||
36 | + ..\core\srs_core_rtmp.cpp, | ||
37 | + ..\core\srs_core_handshake.hpp, | ||
38 | + ..\core\srs_core_handshake.cpp, | ||
39 | + ..\core\srs_core_protocol.hpp, | ||
40 | + ..\core\srs_core_protocol.cpp, | ||
41 | + ..\core\srs_core_amf0.hpp, | ||
42 | + ..\core\srs_core_amf0.cpp, | ||
43 | + ..\core\srs_core_stream.hpp, | ||
44 | + ..\core\srs_core_stream.cpp, | ||
45 | + ..\core\srs_core_socket.hpp, | ||
46 | + ..\core\srs_core_socket.cpp, | ||
47 | + ..\core\srs_core_buffer.hpp, | ||
48 | + ..\core\srs_core_buffer.cpp, | ||
49 | + ..\core\srs_core_pithy_print.hpp, | ||
50 | + ..\core\srs_core_pithy_print.cpp, | ||
51 | + ..\core\srs_core_log.hpp, | ||
52 | + ..\core\srs_core_log.cpp, | ||
53 | + research readonly separator, | ||
54 | + ..\..\research\ts_info.cc; | ||
55 | + | ||
55 | mainconfig | 56 | mainconfig |
56 | "" = "MAIN"; | 57 | "" = "MAIN"; |
57 | 58 |
-
请 注册 或 登录 后发表评论