Repository: ossrs/srs
File: trunk/src/srt/srt_to_rtmp.cpp (C++)

Code before:
            key_path.c_str());
        return;
    }
    rtmp_ptr = iter->second;
    _rtmp_client_map.erase(iter);
    srs_trace("close rtmp session which key_path is %s", key_path.c_str());
    rtmp_ptr->close();
    
    return;
}

//the cycle is running in srs coroutine
srs_error_t srt2rtmp::cycle() {
    srs_error_t err = srs_success;
    _lastcheck_ts = 0;

    while(true) {
        SRT_DATA_MSG_PTR msg_ptr = get_data_message();

        if (!msg_ptr) {
            srs_usleep((30 * SRS_UTIME_MILLISECONDS));
        } else {
            switch (msg_ptr->msg_type()) {
                case SRT_MSG_DATA_TYPE:
                {
                    if (handle_ts_data(msg_ptr) != srs_success) {
                        std::unique_lock<std::mutex> locker(_srt_error_mutex);
                        _srt_error_map[msg_ptr->get_path()] = -1;
                    }
                    break;
                }
                case SRT_MSG_CLOSE_TYPE:
                {
                    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",
                        msg_ptr->msg_type(), msg_ptr->get_path().c_str());
                    assert(0);
                }
            }
            
        }
        check_rtmp_alive();

Review comment (suggestion):
Error code: `ERROR_SUCCESS` 0

Error object: `srs_success` NULL/0

`TRANS_BY_GPT3`

Code after:
            key_path.c_str());
        return;
    }
    rtmp_ptr = iter->second;
    _rtmp_client_map.erase(iter);
    srs_trace("close rtmp session which key_path is %s", key_path.c_str());
    rtmp_ptr->close();
    
    return;
}

//the cycle is running in srs coroutine
srs_error_t srt2rtmp::cycle() {
    srs_error_t err = srs_success;
    _lastcheck_ts = 0;
    int err_code = -1;

    while(true) {
        SRT_DATA_MSG_PTR msg_ptr = get_data_message();

        if (!msg_ptr) {
            srs_usleep((30 * SRS_UTIME_MILLISECONDS));
        } else {
            switch (msg_ptr->msg_type()) {
                case SRT_MSG_DATA_TYPE:
                {
                    err_code = handle_ts_data(msg_ptr);
                    if (err_code  != ERROR_SUCCESS) {
                        std::unique_lock<std::mutex> locker(_srt_error_mutex);
                        _srt_error_map[msg_ptr->get_path()] = err_code;
                    }
                    break;
                }
                case SRT_MSG_CLOSE_TYPE:
                {
                    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",
                        msg_ptr->msg_type(), msg_ptr->get_path().c_str());
                    assert(0);
                }
            }