Changeset 121 for pjproject/trunk/pjmedia/src/pjmedia/stream.c
- Timestamp:
- Jan 18, 2006 11:12:57 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r66 r121 25 25 #include <pj/string.h> /* memcpy() */ 26 26 #include <pj/pool.h> 27 #include <pj/assert.h> 28 #include <pj/compat/socket.h> 29 #include <pj/sock_select.h> 30 #include <pj/errno.h> 27 31 #include <stdlib.h> 32 28 33 29 34 #define THISFILE "stream.c" … … 92 97 struct pj_audio_frame frame_in, frame_out; 93 98 94 PJ_UNUSED_ARG(timestamp) 99 PJ_UNUSED_ARG(timestamp); 95 100 96 101 /* Lock mutex */ … … 153 158 void *rtphdr; 154 159 int rtphdrlen; 155 int sent;160 pj_ssize_t sent; 156 161 #if 0 157 162 static FILE *fhnd = NULL; 158 163 #endif 159 164 160 PJ_UNUSED_ARG(timestamp) 165 PJ_UNUSED_ARG(timestamp); 161 166 162 167 /* Start locking channel mutex */ … … 203 208 204 209 /* Send. */ 205 sent = pj_sock_sendto (channel->rtp_sock, channel->out_pkt, frame_out.size+sizeof(pj_rtp_hdr), 0, 210 sent = frame_out.size+sizeof(pj_rtp_hdr); 211 status = pj_sock_sendto (channel->rtp_sock, channel->out_pkt, &sent, 0, 206 212 &channel->dst_addr, sizeof(channel->dst_addr)); 207 if (sent != (int)frame_out.size + (int)sizeof(pj_rtp_hdr)) { 208 pj_perror(THISFILE, "Error sending RTP packet to %s:%d", 209 pj_sockaddr_get_str_addr(&channel->dst_addr), 210 pj_sockaddr_get_port(&channel->dst_addr)); 213 if (status != PJ_SUCCESS) 211 214 goto on_return; 212 }213 215 214 216 /* Update stat */ … … 232 234 233 235 234 static void*PJ_THREAD_FUNC stream_decoder_transport_thread (void*arg)236 static int PJ_THREAD_FUNC stream_decoder_transport_thread (void*arg) 235 237 { 236 238 pj_media_stream_t *channel = arg; 237 239 238 240 while (!channel->thread_quit_flag) { 239 int len, size;241 pj_ssize_t len, size; 240 242 const pj_rtp_hdr *hdr; 241 243 const void *payload; … … 245 247 246 248 /* Wait for packet. */ 247 fd_set fds;249 pj_fd_set_t fds; 248 250 pj_time_val timeout; 249 251 … … 259 261 260 262 /* Get packet from socket. */ 261 len = pj_sock_recv (channel->rtp_sock, channel->in_pkt, channel->in_pkt_size, 0); 262 if (len < 1) { 263 if (pj_getlasterror() == PJ_ECONNRESET) { 263 len = channel->in_pkt_size; 264 status = pj_sock_recv (channel->rtp_sock, channel->in_pkt, &len, 0); 265 if (len < 1 || status != PJ_SUCCESS) { 266 if (pj_get_netos_error() == PJ_STATUS_FROM_OS(OSERR_ECONNRESET)) { 264 267 /* On Win2K SP2 (or above) and WinXP, recv() will get WSAECONNRESET 265 268 when the sending side receives ICMP port unreachable. … … 267 270 continue; 268 271 } 269 pj_perror(THISFILE, "Error receiving packet from socket (len=%d)", len);272 //pj_perror(THISFILE, "Error receiving packet from socket (len=%d)", len); 270 273 pj_thread_sleep(1); 271 274 continue; … … 326 329 } 327 330 328 return NULL;331 return 0; 329 332 } 330 333 … … 349 352 void *ptr; 350 353 unsigned size; 351 int status;354 pj_status_t status; 352 355 353 356 /* Allocate memory for channel descriptor */ … … 370 373 371 374 /* Create mutex for the channel. */ 372 channel->mutex = pj_mutex_create(pool, NULL, PJ_MUTEX_SIMPLE);373 if ( channel->mutex == NULL)375 status = pj_mutex_create_simple(pool, NULL, &channel->mutex); 376 if (status != PJ_SUCCESS) 374 377 goto err_cleanup; 375 378 … … 485 488 } 486 489 487 channel->transport_thread= pj_thread_create(pool, "decode",488 489 0, NULL, 0);490 if ( !channel->transport_thread) {491 pj_perror(THISFILE, "Unable to create transport thread");490 status = pj_thread_create(pool, "decode", 491 &stream_decoder_transport_thread, channel, 492 0, 0, &channel->transport_thread); 493 if (status != PJ_SUCCESS) { 494 //pj_perror(THISFILE, "Unable to create transport thread"); 492 495 goto err_cleanup; 493 496 } … … 574 577 PJ_DEF(pj_status_t) pj_media_stream_pause (pj_media_stream_t *channel) 575 578 { 576 PJ_UNUSED_ARG(channel) 579 PJ_UNUSED_ARG(channel); 577 580 return -1; 578 581 } … … 580 583 PJ_DEF(pj_status_t) pj_media_stream_resume (pj_media_stream_t *channel) 581 584 { 582 PJ_UNUSED_ARG(channel) 585 PJ_UNUSED_ARG(channel); 583 586 return -1; 584 587 }
Note: See TracChangeset
for help on using the changeset viewer.