Ignore:
Timestamp:
Feb 8, 2006 10:43:39 PM (18 years ago)
Author:
bennylp
Message:

Finished new pjmedia rewrite

File:
1 edited

Legend:

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

    r121 r159  
    2828#include <pjmedia/sound.h> 
    2929#include <pjmedia/codec.h> 
    30 #include <pjmedia/mediamgr.h> 
     30#include <pjmedia/endpoint.h> 
    3131#include <pj/sock.h> 
    3232 
     
    4040 */ 
    4141 
    42 typedef struct pj_media_stream_t pj_media_stream_t; 
     42/** 
     43 * Opaque declaration for media channel. 
     44 * Media channel is unidirectional flow of media from sender to 
     45 * receiver. 
     46 */ 
     47typedef struct pjmedia_channel pjmedia_channel; 
    4348 
    44 /** Parameter for creating channel. */ 
    45 typedef struct pj_media_stream_create_param 
     49/**  
     50 * This structure describes media stream information. Each media stream 
     51 * corresponds to one "m=" line in SDP session descriptor, and it has 
     52 * its own RTP/RTCP socket pair. 
     53 */ 
     54struct pjmedia_stream_info 
    4655{ 
    47     /** Codec ID, must NOT be NULL. */ 
    48     pj_codec_id          *codec_id; 
     56    pjmedia_type        type;       /**< Media type (audio, video)          */ 
     57    pjmedia_dir         dir;        /**< Media direction.                   */ 
     58    pjmedia_sock_info   sock_info;  /**< Media transport (RTP/RTCP sockets) */ 
     59    pj_sockaddr_in      rem_addr;   /**< Remote RTP address                 */ 
     60    pjmedia_codec_info  fmt;        /**< Codec format info.                 */ 
     61    pj_uint32_t         ssrc;       /**< RTP SSRC.                          */ 
     62    int                 jb_min;     /**< Jitter buffer min delay.           */ 
     63    int                 jb_max;     /**< Jitter buffer max delay.           */ 
     64    int                 jb_maxcnt;  /**< Jitter buffer max delay.           */ 
     65}; 
    4966 
    50     /** Media manager, must NOT be NULL. */ 
    51     pj_med_mgr_t         *mediamgr; 
    5267 
    53     /** Direction: IN_OUT, or IN only, or OUT only. */ 
    54     pj_media_dir_t        dir; 
     68/** 
     69 * Individual channel statistic. 
     70 */ 
     71struct pjmedia_channel_stat 
     72{ 
     73    pj_uint32_t pkt;        /**< Total number of packets.                   */ 
     74    pj_uint32_t bytes;      /**< Total number of bytes, including RTP hdr.  */ 
     75    pj_uint32_t lost;       /**< Total number of packet lost                */ 
     76}; 
    5577 
    56     /** RTP socket. */ 
    57     pj_sock_t            rtp_sock; 
     78/** 
     79 * Stream statistic. 
     80 */ 
     81struct pjmedia_stream_stat 
     82{ 
     83    pjmedia_channel_stat    enc;    /**< Encoder statistics.                */ 
     84    pjmedia_channel_stat    dec;    /**< Decoder statistics.                */ 
     85}; 
    5886 
    59     /** RTCP socket. */ 
    60     pj_sock_t            rtcp_sock; 
    6187 
    62     /** Address of remote */ 
    63     pj_sockaddr_in       *remote_addr; 
     88/** 
     89 * Create a media stream based on the specified stream parameter. 
     90 * All channels in the stream initially will be inactive. 
     91 * 
     92 * @param endpt         Media endpoint. 
     93 * @param pool          Pool to allocate memory for the stream. A large 
     94 *                      number of memory may be needed because jitter 
     95 *                      buffer needs to preallocate some storage. 
     96 * @param info          Stream information. 
     97 * @param p_stream      Pointer to receive the media stream. 
     98 * 
     99 * @return              PJ_SUCCESS on success. 
     100 */ 
     101PJ_DECL(pj_status_t) pjmedia_stream_create(pjmedia_endpt *endpt, 
     102                                           pj_pool_t *pool, 
     103                                           const pjmedia_stream_info *info, 
     104                                           pjmedia_stream **p_stream); 
    64105 
    65     /** RTP SSRC */ 
    66     pj_uint32_t           ssrc; 
     106/** 
     107 * Destroy the media stream. 
     108 * 
     109 * @param stream        The media stream. 
     110 * 
     111 * @return              PJ_SUCCESS on success. 
     112 */ 
     113PJ_DECL(pj_status_t) pjmedia_stream_destroy(pjmedia_stream *stream); 
    67114 
    68     /** Jitter buffer parameters. */ 
    69     int                   jb_min, jb_max, jb_maxcnt; 
     115/** 
     116 * Start the media stream. This will start the appropriate channels 
     117 * in the media stream, depending on the media direction that was set 
     118 * when the stream was created. 
     119 * 
     120 * @param stream        The media stream. 
     121 * 
     122 * @return              PJ_SUCCESS on success. 
     123 */ 
     124PJ_DECL(pj_status_t) pjmedia_stream_start(pjmedia_stream *stream); 
    70125 
    71 } pj_media_stream_create_param; 
    72126 
    73 typedef struct pj_media_stream_stat 
    74 { 
    75     pj_uint32_t pkt_tx, pkt_rx; /* packets transmitted/received */ 
    76     pj_uint32_t oct_tx, oct_rx; /* octets transmitted/received */ 
    77     pj_uint32_t jitter;         /* receive jitter in ms */ 
    78     pj_uint32_t pkt_lost;       /* total packet lost count */ 
    79 } pj_media_stream_stat; 
     127/** 
     128 * Get the stream statistics. 
     129 * 
     130 * @param stream        The media stream. 
     131 * @param stat          Media stream statistics. 
     132 * 
     133 * @return              PJ_SUCCESS on success. 
     134 */ 
     135PJ_DECL(pj_status_t) pjmedia_stream_get_stat( const pjmedia_stream *stream, 
     136                                              pjmedia_stream_stat *stat); 
    80137 
    81 PJ_DECL(pj_status_t) pj_media_stream_create (pj_pool_t *pool, 
    82                                              pj_media_stream_t **enc_stream, 
    83                                              pj_media_stream_t **dec_stream, 
    84                                              pj_media_stream_create_param *param); 
    85 PJ_DECL(pj_status_t) pj_media_stream_start (pj_media_stream_t *stream); 
    86 PJ_DECL(pj_status_t) pj_media_stream_get_stat (const pj_media_stream_t *stream, 
    87                                                pj_media_stream_stat *stat); 
    88 PJ_DECL(pj_status_t) pj_media_stream_pause (pj_media_stream_t *stream); 
    89 PJ_DECL(pj_status_t) pj_media_stream_resume (pj_media_stream_t *stream); 
    90 PJ_DECL(pj_status_t) pj_media_stream_destroy (pj_media_stream_t *stream); 
     138/** 
     139 * Pause the individual channel in the stream. 
     140 * 
     141 * @param channel       The media channel. 
     142 * @param dir           Which direction to pause. 
     143 * 
     144 * @return              PJ_SUCCESS on success. 
     145 */ 
     146PJ_DECL(pj_status_t) pjmedia_stream_pause( pjmedia_stream *stream, 
     147                                           pjmedia_dir dir); 
     148 
     149/** 
     150 * Resume the individual channel in the stream. 
     151 * 
     152 * @param channel       The media channel. 
     153 * @param dir           Which direction to resume. 
     154 * 
     155 * @return              PJ_SUCCESS on success; 
     156 */ 
     157PJ_DECL(pj_status_t) pjmedia_stream_resume(pjmedia_stream *stream, 
     158                                           pjmedia_dir dir); 
     159 
    91160 
    92161/** 
Note: See TracChangeset for help on using the changeset viewer.