Skip to content

Commit

Permalink
Fix #25, supports build by VS2015
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 23, 2019
1 parent 4ca1e11 commit 02e5212
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
64 changes: 41 additions & 23 deletions src/srs/srs_librtmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SRS_AUTO_HEADER_HPP
#define SRS_AUTO_HEADER_HPP

#define SRS_AUTO_BUILD_TS "1577092348"
#define SRS_AUTO_BUILD_DATE "2019-12-23 17:12:28"
#define SRS_AUTO_BUILD_TS "1577095973"
#define SRS_AUTO_BUILD_DATE "2019-12-23 18:12:53"
#define SRS_AUTO_UNAME "Darwin Mac 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64"
#define SRS_AUTO_USER_CONFIGURE "--x86-x64 --export-librtmp-single=/Users/winlin/git/srs-librtmp/src/srs"
#define SRS_AUTO_CONFIGURE "--prefix=/usr/local/srs --without-hls --without-hds --without-dvr --without-nginx --without-ssl --without-ffmpeg --without-transcode --without-ingest --without-stat --without-http-callback --without-http-server --without-stream-caster --without-http-api --with-librtmp --with-research --without-utest --without-gperf --without-gmc --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace"
Expand Down Expand Up @@ -12079,9 +12079,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);
Expand Down Expand Up @@ -13289,7 +13287,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;
}

Expand Down Expand Up @@ -13580,7 +13578,7 @@ int srs_av_base64_decode(u_int8_t* out, const char* in_str, int out_size)
*dst++ = v >> 4;
out1:
out0:
return bits & 1 ? -1 : dst - out;
return (int)(bits & 1 ? -1 : dst - out);
}

/*****************************************************************************
Expand Down Expand Up @@ -13740,7 +13738,7 @@ int srs_chunk_header_c0(
}

// always has header
return p - cache;
return (int)(p - cache);
}

int srs_chunk_header_c3(
Expand Down Expand Up @@ -13790,7 +13788,7 @@ int srs_chunk_header_c3(
}

// always has header
return p - cache;
return (int)(p - cache);
}

// following is generated by src/kernel/srs_kernel_flv.cpp
Expand Down Expand Up @@ -16159,7 +16157,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;
Expand Down Expand Up @@ -16276,7 +16278,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;
Expand Down Expand Up @@ -20269,7 +20275,7 @@ char* SrsAmf0Any::human_print(char** pdata, int* psize)
*pdata = data;
}
if (psize) {
*psize = str.length();
*psize = (int)str.length();
}

return data;
Expand Down Expand Up @@ -21142,7 +21148,7 @@ void SrsAmf0StrictArray::clear()

int SrsAmf0StrictArray::count()
{
return properties.size();
return (int)properties.size();
}

SrsAmf0Any* SrsAmf0StrictArray::at(int index)
Expand All @@ -21159,7 +21165,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)
Expand Down Expand Up @@ -21846,7 +21852,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;
Expand Down Expand Up @@ -22658,7 +22664,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;
Expand Down Expand Up @@ -33511,8 +33517,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;
}
Expand Down Expand Up @@ -33752,7 +33762,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;
Expand Down Expand Up @@ -35987,8 +35997,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;
Expand Down Expand Up @@ -36094,7 +36108,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;
Expand Down Expand Up @@ -36153,8 +36167,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;
Expand Down
4 changes: 1 addition & 3 deletions src/srs/srs_librtmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 02e5212

Please sign in to comment.