Ignore:
Timestamp:
Nov 3, 2016 9:39:20 AM (4 years ago)
Author:
riza
Message:

Re #1977: Add attach2() and pjmedia_transport_attach2() to pjmedia transport interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/transport.h

    r4811 r5478  
    242242 
    243243/** 
     244 * Forward declaration for media transport attach param. 
     245 */ 
     246typedef struct pjmedia_transport_attach_param pjmedia_transport_attach_param; 
     247 
     248/** 
    244249 * This enumeration specifies the general behaviour of media processing 
    245250 */ 
     
    304309     * to be used by the stream for the first time, and it tells the transport 
    305310     * about remote RTP address to send the packet and some callbacks to be  
    306      * called for incoming packets. 
     311     * called for incoming packets. This function exists for backwards 
     312     * compatibility. Transports should implement attach2 instead. 
    307313     * 
    308314     * Application should call #pjmedia_transport_attach() instead of  
     
    434440     */ 
    435441    pj_status_t (*destroy)(pjmedia_transport *tp); 
     442 
     443    /** 
     444     * This function is called by the stream when the transport is about 
     445     * to be used by the stream for the first time, and it tells the transport 
     446     * about remote RTP address to send the packet and some callbacks to be 
     447     * called for incoming packets. 
     448     * 
     449     * Application should call #pjmedia_transport_attach2() instead of 
     450     * calling this function directly. 
     451     */ 
     452    pj_status_t (*attach2)(pjmedia_transport *tp, 
     453                           pjmedia_transport_attach_param *att_param); 
    436454}; 
    437455 
     
    546564}; 
    547565 
     566 
     567/** 
     568 * This structure describes the data passed when calling 
     569 * #pjmedia_transport_attach2(). 
     570 */ 
     571struct pjmedia_transport_attach_param 
     572{ 
     573    /** 
     574     * The media stream. 
     575     */ 
     576    void *stream; 
     577 
     578    /** 
     579     * Indicate the stream type, either it's audio (PJMEDIA_TYPE_AUDIO)  
     580     * or video (PJMEDIA_TYPE_VIDEO). 
     581     */ 
     582    pjmedia_type media_type; 
     583 
     584    /** 
     585     * Remote RTP address to send RTP packet to. 
     586     */ 
     587    pj_sockaddr rem_addr; 
     588 
     589    /** 
     590     * Optional remote RTCP address. If the argument is NULL 
     591     * or if the address is zero, the RTCP address will be 
     592     * calculated from the RTP address (which is RTP port plus one). 
     593     */ 
     594    pj_sockaddr rem_rtcp; 
     595 
     596    /** 
     597     * Length of the remote address. 
     598     */ 
     599    unsigned addr_len; 
     600 
     601    /** 
     602     * Arbitrary user data to be set when the callbacks are called. 
     603     */ 
     604    void *user_data; 
     605 
     606    /** 
     607     * Callback to be called when RTP packet is received on the transport. 
     608     */ 
     609    void (*rtp_cb)(void *user_data, void *pkt, pj_ssize_t); 
     610 
     611    /** 
     612     * Callback to be called when RTCP packet is received on the transport. 
     613     */ 
     614    void (*rtcp_cb)(void *user_data, void *pkt, pj_ssize_t); 
     615}; 
    548616 
    549617/** 
     
    600668    } 
    601669    return NULL; 
     670} 
     671 
     672 
     673/** 
     674 * Attach callbacks to be called on receipt of incoming RTP/RTCP packets. 
     675 * This is just a simple wrapper which calls <tt>attach2()</tt> member of 
     676 * the transport if it is implemented, otherwise it calls <tt>attach()</tt> 
     677 * member of the transport. 
     678 * 
     679 * @param tp        The media transport. 
     680 * @param att_param The transport attach param. 
     681 * 
     682 * @return          PJ_SUCCESS on success, or the appropriate error code. 
     683 */ 
     684PJ_INLINE(pj_status_t) pjmedia_transport_attach2(pjmedia_transport *tp, 
     685                                      pjmedia_transport_attach_param *att_param) 
     686{ 
     687    if (tp->op->attach2) { 
     688        return tp->op->attach2(tp, att_param); 
     689    } else { 
     690        return tp->op->attach(tp, att_param->user_data,  
     691                              (pj_sockaddr_t*)&att_param->rem_addr,  
     692                              (pj_sockaddr_t*)&att_param->rem_rtcp,  
     693                              att_param->addr_len, att_param->rtp_cb,  
     694                              att_param->rtcp_cb); 
     695    } 
    602696} 
    603697 
Note: See TracChangeset for help on using the changeset viewer.