Changeset 5897


Ignore:
Timestamp:
Oct 16, 2018 12:03:21 PM (6 years ago)
Author:
ming
Message:

Fixed #2157: Update media transport adapter sample

File:
1 edited

Legend:

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

    r5478 r5897  
    9797                                        void *pkt, 
    9898                                        pj_ssize_t); 
     99    void               (*stream_rtp_cb2)(pjmedia_tp_cb_param *param); 
    99100    void               (*stream_rtcp_cb)(void *user_data, 
    100101                                         void *pkt, 
     
    161162 * receives RTP packet. 
    162163 */ 
    163 static void transport_rtp_cb(void *user_data, void *pkt, pj_ssize_t size) 
    164 { 
    165     struct tp_adapter *adapter = (struct tp_adapter*)user_data; 
    166  
    167     pj_assert(adapter->stream_rtp_cb != NULL); 
     164static void transport_rtp_cb2(pjmedia_tp_cb_param *param) 
     165{ 
     166    struct tp_adapter *adapter = (struct tp_adapter*)param->user_data; 
     167 
     168    pj_assert(adapter->stream_rtp_cb != NULL || 
     169              adapter->stream_rtp_cb2 != NULL); 
    168170 
    169171    /* Call stream's callback */ 
    170     adapter->stream_rtp_cb(adapter->stream_user_data, pkt, size); 
     172    if (adapter->stream_rtp_cb2) { 
     173        pjmedia_tp_cb_param cbparam; 
     174         
     175        pj_memcpy(&cbparam, param, sizeof(cbparam)); 
     176        cbparam.user_data = adapter->stream_user_data; 
     177        adapter->stream_rtp_cb2(&cbparam); 
     178    } else { 
     179        adapter->stream_rtp_cb(adapter->stream_user_data, param->pkt, 
     180                               param->size); 
     181    } 
    171182} 
    172183 
     
    200211    pj_assert(adapter->stream_user_data == NULL); 
    201212    adapter->stream_user_data = att_param->user_data; 
    202     adapter->stream_rtp_cb = att_param->rtp_cb; 
     213    if (att_param->rtp_cb) { 
     214        adapter->stream_rtp_cb = att_param->rtp_cb; 
     215    } else { 
     216        adapter->stream_rtp_cb2 = att_param->rtp_cb2; 
     217    } 
    203218    adapter->stream_rtcp_cb = att_param->rtcp_cb; 
    204219    adapter->stream_ref = att_param->stream; 
    205220 
    206     att_param->rtp_cb = &transport_rtp_cb; 
     221    att_param->rtp_cb2 = &transport_rtp_cb2; 
    207222    att_param->rtcp_cb = &transport_rtcp_cb; 
    208223    att_param->user_data = adapter; 
     
    212227        adapter->stream_user_data = NULL; 
    213228        adapter->stream_rtp_cb = NULL; 
     229        adapter->stream_rtp_cb2 = NULL; 
    214230        adapter->stream_rtcp_cb = NULL; 
    215231        adapter->stream_ref = NULL; 
Note: See TracChangeset for help on using the changeset viewer.