From 1b3fe4eb06f4872556b2777e42ea5cef434877a4 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 12:01:50 +0800 Subject: [PATCH 1/9] For #1535, deprecate Adobe HDS(f4m). 3.0.77 --- README.md | 4 +++- trunk/src/core/srs_core.hpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 07a127948..7bf50927f 100755 --- a/README.md +++ b/README.md @@ -121,13 +121,13 @@ For previous versions, please read: - [x] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92]. - [x] Support listen at IPv4 and IPv6, read [#460][bug #460]. - [x] Support SO_REUSEPORT, to improve edge server performance, read [#775][bug #775]. -- [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). - [x] [Experimental] Support MPEG-DASH, the future live streaming protocol, read [#299][bug #299]. - [x] [Experimental] Support pushing MPEG-TS over UDP, please read [bug #250][bug #250]. - [x] [Experimental] Support pushing RTSP, please read [bug #133][bug #133]. - [x] [Experimental] Support pushing FLV over HTTP POST, please read [wiki]([CN][v2_CN_Streamer2], [EN][v2_EN_Streamer2]). - [x] [Experimental] Support multiple processes by [dolphin][srs-dolphin] or [oryx][oryx]. - [x] [Experimental] Support a simple [mgmt console][console], please read [srs-ngb][srs-ngb]. +- [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). - [ ] Utest cover almost all kernel code. - [ ] Enhanced forwarding with vhost and variables. - [ ] Support source cleanup for idle streams. @@ -145,6 +145,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2019-12-23, For [#1535][bug #1535], deprecate Adobe HDS(f4m)([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). 3.0.77 * v3.0, 2019-12-20, Fix [#1508][bug #1508], http-client support read chunked response. 3.0.76 * v3.0, 2019-12-20, For [#1508][bug #1508], refactor srs_is_digital, support all zeros. * v3.0, 2019-12-19, [3.0 alpha5(3.0.75)][r3.0a5] released. 115362 lines. @@ -1544,6 +1545,7 @@ Winlin [bug #1520]: https://github.com/ossrs/srs/issues/1520 [bug #1223]: https://github.com/ossrs/srs/issues/1223 [bug #1508]: https://github.com/ossrs/srs/issues/1508 +[bug #1535]: https://github.com/ossrs/srs/issues/1535 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index ad70e2fa2..866ca2e92 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 76 +#define VERSION_REVISION 77 // The macros generated by configure script. #include From 9aaf5123ad96b637375ecefe804df3cbc163a386 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 12:10:35 +0800 Subject: [PATCH 2/9] For #1535, deprecate BWT(bandwith testing). 3.0.78 --- README.md | 3 ++- trunk/src/core/srs_core.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7bf50927f..3614aa96d 100755 --- a/README.md +++ b/README.md @@ -107,7 +107,6 @@ For previous versions, please read: - [x] Support gop-cache([CN][v3_CN_LowLatency2], [EN][v3_EN_LowLatency2]) for player fast startup. - [x] Support Vhost([CN][v1_CN_RtmpUrlVhost], [EN][v1_EN_RtmpUrlVhost]) and \_\_defaultVhost\_\_. - [x] Support reloading([CN][v1_CN_Reload], [EN][v1_EN_Reload]) to apply changes of config. -- [x] Support bandwidth testing([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]) and flash client example. - [x] Support listening at multiple ports. - [x] Support forwarding([CN][v3_CN_Forward], [EN][v3_EN_Forward]) from master to slave server. - [x] Support transcoding([CN][v3_CN_FFMPEG], [EN][v3_EN_FFMPEG]) live streaming by FFMPEG. @@ -128,6 +127,7 @@ For previous versions, please read: - [x] [Experimental] Support multiple processes by [dolphin][srs-dolphin] or [oryx][oryx]. - [x] [Experimental] Support a simple [mgmt console][console], please read [srs-ngb][srs-ngb]. - [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). +- [x] [Deprecated] Support bandwidth testing([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]) and flash client example. - [ ] Utest cover almost all kernel code. - [ ] Enhanced forwarding with vhost and variables. - [ ] Support source cleanup for idle streams. @@ -145,6 +145,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2019-12-23, For [#1535][bug #1535], deprecate BWT(bandwidth testing)([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]). 3.0.78 * v3.0, 2019-12-23, For [#1535][bug #1535], deprecate Adobe HDS(f4m)([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). 3.0.77 * v3.0, 2019-12-20, Fix [#1508][bug #1508], http-client support read chunked response. 3.0.76 * v3.0, 2019-12-20, For [#1508][bug #1508], refactor srs_is_digital, support all zeros. diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 866ca2e92..9db03ce7c 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 77 +#define VERSION_REVISION 78 // The macros generated by configure script. #include From 2d29e3c4e6aad585575e593a83d4546cf398108f Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 12:21:46 +0800 Subject: [PATCH 3/9] For #1535, deprecate Adobe FMS/AMS edge token traversing authentication. 3.0.79 --- README.md | 3 ++- trunk/src/core/srs_core.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3614aa96d..6ba15b386 100755 --- a/README.md +++ b/README.md @@ -97,7 +97,6 @@ For previous versions, please read: - [x] Support HTTP RAW API, please read [#459][bug #459], [#470][bug #470], [#319][bug #319]. - [x] Support HTTP callback([CN][v3_CN_HTTPCallback], [EN][v3_EN_HTTPCallback]) for authentication and integration. - [x] Support RTMP client library: srs-librtmp([CN][v3_CN_SrsLibrtmp], [EN][v3_EN_SrsLibrtmp]) -- [x] Support Adobe FMS/AMS token traverse([CN][v3_CN_DRM2], [EN][v3_EN_DRM2]) authentication. - [x] Support DVR([CN][v3_CN_DVR], [EN][v3_EN_DVR]) to record live streaming to FLV file. - [x] Support DVR in MP4 format, read [#738][bug #738]. - [x] Support DVR control module like NGINX-RTMP, please read [#459][bug #459]. @@ -128,6 +127,7 @@ For previous versions, please read: - [x] [Experimental] Support a simple [mgmt console][console], please read [srs-ngb][srs-ngb]. - [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). - [x] [Deprecated] Support bandwidth testing([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]) and flash client example. +- [x] [Deprecated] Support Adobe FMS/AMS token traverse([CN][v3_CN_DRM2], [EN][v3_EN_DRM2]) authentication. - [ ] Utest cover almost all kernel code. - [ ] Enhanced forwarding with vhost and variables. - [ ] Support source cleanup for idle streams. @@ -145,6 +145,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2019-12-23, For [#1535][bug #1535], deprecate Adobe FMS/AMS edge token traversing([CN][v3_CN_DRM2], [EN][v3_EN_DRM2]) authentication. 3.0.79 * v3.0, 2019-12-23, For [#1535][bug #1535], deprecate BWT(bandwidth testing)([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]). 3.0.78 * v3.0, 2019-12-23, For [#1535][bug #1535], deprecate Adobe HDS(f4m)([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). 3.0.77 * v3.0, 2019-12-20, Fix [#1508][bug #1508], http-client support read chunked response. 3.0.76 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 9db03ce7c..ca877a14d 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 78 +#define VERSION_REVISION 79 // The macros generated by configure script. #include From 6073cde63b8435b717055724d88dee76da6300e7 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 14:08:11 +0800 Subject: [PATCH 4/9] Mark some features as experimental. --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6ba15b386..4a67a2be4 100755 --- a/README.md +++ b/README.md @@ -94,11 +94,8 @@ For previous versions, please read: - [x] Support native HTTP server([CN][v3_CN_SampleHTTP], [EN][v3_EN_SampleHTTP]) for http api and http live streaming. - [x] Support HTTP CORS for js in http api and http live streaming. - [x] Support HTTP API([CN][v3_CN_HTTPApi], [EN][v3_EN_HTTPApi]) for system management. -- [x] Support HTTP RAW API, please read [#459][bug #459], [#470][bug #470], [#319][bug #319]. - [x] Support HTTP callback([CN][v3_CN_HTTPCallback], [EN][v3_EN_HTTPCallback]) for authentication and integration. -- [x] Support RTMP client library: srs-librtmp([CN][v3_CN_SrsLibrtmp], [EN][v3_EN_SrsLibrtmp]) - [x] Support DVR([CN][v3_CN_DVR], [EN][v3_EN_DVR]) to record live streaming to FLV file. -- [x] Support DVR in MP4 format, read [#738][bug #738]. - [x] Support DVR control module like NGINX-RTMP, please read [#459][bug #459]. - [x] Support EXEC like NGINX-RTMP, please read [bug #367][bug #367]. - [x] Support security strategy including allow/deny publish/play IP([CN][v2_CN_Security], [EN][v2_EN_Security]). @@ -119,15 +116,19 @@ For previous versions, please read: - [x] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92]. - [x] Support listen at IPv4 and IPv6, read [#460][bug #460]. - [x] Support SO_REUSEPORT, to improve edge server performance, read [#775][bug #775]. +- [x] [Experimental] Support docker by [srs-docker](https://github.com/ossrs/srs-docker). +- [x] [Experimental] Support DVR in MP4 format, read [#738][bug #738]. - [x] [Experimental] Support MPEG-DASH, the future live streaming protocol, read [#299][bug #299]. - [x] [Experimental] Support pushing MPEG-TS over UDP, please read [bug #250][bug #250]. - [x] [Experimental] Support pushing RTSP, please read [bug #133][bug #133]. - [x] [Experimental] Support pushing FLV over HTTP POST, please read [wiki]([CN][v2_CN_Streamer2], [EN][v2_EN_Streamer2]). - [x] [Experimental] Support multiple processes by [dolphin][srs-dolphin] or [oryx][oryx]. - [x] [Experimental] Support a simple [mgmt console][console], please read [srs-ngb][srs-ngb]. -- [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]). -- [x] [Deprecated] Support bandwidth testing([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]) and flash client example. -- [x] [Deprecated] Support Adobe FMS/AMS token traverse([CN][v3_CN_DRM2], [EN][v3_EN_DRM2]) authentication. +- [x] [Experimental] Support RTMP client library: srs-librtmp([CN][v3_CN_SrsLibrtmp], [EN][v3_EN_SrsLibrtmp]) +- [x] [Experimental] Support HTTP RAW API, please read [#459][bug #459], [#470][bug #470], [#319][bug #319]. +- [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]) and [#1535][bug #1535]. +- [x] [Deprecated] Support bandwidth testing([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]), please read [#1535][bug #1535]. +- [x] [Deprecated] Support Adobe FMS/AMS token traverse([CN][v3_CN_DRM2], [EN][v3_EN_DRM2]) authentication, please read [#1535][bug #1535]. - [ ] Utest cover almost all kernel code. - [ ] Enhanced forwarding with vhost and variables. - [ ] Support source cleanup for idle streams. From 316628632bcbc088a852fe8a094d8f12acd98bcc Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 17:01:02 +0800 Subject: [PATCH 5/9] Support build srs-librtmp by VS2015. 2.0.267 --- README.md | 1 + trunk/src/core/srs_core.hpp | 19 +++++++------ trunk/src/kernel/srs_kernel_flv.cpp | 4 +-- trunk/src/kernel/srs_kernel_utility.cpp | 8 +++--- trunk/src/libs/srs_lib_simple_socket.cpp | 31 +++++++++++++++++----- trunk/src/libs/srs_librtmp.hpp | 21 ++++++++++----- trunk/src/protocol/srs_protocol_buffer.cpp | 2 +- trunk/src/protocol/srs_raw_avc.cpp | 4 +-- trunk/src/protocol/srs_rtmp_amf0.cpp | 2 +- trunk/src/protocol/srs_rtmp_stack.cpp | 13 ++++++--- trunk/src/protocol/srs_rtmp_stack.hpp | 3 ++- trunk/src/utest/srs_utest_config.cpp | 4 +-- 12 files changed, 74 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 7ed8b1474..e72f55032 100755 --- a/README.md +++ b/README.md @@ -338,6 +338,7 @@ Remark: ## History +* v2.0, 2019-12-23, Fix [srs-librtmp #25](https://github.com/ossrs/srs-librtmp/issues/25), build srs-librtmp on windows. 2.0.267 * v2.0, 2019-12-13, Support openssl versions greater than 1.1.0. 2.0.266 * v2.0, 2019-11-29, [2.0 release7(2.0.265)][r2.0r7] released. 86994 lines. * v2.0, 2019-11-29, For [srs-docker](https://github.com/ossrs/srs-docker/tree/master/2.0), install Cherrypy without sudo. 2.0.265 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index e2c7c7ccd..2ba1b4cb4 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 266 +#define VERSION_REVISION 267 // generated by configure, only macros. #include @@ -127,13 +127,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. className(const className&); \ className& operator= (const className&) -/** - * important check for st(state-threads), - * only support the following cpus: i386/amd64/x86_64/arm - * @reamrk to patch ST for arm, read https://github.com/ossrs/state-threads/issues/1 - */ -#if !defined(__amd64__) && !defined(__x86_64__) && !defined(__i386__) && !defined(__arm__) - #error "only support i386/amd64/x86_64/arm cpu" +// For librtmp, it is pure c++ and supports all OS. +#ifndef SRS_EXPORT_LIBRTMP + /** + * important check for st(state-threads), + * only support the following cpus: i386/amd64/x86_64/arm + * @reamrk to patch ST for arm, read https://github.com/ossrs/state-threads/issues/1 + */ + #if !defined(__amd64__) && !defined(__x86_64__) && !defined(__i386__) && !defined(__arm__) + #error "only support i386/amd64/x86_64/arm cpu" + #endif #endif #endif diff --git a/trunk/src/kernel/srs_kernel_flv.cpp b/trunk/src/kernel/srs_kernel_flv.cpp index 9d71747c9..a79cea810 100644 --- a/trunk/src/kernel/srs_kernel_flv.cpp +++ b/trunk/src/kernel/srs_kernel_flv.cpp @@ -303,12 +303,12 @@ int SrsSharedPtrMessage::chunk_header(char* cache, int nb_cache, bool c0) { if (c0) { return srs_chunk_header_c0( - ptr->header.perfer_cid, timestamp, ptr->header.payload_length, + ptr->header.perfer_cid, (u_int32_t)timestamp, ptr->header.payload_length, ptr->header.message_type, stream_id, cache, nb_cache); } else { return srs_chunk_header_c3( - ptr->header.perfer_cid, timestamp, + ptr->header.perfer_cid, (u_int32_t)timestamp, cache, nb_cache); } } diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 4e75b06f2..8abb16e61 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -353,7 +353,7 @@ int srs_do_create_dir_recursively(string dir) mode_t mode = S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IXOTH; if (::mkdir(dir.c_str(), mode) < 0) { #else - if (::mkdir(dir.c_str()) < 0) { + if (::_mkdir(dir.c_str()) < 0) { #endif if (errno == EEXIST) { return ERROR_SYSTEM_DIR_EXISTS; @@ -833,9 +833,9 @@ int srs_chunk_header_c0( *p++ = pp[1]; *p++ = pp[0]; } else { - *p++ = 0xFF; - *p++ = 0xFF; - *p++ = 0xFF; + *p++ = (char)0xFF; + *p++ = (char)0xFF; + *p++ = (char)0xFF; } // message_length, 3bytes, big-endian diff --git a/trunk/src/libs/srs_lib_simple_socket.cpp b/trunk/src/libs/srs_lib_simple_socket.cpp index 79d2bcf38..e025a1c7a 100644 --- a/trunk/src/libs/srs_lib_simple_socket.cpp +++ b/trunk/src/libs/srs_lib_simple_socket.cpp @@ -163,17 +163,27 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. int srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t timeout_us) { SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx; - + +#ifdef _WIN32 + DWORD tv = (DWORD)(timeout_us/1000); + + // To convert tv to const char* to make VS2015 happy. + if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv, sizeof(tv)) == -1) { + return SOCKET_ERRNO(); + } +#else int sec = (int)(timeout_us / 1000000LL); int microsec = (int)(timeout_us % 1000000LL); - + sec = srs_max(0, sec); microsec = srs_max(0, microsec); - + struct timeval tv = { sec , microsec }; - if (setsockopt(skt->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) { + if (setsockopt(skt->fd, SOL_SOCKET, SO_RCVTIMEO, tvv, sizeof(tv)) == -1) { return SOCKET_ERRNO(); } +#endif + skt->recv_timeout = timeout_us; return ERROR_SUCCESS; @@ -191,7 +201,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. int srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t timeout_us) { SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx; - + +#ifdef _WIN32 + DWORD tv = (DWORD)(timeout_us/1000); + + // To convert tv to const char* to make VS2015 happy. + if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv, sizeof(tv)) == -1) { + return SOCKET_ERRNO(); + } +#else int sec = (int)(timeout_us / 1000000LL); int microsec = (int)(timeout_us % 1000000LL); @@ -199,9 +217,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. microsec = srs_max(0, microsec); struct timeval tv = { sec , microsec }; - if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) { + if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, tvv, sizeof(tv)) == -1) { return SOCKET_ERRNO(); } +#endif skt->send_timeout = timeout_us; diff --git a/trunk/src/libs/srs_librtmp.hpp b/trunk/src/libs/srs_librtmp.hpp index f70de7725..618b71e8c 100644 --- a/trunk/src/libs/srs_librtmp.hpp +++ b/trunk/src/libs/srs_librtmp.hpp @@ -43,18 +43,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *************************************************************/ // for srs-librtmp, @see https://github.com/ossrs/srs/issues/213 #ifdef _WIN32 + // To disable some security warnings. + #define _CRT_SECURE_NO_WARNINGS // include windows first. #include // the type used by this header for windows. + #if defined(_MSC_VER) + #include + #else + typedef char int8_t; + typedef short int16_t; + typedef int int32_t; + typedef long long int64_t; + #endif typedef unsigned long long u_int64_t; - typedef long long int64_t; typedef unsigned int u_int32_t; typedef u_int32_t uint32_t; - typedef int int32_t; typedef unsigned char u_int8_t; - typedef char int8_t; typedef unsigned short u_int16_t; - typedef short int16_t; typedef int64_t ssize_t; struct iovec { void *iov_base; /* Starting address */ @@ -1051,7 +1057,6 @@ typedef void* srs_hijack_io_t; // for srs-librtmp, @see https://github.com/ossrs/srs/issues/213 #ifdef _WIN32 // for time. - #define _CRT_SECURE_NO_WARNINGS #include int gettimeofday(struct timeval* tv, struct timezone* tz); #define PRId64 "lld" @@ -1094,8 +1099,10 @@ typedef void* srs_hijack_io_t; int socket_setup(); int socket_cleanup(); - // others. - #define snprintf _snprintf + // snprintf is defined in VS2015, so we only define this macro before that. + #if defined(_MSC_VER) && _MSC_VER < 1900 + #define snprintf _snprintf + #endif #endif #ifdef __cplusplus diff --git a/trunk/src/protocol/srs_protocol_buffer.cpp b/trunk/src/protocol/srs_protocol_buffer.cpp index 8b644fa62..4543ae823 100755 --- a/trunk/src/protocol/srs_protocol_buffer.cpp +++ b/trunk/src/protocol/srs_protocol_buffer.cpp @@ -201,7 +201,7 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size) // we just move the ptr to next. srs_assert((int)nread > 0); end += nread; - nb_free_space -= nread; + nb_free_space -= (int)nread; } return ret; diff --git a/trunk/src/protocol/srs_raw_avc.cpp b/trunk/src/protocol/srs_raw_avc.cpp index aaf1f8fb2..26dc8933b 100644 --- a/trunk/src/protocol/srs_raw_avc.cpp +++ b/trunk/src/protocol/srs_raw_avc.cpp @@ -200,7 +200,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts, // numOfSequenceParameterSets, always 1 stream.write_1bytes(0x01); // sequenceParameterSetLength - stream.write_2bytes(sps.length()); + stream.write_2bytes((int16_t)sps.length()); // sequenceParameterSetNALUnit stream.write_string(sps); } @@ -211,7 +211,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts, // numOfPictureParameterSets, always 1 stream.write_1bytes(0x01); // pictureParameterSetLength - stream.write_2bytes(pps.length()); + stream.write_2bytes((int16_t)pps.length()); // pictureParameterSetNALUnit stream.write_string(pps); } diff --git a/trunk/src/protocol/srs_rtmp_amf0.cpp b/trunk/src/protocol/srs_rtmp_amf0.cpp index e2a041bb0..a8da45bb4 100644 --- a/trunk/src/protocol/srs_rtmp_amf0.cpp +++ b/trunk/src/protocol/srs_rtmp_amf0.cpp @@ -1842,7 +1842,7 @@ namespace _srs_internal srs_error("amf0 write string length failed. ret=%d", ret); return ret; } - stream->write_2bytes(value.length()); + stream->write_2bytes((int16_t)value.length()); srs_verbose("amf0 write string length success. len=%d", (int)value.length()); // empty string diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index dac4cd2eb..ca5867f3d 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -244,6 +244,8 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) cs_cache[cid] = cs; } + + out_c0c3_caches = new char[SRS_CONSTS_C0C3_HEADERS_MAX]; } SrsProtocol::~SrsProtocol() @@ -282,6 +284,8 @@ SrsProtocol::~SrsProtocol() srs_freep(cs); } srs_freepa(cs_cache); + + srs_freepa(out_c0c3_caches); } void SrsProtocol::set_auto_response(bool v) @@ -656,12 +660,12 @@ int SrsProtocol::do_simple_send(SrsMessageHeader* mh, char* payload, int size) int nbh = 0; if (p == payload) { nbh = srs_chunk_header_c0( - mh->perfer_cid, mh->timestamp, mh->payload_length, + mh->perfer_cid, (uint32_t)mh->timestamp, mh->payload_length, mh->message_type, mh->stream_id, c0c3, sizeof(c0c3)); } else { nbh = srs_chunk_header_c3( - mh->perfer_cid, mh->timestamp, + mh->perfer_cid, (uint32_t)mh->timestamp, c0c3, sizeof(c0c3)); } srs_assert(nbh > 0);; @@ -2566,8 +2570,9 @@ int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip) int ret = ERROR_SUCCESS; SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket(); - - pkt->props->set("fmsVer", SrsAmf0Any::str("FMS/"RTMP_SIG_FMS_VER)); + + // @remark For windows, there must be a space between const string and macro. + pkt->props->set("fmsVer", SrsAmf0Any::str("FMS/" RTMP_SIG_FMS_VER)); pkt->props->set("capabilities", SrsAmf0Any::number(127)); pkt->props->set("mode", SrsAmf0Any::number(1)); diff --git a/trunk/src/protocol/srs_rtmp_stack.hpp b/trunk/src/protocol/srs_rtmp_stack.hpp index 9900000dc..bc21d1d6e 100644 --- a/trunk/src/protocol/srs_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_rtmp_stack.hpp @@ -268,7 +268,8 @@ private: * * @remark, the c0c3 cache cannot be realloc. */ - char out_c0c3_caches[SRS_CONSTS_C0C3_HEADERS_MAX]; + // To allocate it in heap to make VS2015 happy. + char* out_c0c3_caches; // whether warned user to increase the c0c3 header cache. bool warned_c0c3_cache_dry; /** diff --git a/trunk/src/utest/srs_utest_config.cpp b/trunk/src/utest/srs_utest_config.cpp index 033aa3ec2..ce697623a 100644 --- a/trunk/src/utest/srs_utest_config.cpp +++ b/trunk/src/utest/srs_utest_config.cpp @@ -840,10 +840,10 @@ VOID TEST(ConfigMainTest, CheckConf_max_connections) MockSrsConfig conf; EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connections 0;")); } - + if (true) { MockSrsConfig conf; - EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connections 1000000;")); + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connections 100000000;")); } if (true) { From c6732d0fbbeb144220304c7c12dfda1d88df7456 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 17:02:09 +0800 Subject: [PATCH 6/9] Support build srs-librtmp by VS2015. 2.0.267 --- trunk/src/libs/srs_lib_simple_socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk/src/libs/srs_lib_simple_socket.cpp b/trunk/src/libs/srs_lib_simple_socket.cpp index e025a1c7a..8f773835e 100644 --- a/trunk/src/libs/srs_lib_simple_socket.cpp +++ b/trunk/src/libs/srs_lib_simple_socket.cpp @@ -179,7 +179,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. microsec = srs_max(0, microsec); struct timeval tv = { sec , microsec }; - if (setsockopt(skt->fd, SOL_SOCKET, SO_RCVTIMEO, tvv, sizeof(tv)) == -1) { + if (setsockopt(skt->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) { return SOCKET_ERRNO(); } #endif @@ -217,7 +217,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. microsec = srs_max(0, microsec); struct timeval tv = { sec , microsec }; - if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, tvv, sizeof(tv)) == -1) { + if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) { return SOCKET_ERRNO(); } #endif From 08bbbc5414fd0b34214f59275178556726b8694d Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 17:11:31 +0800 Subject: [PATCH 7/9] Support build srs-librtmp by VS2015. 2.0.267 --- trunk/src/protocol/srs_rtmp_stack.cpp | 3 ++- trunk/src/protocol/srs_rtmp_utility.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index ca5867f3d..d002356b3 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -211,7 +211,8 @@ int SrsPacket::encode_packet(SrsStream* stream) SrsProtocol::AckWindowSize::AckWindowSize() { window = 0; - sequence_number = nb_recv_bytes = 0; + sequence_number = 0; + nb_recv_bytes = 0; } SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) diff --git a/trunk/src/protocol/srs_rtmp_utility.cpp b/trunk/src/protocol/srs_rtmp_utility.cpp index b050488f0..e37612d49 100644 --- a/trunk/src/protocol/srs_rtmp_utility.cpp +++ b/trunk/src/protocol/srs_rtmp_utility.cpp @@ -71,8 +71,9 @@ void srs_discovery_tc_url( vhost = host; srs_vhost_resolve(vhost, app, param); srs_vhost_resolve(vhost, stream, param); - - if (param == "?vhost="SRS_CONSTS_RTMP_DEFAULT_VHOST) { + + // There must be a space to make VS2015 happy. + if (param == "?vhost=" SRS_CONSTS_RTMP_DEFAULT_VHOST) { param = ""; } } From 01a4503ceba411ceca8ae68eb5b25081840c0884 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 18:12:45 +0800 Subject: [PATCH 8/9] Support build srs-librtmp by VS2015. 2.0.267 --- trunk/src/kernel/srs_kernel_file.cpp | 10 +++++++++- trunk/src/kernel/srs_kernel_utility.cpp | 8 ++++---- trunk/src/libs/srs_lib_simple_socket.cpp | 18 +++++++++++++----- trunk/src/libs/srs_librtmp.cpp | 10 +++++++--- trunk/src/libs/srs_librtmp.hpp | 4 +--- trunk/src/protocol/srs_rtmp_amf0.cpp | 8 ++++---- trunk/src/protocol/srs_rtmp_stack.cpp | 2 +- 7 files changed, 39 insertions(+), 21 deletions(-) diff --git a/trunk/src/kernel/srs_kernel_file.cpp b/trunk/src/kernel/srs_kernel_file.cpp index 611a62599..adbe94baa 100644 --- a/trunk/src/kernel/srs_kernel_file.cpp +++ b/trunk/src/kernel/srs_kernel_file.cpp @@ -133,7 +133,11 @@ int SrsFileWriter::write(void* buf, size_t count, ssize_t* pnwrite) ssize_t nwrite; // TODO: FIXME: use st_write. - if ((nwrite = ::write(fd, buf, count)) < 0) { +#ifdef _WIN32 + if ((nwrite = ::_write(fd, buf, (unsigned int)count)) < 0) { +#else + if ((nwrite = ::write(fd, buf, (size_t)count)) < 0) { +#endif ret = ERROR_SYSTEM_FILE_WRITE; srs_error("write to file %s failed. ret=%d", path.c_str(), ret); return ret; @@ -250,7 +254,11 @@ int SrsFileReader::read(void* buf, size_t count, ssize_t* pnread) ssize_t nread; // TODO: FIXME: use st_read. +#ifdef _WIN32 + if ((nread = ::_read(fd, buf, (unsigned int)count)) < 0) { +#else if ((nread = ::read(fd, buf, count)) < 0) { +#endif ret = ERROR_SYSTEM_FILE_READ; srs_error("read from file %s failed. ret=%d", path.c_str(), ret); return ret; diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 8abb16e61..ba663604e 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -430,7 +430,7 @@ bool srs_avc_startswith_annexb(SrsStream* stream, int* pnb_start_code) char* p = bytes; for (;;) { - if (!stream->require(p - bytes + 3)) { + if (!stream->require((int)(p - bytes + 3))) { return false; } @@ -721,7 +721,7 @@ out2: *dst++ = v >> 4; out1: out0: - return bits & 1 ? -1 : dst - out; + return (int)(bits & 1 ? -1 : dst - out); } /***************************************************************************** @@ -881,7 +881,7 @@ int srs_chunk_header_c0( } // always has header - return p - cache; + return (int)(p - cache); } int srs_chunk_header_c3( @@ -931,6 +931,6 @@ int srs_chunk_header_c3( } // always has header - return p - cache; + return (int)(p - cache); } diff --git a/trunk/src/libs/srs_lib_simple_socket.cpp b/trunk/src/libs/srs_lib_simple_socket.cpp index 8f773835e..6bc304101 100644 --- a/trunk/src/libs/srs_lib_simple_socket.cpp +++ b/trunk/src/libs/srs_lib_simple_socket.cpp @@ -135,8 +135,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx; int ret = ERROR_SUCCESS; - - ssize_t nb_read = ::recv(skt->fd, (char*)buf, size, 0); + +#ifdef _WIN32 + ssize_t nb_read = (int)::recv(skt->fd, (char*)buf, (int)size, 0); +#else + ssize_t nb_read = (int)::recv(skt->fd, (char*)buf, size, 0); +#endif if (nread) { *nread = nb_read; @@ -242,7 +246,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. int ret = ERROR_SUCCESS; - ssize_t nb_write = ::writev(skt->fd, iov, iov_size); + ssize_t nb_write = ::writev((int)skt->fd, iov, iov_size); if (nwrite) { *nwrite = nb_write; @@ -301,8 +305,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx; int ret = ERROR_SUCCESS; - - ssize_t nb_write = ::send(skt->fd, (char*)buf, size, 0); + +#ifdef _WIN32 + ssize_t nb_write = (int)::send(skt->fd, (char*)buf, (int)size, 0); +#else + ssize_t nb_write = (int)::send(skt->fd, (char*)buf, size, 0); +#endif if (nwrite) { *nwrite = nb_write; diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index 03b8c1544..d5fc3105b 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -202,8 +202,12 @@ struct Context ssize_t nwrite = 0; for (int i = 0; i < iovcnt; i++) { const struct iovec* current = iov + i; - - int nsent = ::send(fd, (char*)current->iov_base, current->iov_len, 0); + +#ifdef _WIN32 + int nsent = (int)::send(fd, (char*)current->iov_base, (int)current->iov_len, 0); +#else + int nsent = (int)::send(fd, (char*)current->iov_base, (size_t)current->iov_len, 0); +#endif if (nsent < 0) { return nsent; } @@ -443,7 +447,7 @@ struct Context if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 7 && words[7] != 0x0001) || (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) + if (!inet_ntop4(src+12, tp, (socklen_t)(sizeof tmp - (tp - tmp)))) return (NULL); tp += strlen(tp); break; diff --git a/trunk/src/libs/srs_librtmp.hpp b/trunk/src/libs/srs_librtmp.hpp index 618b71e8c..a3cd0faed 100644 --- a/trunk/src/libs/srs_librtmp.hpp +++ b/trunk/src/libs/srs_librtmp.hpp @@ -1085,9 +1085,7 @@ typedef void* srs_hijack_io_t; #define open _open #define close _close #define lseek _lseek - #define write _write - #define read _read - + // for pid. typedef int pid_t; pid_t getpid(void); diff --git a/trunk/src/protocol/srs_rtmp_amf0.cpp b/trunk/src/protocol/srs_rtmp_amf0.cpp index a8da45bb4..cc70212e0 100644 --- a/trunk/src/protocol/srs_rtmp_amf0.cpp +++ b/trunk/src/protocol/srs_rtmp_amf0.cpp @@ -275,7 +275,7 @@ char* SrsAmf0Any::human_print(char** pdata, int* psize) *pdata = data; } if (psize) { - *psize = str.length(); + *psize = (int)str.length(); } return data; @@ -1148,7 +1148,7 @@ void SrsAmf0StrictArray::clear() int SrsAmf0StrictArray::count() { - return properties.size(); + return (int)properties.size(); } SrsAmf0Any* SrsAmf0StrictArray::at(int index) @@ -1165,7 +1165,7 @@ void SrsAmf0StrictArray::append(SrsAmf0Any* any) int SrsAmf0Size::utf8(string value) { - return 2 + value.length(); + return (int)(2 + value.length()); } int SrsAmf0Size::str(string value) @@ -1852,7 +1852,7 @@ namespace _srs_internal } // data - if (!stream->require(value.length())) { + if (!stream->require((int)value.length())) { ret = ERROR_RTMP_AMF0_ENCODE; srs_error("amf0 write string data failed. ret=%d", ret); return ret; diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index d002356b3..cc11cb44c 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -675,7 +675,7 @@ int SrsProtocol::do_simple_send(SrsMessageHeader* mh, char* payload, int size) iovs[0].iov_base = c0c3; iovs[0].iov_len = nbh; - int payload_size = srs_min(end - p, out_chunk_size); + int payload_size = (int)srs_min(end - p, out_chunk_size); iovs[1].iov_base = p; iovs[1].iov_len = payload_size; p += payload_size; From c5f31570cd2954ca20eea547cd52a7eb18987c48 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 23 Dec 2019 18:31:14 +0800 Subject: [PATCH 9/9] Support parsing vhost splited by single seperator. 2.0.268 --- README.md | 1 + trunk/src/core/srs_core.hpp | 2 +- trunk/src/protocol/srs_rtmp_utility.cpp | 1 + trunk/src/utest/srs_utest_protocol.cpp | 5 +++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e72f55032..c282c30d8 100755 --- a/README.md +++ b/README.md @@ -338,6 +338,7 @@ Remark: ## History +* v2.0, 2019-12-23, Fix [srs-librtmp #22](https://github.com/ossrs/srs-librtmp/issues/22), parse vhost splited by single seperator. 2.0.268 * v2.0, 2019-12-23, Fix [srs-librtmp #25](https://github.com/ossrs/srs-librtmp/issues/25), build srs-librtmp on windows. 2.0.267 * v2.0, 2019-12-13, Support openssl versions greater than 1.1.0. 2.0.266 * v2.0, 2019-11-29, [2.0 release7(2.0.265)][r2.0r7] released. 86994 lines. diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 2ba1b4cb4..68600f5e5 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 267 +#define VERSION_REVISION 268 // generated by configure, only macros. #include diff --git a/trunk/src/protocol/srs_rtmp_utility.cpp b/trunk/src/protocol/srs_rtmp_utility.cpp index e37612d49..8c9b9908a 100644 --- a/trunk/src/protocol/srs_rtmp_utility.cpp +++ b/trunk/src/protocol/srs_rtmp_utility.cpp @@ -90,6 +90,7 @@ void srs_vhost_resolve(string& vhost, string& app, string& param) app = srs_string_replace(app, ",", "?"); app = srs_string_replace(app, "...", "?"); app = srs_string_replace(app, "&&", "?"); + app = srs_string_replace(app, "&", "?"); app = srs_string_replace(app, "=", "?"); if (srs_string_ends_with(app, "/_definst_")){ app = srs_erase_last_substr(app, "/_definst_"); diff --git a/trunk/src/utest/srs_utest_protocol.cpp b/trunk/src/utest/srs_utest_protocol.cpp index 119acfd3b..77ac81752 100644 --- a/trunk/src/utest/srs_utest_protocol.cpp +++ b/trunk/src/utest/srs_utest_protocol.cpp @@ -444,6 +444,11 @@ VOID TEST(ProtocolUtilityTest, VhostResolve) srs_vhost_resolve(vhost, app, param); EXPECT_STREQ("changed1", vhost.c_str()); EXPECT_STREQ("app", app.c_str()); + + app = "app?vhost=changed1&query=true"; + srs_vhost_resolve(vhost, app, param); + EXPECT_STREQ("changed1", vhost.c_str()); + EXPECT_STREQ("app", app.c_str()); app = "app?other=true&&vhost=changed2&&query=true"; srs_vhost_resolve(vhost, app, param);