mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Squash: Bug fixed
This commit is contained in:
parent
d78a4f25a6
commit
88c8a4f6c0
12 changed files with 72 additions and 33 deletions
|
@ -134,6 +134,7 @@ We are grateful to the community for contributing bugfix and improvements, pleas
|
|||
|
||||
## Releases
|
||||
|
||||
* 2022-02-15, Release [v4.0-b9](https://github.com/ossrs/srs/releases/tag/v4.0-b9), v4.0-b9, 4.0 beta9, v4.0.245, 144474 lines.
|
||||
* 2022-02-11, Release [v4.0-b8](https://github.com/ossrs/srs/releases/tag/v4.0-b8), v4.0-b8, 4.0 beta8, v4.0.241, 144445 lines.
|
||||
* 2022-02-09, Release [v4.0-b7](https://github.com/ossrs/srs/releases/tag/v4.0-b7), v4.0-b7, 4.0 beta7, v4.0.240, 144437 lines.
|
||||
* 2022-02-04, Release [v4.0-b6](https://github.com/ossrs/srs/releases/tag/v4.0-b6), v4.0-b6, 4.0 beta6, v4.0.238, 144437 lines.
|
||||
|
|
|
@ -609,6 +609,12 @@ fi
|
|||
#####################################################################################
|
||||
if [[ $SRS_RTC == YES ]]; then
|
||||
SRTP_OPTIONS=""
|
||||
# To eliminate warnings, see https://stackoverflow.com/a/34208904/17679565
|
||||
# was built for newer macOS version (11.6) than being linked (11.0)
|
||||
if [[ $SRS_OSX == YES ]]; then
|
||||
export MACOSX_DEPLOYMENT_TARGET=11.0
|
||||
echo "Set MACOSX_DEPLOYMENT_TARGET to avoid warnings"
|
||||
fi
|
||||
# If use ASM for SRTP, we enable openssl(with ASM).
|
||||
if [[ $SRS_SRTP_ASM == YES ]]; then
|
||||
SRTP_OPTIONS="--enable-openssl"
|
||||
|
|
|
@ -34,6 +34,9 @@ The changelog for SRS.
|
|||
|
||||
## SRS 4.0 Changelog
|
||||
|
||||
* v4.0, 2022-02-15, Fix warnings for uuid. v4.0.245
|
||||
* v4.0, 2022-02-15, Merge [#2917](https://github.com/ossrs/srs/pull/2917): SRT: Close connection if RTMP failed. (#2917). v4.0.244
|
||||
* v4.0, 2022-02-15, Refine build script for SRT to avoid warnings. v4.0.243
|
||||
* v4.0, 2022-02-11, Support new fields for feature query. v4.0.241
|
||||
* v4.0, 2022-02-09, Mirror docker images in TCR Singapore. v4.0.240
|
||||
* v4.0, 2022-02-08, Refine the error for WebRTC H5 publisher. v4.0.239
|
||||
|
|
|
@ -64,8 +64,6 @@ void srs_build_features(stringstream& ss)
|
|||
SRS_CHECK_FEATURE3(!string(region).empty(), "region", region, ss);
|
||||
string source = srs_getenv("SRS_SOURCE");
|
||||
SRS_CHECK_FEATURE3(!string(source).empty(), "source", source, ss);
|
||||
string mgmt = srs_getenv("SRS_MGMT");
|
||||
SRS_CHECK_FEATURE3(!string(mgmt).empty(), "mgmt", mgmt, ss);
|
||||
|
||||
int nn_vhosts = 0;
|
||||
bool rtsp = false, forward = false, ingest = false, edge = false, hls = false, dvr = false, flv = false;
|
||||
|
|
|
@ -148,6 +148,7 @@
|
|||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
|
||||
# ifdef HAVE___PROGNAME
|
||||
extern char *__progname;
|
||||
|
@ -181,9 +182,10 @@ prog_inv_sh_nm_from_file(char *f, char stripext)
|
|||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ERR_H
|
||||
#if 0
|
||||
static inline void
|
||||
errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
|
||||
{
|
||||
|
@ -202,6 +204,7 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
|
|||
if (doexit)
|
||||
exit(excode);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ERR
|
||||
# define err(E, FMT...) errmsg(1, E, 1, FMT)
|
||||
|
@ -221,10 +224,12 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
|
|||
#endif /* !HAVE_ERR_H */
|
||||
|
||||
|
||||
#if 0
|
||||
static inline __attribute__((const)) int is_power_of_2(unsigned long num)
|
||||
{
|
||||
return (num != 0 && ((num & (num - 1)) == 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LOFF_T
|
||||
typedef int64_t loff_t;
|
||||
|
@ -263,6 +268,7 @@ static inline int dirfd(DIR *d)
|
|||
#define IUTF8 0040000
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* MAXHOSTNAMELEN replacement
|
||||
*/
|
||||
|
@ -282,6 +288,7 @@ static inline size_t get_hostname_max(void)
|
|||
#endif
|
||||
return 64;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_USLEEP
|
||||
/*
|
||||
|
@ -825,7 +832,7 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
|
|||
rewind(state_f);
|
||||
len = fprintf(state_f,
|
||||
"clock: %04x tv: %016lu %08lu adj: %08d\n",
|
||||
clock_seq, last.tv_sec, last.tv_usec, adjustment);
|
||||
clock_seq, last.tv_sec, (unsigned long)last.tv_usec, adjustment);
|
||||
fflush(state_f);
|
||||
if (ftruncate(state_fd, len) < 0) {
|
||||
fprintf(state_f, " \n");
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 241
|
||||
#define VERSION_REVISION 245
|
||||
|
||||
#endif
|
||||
|
|
|
@ -126,9 +126,9 @@ srs_error_t do_main(int argc, char** argv)
|
|||
// config already applied to log.
|
||||
srs_trace2(TAG_MAIN, "%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE);
|
||||
srs_trace("authors: %sand %s", RTMP_SIG_SRS_AUTHORS, SRS_CONSTRIBUTORS);
|
||||
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, pkg: %s, source: %s, mgmt: %s",
|
||||
srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, pkg: %s, region: %s, source: %s",
|
||||
_srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL, SRS_PACKAGER,
|
||||
srs_getenv("SRS_REGION").c_str(), srs_getenv("SRS_SOURCE").c_str(), srs_getenv("SRS_MGMT").c_str());
|
||||
srs_getenv("SRS_REGION").c_str(), srs_getenv("SRS_SOURCE").c_str());
|
||||
srs_trace("configure detail: " SRS_CONFIGURE);
|
||||
#ifdef SRS_EMBEDED_TOOL_CHAIN
|
||||
srs_trace("crossbuild tool chain: " SRS_EMBEDED_TOOL_CHAIN);
|
||||
|
|
|
@ -205,6 +205,19 @@ void srt_handle::handle_push_data(SRT_SOCKSTATUS status, const std::string& subp
|
|||
srt_conn_ptr->update_timestamp(srt_now_ms);
|
||||
|
||||
srt2rtmp::get_instance()->insert_data_message(data, ret, subpath);
|
||||
{
|
||||
std::unique_lock<std::mutex> locker(srt2rtmp::_srt_error_mutex);
|
||||
if (srt2rtmp::_srt_error_map.count(subpath) == 1) {
|
||||
int err_code = srt2rtmp::_srt_error_map[subpath];
|
||||
if (err_code != ERROR_SUCCESS) {
|
||||
close_push_conn(conn_fd);
|
||||
srt_log_error("handle_push_data srt to rtmp error:%d, fd:%d", err_code,conn_fd);
|
||||
//todo: reset to next use, maybe update by srt2rtmp::cycle again
|
||||
srt2rtmp::_srt_error_map[subpath] = ERROR_SUCCESS;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//send data to subscriber(players)
|
||||
//streamid, play map<SRTSOCKET, SRT_CONN_PTR>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include <sstream>
|
||||
|
||||
std::shared_ptr<srt2rtmp> srt2rtmp::s_srt2rtmp_ptr;
|
||||
std::mutex srt2rtmp::_srt_error_mutex;
|
||||
std::map<std::string, int> srt2rtmp::_srt_error_map;
|
||||
|
||||
std::shared_ptr<srt2rtmp> srt2rtmp::get_instance() {
|
||||
if (!s_srt2rtmp_ptr) {
|
||||
|
@ -155,6 +157,7 @@ void srt2rtmp::handle_close_rtmpsession(const std::string& key_path) {
|
|||
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();
|
||||
|
@ -165,7 +168,11 @@ srs_error_t srt2rtmp::cycle() {
|
|||
switch (msg_ptr->msg_type()) {
|
||||
case SRT_MSG_DATA_TYPE:
|
||||
{
|
||||
handle_ts_data(msg_ptr);
|
||||
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:
|
||||
|
@ -194,7 +201,7 @@ srs_error_t srt2rtmp::cycle() {
|
|||
}
|
||||
}
|
||||
|
||||
void srt2rtmp::handle_ts_data(SRT_DATA_MSG_PTR data_ptr) {
|
||||
int srt2rtmp::handle_ts_data(SRT_DATA_MSG_PTR data_ptr) {
|
||||
RTMP_CLIENT_PTR rtmp_ptr;
|
||||
auto iter = _rtmp_client_map.find(data_ptr->get_path());
|
||||
if (iter == _rtmp_client_map.end()) {
|
||||
|
@ -205,9 +212,7 @@ void srt2rtmp::handle_ts_data(SRT_DATA_MSG_PTR data_ptr) {
|
|||
rtmp_ptr = iter->second;
|
||||
}
|
||||
|
||||
rtmp_ptr->receive_ts_data(data_ptr);
|
||||
|
||||
return;
|
||||
return rtmp_ptr->receive_ts_data(data_ptr);
|
||||
}
|
||||
|
||||
void srt2rtmp::handle_log_data(SRT_DATA_MSG_PTR data_ptr) {
|
||||
|
@ -347,9 +352,8 @@ srs_error_t rtmp_client::connect() {
|
|||
return err;
|
||||
}
|
||||
|
||||
void rtmp_client::receive_ts_data(SRT_DATA_MSG_PTR data_ptr) {
|
||||
_ts_demux_ptr->decode(data_ptr, shared_from_this());//on_data_callback is the decode callback
|
||||
return;
|
||||
int rtmp_client::receive_ts_data(SRT_DATA_MSG_PTR data_ptr) {
|
||||
return _ts_demux_ptr->decode(data_ptr, shared_from_this());//on_data_callback is the decode callback
|
||||
}
|
||||
|
||||
srs_error_t rtmp_client::write_h264_sps_pps(uint32_t dts, uint32_t pts) {
|
||||
|
@ -672,13 +676,13 @@ srs_error_t rtmp_client::on_ts_audio(std::shared_ptr<SrsBuffer> avs_ptr, uint64_
|
|||
return err;
|
||||
}
|
||||
|
||||
void rtmp_client::on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media_type,
|
||||
int rtmp_client::on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media_type,
|
||||
uint64_t dts, uint64_t pts)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
if (!data_ptr || (data_ptr->get_data() == nullptr) || (data_ptr->data_len() == 0)) {
|
||||
assert(0);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto avs_ptr = std::make_shared<SrsBuffer>((char*)data_ptr->get_data(), data_ptr->data_len());
|
||||
|
@ -689,13 +693,16 @@ void rtmp_client::on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media
|
|||
err = on_ts_audio(avs_ptr, dts, pts);
|
||||
} else {
|
||||
srs_error("mpegts demux unkown stream type:0x%02x, only support h264+aac", media_type);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (err != srs_success) {
|
||||
srs_error("send media data error:", srs_error_code(err));
|
||||
srs_error("send media data error:%s", srs_error_desc(err).c_str());
|
||||
int err_code = srs_error_code(err);
|
||||
srs_freep(err);
|
||||
return err_code;
|
||||
}
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtmp_packet_queue::rtmp_packet_queue():_queue_timeout(QUEUE_DEF_TIMEOUT)
|
||||
|
|
|
@ -69,9 +69,9 @@ private:
|
|||
class rtmp_client : public ts_media_data_callback_I, public std::enable_shared_from_this<rtmp_client> {
|
||||
public:
|
||||
rtmp_client(std::string key_path);
|
||||
~rtmp_client();
|
||||
virtual ~rtmp_client();
|
||||
|
||||
void receive_ts_data(SRT_DATA_MSG_PTR data_ptr);
|
||||
int receive_ts_data(SRT_DATA_MSG_PTR data_ptr);
|
||||
int64_t get_last_live_ts();
|
||||
std::string get_url();
|
||||
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
void close();
|
||||
|
||||
private:
|
||||
virtual void on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media_type, uint64_t dts, uint64_t pts);
|
||||
virtual int on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media_type, uint64_t dts, uint64_t pts);
|
||||
|
||||
private:
|
||||
srs_error_t on_ts_video(std::shared_ptr<SrsBuffer> avs_ptr, uint64_t dts, uint64_t pts);
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
private:
|
||||
SRT_DATA_MSG_PTR get_data_message();
|
||||
virtual srs_error_t cycle();
|
||||
void handle_ts_data(SRT_DATA_MSG_PTR data_ptr);
|
||||
int handle_ts_data(SRT_DATA_MSG_PTR data_ptr);
|
||||
void handle_close_rtmpsession(const std::string& key_path);
|
||||
void handle_log_data(SRT_DATA_MSG_PTR data_ptr);
|
||||
void check_rtmp_alive();
|
||||
|
@ -154,6 +154,9 @@ private:
|
|||
|
||||
std::unordered_map<std::string, RTMP_CLIENT_PTR> _rtmp_client_map;
|
||||
int64_t _lastcheck_ts;
|
||||
public:
|
||||
static std::mutex _srt_error_mutex;
|
||||
static std::map<std::string, int> _srt_error_map;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -276,7 +276,9 @@ int ts_demux::decode_unit(unsigned char* data_p, std::string key_path, TS_DATA_C
|
|||
uint64_t pts = 0;
|
||||
|
||||
//callback last media data in data buffer
|
||||
on_callback(callback, _last_pid, key_path, _last_dts, _last_pts);
|
||||
int err_code = on_callback(callback, _last_pid, key_path, _last_dts, _last_pts);
|
||||
if (err_code != 0)
|
||||
return err_code;
|
||||
|
||||
int ret = pes_parse(data_p+npos, npos, &ret_data_p, ret_size, dts, pts);
|
||||
if (ret > 188) {
|
||||
|
@ -320,7 +322,7 @@ int ts_demux::decode(SRT_DATA_MSG_PTR data_ptr, TS_DATA_CALLBACK_PTR callback)
|
|||
continue;
|
||||
}
|
||||
ret = decode_unit(data, path, callback);
|
||||
if (ret < 0)
|
||||
if (ret != 0) // srs_error_code is positive
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -335,15 +337,15 @@ void ts_demux::insert_into_databuf(unsigned char* data_p, size_t data_size, std:
|
|||
return;
|
||||
}
|
||||
|
||||
void ts_demux::on_callback(TS_DATA_CALLBACK_PTR callback, unsigned short pid, std::string key_path,
|
||||
int ts_demux::on_callback(TS_DATA_CALLBACK_PTR callback, unsigned short pid, std::string key_path,
|
||||
uint64_t dts, uint64_t pts) {
|
||||
if ((_data_total <=0 ) || (_data_buffer_vec.empty())) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto iter = _pmt._pid2steamtype.find(pid);
|
||||
if (iter == _pmt._pid2steamtype.end()) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
unsigned char stream_type = iter->second;
|
||||
auto total_data_ptr = std::make_shared<SRT_DATA_MSG>(_data_total, key_path);
|
||||
|
@ -358,8 +360,7 @@ void ts_demux::on_callback(TS_DATA_CALLBACK_PTR callback, unsigned short pid, st
|
|||
_data_buffer_vec.clear();
|
||||
_data_total = 0;
|
||||
|
||||
callback->on_data_callback(total_data_ptr, stream_type, dts, pts);
|
||||
return;
|
||||
return callback->on_data_callback(total_data_ptr, stream_type, dts, pts);
|
||||
}
|
||||
|
||||
bool ts_demux::is_pmt(unsigned short pid) {
|
||||
|
|
|
@ -74,7 +74,7 @@ Value Description
|
|||
|
||||
class ts_media_data_callback_I {
|
||||
public:
|
||||
virtual void on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media_type, uint64_t dts, uint64_t pts) = 0;
|
||||
virtual int on_data_callback(SRT_DATA_MSG_PTR data_ptr, unsigned int media_type, uint64_t dts, uint64_t pts) = 0;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<ts_media_data_callback_I> TS_DATA_CALLBACK_PTR;
|
||||
|
@ -227,7 +227,7 @@ private:
|
|||
int pes_parse(unsigned char* p, size_t npos, unsigned char** ret_pp, size_t& ret_size,
|
||||
uint64_t& dts, uint64_t& pts);
|
||||
void insert_into_databuf(unsigned char* data_p, size_t data_size, std::string key_path, unsigned short pid);
|
||||
void on_callback(TS_DATA_CALLBACK_PTR callback, unsigned short pid,
|
||||
int on_callback(TS_DATA_CALLBACK_PTR callback, unsigned short pid,
|
||||
std::string key_path, uint64_t dts, uint64_t pts);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue