winlin

refine log and thread function name

@@ -686,13 +686,15 @@ int SrsConfig::parse_file(const char* filename) @@ -686,13 +686,15 @@ int SrsConfig::parse_file(const char* filename)
686 686
687 // check log 687 // check log
688 std::string log_filename = this->get_srs_log_file(); 688 std::string log_filename = this->get_srs_log_file();
689 - if (this->get_srs_log_tank_file() && log_filename.empty()) { 689 + if (get_srs_log_tank_file() && log_filename.empty()) {
690 ret = ERROR_SYSTEM_CONFIG_INVALID; 690 ret = ERROR_SYSTEM_CONFIG_INVALID;
691 srs_error("must specifies the file to write log to. ret=%d", ret); 691 srs_error("must specifies the file to write log to. ret=%d", ret);
692 return ret; 692 return ret;
693 } 693 }
694 - if (!log_filename.empty()) { 694 + if (get_srs_log_tank_file()) {
695 srs_trace("log file is %s", log_filename.c_str()); 695 srs_trace("log file is %s", log_filename.c_str());
  696 + } else {
  697 + srs_trace("write log to console");
696 } 698 }
697 699
698 return ret; 700 return ret;
@@ -569,7 +569,7 @@ int SrsEncoder::cycle() @@ -569,7 +569,7 @@ int SrsEncoder::cycle()
569 return ret; 569 return ret;
570 } 570 }
571 571
572 -void SrsEncoder::on_leave_loop() 572 +void SrsEncoder::on_thread_stop()
573 { 573 {
574 // kill ffmpeg when finished and it alive 574 // kill ffmpeg when finished and it alive
575 std::vector<SrsFFMPEG*>::iterator it; 575 std::vector<SrsFFMPEG*>::iterator it;
@@ -101,7 +101,7 @@ public: @@ -101,7 +101,7 @@ public:
101 // interface ISrsThreadHandler. 101 // interface ISrsThreadHandler.
102 public: 102 public:
103 virtual int cycle(); 103 virtual int cycle();
104 - virtual void on_leave_loop(); 104 + virtual void on_thread_stop();
105 private: 105 private:
106 virtual void clear_engines(); 106 virtual void clear_engines();
107 virtual SrsFFMPEG* at(int index); 107 virtual SrsFFMPEG* at(int index);
@@ -126,7 +126,7 @@ int SrsListener::listen(int _port) @@ -126,7 +126,7 @@ int SrsListener::listen(int _port)
126 return ret; 126 return ret;
127 } 127 }
128 128
129 -void SrsListener::on_enter_loop() 129 +void SrsListener::on_thread_start()
130 { 130 {
131 srs_trace("listen cycle start, port=%d, type=%d, fd=%d", port, type, fd); 131 srs_trace("listen cycle start, port=%d, type=%d, fd=%d", port, type, fd);
132 } 132 }
@@ -69,7 +69,7 @@ public: @@ -69,7 +69,7 @@ public:
69 virtual int listen(int port); 69 virtual int listen(int port);
70 // interface ISrsThreadHandler. 70 // interface ISrsThreadHandler.
71 public: 71 public:
72 - virtual void on_enter_loop(); 72 + virtual void on_thread_start();
73 virtual int cycle(); 73 virtual int cycle();
74 }; 74 };
75 75
@@ -34,7 +34,7 @@ ISrsThreadHandler::~ISrsThreadHandler() @@ -34,7 +34,7 @@ ISrsThreadHandler::~ISrsThreadHandler()
34 { 34 {
35 } 35 }
36 36
37 -void ISrsThreadHandler::on_enter_loop() 37 +void ISrsThreadHandler::on_thread_start()
38 { 38 {
39 } 39 }
40 40
@@ -50,7 +50,7 @@ int ISrsThreadHandler::on_end_cycle() @@ -50,7 +50,7 @@ int ISrsThreadHandler::on_end_cycle()
50 return ret; 50 return ret;
51 } 51 }
52 52
53 -void ISrsThreadHandler::on_leave_loop() 53 +void ISrsThreadHandler::on_thread_stop()
54 { 54 {
55 } 55 }
56 56
@@ -114,9 +114,9 @@ void SrsThread::thread_cycle() @@ -114,9 +114,9 @@ void SrsThread::thread_cycle()
114 srs_assert(handler); 114 srs_assert(handler);
115 115
116 _srs_context->generate_id(); 116 _srs_context->generate_id();
117 - srs_trace("thread cycle start"); 117 + srs_info("thread cycle start");
118 118
119 - handler->on_end_cycle(); 119 + handler->on_thread_start();
120 120
121 loop = true; 121 loop = true;
122 while (loop) { 122 while (loop) {
@@ -146,7 +146,7 @@ failed: @@ -146,7 +146,7 @@ failed:
146 st_usleep(cycle_interval_us); 146 st_usleep(cycle_interval_us);
147 } 147 }
148 148
149 - handler->on_leave_loop(); 149 + handler->on_thread_stop();
150 srs_trace("thread cycle finished"); 150 srs_trace("thread cycle finished");
151 } 151 }
152 152
@@ -34,14 +34,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -34,14 +34,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 /** 34 /**
35 * the handler for the thread, callback interface. 35 * the handler for the thread, callback interface.
36 * the thread model defines as: 36 * the thread model defines as:
37 -* handler->on_enter_loop() 37 +* handler->on_thread_start()
38 * while loop: 38 * while loop:
39 * handler->on_before_cycle() 39 * handler->on_before_cycle()
40 * handler->cycle() 40 * handler->cycle()
41 * handler->on_end_cycle() 41 * handler->on_end_cycle()
42 * if !loop then break for user stop thread. 42 * if !loop then break for user stop thread.
43 * sleep(CycleIntervalMilliseconds) 43 * sleep(CycleIntervalMilliseconds)
44 -* handler->on_leave_loop() 44 +* handler->on_thread_stop()
45 * when stop, the thread will interrupt the st_thread, 45 * when stop, the thread will interrupt the st_thread,
46 * which will cause the socket to return error and 46 * which will cause the socket to return error and
47 * terminate the cycle thread. 47 * terminate the cycle thread.
@@ -69,11 +69,11 @@ public: @@ -69,11 +69,11 @@ public:
69 ISrsThreadHandler(); 69 ISrsThreadHandler();
70 virtual ~ISrsThreadHandler(); 70 virtual ~ISrsThreadHandler();
71 public: 71 public:
72 - virtual void on_enter_loop(); 72 + virtual void on_thread_start();
73 virtual int on_before_cycle(); 73 virtual int on_before_cycle();
74 virtual int cycle() = 0; 74 virtual int cycle() = 0;
75 virtual int on_end_cycle(); 75 virtual int on_end_cycle();
76 - virtual void on_leave_loop(); 76 + virtual void on_thread_stop();
77 }; 77 };
78 78
79 /** 79 /**
@@ -166,8 +166,8 @@ string srs_client_type_string(SrsRtmpConnType type) @@ -166,8 +166,8 @@ string srs_client_type_string(SrsRtmpConnType type)
166 { 166 {
167 switch (type) { 167 switch (type) {
168 case SrsRtmpConnPlay: return "Play"; 168 case SrsRtmpConnPlay: return "Play";
169 - case SrsRtmpConnFlashPublish: return "FlashPublish";  
170 - case SrsRtmpConnFMLEPublish: return "FMLEPublish"; 169 + case SrsRtmpConnFlashPublish: return "publish(FlashPublish)";
  170 + case SrsRtmpConnFMLEPublish: return "publish(FMLEPublish)";
171 default: return "Unknown"; 171 default: return "Unknown";
172 } 172 }
173 return "Unknown"; 173 return "Unknown";