Ignore:
Timestamp:
May 17, 2006 5:17:39 PM (18 years ago)
Author:
bennylp
Message:

Major modification in pjmedia to split stream transport into separate functionality, to allow using custom transports with streams

File:
1 edited

Legend:

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

    r438 r452  
    7070    pjmedia_type        type;       /**< Media type (audio, video)          */ 
    7171    pjmedia_dir         dir;        /**< Media direction.                   */ 
    72     pjmedia_sock_info   sock_info;  /**< Media transport (RTP/RTCP sockets) */ 
    7372    pj_sockaddr_in      rem_addr;   /**< Remote RTP address                 */ 
    7473    pjmedia_codec_info  fmt;        /**< Incoming codec format info.        */ 
     
    101100 
    102101/** 
     102 * @see pjmedia_transport_op. 
     103 */ 
     104typedef struct pjmedia_transport pjmedia_transport; 
     105 
     106 
     107/** 
     108 * This structure describes the operations for the stream transport. 
     109 */ 
     110struct pjmedia_transport_op 
     111{ 
     112    /** 
     113     * This function is called by the stream when the transport is about 
     114     * to be used by the stream for the first time, and it tells the transport 
     115     * about remote RTP address to send the packet and some callbacks to be  
     116     * called for incoming packets. 
     117     */ 
     118    pj_status_t (*attach)(pjmedia_transport *tp, 
     119                          pjmedia_stream *strm, 
     120                          const pj_sockaddr_t *rem_addr, 
     121                          unsigned addr_len, 
     122                          void (*rtp_cb)(pjmedia_stream*, 
     123                                         const void*, 
     124                                         pj_ssize_t), 
     125                          void (*rtcp_cb)(pjmedia_stream*, 
     126                                          const void*, 
     127                                          pj_ssize_t)); 
     128 
     129    /** 
     130     * This function is called by the stream when the stream is no longer 
     131     * need the transport (normally when the stream is about to be closed). 
     132     */ 
     133    void (*detach)(pjmedia_transport *tp, 
     134                   pjmedia_stream *strm); 
     135 
     136    /** 
     137     * This function is called by the stream to send RTP packet using the  
     138     * transport. 
     139     */ 
     140    pj_status_t (*send_rtp)(pjmedia_transport *tp, 
     141                            const void *pkt, 
     142                            pj_size_t size); 
     143 
     144    /** 
     145     * This function is called by the stream to send RTCP packet using the 
     146     * transport. 
     147     */ 
     148    pj_status_t (*send_rtcp)(pjmedia_transport *tp, 
     149                             const void *pkt, 
     150                             pj_size_t size); 
     151 
     152}; 
     153 
     154 
     155/** 
     156 * @see pjmedia_transport_op. 
     157 */ 
     158typedef struct pjmedia_transport_op pjmedia_transport_op; 
     159 
     160 
     161/** 
     162 * This structure declares stream transport. A stream transport is called 
     163 * by the stream to transmit a packet, and will notify stream when 
     164 * incoming packet is arrived. 
     165 */ 
     166struct pjmedia_transport 
     167{ 
     168    char                  name[PJ_MAX_OBJ_NAME]; 
     169 
     170    pjmedia_transport_op *op; 
     171}; 
     172 
     173 
     174 
     175/** 
    103176 * Create a media stream based on the specified parameter. After the stream 
    104177 * has been created, application normally would want to get the media port  
     
    115188 *                      buffer needs to preallocate some storage. 
    116189 * @param info          Stream information. 
     190 * @param tp            Stream transport instance used to transmit  
     191 *                      and receive RTP/RTCP packets to/from the underlying  
     192 *                      transport.  
    117193 * @param user_data     Arbitrary user data (for future callback feature). 
    118194 * @param p_stream      Pointer to receive the media stream. 
     
    123199                                           pj_pool_t *pool, 
    124200                                           const pjmedia_stream_info *info, 
     201                                           pjmedia_transport *tp, 
    125202                                           void *user_data, 
    126203                                           pjmedia_stream **p_stream); 
     
    152229 
    153230/** 
     231 * Get the media transport object associated with this stream. 
     232 * 
     233 * @param st            The media stream. 
     234 * 
     235 * @return              The transport object being used by the stream. 
     236 */ 
     237PJ_DECL(pjmedia_transport*) pjmedia_stream_get_transport(pjmedia_stream *st); 
     238 
     239 
     240/** 
    154241 * Start the media stream. This will start the appropriate channels 
    155242 * in the media stream, depending on the media direction that was set 
     
    225312 
    226313/** 
    227  * Retrieve the incoming DTMF digits from the stream. Note that the digits 
    228  * buffer will not be NULL terminated. 
     314 * Retrieve the incoming DTMF digits from the stream, and remove the digits 
     315 * from stream's DTMF buffer. Note that the digits buffer will not be NULL  
     316 * terminated. 
    229317 * 
    230318 * @param stream        The media stream. 
Note: See TracChangeset for help on using the changeset viewer.