Import upstream version 5.0.0
Debian Janitor
2 years ago
5 | 5 | |
6 | 6 | ## [Unreleased] |
7 | 7 | |
8 | ## [5.0.0] - 2021-07-08 | |
9 | ||
10 | ### Fixed | |
11 | - small memory leak around TMMBR receiving. | |
12 | ||
13 | ||
14 | ## [4.5.0] - 2021-03-29 | |
15 | ||
16 | ### Fixed | |
17 | - minor fixes | |
8 | 18 | |
9 | 19 | ## [4.4.0] - 2019-06-16 |
10 | 20 |
20 | 20 | ############################################################################ |
21 | 21 | |
22 | 22 | cmake_minimum_required(VERSION 3.1) |
23 | project(oRTP VERSION 4.4.0) | |
23 | project(oRTP VERSION 5.0.0) | |
24 | 24 | |
25 | 25 | |
26 | 26 | set(ORTP_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}) |
39 | 39 | #include <stdarg.h> |
40 | 40 | #include <string.h> |
41 | 41 | |
42 | #ifdef __linux | |
42 | #ifdef __linux__ | |
43 | 43 | #include <stdint.h> |
44 | 44 | #endif |
45 | 45 | |
132 | 132 | #if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP) |
133 | 133 | #define ORTP_WINDOWS_DESKTOP 1 |
134 | 134 | #elif defined(WINAPI_FAMILY_PARTITION) |
135 | // See bctoolbox/include/port.h for WINAPI_PARTITION checker | |
135 | 136 | #if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
136 | 137 | #define ORTP_WINDOWS_DESKTOP 1 |
138 | #elif defined (WINAPI_PARTITION_PC_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP) | |
139 | #define ORTP_WINDOWS_DESKTOP 1 | |
140 | #define ORTP_WINDOWS_UWP 1 | |
137 | 141 | #elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) |
138 | 142 | #define ORTP_WINDOWS_PHONE 1 |
139 | 143 | #elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) |
76 | 76 | list(APPEND ORTP_SOURCE_FILES_CXX winrttimer.cpp winrttimer.h) |
77 | 77 | set_source_files_properties(winrttimer.cpp PROPERTIES COMPILE_FLAGS "/ZW /AI\$(WindowsSDK_MetadataPath)") |
78 | 78 | endif() |
79 | list(APPEND LIBS ws2_32)# symbols for in6addr_any | |
79 | 80 | endif() |
80 | 81 | |
81 | 82 | if(WIN32) |
134 | 135 | target_link_libraries(ortp PUBLIC bctoolbox PRIVATE ${LIBS}) |
135 | 136 | if(MSVC) |
136 | 137 | if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") |
137 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/ortp.pdb | |
138 | install(FILES $<TARGET_PDB_FILE:ortp> | |
138 | 139 | DESTINATION ${CMAKE_INSTALL_BINDIR} |
139 | 140 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
140 | 141 | ) |
85 | 85 | PAGE_READWRITE, // read/write access |
86 | 86 | 0, // size: high 32-bits |
87 | 87 | SHMEMSIZE, // size: low 32-bits |
88 | #ifdef ORTP_WINDOWS_UWP | |
89 | L"oRTPSharedMemory"); // name of map object | |
90 | #else | |
88 | 91 | "oRTPSharedMemory"); // name of map object |
92 | #endif | |
89 | 93 | |
90 | 94 | if (hMapObject == NULL) |
91 | 95 | return FALSE; |
147 | 147 | |
148 | 148 | static const char *find_param_occurence_of(const char *fmtp, const char *param){ |
149 | 149 | const char *pos=fmtp; |
150 | int param_len = (int)strlen(param); | |
150 | 151 | do{ |
151 | 152 | pos=strstr(pos,param); |
152 | 153 | if (pos){ |
153 | 154 | /*check that the occurence found is not a subword of a parameter name*/ |
154 | if (pos==fmtp) break; | |
155 | if (pos[-1]==';' || pos[-1]==' '){ | |
156 | break; | |
155 | if (pos==fmtp){ | |
156 | if (pos[param_len] == '=') break; /* found it */ | |
157 | }else if ((pos[-1]==';' || pos[-1]==' ') && pos[param_len] == '='){ | |
158 | break; /* found it */ | |
157 | 159 | } |
158 | 160 | pos+=strlen(param); |
159 | 161 | } |
160 | }while(pos!=NULL); | |
162 | }while (pos!=NULL); | |
161 | 163 | return pos; |
162 | 164 | } |
163 | 165 |
25 | 25 | #include "ortp/str_utils.h" |
26 | 26 | #include "utils.h" |
27 | 27 | #include <bctoolbox/port.h> |
28 | #include <bctoolbox/charconv.h> | |
28 | 29 | |
29 | 30 | #if defined(_WIN32) && !defined(_WIN32_WCE) |
30 | 31 | #include <process.h> |
531 | 532 | ortp_pipe_t ortp_server_pipe_create(const char *name){ |
532 | 533 | #ifdef ORTP_WINDOWS_DESKTOP |
533 | 534 | ortp_pipe_t h; |
534 | char *pipename=make_pipe_name(name); | |
535 | h=CreateNamedPipe(pipename,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_MESSAGE|PIPE_WAIT,1, | |
536 | 32768,32768,0,NULL); | |
537 | ortp_free(pipename); | |
535 | #ifdef ORTP_WINDOWS_UWP | |
536 | char *pipenameBuf=make_pipe_name(name); | |
537 | wchar_t * pipename = bctbx_string_to_wide_string(pipenameBuf); | |
538 | ortp_free(pipenameBuf); | |
539 | #else | |
540 | char *pipename=make_pipe_name(name); | |
541 | #endif | |
542 | ||
543 | h=CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_MESSAGE|PIPE_WAIT, 1, 32768, 32768, 0, NULL); | |
538 | 544 | if (h==INVALID_HANDLE_VALUE){ |
539 | 545 | ortp_error("Fail to create named pipe %s",pipename); |
540 | 546 | } |
547 | ||
548 | #ifdef ORTP_WINDOWS_UWP | |
549 | bctbx_free(pipename); | |
550 | #else | |
551 | ortp_free(pipename); | |
552 | #endif | |
541 | 553 | if (event==NULL) event=CreateEvent(NULL,TRUE,FALSE,NULL); |
542 | 554 | return h; |
543 | 555 | #else |
595 | 607 | } |
596 | 608 | |
597 | 609 | ortp_pipe_t ortp_client_pipe_connect(const char *name){ |
598 | #ifdef ORTP_WINDOWS_DESKTOP | |
610 | #if defined( ORTP_WINDOWS_DESKTOP) && !defined(ORTP_WINDOWS_UWP) | |
599 | 611 | char *pipename=make_pipe_name(name); |
600 | 612 | ortp_pipe_t hpipe = CreateFile( |
601 | 613 | pipename, // pipe name |
646 | 658 | void *ortp_shm_open(unsigned int keyid, int size, int create){ |
647 | 659 | #ifdef ORTP_WINDOWS_DESKTOP |
648 | 660 | HANDLE h; |
661 | void *buf; | |
662 | ||
663 | #ifdef BCTBX_WINDOWS_UWP | |
664 | char nameBuf[64]; | |
665 | snprintf(nameBuf,sizeof(nameBuf),"%x",keyid); | |
666 | wchar_t * name = bctbx_string_to_wide_string(nameBuf); | |
667 | #else | |
649 | 668 | char name[64]; |
650 | void *buf; | |
651 | ||
652 | 669 | snprintf(name,sizeof(name),"%x",keyid); |
670 | #endif | |
671 | ||
653 | 672 | if (create){ |
654 | 673 | h = CreateFileMapping( |
655 | 674 | INVALID_HANDLE_VALUE, // use paging file |
668 | 687 | ortp_error("Fail to open file mapping (create=%i)",create); |
669 | 688 | return NULL; |
670 | 689 | } |
690 | #ifdef BCTBX_WINDOWS_UWP | |
691 | bctbx_free(name); | |
692 | #endif | |
671 | 693 | buf = (LPTSTR) MapViewOfFile(h, // handle to map object |
672 | 694 | FILE_MAP_ALL_ACCESS, // read/write permission |
673 | 695 | 0, |
719 | 741 | |
720 | 742 | void _ortp_get_cur_time(ortpTimeSpec *ret, bool_t realtime){ |
721 | 743 | #if defined(_WIN32_WCE) || defined(_WIN32) |
722 | #if defined( ORTP_WINDOWS_DESKTOP ) && !defined(ENABLE_MICROSOFT_STORE_APP) | |
744 | #if defined( ORTP_WINDOWS_DESKTOP ) && !defined(ENABLE_MICROSOFT_STORE_APP) && !defined(ORTP_WINDOWS_UWP) | |
723 | 745 | DWORD timemillis; |
724 | 746 | # if defined(_WIN32_WCE) |
725 | 747 | timemillis=GetTickCount(); |
784 | 806 | } |
785 | 807 | |
786 | 808 | void ortp_sleep_until(const ortpTimeSpec *ts){ |
787 | #ifdef __linux | |
809 | #ifdef __linux__ | |
788 | 810 | struct timespec rq; |
789 | 811 | rq.tv_sec=ts->tv_sec; |
790 | 812 | rq.tv_nsec=ts->tv_nsec; |
862 | 884 | return 0; |
863 | 885 | } |
864 | 886 | #endif |
865 | #elif defined(__QNXNTO__) || ((defined(__linux) || defined(__APPLE__)) && !defined(HAVE_ARC4RANDOM)) | |
887 | #elif defined(__QNXNTO__) || ((defined(__linux__) || defined(__APPLE__)) && !defined(HAVE_ARC4RANDOM)) | |
866 | 888 | |
867 | 889 | static unsigned int ortp_urandom(void) { |
868 | 890 | static int fd=-1; |
888 | 910 | #else |
889 | 911 | return arc4random(); |
890 | 912 | #endif |
891 | #elif defined(__linux) || defined(__APPLE__) | |
913 | #elif defined(__linux__) || defined(__APPLE__) | |
892 | 914 | return ortp_urandom(); |
893 | 915 | #elif defined(_WIN32) |
894 | 916 | static int initd=0; |
88 | 88 | #else //_WIN32 |
89 | 89 | |
90 | 90 | |
91 | #ifdef ENABLE_MICROSOFT_STORE_APP | |
91 | #if defined(ENABLE_MICROSOFT_STORE_APP) || defined(ORTP_WINDOWS_UWP) | |
92 | 92 | |
93 | 93 | #include <windows.h> |
94 | 94 | #include <mmsystem.h> |
383 | 383 | if (size<sizeof(rtcp_app_t)) return 0; |
384 | 384 | rtcp_common_header_init(&app->ch,session,RTCP_APP,subtype,size); |
385 | 385 | app->ssrc=htonl(session->snd.ssrc); |
386 | memset(app->name, 0, 4); | |
387 | strncpy(app->name, name, sizeof(app->name) - 1); | |
386 | memset(app->name, 0, sizeof(app->name)); | |
387 | memcpy(app->name, name, sizeof(app->name)); | |
388 | 388 | return sizeof(rtcp_app_t); |
389 | 389 | } |
390 | 390 |
454 | 454 | msgpullup(primarymsg, (size_t)-1); |
455 | 455 | |
456 | 456 | // TODO: Fix when possible |
457 | int len = primarymsg->b_wptr - primarymsg->b_rptr; | |
457 | size_t len = primarymsg->b_wptr - primarymsg->b_rptr; | |
458 | 458 | memcpy(m->b_rptr, primarymsg->b_rptr, len); |
459 | 459 | m->b_wptr = m->b_rptr + len; |
460 | 460 |
1664 | 1664 | meta_rtp_transport_destroy(rtcp_meta_transport); |
1665 | 1665 | |
1666 | 1666 | #if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP) |
1667 | #ifndef ENABLE_MICROSOFT_STORE_APP | |
1667 | #if !defined(ENABLE_MICROSOFT_STORE_APP) && !defined(ORTP_WINDOWS_UWP) | |
1668 | 1668 | if (session->rtp.QoSFlowID != 0) |
1669 | 1669 | { |
1670 | 1670 | ortp_message("check OS support for qwave.lib"); |
1686 | 1686 | #endif //ENABLE_MICROSOFT_STORE_APP |
1687 | 1687 | #endif |
1688 | 1688 | |
1689 | if (session->rtcp.tmmbr_info.sent) | |
1690 | freemsg(session->rtcp.tmmbr_info.sent); | |
1689 | 1691 | if (session->rtcp.tmmbr_info.received) |
1690 | 1692 | freemsg(session->rtcp.tmmbr_info.received); |
1691 | 1693 | if (session->rtcp.send_algo.fb_packets) |
2219 | 2221 | |
2220 | 2222 | if (id == (int)(*tmp >> 4)) { |
2221 | 2223 | if (data) *data = tmp + 1; |
2222 | return size; | |
2224 | return (int)size; | |
2223 | 2225 | } |
2224 | 2226 | |
2225 | 2227 | tmp += size + 1; |
2234 | 2236 | |
2235 | 2237 | if (id == (int)*tmp) { |
2236 | 2238 | if (data) *data = tmp + 2; |
2237 | return size; | |
2239 | return (int)size; | |
2238 | 2240 | } |
2239 | 2241 | |
2240 | 2242 | tmp += size + 2; |
2585 | 2587 | return 0; |
2586 | 2588 | } |
2587 | 2589 | |
2588 | ret = msgdsize(msg); | |
2590 | ret = (int)msgdsize(msg); | |
2589 | 2591 | } |
2590 | 2592 | } |
2591 | 2593 |
264 | 264 | if (ortp_WSARecvMsg == NULL) { |
265 | 265 | GUID guid = WSAID_WSARECVMSG; |
266 | 266 | DWORD bytes_returned; |
267 | if (WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid), | |
267 | if ( WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid), | |
268 | 268 | &ortp_WSARecvMsg, sizeof(ortp_WSARecvMsg), &bytes_returned, NULL, NULL) == SOCKET_ERROR) { |
269 | ortp_warning("WSARecvMsg function not found."); | |
269 | ortp_warning("WSARecvMsg function not found [%d].", WSAGetLastError()); | |
270 | 270 | } |
271 | 271 | } |
272 | 272 | #endif |
661 | 661 | if (session->rtp.gs.socket == (ortp_socket_t)-1) return 0; |
662 | 662 | |
663 | 663 | #if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP) |
664 | #ifndef ENABLE_MICROSOFT_STORE_APP | |
664 | #if !defined(ENABLE_MICROSOFT_STORE_APP) && !defined(ORTP_WINDOWS_UWP) | |
665 | 665 | ortp_message("check OS support for qwave.lib"); |
666 | 666 | if (IsWindowsVistaOrGreater()) { |
667 | 667 | if (session->dscp==0) |
735 | 735 | } |
736 | 736 | } |
737 | 737 | #if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP) |
738 | #ifndef ENABLE_MICROSOFT_STORE_APP | |
738 | #if !defined(ENABLE_MICROSOFT_STORE_APP) && !defined(ORTP_WINDOWS_UWP) | |
739 | 739 | } |
740 | 740 | #endif // ENABLE_MICROSOFT_STORE_APP |
741 | 741 | #endif |
1016 | 1016 | |
1017 | 1017 | #if defined(_WIN32) || defined(_WIN32_WCE) |
1018 | 1018 | #define MAX_BUF 64 |
1019 | static int rtp_sendmsg(int sock, mblk_t *m, const struct sockaddr *rem_addr, socklen_t addr_len) { | |
1019 | static int rtp_sendmsg(ortp_socket_t sock, mblk_t *m, const struct sockaddr *rem_addr, socklen_t addr_len) { | |
1020 | 1020 | WSAMSG msg = {0}; |
1021 | 1021 | WSABUF wsabuf[MAX_BUF]; |
1022 | 1022 | DWORD dwBytes = 0; |
1029 | 1029 | struct sockaddr_storage v4, v6Mapped; |
1030 | 1030 | socklen_t v4Len=0, v6MappedLen=0; |
1031 | 1031 | bool_t useV4 = FALSE; |
1032 | struct sockaddr remote_address = {0}; | |
1033 | struct addrinfo* feed_server = NULL; | |
1032 | 1034 | |
1033 | 1035 | for (wsabufLen = 0; wsabufLen < MAX_BUF && mTrack != NULL; mTrack = mTrack->b_cont, ++wsabufLen) { |
1036 | wsabuf[wsabufLen].len = (ULONG)(mTrack->b_wptr - mTrack->b_rptr); | |
1034 | 1037 | wsabuf[wsabufLen].buf = mTrack->b_rptr; |
1035 | wsabuf[wsabufLen].len = mTrack->b_wptr - mTrack->b_rptr; | |
1036 | 1038 | } |
1037 | 1039 | msg.lpBuffers = wsabuf; // contents |
1038 | 1040 | msg.dwBufferCount = wsabufLen; |
1044 | 1046 | } |
1045 | 1047 | ortp_error("Too long msgb (%i fragments) , didn't fit into iov, end discarded.", MAX_BUF + count); |
1046 | 1048 | } |
1047 | msg.name = (SOCKADDR *)rem_addr; | |
1048 | msg.namelen = addr_len; | |
1049 | if( addr_len == 0){ | |
1050 | // Get the local host information | |
1051 | msg.namelen = 0; | |
1052 | msg.name = NULL; | |
1053 | }else{ | |
1054 | msg.namelen = addr_len; | |
1055 | msg.name = (SOCKADDR *)rem_addr; | |
1056 | } | |
1049 | 1057 | msg.Control.buf = ctrlBuffer; |
1050 | 1058 | msg.Control.len = sizeof(ctrlBuffer); |
1051 | 1059 | cmsg = WSA_CMSG_FIRSTHDR(&msg); |
1084 | 1092 | msg.Control.len = controlSize; |
1085 | 1093 | if (controlSize == 0) |
1086 | 1094 | msg.Control.buf = NULL; |
1087 | error = WSASendMsg(sock, &msg, 0, &dwBytes, NULL, NULL); | |
1088 | if( error == SOCKET_ERROR && controlSize != 0){ | |
1095 | error = WSASendMsg((SOCKET)sock, &msg, 0, &dwBytes, NULL, NULL); | |
1096 | if( error == SOCKET_ERROR && controlSize != 0){// Debug note : if unexpected WSAEFAULT, check the location of memory allocation of msg. It must be on ortp addresses space. | |
1089 | 1097 | int errorCode = WSAGetLastError(); |
1090 | 1098 | if( errorCode == WSAEINVAL || errorCode==WSAENETUNREACH || errorCode==WSAEFAULT) |
1091 | 1099 | { |
1092 | 1100 | msg.Control.len = 0; |
1093 | 1101 | msg.Control.buf = NULL; |
1094 | error = WSASendMsg(sock, &msg, 0, &dwBytes, NULL, NULL); | |
1095 | } | |
1096 | } | |
1097 | return error; | |
1102 | error = WSASendMsg((SOCKET)sock, &msg, 0, &dwBytes, NULL, NULL); | |
1103 | } | |
1104 | } | |
1105 | mTrack = m; | |
1106 | if(error >= 0) | |
1107 | return dwBytes;// Return the bytes that have been sent | |
1108 | else | |
1109 | return error; | |
1098 | 1110 | } |
1099 | 1111 | #else |
1100 | 1112 | #ifdef USE_SENDMSG |
1101 | 1113 | #define MAX_IOV 64 |
1102 | static int rtp_sendmsg(int sock,mblk_t *m, const struct sockaddr *rem_addr, socklen_t addr_len){ | |
1114 | static int rtp_sendmsg(ortp_socket_t sock,mblk_t *m, const struct sockaddr *rem_addr, socklen_t addr_len){ | |
1103 | 1115 | struct msghdr msg; |
1104 | 1116 | struct iovec iov[MAX_IOV]; |
1105 | 1117 | int iovlen; |
1209 | 1221 | msg.msg_controllen = controlSize; |
1210 | 1222 | if( controlSize==0) // Have to reset msg_control to NULL as msg_controllen is not sufficient on some platforms |
1211 | 1223 | msg.msg_control = NULL; |
1212 | error = sendmsg(sock,&msg,0); | |
1224 | error = sendmsg((int)sock,&msg,0); | |
1213 | 1225 | if( error == -1 && controlSize != 0 && (errno == EINVAL || errno==ENETUNREACH || errno==EFAULT)) { |
1214 | 1226 | msg.msg_controllen =0; |
1215 | 1227 | msg.msg_control = NULL; |
1216 | error = sendmsg(sock,&msg,0); | |
1228 | error = sendmsg((int)sock,&msg,0); | |
1217 | 1229 | } |
1218 | 1230 | return error; |
1219 | 1231 | } |
1225 | 1237 | } |
1226 | 1238 | |
1227 | 1239 | int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen) { |
1228 | int error; | |
1240 | int sent_bytes; | |
1229 | 1241 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(USE_SENDMSG) |
1230 | error = rtp_sendmsg(sockfd, m, destaddr, destlen); | |
1242 | sent_bytes = rtp_sendmsg(sockfd, m, destaddr, destlen); | |
1231 | 1243 | #else |
1232 | 1244 | if (m->b_cont != NULL) |
1233 | 1245 | msgpullup(m, -1); |
1234 | error = sendto(sockfd, (char*)m->b_rptr, (int)(m->b_wptr - m->b_rptr), 0, destaddr, destlen); | |
1235 | #endif | |
1236 | return error; | |
1246 | sent_bytes = sendto(sockfd, (char*)m->b_rptr, (int)(m->b_wptr - m->b_rptr), 0, destaddr, destlen); | |
1247 | #endif | |
1248 | return sent_bytes; | |
1237 | 1249 | } |
1238 | 1250 | |
1239 | 1251 | int rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){ |
1516 | 1528 | return error; |
1517 | 1529 | } |
1518 | 1530 | #endif |
1519 | ||
1520 | 1531 | int rtp_session_rtp_recv_abstract(ortp_socket_t socket, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen) { |
1521 | 1532 | int ret; |
1522 | 1533 | int bufsz = (int) (msg->b_datap->db_lim - msg->b_datap->db_base); |
1525 | 1536 | WSAMSG msghdr = {0}; |
1526 | 1537 | WSACMSGHDR *cmsghdr; |
1527 | 1538 | WSABUF data_buf; |
1528 | DWORD bytes_received; | |
1529 | ||
1539 | DWORD bytes_received=0; | |
1540 | int error = 0; | |
1530 | 1541 | if (ortp_WSARecvMsg == NULL) { |
1531 | 1542 | return recvfrom(socket, (char *)msg->b_wptr, bufsz, flags, from, fromlen); |
1532 | 1543 | } |
1537 | 1548 | } |
1538 | 1549 | data_buf.buf = (char *)msg->b_wptr; |
1539 | 1550 | data_buf.len = bufsz; |
1551 | msghdr.dwBufferCount = 1; | |
1540 | 1552 | msghdr.lpBuffers = &data_buf; |
1541 | msghdr.dwBufferCount = 1; | |
1542 | 1553 | msghdr.Control.buf = control; |
1543 | 1554 | msghdr.Control.len = sizeof(control); |
1544 | 1555 | msghdr.dwFlags = flags; |
1611 | 1622 | memcpy(&msg->net_addr,from,*fromlen); |
1612 | 1623 | msg->net_addrlen = *fromlen; |
1613 | 1624 | } |
1625 | }else{ | |
1614 | 1626 | } |
1615 | 1627 | return ret; |
1616 | 1628 | } |
1920 | 1932 | { |
1921 | 1933 | if (session->on_network_error.count>0){ |
1922 | 1934 | rtp_signal_table_emit3(&session->on_network_error,"Error receiving RTP packet",ORTP_INT_TO_POINTER(getSocketErrorCode())); |
1923 | }else ortp_warning("Error receiving RTP packet: %s, err num [%i],error [%i]",getSocketError(),errnum,error); | |
1935 | #ifdef _WIN32 | |
1936 | }else if(errnum!=WSAECONNRESET) ortp_warning("Error receiving RTP packet err num [%i], error [%i]: %s",errnum,error,getSocketError());// Windows spam WSAECONNRESET and is not useful | |
1937 | #else | |
1938 | }else ortp_warning("Error receiving RTP packet err num [%i], error [%i]: %s",errnum,error,getSocketError()); | |
1939 | #endif | |
1924 | 1940 | #if TARGET_OS_IPHONE |
1925 | 1941 | /*hack for iOS and non-working socket because of background mode*/ |
1926 | 1942 | if (errnum==ENOTCONN){ |
2040 | 2056 | { |
2041 | 2057 | if (session->on_network_error.count>0){ |
2042 | 2058 | rtp_signal_table_emit3(&session->on_network_error,"Error receiving RTCP packet",ORTP_INT_TO_POINTER(getSocketErrorCode())); |
2059 | #ifdef _WIN32 | |
2060 | }else if(errnum!=WSAECONNRESET) ortp_warning("Error receiving RTCP packet: %s, err num [%i],error [%i]",getSocketError(),errnum,error);// Windows spam WSAECONNRESET and is not useful | |
2061 | #else | |
2043 | 2062 | }else ortp_warning("Error receiving RTCP packet: %s, err num [%i],error [%i]",getSocketError(),errnum,error); |
2063 | #endif | |
2044 | 2064 | #if TARGET_OS_IPHONE |
2045 | 2065 | /*hack for iOS and non-working socket because of background mode*/ |
2046 | 2066 | if (errnum==ENOTCONN){ |
409 | 409 | addr_in6->sin6_port = recvaddr->port; |
410 | 410 | memcpy(&addr_in6->sin6_addr, &recvaddr->addr.ipi6_addr, sizeof(recvaddr->addr.ipi6_addr)); |
411 | 411 | *socklen = sizeof(struct sockaddr_in6); |
412 | }else{ | |
413 | *socklen = 0; | |
412 | 414 | } |
413 | 415 | } |
414 | 416 | void ortp_sockaddr_to_recvaddr(const struct sockaddr * addr, ortp_recv_addr_t * recvaddr) { |