Changeset 5747


Ignore:
Timestamp:
Feb 26, 2018 10:14:27 AM (6 years ago)
Author:
nanang
Message:

Close #2097: Updated UDP media transport to start socket read operation in pjmedia_transport_media_start().

Location:
pjproject/trunk
Files:
5 edited

Legend:

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

    r5737 r5747  
    5757    void               *user_data;      /**< Only valid when attached       */ 
    5858    //pj_bool_t         attached;       /**< Has attachment?                */ 
     59    pj_bool_t           started;        /**< Has started?                   */ 
    5960    pj_sockaddr         rem_rtp_addr;   /**< Remote RTP address             */ 
    6061    unsigned            rem_rtp_cnt;    /**< How many pkt from this addr.   */ 
     
    282283    pj_ioqueue_t *ioqueue; 
    283284    pj_ioqueue_callback rtp_cb, rtcp_cb; 
    284     pj_ssize_t size; 
    285285    unsigned i; 
    286286    pj_status_t status; 
     
    355355                               sizeof(tp->rtp_pending_write[i].op_key)); 
    356356 
     357#if 0 // See #2097: move read op kick-off to media_start() 
    357358    /* Kick of pending RTP read from the ioqueue */ 
    358359    tp->rtp_addrlen = sizeof(tp->rtp_src_addr); 
     
    363364    if (status != PJ_EPENDING) 
    364365        goto on_error; 
     366#endif 
    365367 
    366368 
     
    382384 
    383385 
     386#if 0 // See #2097: move read op kick-off to media_start() 
    384387    /* Kick of pending RTCP read from the ioqueue */ 
    385388    size = sizeof(tp->rtcp_pkt); 
     
    390393    if (status != PJ_EPENDING) 
    391394        goto on_error; 
     395#endif     
    392396 
    393397    tp->ioqueue = ioqueue; 
     
    571575            bytes_read = -status; 
    572576 
    573     } while (status != PJ_EPENDING && status != PJ_ECANCELLED); 
     577    } while (status != PJ_EPENDING && status != PJ_ECANCELLED && 
     578             udp->started); 
    574579} 
    575580 
     
    581586{ 
    582587    struct transport_udp *udp; 
    583     pj_status_t status; 
     588    pj_status_t status = PJ_SUCCESS; 
    584589 
    585590    PJ_UNUSED_ARG(op_key); 
     
    651656            bytes_read = -status; 
    652657 
    653     } while (status != PJ_EPENDING && status != PJ_ECANCELLED); 
     658    } while (status != PJ_EPENDING && status != PJ_ECANCELLED && 
     659             udp->started); 
    654660} 
    655661 
     
    9981004                                  unsigned media_index) 
    9991005{ 
    1000     PJ_ASSERT_RETURN(tp && pool && sdp_local, PJ_EINVAL); 
    1001  
    1002     PJ_UNUSED_ARG(tp); 
     1006    struct transport_udp *udp = (struct transport_udp*)tp; 
     1007    pj_ssize_t size; 
     1008    pj_status_t status; 
     1009 
     1010    PJ_ASSERT_RETURN(tp, PJ_EINVAL); 
     1011 
    10031012    PJ_UNUSED_ARG(pool); 
    10041013    PJ_UNUSED_ARG(sdp_local); 
     
    10061015    PJ_UNUSED_ARG(media_index); 
    10071016 
     1017    /* Just return success if there is already pending read */ 
     1018    if (udp->started) 
     1019        return PJ_SUCCESS; 
     1020 
     1021    /* Kick off pending RTP read from the ioqueue */ 
     1022    udp->rtp_addrlen = sizeof(udp->rtp_src_addr); 
     1023    size = sizeof(udp->rtp_pkt); 
     1024    status = pj_ioqueue_recvfrom(udp->rtp_key, &udp->rtp_read_op, 
     1025                                 udp->rtp_pkt, &size, PJ_IOQUEUE_ALWAYS_ASYNC, 
     1026                                 &udp->rtp_src_addr, &udp->rtp_addrlen); 
     1027    if (status != PJ_EPENDING) 
     1028        return status; 
     1029 
     1030    /* Kick off pending RTCP read from the ioqueue */ 
     1031    udp->rtcp_addr_len = sizeof(udp->rtcp_src_addr); 
     1032    size = sizeof(udp->rtcp_pkt); 
     1033    status = pj_ioqueue_recvfrom(udp->rtcp_key, &udp->rtcp_read_op, 
     1034                                 udp->rtcp_pkt, &size, 
     1035                                 PJ_IOQUEUE_ALWAYS_ASYNC, 
     1036                                 &udp->rtcp_src_addr, &udp->rtcp_addr_len); 
     1037    if (status != PJ_EPENDING) 
     1038        return status; 
     1039 
     1040    udp->started = PJ_TRUE; 
     1041 
    10081042    return PJ_SUCCESS; 
    10091043} 
     
    10111045static pj_status_t transport_media_stop(pjmedia_transport *tp) 
    10121046{ 
    1013     PJ_UNUSED_ARG(tp); 
     1047    struct transport_udp *udp = (struct transport_udp*)tp; 
     1048 
     1049    PJ_ASSERT_RETURN(tp, PJ_EINVAL); 
     1050 
     1051    /* Just return success if there is no pending read */ 
     1052    if (!udp->started) 
     1053        return PJ_SUCCESS; 
     1054 
     1055    pj_ioqueue_post_completion(udp->rtp_key, &udp->rtp_read_op, 
     1056                               -PJ_ECANCELLED); 
     1057 
     1058    pj_ioqueue_post_completion(udp->rtcp_key, &udp->rtcp_read_op, 
     1059                               -PJ_ECANCELLED); 
     1060 
     1061    udp->started = PJ_FALSE; 
    10141062 
    10151063    return PJ_SUCCESS; 
  • pjproject/trunk/pjsip-apps/src/samples/simpleua.c

    r5241 r5747  
    871871    } 
    872872 
     873    /* Start the UDP media transport */ 
     874    pjmedia_transport_media_start(g_med_transport[0], 0, 0, 0, 0); 
     875 
    873876    /* Get the media port interface of the audio stream.  
    874877     * Media port interface is basicly a struct containing get_frame() and 
     
    947950        } 
    948951 
     952        /* Start the UDP media transport */ 
     953        pjmedia_transport_media_start(g_med_transport[1], 0, 0, 0, 0); 
     954 
    949955        if (vstream_info.dir & PJMEDIA_DIR_DECODING) { 
    950956            status = pjmedia_vid_dev_default_param( 
  • pjproject/trunk/pjsip-apps/src/samples/siprtp.c

    r5535 r5747  
    14711471    } 
    14721472 
     1473    /* Start media transport */ 
     1474    pjmedia_transport_media_start(audio->transport, 0, 0, 0, 0); 
     1475 
    14731476    /* Start media thread. */ 
    14741477    audio->thread_quit_flag = 0; 
  • pjproject/trunk/pjsip-apps/src/samples/streamutil.c

    r5681 r5747  
    345345        return status; 
    346346    } 
     347 
     348    /* Start media transport */ 
     349    pjmedia_transport_media_start(transport, 0, 0, 0, 0); 
    347350 
    348351 
  • pjproject/trunk/pjsip-apps/src/samples/vid_streamutil.c

    r5618 r5747  
    286286    } 
    287287 
     288    /* Start media transport */ 
     289    pjmedia_transport_media_start(transport, 0, 0, 0, 0); 
    288290 
    289291    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.