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

Support build srs-librtmp by VS2015. 2.0.267

This commit is contained in:
winlin 2019-12-23 17:01:02 +08:00
parent fde11756c3
commit 316628632b
12 changed files with 79 additions and 43 deletions

View file

@ -338,6 +338,7 @@ Remark:
## History ## 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-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> * <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 * 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

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version // current release version
#define VERSION_MAJOR 2 #define VERSION_MAJOR 2
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 266 #define VERSION_REVISION 267
// generated by configure, only macros. // generated by configure, only macros.
#include <srs_auto_headers.hpp> #include <srs_auto_headers.hpp>
@ -127,6 +127,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
className(const className&); \ className(const className&); \
className& operator= (const className&) className& operator= (const className&)
// For librtmp, it is pure c++ and supports all OS.
#ifndef SRS_EXPORT_LIBRTMP
/** /**
* important check for st(state-threads), * important check for st(state-threads),
* only support the following cpus: i386/amd64/x86_64/arm * only support the following cpus: i386/amd64/x86_64/arm
@ -135,5 +137,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#if !defined(__amd64__) && !defined(__x86_64__) && !defined(__i386__) && !defined(__arm__) #if !defined(__amd64__) && !defined(__x86_64__) && !defined(__i386__) && !defined(__arm__)
#error "only support i386/amd64/x86_64/arm cpu" #error "only support i386/amd64/x86_64/arm cpu"
#endif #endif
#endif
#endif #endif

View file

@ -303,12 +303,12 @@ int SrsSharedPtrMessage::chunk_header(char* cache, int nb_cache, bool c0)
{ {
if (c0) { if (c0) {
return srs_chunk_header_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, ptr->header.message_type, stream_id,
cache, nb_cache); cache, nb_cache);
} else { } else {
return srs_chunk_header_c3( return srs_chunk_header_c3(
ptr->header.perfer_cid, timestamp, ptr->header.perfer_cid, (u_int32_t)timestamp,
cache, nb_cache); cache, nb_cache);
} }
} }

View file

@ -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; 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) { if (::mkdir(dir.c_str(), mode) < 0) {
#else #else
if (::mkdir(dir.c_str()) < 0) { if (::_mkdir(dir.c_str()) < 0) {
#endif #endif
if (errno == EEXIST) { if (errno == EEXIST) {
return ERROR_SYSTEM_DIR_EXISTS; return ERROR_SYSTEM_DIR_EXISTS;
@ -833,9 +833,9 @@ int srs_chunk_header_c0(
*p++ = pp[1]; *p++ = pp[1];
*p++ = pp[0]; *p++ = pp[0];
} else { } else {
*p++ = 0xFF; *p++ = (char)0xFF;
*p++ = 0xFF; *p++ = (char)0xFF;
*p++ = 0xFF; *p++ = (char)0xFF;
} }
// message_length, 3bytes, big-endian // message_length, 3bytes, big-endian

View file

@ -164,6 +164,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{ {
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx; 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 sec = (int)(timeout_us / 1000000LL);
int microsec = (int)(timeout_us % 1000000LL); int microsec = (int)(timeout_us % 1000000LL);
@ -171,9 +179,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
microsec = srs_max(0, microsec); microsec = srs_max(0, microsec);
struct timeval tv = { sec , 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(); return SOCKET_ERRNO();
} }
#endif
skt->recv_timeout = timeout_us; skt->recv_timeout = timeout_us;
return ERROR_SUCCESS; return ERROR_SUCCESS;
@ -192,6 +202,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{ {
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx; 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 sec = (int)(timeout_us / 1000000LL);
int microsec = (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); microsec = srs_max(0, microsec);
struct timeval tv = { sec , 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(); return SOCKET_ERRNO();
} }
#endif
skt->send_timeout = timeout_us; skt->send_timeout = timeout_us;

View file

@ -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 // for srs-librtmp, @see https://github.com/ossrs/srs/issues/213
#ifdef _WIN32 #ifdef _WIN32
// To disable some security warnings.
#define _CRT_SECURE_NO_WARNINGS
// include windows first. // include windows first.
#include <windows.h> #include <windows.h>
// the type used by this header for windows. // the type used by this header for windows.
typedef unsigned long long u_int64_t; #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; typedef long long int64_t;
#endif
typedef unsigned long long u_int64_t;
typedef unsigned int u_int32_t; typedef unsigned int u_int32_t;
typedef u_int32_t uint32_t; typedef u_int32_t uint32_t;
typedef int int32_t;
typedef unsigned char u_int8_t; typedef unsigned char u_int8_t;
typedef char int8_t;
typedef unsigned short u_int16_t; typedef unsigned short u_int16_t;
typedef short int16_t;
typedef int64_t ssize_t; typedef int64_t ssize_t;
struct iovec { struct iovec {
void *iov_base; /* Starting address */ 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 // for srs-librtmp, @see https://github.com/ossrs/srs/issues/213
#ifdef _WIN32 #ifdef _WIN32
// for time. // for time.
#define _CRT_SECURE_NO_WARNINGS
#include <time.h> #include <time.h>
int gettimeofday(struct timeval* tv, struct timezone* tz); int gettimeofday(struct timeval* tv, struct timezone* tz);
#define PRId64 "lld" #define PRId64 "lld"
@ -1094,9 +1099,11 @@ typedef void* srs_hijack_io_t;
int socket_setup(); int socket_setup();
int socket_cleanup(); int socket_cleanup();
// others. // snprintf is defined in VS2015, so we only define this macro before that.
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -201,7 +201,7 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
// we just move the ptr to next. // we just move the ptr to next.
srs_assert((int)nread > 0); srs_assert((int)nread > 0);
end += nread; end += nread;
nb_free_space -= nread; nb_free_space -= (int)nread;
} }
return ret; return ret;

