diff --git a/trunk/src/kernel/srs_kernel_file.cpp b/trunk/src/kernel/srs_kernel_file.cpp index 611a625993..adbe94baa7 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 8abb16e619..ba663604e0 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 @@ 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); } /***************************************************************************** @@ -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 8f773835e2..6bc3041011 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 03b8c1544c..d5fc3105b4 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 618b71e8c2..a3cd0faedd 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 a8da45bb44..cc70212e02 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 d002356b33..cc11cb44c0 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;