1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

SRT: Use thread-safe log for multiple-threading SRT module. (#2474)

* solve srt push bugs

* solve h264 mutiple nalus in srt when obs is configured in zerolatency

* optimize error code

* optimize error code

* optimize error code

* add commemnt:we only skip pps/sps frame and send left nalus in srt

* add commemnt:we only skip pps/sps frame and send left nalus in srt

* optimize srt log system

* update conf

* update srt hpp

Co-authored-by: shiwei <shiwei05@kuaishou.com>
This commit is contained in:
Alex.CR 2021-07-21 10:15:24 +08:00 committed by winlin
parent 4ca433d3f8
commit 4b7ba0e1e9
12 changed files with 268 additions and 62 deletions

View file

@ -76,6 +76,17 @@ void srt2rtmp::insert_ctrl_message(unsigned int msg_type, const std::string& key
//_notify_cond.notify_one();
return;
}
void srt2rtmp::insert_log_message(LOGGER_LEVEL level, const std::string& log_content) {
std::unique_lock<std::mutex> locker(_mutex);
SRT_DATA_MSG_PTR msg_ptr = std::make_shared<SRT_DATA_MSG>(level, log_content);
msg_ptr->set_msg_type(SRT_MSG_LOG_TYPE);
_msg_queue.push(msg_ptr);
return;
}
SRT_DATA_MSG_PTR srt2rtmp::get_data_message() {
std::unique_lock<std::mutex> locker(_mutex);
SRT_DATA_MSG_PTR msg_ptr;
@ -161,6 +172,11 @@ srs_error_t srt2rtmp::cycle() {
handle_close_rtmpsession(msg_ptr->get_path());
break;
}
case SRT_MSG_LOG_TYPE:
{
handle_log_data(msg_ptr);
break;
}
default:
{
srs_error("srt to rtmp get wrong message type(%u), path:%s",
@ -193,6 +209,36 @@ void srt2rtmp::handle_ts_data(SRT_DATA_MSG_PTR data_ptr) {
return;
}
void srt2rtmp::handle_log_data(SRT_DATA_MSG_PTR data_ptr) {
switch (data_ptr->get_log_level()) {
case SRT_LOGGER_INFO_LEVEL:
{
srs_info(data_ptr->get_log_string());
break;
}
case SRT_LOGGER_TRACE_LEVEL:
{
srs_trace(data_ptr->get_log_string());
break;
}
case SRT_LOGGER_WARN_LEVEL:
{
srs_warn(data_ptr->get_log_string());
break;
}
case SRT_LOGGER_ERROR_LEVEL:
{
srs_error(data_ptr->get_log_string());
break;
}
default:
{
srs_trace(data_ptr->get_log_string());
}
}
return;
}
rtmp_client::rtmp_client(std::string key_path):_key_path(key_path)
, _connect_flag(false) {
const std::string DEF_VHOST = "DEFAULT_VHOST";