View file

@ -200,7 +200,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts,
// numOfSequenceParameterSets, always 1 // numOfSequenceParameterSets, always 1
stream.write_1bytes(0x01); stream.write_1bytes(0x01);
// sequenceParameterSetLength // sequenceParameterSetLength
stream.write_2bytes(sps.length()); stream.write_2bytes((int16_t)sps.length());
// sequenceParameterSetNALUnit // sequenceParameterSetNALUnit
stream.write_string(sps); stream.write_string(sps);
} }
@ -211,7 +211,7 @@ int SrsRawH264Stream::mux_sequence_header(string sps, string pps, u_int32_t dts,
// numOfPictureParameterSets, always 1 // numOfPictureParameterSets, always 1
stream.write_1bytes(0x01); stream.write_1bytes(0x01);
// pictureParameterSetLength // pictureParameterSetLength
stream.write_2bytes(pps.length()); stream.write_2bytes((int16_t)pps.length());
// pictureParameterSetNALUnit // pictureParameterSetNALUnit
stream.write_string(pps); stream.write_string(pps);
} }

View file

@ -1842,7 +1842,7 @@ namespace _srs_internal
srs_error("amf0 write string length failed. ret=%d", ret); srs_error("amf0 write string length failed. ret=%d", ret);
return 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()); srs_verbose("amf0 write string length success. len=%d", (int)value.length());
// empty string // empty string

View file

@ -244,6 +244,8 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io)
cs_cache[cid] = cs; cs_cache[cid] = cs;
} }
out_c0c3_caches = new char[SRS_CONSTS_C0C3_HEADERS_MAX];
} }
SrsProtocol::~SrsProtocol() SrsProtocol::~SrsProtocol()
@ -282,6 +284,8 @@ SrsProtocol::~SrsProtocol()
srs_freep(cs); srs_freep(cs);
} }
srs_freepa(cs_cache); srs_freepa(cs_cache);
srs_freepa(out_c0c3_caches);
} }
void SrsProtocol::set_auto_response(bool v) 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; int nbh = 0;
if (p == payload) { if (p == payload) {
nbh = srs_chunk_header_c0( 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, mh->message_type, mh->stream_id,
c0c3, sizeof(c0c3)); c0c3, sizeof(c0c3));
} else { } else {
nbh = srs_chunk_header_c3( nbh = srs_chunk_header_c3(
mh->perfer_cid, mh->timestamp, mh->perfer_cid, (uint32_t)mh->timestamp,
c0c3, sizeof(c0c3)); c0c3, sizeof(c0c3));
} }
srs_assert(nbh > 0);; srs_assert(nbh > 0);;
@ -2567,6 +2571,7 @@ int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip)
SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket(); 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("fmsVer", SrsAmf0Any::str("FMS/" RTMP_SIG_FMS_VER));
pkt->props->set("capabilities", SrsAmf0Any::number(127)); pkt->props->set("capabilities", SrsAmf0Any::number(127));
pkt->props->set("mode", SrsAmf0Any::number(1)); pkt->props->set("mode", SrsAmf0Any::number(1));

View file

@ -268,7 +268,8 @@ private:
* *
* @remark, the c0c3 cache cannot be realloc. * @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. // whether warned user to increase the c0c3 header cache.
bool warned_c0c3_cache_dry; bool warned_c0c3_cache_dry;
/** /**

View file

@ -843,7 +843,7 @@ VOID TEST(ConfigMainTest, CheckConf_max_connections)
if (true) { if (true) {
MockSrsConfig conf; 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) { if (true) {