mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge SRS2 for running srs-librtmp on Windows. 3.0.80
This commit is contained in:
commit
40f6ecaee2
13 changed files with 110 additions and 38 deletions
|
@ -146,6 +146,7 @@ For previous versions, please read:
|
|||
|
||||
## V3 changes
|
||||
|
||||
* v3.0, 2019-12-23, Merge SRS2 for running srs-librtmp on Windows. 3.0.80
|
||||
* 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
|
||||
|
@ -250,6 +251,8 @@ For previous versions, please read:
|
|||
|
||||
## V2 changes
|
||||
|
||||
* 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
|
||||
* <strong>v2.0, 2019-11-29, [2.0 release7(2.0.265)][r2.0r7] released. 86994 lines.</strong>
|
||||
* 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
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// The version config.
|
||||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 79
|
||||
#define VERSION_REVISION 80
|
||||
|
||||
// The macros generated by configure script.
|
||||
#include <srs_auto_headers.hpp>
|
||||
|
@ -93,10 +93,13 @@
|
|||
} \
|
||||
(void)0
|
||||
|
||||
// Checking 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__)
|
||||
// For librtmp, it is pure c++ and supports all OS.
|
||||
#ifndef SRS_EXPORT_LIBRTMP
|
||||
// Checking 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
|
||||
|
||||
// Error predefined for all modules.
|
||||
|
|
|
@ -129,7 +129,11 @@ srs_error_t SrsFileWriter::write(void* buf, size_t count, ssize_t* pnwrite)
|
|||
|
||||
ssize_t nwrite;
|
||||
// TODO: FIXME: use st_write.
|
||||
#ifdef _WIN32
|
||||
if ((nwrite = ::_write(fd, buf, (unsigned int)count)) < 0) {
|
||||
#else
|
||||
if ((nwrite = _srs_write_fn(fd, buf, count)) < 0) {
|
||||
#endif
|
||||
return srs_error_new(ERROR_SYSTEM_FILE_WRITE, "write to file %s failed", path.c_str());
|
||||
}
|
||||
|
||||
|
@ -269,7 +273,11 @@ srs_error_t 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 = _srs_read_fn(fd, buf, count)) < 0) {
|
||||
#endif
|
||||
return srs_error_new(ERROR_SYSTEM_FILE_READ, "read from file %s failed", path.c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -572,7 +572,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;
|
||||
|
@ -1102,9 +1102,9 @@ int srs_chunk_header_c0(int perfer_cid, uint32_t timestamp, int32_t payload_leng
|
|||
*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
|
||||
|
|
|
@ -186,6 +186,14 @@ int srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t tm)
|
|||
{
|
||||
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_RCVTIMEO, &tv, sizeof(tv)) == -1) {
|
||||
return SOCKET_ERRNO();
|
||||
}
|
||||
#else
|
||||
// The default for this option is zero,
|
||||
// which indicates that a receive operation shall not time out.
|
||||
int32_t sec = 0;
|
||||
|
@ -200,6 +208,7 @@ int srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t tm)
|
|||
if (setsockopt(skt->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
|
||||
return SOCKET_ERRNO();
|
||||
}
|
||||
#endif
|
||||
|
||||
skt->rtm = tm;
|
||||
|
||||
|
@ -219,6 +228,14 @@ int srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t tm)
|
|||
{
|
||||
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, &tv, sizeof(tv)) == -1) {
|
||||
return SOCKET_ERRNO();
|
||||
}
|
||||
#else
|
||||
// The default for this option is zero,
|
||||
// which indicates that a receive operation shall not time out.
|
||||
int32_t sec = 0;
|
||||
|
@ -233,6 +250,7 @@ int srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t tm)
|
|||
if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) {
|
||||
return SOCKET_ERRNO();
|
||||
}
|
||||
#endif
|
||||
|
||||
skt->stm = tm;
|
||||
|
||||
|
|
|
@ -44,21 +44,24 @@
|
|||
*************************************************************/
|
||||
// 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 <windows.h>
|
||||
// the type used by this header for windows.
|
||||
#if defined(_MSC_VER)
|
||||
#include <stdint.h>
|
||||
#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 u_int64_t uint64_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 u_int8_t uint8_t;
|
||||
typedef char int8_t;
|
||||
typedef unsigned short u_int16_t;
|
||||
typedef u_int16_t uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef int64_t ssize_t;
|
||||
struct iovec {
|
||||
void *iov_base; /* Starting address */
|
||||
|
@ -1175,8 +1178,6 @@ extern int srs_hijack_io_write(srs_hijack_io_t ctx, void* buf, size_t size, ssiz
|
|||
*************************************************************/
|
||||
// for srs-librtmp, @see https://github.com/ossrs/srs/issues/213
|
||||
#ifdef _WIN32
|
||||
// for time.
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <time.h>
|
||||
int gettimeofday(struct timeval* tv, struct timezone* tz);
|
||||
#define PRId64 "lld"
|
||||
|
@ -1205,8 +1206,6 @@ typedef int mode_t;
|
|||
#define open _open
|
||||
#define close _close
|
||||
#define lseek _lseek
|
||||
#define write _write
|
||||
#define read _read
|
||||
|
||||
// for socket.
|
||||
ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
|
||||
|
|
|
@ -1169,7 +1169,7 @@ void SrsAmf0StrictArray::append(SrsAmf0Any* any)
|
|||
|
||||
int SrsAmf0Size::utf8(string value)
|
||||
{
|
||||
return 2 + (int)value.length();
|
||||
return (int)(2 + value.length());
|
||||
}
|
||||
|
||||
int SrsAmf0Size::str(string value)
|
||||
|
@ -1752,7 +1752,7 @@ namespace _srs_internal
|
|||
if (!stream->require(2)) {
|
||||
return srs_error_new(ERROR_RTMP_AMF0_ENCODE, "requires 2 only %d bytes", stream->left());
|
||||
}
|
||||
stream->write_2bytes(value.length());
|
||||
stream->write_2bytes((int16_t)value.length());
|
||||
|
||||
// empty string
|
||||
if (value.length() <= 0) {
|
||||
|
|
|
@ -194,7 +194,7 @@ srs_error_t SrsFastStream::grow(ISrsReader* 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 err;
|
||||
|
|
|
@ -61,6 +61,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_")) {
|
||||
|
@ -79,6 +80,11 @@ void srs_vhost_resolve(string& vhost, string& app, string& param)
|
|||
}
|
||||
}
|
||||
|
||||
// vhost with params.
|
||||
if ((pos = vhost.find("?")) != std::string::npos) {
|
||||
vhost = vhost.substr(0, pos);
|
||||
}
|
||||
|
||||
/* others */
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ srs_error_t SrsRawH264Stream::mux_sequence_header(string sps, string pps, uint32
|
|||
// 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);
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ srs_error_t SrsRawH264Stream::mux_sequence_header(string sps, string pps, uint32
|
|||
// 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);
|
||||
}
|
||||
|
|
|
@ -220,7 +220,8 @@ srs_error_t SrsPacket::encode_packet(SrsBuffer* stream)
|
|||
SrsProtocol::AckWindowSize::AckWindowSize()
|
||||
{
|
||||
window = 0;
|
||||
sequence_number = nb_recv_bytes = 0;
|
||||
sequence_number = 0;
|
||||
nb_recv_bytes = 0;
|
||||
}
|
||||
|
||||
SrsProtocol::SrsProtocol(ISrsProtocolReadWriter* io)
|
||||
|
@ -253,6 +254,8 @@ SrsProtocol::SrsProtocol(ISrsProtocolReadWriter* io)
|
|||
|
||||
cs_cache[cid] = cs;
|
||||
}
|
||||
|
||||
out_c0c3_caches = new char[SRS_CONSTS_C0C3_HEADERS_MAX];
|
||||
}
|
||||
|
||||
SrsProtocol::~SrsProtocol()
|
||||
|
@ -291,6 +294,8 @@ SrsProtocol::~SrsProtocol()
|
|||
srs_freep(cs);
|
||||
}
|
||||
srs_freepa(cs_cache);
|
||||
|
||||
srs_freepa(out_c0c3_caches);
|
||||
}
|
||||
|
||||
void SrsProtocol::set_auto_response(bool v)
|
||||
|
@ -2376,6 +2381,7 @@ srs_error_t SrsRtmpServer::response_connect_app(SrsRequest *req, const char* ser
|
|||
|
||||
SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket();
|
||||
|
||||
// @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));
|
||||
|
|
|
@ -213,7 +213,8 @@ private:
|
|||
// The c0c3 caches must use unit SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE bytes.
|
||||
//
|
||||
// @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;
|
||||
// The output chunk size, default to 128, set by config.
|
||||
|
|
|
@ -3271,6 +3271,34 @@ VOID TEST(ProtocolRTMPTest, GenerateURL)
|
|||
*/
|
||||
VOID TEST(ProtocolRTMPTest, DiscoveryTcUrl)
|
||||
{
|
||||
// vhost and params
|
||||
if (true) {
|
||||
int port; std::string tcUrl, schema, ip, vhost, app, stream, param;
|
||||
|
||||
tcUrl = "rtmp://127.0.0.1:19351/live?vhost=demo&token=abc"; stream= "show";
|
||||
srs_discovery_tc_url(tcUrl, schema, ip, vhost, app, stream, port, param);
|
||||
EXPECT_STREQ("rtmp", schema.c_str());
|
||||
EXPECT_STREQ("127.0.0.1", ip.c_str());
|
||||
EXPECT_STREQ("demo", vhost.c_str());
|
||||
EXPECT_STREQ("live", app.c_str());
|
||||
EXPECT_STREQ("show", stream.c_str());
|
||||
EXPECT_EQ(19351, port);
|
||||
}
|
||||
|
||||
// vhost and params
|
||||
if (true) {
|
||||
int port; std::string tcUrl, schema, ip, vhost, app, stream, param;
|
||||
|
||||
tcUrl = "rtmp://127.0.0.1:19351/live"; stream= "show?vhost=demo&token=abc";
|
||||
srs_discovery_tc_url(tcUrl, schema, ip, vhost, app, stream, port, param);
|
||||
EXPECT_STREQ("rtmp", schema.c_str());
|
||||
EXPECT_STREQ("127.0.0.1", ip.c_str());
|
||||
EXPECT_STREQ("demo", vhost.c_str());
|
||||
EXPECT_STREQ("live", app.c_str());
|
||||
EXPECT_STREQ("show", stream.c_str());
|
||||
EXPECT_EQ(19351, port);
|
||||
}
|
||||
|
||||
// default vhost in param
|
||||
if (true) {
|
||||
int port; std::string tcUrl, schema, ip, vhost, app, stream, param;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue