Skip to content

Commit

Permalink
Support build srs-librtmp by VS2015. 2.0.267
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 23, 2019
1 parent 08bbbc5 commit 01a4503
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 21 deletions.
10 changes: 9 additions & 1 deletion trunk/src/kernel/srs_kernel_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions trunk/src/kernel/srs_kernel_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -721,7 +721,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 @@ -881,7 +881,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 @@ -931,6 +931,6 @@ int srs_chunk_header_c3(
}

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

18 changes: 13 additions & 5 deletions trunk/src/libs/srs_lib_simple_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions trunk/src/libs/srs_librtmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions trunk/src/libs/srs_librtmp.hpp
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
8 changes: 4 additions & 4 deletions trunk/src/protocol/srs_rtmp_amf0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1148,7 +1148,7 @@ void SrsAmf0StrictArray::clear()

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

SrsAmf0Any* SrsAmf0StrictArray::at(int index)
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/protocol/srs_rtmp_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 01a4503

Please sign in to comment.