winlin

refine log and thread function name

... ... @@ -686,13 +686,15 @@ int SrsConfig::parse_file(const char* filename)
// check log
std::string log_filename = this->get_srs_log_file();
if (this->get_srs_log_tank_file() && log_filename.empty()) {
if (get_srs_log_tank_file() && log_filename.empty()) {
ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("must specifies the file to write log to. ret=%d", ret);
return ret;
}
if (!log_filename.empty()) {
if (get_srs_log_tank_file()) {
srs_trace("log file is %s", log_filename.c_str());
} else {
srs_trace("write log to console");
}
return ret;
... ...
... ... @@ -569,7 +569,7 @@ int SrsEncoder::cycle()
return ret;
}
void SrsEncoder::on_leave_loop()
void SrsEncoder::on_thread_stop()
{
// kill ffmpeg when finished and it alive
std::vector<SrsFFMPEG*>::iterator it;
... ...
... ... @@ -101,7 +101,7 @@ public:
// interface ISrsThreadHandler.
public:
virtual int cycle();
virtual void on_leave_loop();
virtual void on_thread_stop();
private:
virtual void clear_engines();
virtual SrsFFMPEG* at(int index);
... ...
... ... @@ -126,7 +126,7 @@ int SrsListener::listen(int _port)
return ret;
}
void SrsListener::on_enter_loop()
void SrsListener::on_thread_start()
{
srs_trace("listen cycle start, port=%d, type=%d, fd=%d", port, type, fd);
}
... ...
... ... @@ -69,7 +69,7 @@ public:
virtual int listen(int port);
// interface ISrsThreadHandler.
public:
virtual void on_enter_loop();
virtual void on_thread_start();
virtual int cycle();
};
... ...
... ... @@ -34,7 +34,7 @@ ISrsThreadHandler::~ISrsThreadHandler()
{
}
void ISrsThreadHandler::on_enter_loop()
void ISrsThreadHandler::on_thread_start()
{
}
... ... @@ -50,7 +50,7 @@ int ISrsThreadHandler::on_end_cycle()
return ret;
}
void ISrsThreadHandler::on_leave_loop()
void ISrsThreadHandler::on_thread_stop()
{
}
... ... @@ -114,9 +114,9 @@ void SrsThread::thread_cycle()
srs_assert(handler);
_srs_context->generate_id();
srs_trace("thread cycle start");
srs_info("thread cycle start");
handler->on_end_cycle();
handler->on_thread_start();
loop = true;
while (loop) {
... ... @@ -146,7 +146,7 @@ failed:
st_usleep(cycle_interval_us);
}
handler->on_leave_loop();
handler->on_thread_stop();
srs_trace("thread cycle finished");
}
... ...
... ... @@ -34,14 +34,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/**
* the handler for the thread, callback interface.
* the thread model defines as:
* handler->on_enter_loop()
* handler->on_thread_start()
* while loop:
* handler->on_before_cycle()
* handler->cycle()
* handler->on_end_cycle()
* if !loop then break for user stop thread.
* sleep(CycleIntervalMilliseconds)
* handler->on_leave_loop()
* handler->on_thread_stop()
* when stop, the thread will interrupt the st_thread,
* which will cause the socket to return error and
* terminate the cycle thread.
... ... @@ -69,11 +69,11 @@ public:
ISrsThreadHandler();
virtual ~ISrsThreadHandler();
public:
virtual void on_enter_loop();
virtual void on_thread_start();
virtual int on_before_cycle();
virtual int cycle() = 0;
virtual int on_end_cycle();
virtual void on_leave_loop();
virtual void on_thread_stop();
};
/**
... ...
... ... @@ -166,8 +166,8 @@ string srs_client_type_string(SrsRtmpConnType type)
{
switch (type) {
case SrsRtmpConnPlay: return "Play";
case SrsRtmpConnFlashPublish: return "FlashPublish";
case SrsRtmpConnFMLEPublish: return "FMLEPublish";
case SrsRtmpConnFlashPublish: return "publish(FlashPublish)";
case SrsRtmpConnFMLEPublish: return "publish(FMLEPublish)";
default: return "Unknown";
}
return "Unknown";
... ...