Ignore:
Timestamp:
Jan 18, 2006 11:12:57 PM (18 years ago)
Author:
bennylp
Message:

Compiled cleanly first time for the new pjlib

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/stream.c

    r66 r121  
    2525#include <pj/string.h>      /* memcpy() */ 
    2626#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> 
    2731#include <stdlib.h> 
     32 
    2833 
    2934#define THISFILE    "stream.c" 
     
    9297    struct pj_audio_frame frame_in, frame_out; 
    9398 
    94     PJ_UNUSED_ARG(timestamp) 
     99    PJ_UNUSED_ARG(timestamp); 
    95100 
    96101    /* Lock mutex */ 
     
    153158    void *rtphdr; 
    154159    int rtphdrlen; 
    155     int sent; 
     160    pj_ssize_t sent; 
    156161#if 0 
    157162    static FILE *fhnd = NULL; 
    158163#endif 
    159164 
    160     PJ_UNUSED_ARG(timestamp) 
     165    PJ_UNUSED_ARG(timestamp); 
    161166 
    162167    /* Start locking channel mutex */ 
     
    203208 
    204209    /* 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,  
    206212                           &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) 
    211214        goto on_return; 
    212     } 
    213215 
    214216    /* Update stat */ 
     
    232234 
    233235 
    234 static void* PJ_THREAD_FUNC stream_decoder_transport_thread (void*arg) 
     236static int PJ_THREAD_FUNC stream_decoder_transport_thread (void*arg) 
    235237{ 
    236238    pj_media_stream_t *channel = arg; 
    237239 
    238240    while (!channel->thread_quit_flag) { 
    239         int len, size; 
     241        pj_ssize_t len, size; 
    240242        const pj_rtp_hdr *hdr; 
    241243        const void *payload; 
     
    245247 
    246248        /* Wait for packet. */ 
    247         fd_set fds; 
     249        pj_fd_set_t fds; 
    248250        pj_time_val timeout; 
    249251 
     
    259261 
    260262        /* 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)) { 
    264267                /* On Win2K SP2 (or above) and WinXP, recv() will get WSAECONNRESET 
    265268                   when the sending side receives ICMP port unreachable. 
     
    267270                continue; 
    268271            } 
    269             pj_perror(THISFILE, "Error receiving packet from socket (len=%d)", len); 
     272            //pj_perror(THISFILE, "Error receiving packet from socket (len=%d)", len); 
    270273            pj_thread_sleep(1); 
    271274            continue; 
     
    326329    } 
    327330 
    328     return NULL; 
     331    return 0; 
    329332} 
    330333 
     
    349352    void *ptr; 
    350353    unsigned size; 
    351     int status; 
     354    pj_status_t status; 
    352355     
    353356    /* Allocate memory for channel descriptor */ 
     
    370373 
    371374    /* 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) 
    374377        goto err_cleanup; 
    375378 
     
    485488        } 
    486489 
    487         channel->transport_thread = pj_thread_create(pool, "decode",  
    488                                                      &stream_decoder_transport_thread, channel, 
    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"); 
    492495            goto err_cleanup; 
    493496        } 
     
    574577PJ_DEF(pj_status_t) pj_media_stream_pause (pj_media_stream_t *channel) 
    575578{ 
    576     PJ_UNUSED_ARG(channel) 
     579    PJ_UNUSED_ARG(channel); 
    577580    return -1; 
    578581} 
     
    580583PJ_DEF(pj_status_t) pj_media_stream_resume (pj_media_stream_t *channel) 
    581584{ 
    582     PJ_UNUSED_ARG(channel) 
     585    PJ_UNUSED_ARG(channel); 
    583586    return -1; 
    584587} 
Note: See TracChangeset for help on using the changeset viewer.