Changeset 188


Ignore:
Timestamp:
Feb 15, 2006 12:24:23 PM (18 years ago)
Author:
bennylp
Message:

Created and updated PJMEDIA documentation

Location:
pjproject/trunk/pjmedia
Files:
1 added
26 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/build/pjmedia.dsp

    r159 r188  
    162162# Begin Source File 
    163163 
     164SOURCE=..\include\pjmedia\doxygen.h 
     165# End Source File 
     166# Begin Source File 
     167 
    164168SOURCE=..\include\pjmedia\endpoint.h 
    165169# End Source File 
  • pjproject/trunk/pjmedia/docs

    • Property svn:ignore set to
      html
      latex
      rtf
  • pjproject/trunk/pjmedia/docs/doxygen.cfg

    r1 r188  
    134134# the path. It is allowed to use relative paths in the argument list. 
    135135 
    136 STRIP_FROM_PATH        = "" 
     136STRIP_FROM_PATH        = "c:\project\pjproject" 
    137137 
    138138# The INTERNAL_DOCS tag determines if documentation  
     
    167167# which an include is specified. Set to NO to disable this. 
    168168 
    169 VERBATIM_HEADERS       = NO 
     169VERBATIM_HEADERS       = YES 
    170170 
    171171# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen  
     
    214214# declaration order. 
    215215 
    216 SORT_MEMBER_DOCS       = NO 
     216SORT_MEMBER_DOCS       = YES 
    217217 
    218218# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC  
     
    346346# with spaces. 
    347347 
    348 INPUT                  =  src/pjmedia 
     348INPUT                  =  include/pjmedia 
    349349 
    350350# If the value of the INPUT tag contains directories, you can use the  
     
    501501# standard header. 
    502502 
    503 HTML_HEADER            =  
     503HTML_HEADER            = ../pjlib/docs/header.html 
    504504 
    505505# The HTML_FOOTER tag can be used to specify a personal HTML footer for  
     
    507507# standard footer. 
    508508 
    509 HTML_FOOTER            =  
     509HTML_FOOTER            = ../pjlib/docs/footer.html 
    510510 
    511511# The HTML_STYLESHEET tag can be used to specify a user defined cascading  
     
    514514# will generate a default style sheet 
    515515 
    516 HTML_STYLESHEET        =  
     516HTML_STYLESHEET        = ../pjlib/docs/doxygen.css 
    517517 
    518518# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,  
     
    10071007SEARCHENGINE           = NO 
    10081008 
    1009 # The CGI_NAME tag should be the name of the CGI script that  
    1010 # starts the search engine (doxysearch) with the correct parameters.  
    1011 # A script with this name will be generated by doxygen. 
    1012  
    1013 CGI_NAME               = search.cgi 
    1014  
    1015 # The CGI_URL tag should be the absolute URL to the directory where the  
    1016 # cgi binaries are located. See the documentation of your http daemon for  
    1017 # details. 
    1018  
    1019 CGI_URL                =  
    1020  
    1021 # The DOC_URL tag should be the absolute URL to the directory where the  
    1022 # documentation is located. If left blank the absolute path to the  
    1023 # documentation, with file:// prepended to it, will be used. 
    1024  
    1025 DOC_URL                =  
    1026  
    1027 # The DOC_ABSPATH tag should be the absolute path to the directory where the  
    1028 # documentation is located. If left blank the directory on the local machine  
    1029 # will be used. 
    1030  
    1031 DOC_ABSPATH            =  
    1032  
    1033 # The BIN_ABSPATH tag must point to the directory where the doxysearch binary  
    1034 # is installed. 
    1035  
    1036 BIN_ABSPATH            = /usr/local/bin/ 
    1037  
    1038 # The EXT_DOC_PATHS tag can be used to specify one or more paths to  
    1039 # documentation generated for other projects. This allows doxysearch to search  
    1040 # the documentation for these projects as well. 
    1041  
    1042 EXT_DOC_PATHS          =  
  • pjproject/trunk/pjmedia/include/pjmedia.h

    r162 r188  
    2020#define __PJMEDIA_H__ 
    2121 
     22/** 
     23 * @file pjmedia.h 
     24 * @brief PJMEDIA main header file. 
     25 */ 
     26 
    2227#include <pjmedia/types.h> 
    2328#include <pjmedia/errno.h> 
  • pjproject/trunk/pjmedia/include/pjmedia/codec.h

    r176 r188  
    4444enum pjmedia_rtp_pt 
    4545{ 
    46     PJMEDIA_RTP_PT_PCMU = 0,        /* audio PCMU                           */ 
    47     PJMEDIA_RTP_PT_GSM  = 3,        /* audio GSM                            */ 
    48     PJMEDIA_RTP_PT_G723 = 4,        /* audio G723                           */ 
    49     PJMEDIA_RTP_PT_DVI4_8K = 5,     /* audio DVI4 8KHz                      */ 
    50     PJMEDIA_RTP_PT_DVI4_16K = 6,    /* audio DVI4 16Khz                     */ 
    51     PJMEDIA_RTP_PT_LPC = 7,         /* audio LPC                            */ 
    52     PJMEDIA_RTP_PT_PCMA = 8,        /* audio PCMA                           */ 
    53     PJMEDIA_RTP_PT_G722 = 9,        /* audio G722                           */ 
    54     PJMEDIA_RTP_PT_L16_2 = 10,      /* audio 16bit linear 44.1KHz stereo    */ 
    55     PJMEDIA_RTP_PT_L16_1 = 11,      /* audio 16bit linear 44.1KHz mono      */ 
    56     PJMEDIA_RTP_PT_QCELP = 12,      /* audio QCELP                          */ 
    57     PJMEDIA_RTP_PT_CN = 13,         /* audio Comfort Noise                  */ 
    58     PJMEDIA_RTP_PT_MPA = 14,        /* audio MPEG1/MPEG2 elementary streams */ 
    59     PJMEDIA_RTP_PT_G728 = 15,       /* audio G728                           */ 
    60     PJMEDIA_RTP_PT_DVI4_11K = 16,   /* audio DVI4 11.025KHz mono            */ 
    61     PJMEDIA_RTP_PT_DVI4_22K = 17,   /* audio DVI4 22.050KHz mono            */ 
    62     PJMEDIA_RTP_PT_G729 = 18,       /* audio G729                           */ 
    63  
    64     PJMEDIA_RTP_PT_CELB = 25,       /* video/comb Cell-B by Sun (RFC 2029) */ 
    65     PJMEDIA_RTP_PT_JPEG = 26,       /* video JPEG                           */ 
    66     PJMEDIA_RTP_PT_NV = 28,         /* video NV  by nv program by Xerox     */ 
    67     PJMEDIA_RTP_PT_H261 = 31,       /* video H261                           */ 
    68     PJMEDIA_RTP_PT_MPV = 32,        /* video MPEG1 or MPEG2 elementary      */ 
    69     PJMEDIA_RTP_PT_MP2T = 33,       /* video MPEG2 transport                */ 
    70     PJMEDIA_RTP_PT_H263 = 34,       /* video H263                           */ 
    71  
    72     PJMEDIA_RTP_PT_DYNAMIC = 96,    /* start of dynamic RTP payload         */ 
     46    PJMEDIA_RTP_PT_PCMU = 0,        /**< audio PCMU                         */ 
     47    PJMEDIA_RTP_PT_GSM  = 3,        /**< audio GSM                          */ 
     48    PJMEDIA_RTP_PT_G723 = 4,        /**< audio G723                         */ 
     49    PJMEDIA_RTP_PT_DVI4_8K = 5,     /**< audio DVI4 8KHz                    */ 
     50    PJMEDIA_RTP_PT_DVI4_16K = 6,    /**< audio DVI4 16Khz                   */ 
     51    PJMEDIA_RTP_PT_LPC = 7,         /**< audio LPC                          */ 
     52    PJMEDIA_RTP_PT_PCMA = 8,        /**< audio PCMA                         */ 
     53    PJMEDIA_RTP_PT_G722 = 9,        /**< audio G722                         */ 
     54    PJMEDIA_RTP_PT_L16_2 = 10,      /**< audio 16bit linear 44.1KHz stereo  */ 
     55    PJMEDIA_RTP_PT_L16_1 = 11,      /**< audio 16bit linear 44.1KHz mono    */ 
     56    PJMEDIA_RTP_PT_QCELP = 12,      /**< audio QCELP                        */ 
     57    PJMEDIA_RTP_PT_CN = 13,         /**< audio Comfort Noise                */ 
     58    PJMEDIA_RTP_PT_MPA = 14,        /**< audio MPEG1/MPEG2 elemetr. streams */ 
     59    PJMEDIA_RTP_PT_G728 = 15,       /**< audio G728                         */ 
     60    PJMEDIA_RTP_PT_DVI4_11K = 16,   /**< audio DVI4 11.025KHz mono          */ 
     61    PJMEDIA_RTP_PT_DVI4_22K = 17,   /**< audio DVI4 22.050KHz mono          */ 
     62    PJMEDIA_RTP_PT_G729 = 18,       /**< audio G729                         */ 
     63 
     64    PJMEDIA_RTP_PT_CELB = 25,       /**< video/comb Cell-B by Sun (RFC2029) */ 
     65    PJMEDIA_RTP_PT_JPEG = 26,       /**< video JPEG                         */ 
     66    PJMEDIA_RTP_PT_NV = 28,         /**< video NV  by nv program by Xerox   */ 
     67    PJMEDIA_RTP_PT_H261 = 31,       /**< video H261                         */ 
     68    PJMEDIA_RTP_PT_MPV = 32,        /**< video MPEG1 or MPEG2 elementary    */ 
     69    PJMEDIA_RTP_PT_MP2T = 33,       /**< video MPEG2 transport              */ 
     70    PJMEDIA_RTP_PT_H263 = 34,       /**< video H263                         */ 
     71 
     72    PJMEDIA_RTP_PT_DYNAMIC = 96,    /**< start of dynamic RTP payload       */ 
    7373 
    7474}; 
     
    362362struct pjmedia_codec_mgr 
    363363{ 
     364    /** List of codec factories registered to codec manager. */ 
    364365    pjmedia_codec_factory   factory_list; 
     366 
     367    /** Number of supported codesc. */ 
    365368    unsigned                codec_cnt; 
     369 
     370    /** Array of codec info. */ 
    366371    pjmedia_codec_info      codecs[PJMEDIA_CODEC_MGR_MAX_CODECS]; 
    367372}; 
  • pjproject/trunk/pjmedia/include/pjmedia/config.h

    r121 r188  
    2020#define __PJMED_CONFIG_H__ 
    2121 
    22 /** 
    23  * @defgroup PJMEDIA Media Stack 
    24  */ 
    25  
    2622 
    2723#endif  /* __PJMED_CONFIG_H__ */ 
  • pjproject/trunk/pjmedia/include/pjmedia/endpoint.h

    r176 r188  
    2222 
    2323/** 
    24  * @file mediamgr.h 
    25  * @brief Media Manager. 
     24 * @file endpoint.h 
     25 * @brief Media endpoint. 
    2626 */ 
    2727/** 
    28  * @defgroup PJMED_ENDPT Media Endpoint 
     28 * @defgroup PJMED_ENDPT Multimedia Endpoint 
    2929 * @ingroup PJMEDIA 
    3030 * @{ 
     
    9292 *                      this media endpoint. 
    9393 */ 
    94 PJ_DECL(pjmedia_codec_mgr*) pjmedia_endpt_get_codec_mgr(pjmedia_endpt *mgr); 
     94PJ_DECL(pjmedia_codec_mgr*) pjmedia_endpt_get_codec_mgr(pjmedia_endpt *endpt); 
    9595 
    9696 
  • pjproject/trunk/pjmedia/include/pjmedia/errno.h

    r176 r188  
    251251/** 
    252252 * @hideinitializer 
    253  * Unable to create codec. 
     253 * Codec internal creation error. 
    254254 */ 
    255255#define PJMEDIA_CODEC_EFAILED       (PJMEDIA_ERRNO_START+81)    /* 220081 */ 
     
    298298 
    299299/************************************************************ 
    300  * JITTER BUFFER 
     300 * RTP SESSION ERRORS 
     301 ***********************************************************/ 
     302/** 
     303 * @hideinitializer 
     304 * General invalid RTP packet error. 
     305 */ 
     306#define PJMEDIA_RTP_EINPKT          (PJMEDIA_ERRNO_START+120)    /* 220120 */ 
     307/** 
     308 * @hideinitializer 
     309 * Invalid RTP packet packing. 
     310 */ 
     311#define PJMEDIA_RTP_EINPACK         (PJMEDIA_ERRNO_START+121)    /* 220121 */ 
     312/** 
     313 * @hideinitializer 
     314 * Invalid RTP packet version. 
     315 */ 
     316#define PJMEDIA_RTP_EINVER          (PJMEDIA_ERRNO_START+122)    /* 220122 */ 
     317/** 
     318 * @hideinitializer 
     319 * RTP SSRC id mismatch. 
     320 */ 
     321#define PJMEDIA_RTP_EINSSRC         (PJMEDIA_ERRNO_START+123)    /* 220123 */ 
     322/** 
     323 * @hideinitializer 
     324 * RTP payload type mismatch. 
     325 */ 
     326#define PJMEDIA_RTP_EINPT           (PJMEDIA_ERRNO_START+124)    /* 220124 */ 
     327/** 
     328 * @hideinitializer 
     329 * Invalid RTP packet length. 
     330 */ 
     331#define PJMEDIA_RTP_EINLEN          (PJMEDIA_ERRNO_START+125)    /* 220125 */ 
     332/** 
     333 * @hideinitializer 
     334 * RTP session restarted. 
     335 */ 
     336#define PJMEDIA_RTP_ESESSRESTART    (PJMEDIA_ERRNO_START+130)    /* 220130 */ 
     337/** 
     338 * @hideinitializer 
     339 * RTP session in probation 
     340 */ 
     341#define PJMEDIA_RTP_ESESSPROBATION  (PJMEDIA_ERRNO_START+131)    /* 220131 */ 
     342/** 
     343 * @hideinitializer 
     344 * Bad RTP sequence number 
     345 */ 
     346#define PJMEDIA_RTP_EBADSEQ         (PJMEDIA_ERRNO_START+132)    /* 220132 */ 
     347 
     348 
     349/************************************************************ 
     350 * JITTER BUFFER ERRORS 
    301351 ***********************************************************/ 
    302352 
  • pjproject/trunk/pjmedia/include/pjmedia/jbuf.h

    r169 r188  
    2525 * @brief Adaptive jitter buffer implementation. 
    2626 */ 
     27#include <pjmedia/types.h> 
     28 
    2729/** 
    2830 * @defgroup PJMED_JBUF Adaptive jitter buffer 
    2931 * @ingroup PJMEDIA 
    3032 * @{ 
     33 * 
    3134 */ 
    32  
    33 #include <pjmedia/types.h> 
    3435 
    3536 
     
    3738 
    3839 
     40/** 
     41 * Types of frame returned by the jitter buffer. 
     42 */ 
    3943enum pjmedia_jb_frame_type  
    4044{ 
    41     PJMEDIA_JB_MISSING_FRAME   = 0, 
    42     PJMEDIA_JB_NORMAL_FRAME    = 1, 
    43     PJMEDIA_JB_ZERO_FRAME      = 2, 
     45    PJMEDIA_JB_MISSING_FRAME   = 0, /**< No frame because it's missing.     */ 
     46    PJMEDIA_JB_NORMAL_FRAME    = 1, /**< Normal frame is being returned.    */ 
     47    PJMEDIA_JB_ZERO_FRAME      = 2, /**< Zero frame is being returned.      */ 
    4448}; 
    4549 
    4650 
    47 #define PJMEDIA_JB_DEFAULT_INIT_PREFETCH    15 
     51/** 
     52 * The constant PJMEDIA_JB_DEFAULT_INIT_DELAY specifies default jitter 
     53 * buffer prefetch count during jitter buffer creation. 
     54 */ 
     55#define PJMEDIA_JB_DEFAULT_INIT_DELAY    15 
    4856 
    4957 
     58/** 
     59 * Create the jitter buffer. This function may allocate large chunk of 
     60 * memory to keep the frames in the buffer. 
     61 * 
     62 * @param pool          The pool to allocate memory. 
     63 * @param frame_size    The size of each frame that will be kept in the 
     64 *                      jitter buffer. The value here normaly corresponds 
     65 *                      to the RTP payload size according to the codec 
     66 *                      being used. 
     67 * @param init_delay    Initial jitter buffer delay, in number of frames. 
     68 * @param max_count     Maximum jitter buffer delay, in number of frames. 
     69 * @param p_jb          Pointer to receive jitter buffer instance. 
     70 * 
     71 * @return              PJ_SUCCESS on success. 
     72 */ 
    5073PJ_DECL(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool,  
    5174                                        int frame_size,  
    52                                         int initial_prefetch,  
     75                                        int init_delay,  
    5376                                        int max_count, 
    5477                                        pjmedia_jbuf **p_jb); 
     78 
     79/** 
     80 * Destroy jitter buffer instance. 
     81 * 
     82 * @param jb            The jitter buffer. 
     83 * 
     84 * @return              PJ_SUCCESS on success. 
     85 */ 
    5586PJ_DECL(pj_status_t) pjmedia_jbuf_destroy(pjmedia_jbuf *jb); 
     87 
     88 
     89/** 
     90 * Put a frame to the jitter buffer. If the frame can be accepted (based 
     91 * on the sequence number), the jitter buffer will copy the frame and put 
     92 * it in the appropriate position in the buffer. 
     93 * 
     94 * Application MUST manage it's own synchronization when multiple threads 
     95 * are accessing the jitter buffer at the same time. 
     96 * 
     97 * @param jb            The jitter buffer. 
     98 * @param frame         Pointer to frame buffer to be stored in the jitter 
     99 *                      buffer. 
     100 * @param size          The frame size. 
     101 * @param frame_seq     The frame sequence number. 
     102 * 
     103 * @return              PJ_SUCCESS on success. 
     104 */ 
    56105PJ_DECL(pj_status_t) pjmedia_jbuf_put_frame(pjmedia_jbuf *jb,  
    57106                                            const void *frame,  
    58                                             pj_size_t frame_size,  
     107                                            pj_size_t size,  
    59108                                            int frame_seq); 
     109 
     110/** 
     111 * Get a frame from the jitter buffer. The jitter buffer will return the 
     112 * oldest frame from it's buffer, when it is available. 
     113 * 
     114 * Application MUST manage it's own synchronization when multiple threads 
     115 * are accessing the jitter buffer at the same time. 
     116 * 
     117 * @param jb            The jitter buffer. 
     118 * @param frame         Buffer to receive the payload from the jitter buffer. 
     119 *                      Application MUST make sure that the buffer has 
     120 *                      appropriate size (i.e. not less than the frame size, 
     121 *                      as specified when the jitter buffer was created). 
     122 *                      The jitter buffer only copied a frame to this  
     123 *                      buffer when the frame type returned by this function 
     124 *                      is PJMEDIA_JB_NORMAL_FRAME. 
     125 * @param p_frm_type    Pointer to receive frame type. If jitter buffer is 
     126 *                      currently empty or bufferring, the frame type will 
     127 *                      be set to PJMEDIA_JB_ZERO_FRAME, and no frame will 
     128 *                      be copied. If the jitter buffer detects that frame is 
     129 *                      missing with current sequence number, the frame type 
     130 *                      will be set to PJMEDIA_JB_MISSING_FRAME, and no 
     131 *                      frame will be copied. If there is a frame, the jitter 
     132 *                      buffer will copy the frame to the buffer, and frame 
     133 *                      type will be set to PJMEDIA_JB_NORMAL_FRAME. 
     134 * 
     135 * @return              Always returns PJ_SUCCESS. 
     136 */ 
    60137PJ_DECL(pj_status_t) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb,  
    61138                                             void *frame,  
    62                                              char *p_frame_type); 
    63 PJ_DECL(unsigned)    pjmedia_jbuf_get_prefetch_size(pjmedia_jbuf *jb); 
    64 PJ_DECL(unsigned)    pjmedia_jbuf_get_current_size(pjmedia_jbuf *jb); 
     139                                             char *p_frm_type); 
     140 
     141/** 
     142 * Retrieve the current value of jitter buffer minimum delay, in number 
     143 * of frames. 
     144 * 
     145 * @param jb            The jitter buffer. 
     146 * 
     147 * @return              Number of frames, indicating the minimum delay that  
     148 *                      will be applied by the jitter buffer between frame 
     149 *                      arrival and frame retrieval. 
     150 */ 
     151PJ_DECL(unsigned)    pjmedia_jbuf_get_min_delay_size(pjmedia_jbuf *jb); 
     152 
     153 
     154/** 
     155 * Retrieve the current delay value, in number of frames. 
     156 * 
     157 * @param jb            The jitter buffer. 
     158 * 
     159 * @return              Number of frames, indicating the delay between frame 
     160 *                      arrival and frame retrieval. 
     161 */ 
     162PJ_DECL(unsigned)    pjmedia_jbuf_get_delay(pjmedia_jbuf *jb); 
    65163 
    66164 
  • pjproject/trunk/pjmedia/include/pjmedia/rtcp.h

    r121 r188  
    2525 */ 
    2626 
    27 #include <pj/types.h> 
     27#include <pjmedia/types.h> 
    2828#include <pjmedia/rtp.h> 
    2929 
     
    3232 
    3333/** 
    34  * @defgroup PJMED_RTCP RTCP 
     34 * @defgroup PJMED_RTCP RTCP Management 
    3535 * @ingroup PJMEDIA 
    3636 * @{ 
     
    4242struct pj_rtcp_sr 
    4343{ 
    44     pj_uint32_t     ssrc; 
    45     pj_uint32_t     ntp_sec; 
    46     pj_uint32_t     ntp_frac; 
    47     pj_uint32_t     rtp_ts; 
    48     pj_uint32_t     sender_pcount; 
    49     pj_uint32_t     sender_bcount; 
    50 }; 
    51  
     44    pj_uint32_t     ssrc;           /**< SSRC identification.           */ 
     45    pj_uint32_t     ntp_sec;        /**< NTP time, seconds part.        */ 
     46    pj_uint32_t     ntp_frac;       /**< NTP time, fractions part.      */ 
     47    pj_uint32_t     rtp_ts;         /**< RTP timestamp.                 */ 
     48    pj_uint32_t     sender_pcount;  /**< Sender packet cound.           */ 
     49    pj_uint32_t     sender_bcount;  /**< Sender octet/bytes count.      */ 
     50}; 
     51 
     52/** 
     53 * @see pj_rtcp_sr 
     54 */ 
    5255typedef struct pj_rtcp_sr pj_rtcp_sr; 
    5356 
     
    5760struct pj_rtcp_rr 
    5861{ 
    59     pj_uint32_t     ssrc; 
     62    pj_uint32_t     ssrc;           /**< SSRC identification.           */ 
    6063#if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0 
    61     pj_uint32_t     fract_lost:8; 
    62     pj_uint32_t     total_lost_2:8; 
    63     pj_uint32_t     total_lost_1:8; 
    64     pj_uint32_t     total_lost_0:8; 
     64    pj_uint32_t     fract_lost:8;   /**< Fraction lost.                 */ 
     65    pj_uint32_t     total_lost_2:8; /**< Total lost, bit 16-23.         */ 
     66    pj_uint32_t     total_lost_1:8; /**< Total lost, bit 8-15.          */ 
     67    pj_uint32_t     total_lost_0:8; /**< Total lost, bit 0-7.           */ 
    6568#else 
    66     pj_uint32_t     fract_lost:8; 
    67     pj_uint32_t     total_lost_0:8; 
    68     pj_uint32_t     total_lost_1:8; 
    69     pj_uint32_t     total_lost_2:8; 
     69    pj_uint32_t     fract_lost:8;   /**< Fraction lost.                 */ 
     70    pj_uint32_t     total_lost_0:8; /**< Total lost, bit 0-7.           */ 
     71    pj_uint32_t     total_lost_1:8; /**< Total lost, bit 8-15.          */ 
     72    pj_uint32_t     total_lost_2:8; /**< Total lost, bit 16-23.         */ 
    7073#endif   
    71     pj_uint32_t     last_seq; 
    72     pj_uint32_t     jitter; 
    73     pj_uint32_t     lsr; 
    74     pj_uint32_t     dlsr; 
    75 }; 
    76  
     74    pj_uint32_t     last_seq;       /**< Last sequence number.          */ 
     75    pj_uint32_t     jitter;         /**< Jitter.                        */ 
     76    pj_uint32_t     lsr;            /**< Last SR.                       */ 
     77    pj_uint32_t     dlsr;           /**< Delay since last SR.           */ 
     78}; 
     79 
     80/** 
     81 * @see pj_rtcp_rr 
     82 */ 
    7783typedef struct pj_rtcp_rr pj_rtcp_rr; 
    7884 
     85 
    7986/** 
    8087 * RTCP common header. 
     
    8390{ 
    8491#if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0 
    85     unsigned        version:2;  /* packet type            */ 
    86     unsigned        p:1;        /* padding flag           */ 
    87     unsigned        count:5;    /* varies by payload type */ 
    88     unsigned        pt:8;       /* payload type           */ 
     92    unsigned        version:2;  /**< packet type            */ 
     93    unsigned        p:1;        /**< padding flag           */ 
     94    unsigned        count:5;    /**< varies by payload type */ 
     95    unsigned        pt:8;       /**< payload type           */ 
    8996#else 
    90     unsigned        count:5;    /* varies by payload type */ 
    91     unsigned        p:1;        /* padding flag           */ 
    92     unsigned        version:2;  /* packet type            */ 
    93     unsigned        pt:8;       /* payload type           */ 
     97    unsigned        count:5;    /**< varies by payload type */ 
     98    unsigned        p:1;        /**< padding flag           */ 
     99    unsigned        version:2;  /**< packet type            */ 
     100    unsigned        pt:8;       /**< payload type           */ 
    94101#endif 
    95     pj_uint16_t     length;     /* packet length          */ 
    96 }; 
    97  
     102    pj_uint16_t     length;     /**< packet length          */ 
     103}; 
     104 
     105/** 
     106 * @see pj_rtcp_common 
     107 */ 
    98108typedef struct pj_rtcp_common pj_rtcp_common; 
    99109 
     
    103113struct pj_rtcp_pkt 
    104114{ 
    105     pj_rtcp_common  common;      
    106     pj_rtcp_sr      sr; 
    107     pj_rtcp_rr      rr;         /* variable-length list */ 
    108 }; 
    109  
     115    pj_rtcp_common  common;     /**< Common header.         */ 
     116    pj_rtcp_sr      sr;         /**< Sender report.         */ 
     117    pj_rtcp_rr      rr;         /**< variable-length list   */ 
     118}; 
     119 
     120/** 
     121 * @see pj_rtcp_pkt 
     122 */ 
    110123typedef struct pj_rtcp_pkt pj_rtcp_pkt; 
    111124 
     125 
    112126/** 
    113127 * NTP time representation. 
     
    115129struct pj_rtcp_ntp_rec 
    116130{ 
    117     pj_uint32_t     hi; 
    118     pj_uint32_t     lo; 
    119 }; 
    120  
     131    pj_uint32_t     hi;         /**< High order 32-bit part.    */ 
     132    pj_uint32_t     lo;         /**< Lo order 32-bit part.      */ 
     133}; 
     134 
     135/** 
     136 * @see pj_rtcp_ntp_rec 
     137 */ 
    121138typedef struct pj_rtcp_ntp_rec pj_rtcp_ntp_rec; 
    122139 
     140 
     141 
    123142/** 
    124143 * RTCP session. 
     
    126145struct pj_rtcp_session 
    127146{ 
    128     pj_rtcp_pkt         rtcp_pkt; 
     147    pj_rtcp_pkt     rtcp_pkt;       /**< Cached RTCP packet.                */ 
    129148     
    130     pj_rtp_seq_session  seq_ctrl; 
    131  
    132     pj_uint32_t         received;       /* packets received */ 
    133     pj_uint32_t         expected_prior; /* packet expected at last interval */ 
    134     pj_uint32_t         received_prior; /* packet received at last interval */ 
    135     pj_int32_t          transit;        /* relative trans time for prev pkt */ 
    136     pj_uint32_t         jitter;         /* estimated jitter */ 
     149    pjmedia_rtp_seq_session seq_ctrl;   /**< RTCP sequence number control.  */ 
     150 
     151    pj_uint32_t     received;       /**< # pkts received                    */ 
     152    pj_uint32_t     expected_prior; /**< # pkts expected at last interval  */ 
     153    pj_uint32_t     received_prior; /**< # pkts received at last interval  */ 
     154    pj_int32_t      transit;        /**< Relative trans time for prev pkt  */ 
     155    pj_uint32_t     jitter;         /**< Estimated jitter                  */ 
    137156     
    138     pj_rtcp_ntp_rec     rtcp_lsr;       /* NTP timestamp in last sender report received */ 
    139     unsigned            rtcp_lsr_time;  /* Time when last RTCP SR is received. */ 
    140     unsigned            peer_ssrc;      /* Peer SSRC */ 
     157    pj_rtcp_ntp_rec rtcp_lsr;       /**< NTP ts in last SR received        */ 
     158    unsigned        rtcp_lsr_time;  /**< Time when last SR is received.    */ 
     159    pj_uint32_t     peer_ssrc;      /**< Peer SSRC                          */ 
    141160     
    142161}; 
    143162 
     163/** 
     164 * @see pj_rtcp_session 
     165 */ 
    144166typedef struct pj_rtcp_session pj_rtcp_session; 
    145167 
    146 /** 
    147  * Init RTCP session. 
    148  * @param session The session 
    149  * @param ssrc The SSRC used in to identify the session. 
     168 
     169/** 
     170 * Initialize RTCP session. 
     171 * 
     172 * @param session   The session 
     173 * @param ssrc      The SSRC used in to identify the session. 
    150174 */ 
    151175PJ_DECL(void) pj_rtcp_init( pj_rtcp_session *session, pj_uint32_t ssrc ); 
    152176 
    153 /** 
    154  * Deinit RTCP session. 
    155  * @param session The session. 
     177 
     178/** 
     179 * Deinitialize RTCP session. 
     180 * 
     181 * @param session   The session. 
    156182 */ 
    157183PJ_DECL(void) pj_rtcp_fini( pj_rtcp_session *session); 
     184 
    158185 
    159186/** 
    160187 * Call this function everytime an RTP packet is received to let the RTCP 
    161188 * session do its internal calculations. 
    162  * @param session The session. 
    163  * @param seq The RTP packet sequence number, in host byte order. 
    164  * @param ts The RTP packet timestamp, in host byte order. 
    165  */ 
    166 PJ_DECL(void) pj_rtcp_rx_rtp( pj_rtcp_session *session, pj_uint16_t seq, pj_uint32_t ts ); 
     189 * 
     190 * @param session   The session. 
     191 * @param seq       The RTP packet sequence number, in host byte order. 
     192 * @param ts        The RTP packet timestamp, in host byte order. 
     193 */ 
     194PJ_DECL(void) pj_rtcp_rx_rtp( pj_rtcp_session *session, pj_uint16_t seq,  
     195                              pj_uint32_t ts ); 
     196 
    167197 
    168198/** 
    169199 * Call this function everytime an RTP packet is sent to let the RTCP session 
    170200 * do its internal calculations. 
    171  * @param session The session. 
    172  * @param bytes_payload_size The payload size of the RTP packet (ie packet minus 
    173  *             RTP header). 
    174  */ 
    175 PJ_DECL(void) pj_rtcp_tx_rtp( pj_rtcp_session *session, pj_uint16_t bytes_payload_size ); 
     201 * 
     202 * @param session   The session. 
     203 * @param ptsize    The payload size of the RTP packet (ie packet minus 
     204 *                  RTP header) in bytes. 
     205 */ 
     206PJ_DECL(void) pj_rtcp_tx_rtp( pj_rtcp_session *session, pj_uint16_t ptsize ); 
     207 
    176208 
    177209/** 
    178210 * Build a RTCP SR/RR packet to be transmitted to remote RTP peer. 
    179211 * @param session The session. 
    180  * @param rtcp_pkt [output] Upon return, it will contain pointer to the RTCP packet. 
    181  * @param len [output] Upon return, it will indicate the size of the RTCP packet. 
    182  */ 
    183 PJ_DECL(void) pj_rtcp_build_rtcp( pj_rtcp_session *session, pj_rtcp_pkt **rtcp_pkt, int *len ); 
     212 * 
     213 * @param rtcp_pkt  [output] Upon return, it will contain pointer to the  
     214 *                  RTCP packet. 
     215 * @param len       [output] Upon return, it will indicate the size of  
     216 *                  the RTCP packet. 
     217 */ 
     218PJ_DECL(void) pj_rtcp_build_rtcp( pj_rtcp_session *session,  
     219                                  pj_rtcp_pkt **rtcp_pkt,  
     220                                  int *len ); 
     221 
    184222 
    185223/** 
  • pjproject/trunk/pjmedia/include/pjmedia/rtp.h

    r159 r188  
    2020#define __PJMEDIA_RTP_H__ 
    2121 
    22 #include <pj/types.h> 
    2322 
    2423/** 
    2524 * @file rtp.h 
    26  * @brief RTP implementation. 
    27  */ 
     25 * @brief RTP packet and RTP session declarations. 
     26 */ 
     27#include <pjmedia/types.h> 
     28 
    2829 
    2930PJ_BEGIN_DECL 
     
    3132 
    3233/** 
    33  * @defgroup PJMED_RTP RTP 
     34 * @defgroup PJMED_RTP RTP Packet and RTP Session Management 
    3435 * @ingroup PJMEDIA 
    3536 * @{ 
     
    3940 * on any transports (sockets), to promote even more use. 
    4041 * 
    41  * An RTCP implementation is also separated from this module. 
     42 * An RTCP implementation is available, in separate module. 
    4243 * 
    4344 * The functions that are provided by this module: 
     
    5051 * \section P1 How to Use the RTP Module 
    5152 *  
    52  * First application must call #pj_rtp_session_init to initialize the RTP  
     53 * First application must call #pjmedia_rtp_session_init() to initialize the RTP  
    5354 * session. 
    5455 * 
    5556 * When application wants to send RTP packet, it needs to call  
    56  * #pj_rtp_encode_rtp to build the RTP header. Note that this WILL NOT build 
     57 * #pjmedia_rtp_encode_rtp() to build the RTP header. Note that this WILL NOT build 
    5758 * the complete RTP packet, but instead only the header. Application can 
    5859 * then either concatenate the header with the payload, or send the two 
     
    6162 * 
    6263 * When application receives an RTP packet, first it should call 
    63  * #pj_rtp_decode_rtp to decode RTP header and payload, then it should call 
    64  * #pj_rtp_session_update to check whether we can process the RTP payload, 
     64 * #pjmedia_rtp_decode_rtp to decode RTP header and payload, then it should call 
     65 * #pjmedia_rtp_session_update to check whether we can process the RTP payload, 
    6566 * and to let the RTP session updates its internal status. The decode function 
    6667 * is guaranteed to point the payload to the correct position regardless of 
     
    7071 
    7172 
    72 #ifdef _MSC_VER 
    73 #  pragma warning ( disable : 4214 ) 
     73#pragma pack(1) 
     74 
     75/** 
     76 * RTP packet header. 
     77 */ 
     78struct pjmedia_rtp_hdr 
     79{ 
     80#if defined(PJ_IS_BIG_ENDIAN) && (PJ_IS_BIG_ENDIAN!=0) 
     81    int v:2;            /**< packet type/version            */ 
     82    int p:1;            /**< padding flag                   */ 
     83    int x:1;            /**< extension flag                 */ 
     84    int cc:4;           /**< CSRC count                     */ 
     85    int m:1;            /**< marker bit                     */ 
     86    int pt:7;           /**< payload type                   */ 
     87#else 
     88    int cc:4;           /**< CSRC count                     */ 
     89    int x:1;            /**< header extension flag          */  
     90    int p:1;            /**< padding flag                   */ 
     91    int v:2;            /**< packet type/version            */ 
     92    int pt:7;           /**< payload type                   */ 
     93    int m:1;            /**< marker bit                     */ 
    7494#endif 
    75  
    76  
    77 /** 
    78  * Error codes. 
    79  */ 
    80 enum pj_rtp_error_t 
    81 { 
    82     PJMEDIA_RTP_ERR_RTP_PACKING,            /**< Invalid RTP packet. */ 
    83     PJMEDIA_RTP_ERR_INVALID_VERSION,        /**< Invalid RTP version. */ 
    84     PJMEDIA_RTP_ERR_INVALID_SSRC,           /**< Invalid SSRC. */ 
    85     PJMEDIA_RTP_ERR_INVALID_PT,     /**< Invalid payload type. */ 
    86     PJMEDIA_RTP_ERR_INVALID_PACKET,         /**< Invalid packet. */ 
    87     PJMEDIA_RTP_ERR_SESSION_RESTARTED,   /**< Session has just been restarted. */ 
    88     PJMEDIA_RTP_ERR_SESSION_PROBATION,   /**< Session in probation. */ 
    89     PJMEDIA_RTP_ERR_BAD_SEQUENCE,           /**< Bad RTP sequence number. */ 
    90 }; 
    91  
    92 #pragma pack(1) 
    93 /** 
    94  * RTP packet header. 
    95  */ 
    96 struct pj_rtp_hdr 
    97 { 
    98 #if defined(PJ_IS_BIG_ENDIAN) && (PJ_IS_BIG_ENDIAN!=0) 
    99     pj_uint16_t v:2;    /**< packet type/version            */ 
    100     pj_uint16_t p:1;    /**< padding flag                   */ 
    101     pj_uint16_t x:1;    /**< extension flag         */ 
    102     pj_uint16_t cc:4;   /**< CSRC count             */ 
    103     pj_uint16_t m:1;    /**< marker bit             */ 
    104     pj_uint16_t pt:7;   /**< payload type                   */ 
    105 #else 
    106     pj_uint16_t cc:4;   /**< CSRC count             */ 
    107     pj_uint16_t x:1;    /**< header extension flag    */  
    108     pj_uint16_t p:1;    /**< padding flag                   */ 
    109     pj_uint16_t v:2;    /**< packet type/version            */ 
    110     pj_uint16_t pt:7;   /**< payload type                   */ 
    111     pj_uint16_t m:1;    /**< marker bit             */ 
    112 #endif 
    113     pj_uint16_t seq;    /**< sequence number        */ 
    114     pj_uint32_t ts;     /**< timestamp              */ 
    115     pj_uint32_t ssrc;   /**< synchronization source   */ 
    116 }; 
     95    pj_uint16_t seq;    /**< sequence number                */ 
     96    pj_uint32_t ts;     /**< timestamp                      */ 
     97    pj_uint32_t ssrc;   /**< synchronization source         */ 
     98}; 
     99 
    117100#pragma pack() 
    118101 
    119 typedef struct pj_rtp_hdr pj_rtp_hdr; 
     102/** 
     103 * @see pjmedia_rtp_hdr 
     104 */ 
     105typedef struct pjmedia_rtp_hdr pjmedia_rtp_hdr; 
     106 
    120107 
    121108/** 
    122109 * RTP extendsion header. 
    123110 */ 
    124 struct pj_rtp_ext_hdr 
    125 { 
    126     pj_uint16_t profile_data; 
    127     pj_uint16_t length; 
    128 }; 
    129  
    130 typedef struct pj_rtp_ext_hdr pj_rtp_ext_hdr; 
     111struct pjmedia_rtp_ext_hdr 
     112{ 
     113    pj_uint16_t profile_data;   /**< Profile data.          */ 
     114    pj_uint16_t length;         /**< Length.                */ 
     115}; 
     116 
     117/** 
     118 * @see pjmedia_rtp_ext_hdr 
     119 */ 
     120typedef struct pjmedia_rtp_ext_hdr pjmedia_rtp_ext_hdr; 
     121 
    131122 
    132123/** 
    133124 * A generic sequence number management, used by both RTP and RTCP. 
    134125 */ 
    135 struct pj_rtp_seq_session 
    136 { 
    137     pj_uint16_t     max_seq;        /**< highest sequence number heard */ 
    138     pj_uint32_t     cycles;         /**< shifted count of seq. number cycles */ 
    139     pj_uint32_t     base_seq;       /**< base seq number */ 
    140     pj_uint32_t     bad_seq;        /**< last 'bad' seq number + 1 */ 
    141     pj_uint32_t     probation;      /**< sequ. packets till source is valid */ 
    142 }; 
    143  
    144 typedef struct pj_rtp_seq_session pj_rtp_seq_session; 
     126struct pjmedia_rtp_seq_session 
     127{ 
     128    pj_uint16_t     max_seq;        /**< Highest sequence number heard      */ 
     129    pj_uint32_t     cycles;         /**< Shifted count of seq number cycles */ 
     130    pj_uint32_t     base_seq;       /**< Base seq number                    */ 
     131    pj_uint32_t     bad_seq;        /**< Last 'bad' seq number + 1          */ 
     132    pj_uint32_t     probation;      /**< Sequ. packets till source is valid */ 
     133}; 
     134 
     135/** 
     136 * @see pjmedia_rtp_seq_session 
     137 */ 
     138typedef struct pjmedia_rtp_seq_session pjmedia_rtp_seq_session; 
     139 
    145140 
    146141/** 
    147142 * RTP session descriptor. 
    148143 */ 
    149 struct pj_rtp_session 
    150 { 
    151     pj_rtp_hdr          out_hdr;    /**< Saved header for outgoing packets. */ 
    152     pj_rtp_seq_session  seq_ctrl;   /**< Sequence number management. */ 
    153     pj_uint16_t         out_pt;     /**< Default outgoing payload type. */ 
    154     pj_uint32_t         out_extseq; /**< Outgoing extended sequence number. */ 
    155     pj_uint32_t         peer_ssrc;  /**< Peer SSRC. */ 
    156     pj_uint32_t         received;   /**< Number of received packets. */ 
    157 }; 
    158  
    159 typedef struct pj_rtp_session pj_rtp_session; 
    160  
    161 /** 
    162  * \brief Initialize RTP session. 
     144struct pjmedia_rtp_session 
     145{ 
     146    pjmedia_rtp_hdr         out_hdr;    /**< Saved hdr for outgoing pkts.   */ 
     147    pjmedia_rtp_seq_session seq_ctrl;   /**< Sequence number management.    */ 
     148    pj_uint16_t             out_pt;     /**< Default outgoing payload type. */ 
     149    pj_uint32_t             out_extseq; /**< Outgoing extended seq #.       */ 
     150    pj_uint32_t             peer_ssrc;  /**< Peer SSRC.                     */ 
     151    pj_uint32_t             received;   /**< Number of received packets.    */ 
     152}; 
     153 
     154/** 
     155 * @see pjmedia_rtp_session 
     156 */ 
     157typedef struct pjmedia_rtp_session pjmedia_rtp_session; 
     158 
     159 
     160/** 
    163161 * This function will initialize the RTP session according to given parameters. 
    164162 * 
     
    167165 * @param sender_ssrc   SSRC used for outgoing packets. 
    168166 * 
    169  * @return zero if successfull. 
    170  */ 
    171 PJ_DECL(pj_status_t) pj_rtp_session_init( pj_rtp_session *ses, 
    172                                           int default_pt, pj_uint32_t sender_ssrc ); 
    173  
    174 /** 
    175  * \brief Encode outgoing RTP packet header. 
     167 * @return              PJ_SUCCESS if successfull. 
     168 */ 
     169PJ_DECL(pj_status_t) pjmedia_rtp_session_init( pjmedia_rtp_session *ses, 
     170                                               int default_pt,  
     171                                               pj_uint32_t sender_ssrc ); 
     172 
     173/** 
    176174 * Create the RTP header based on arguments and current state of the RTP 
    177175 * session. 
     
    185183 * @param hdrlen        Upon return will indicate the size of RTP packet header 
    186184 * 
    187  * @return zero if successfull. 
    188  */ 
    189 PJ_DECL(pj_status_t) pj_rtp_encode_rtp( pj_rtp_session *ses, int pt, int m, 
    190                                         int payload_len, int ts_len, 
    191                                         const void **rtphdr, int *hdrlen ); 
    192  
    193 /** 
    194  * \brief Decode an incoming RTP packet. 
    195  * This function will decode incoming packet into RTP header and payload. 
     185 * @return              PJ_SUCCESS if successfull. 
     186 */ 
     187PJ_DECL(pj_status_t) pjmedia_rtp_encode_rtp( pjmedia_rtp_session *ses,  
     188                                             int pt, int m, 
     189                                             int payload_len, int ts_len, 
     190                                             const void **rtphdr,  
     191                                             int *hdrlen ); 
     192 
     193/** 
     194 * This function decodes incoming packet into RTP header and payload. 
    196195 * The decode function is guaranteed to point the payload to the correct  
    197196 * position regardless of any options present in the RTP packet. 
     
    206205 * @param payloadlen    Upon return will indicate the size of the payload. 
    207206 * 
    208  * @return zero if successfull. 
    209  */ 
    210 PJ_DECL(pj_status_t) pj_rtp_decode_rtp( pj_rtp_session *ses,  
    211                                         const void *pkt, int pkt_len, 
    212                                         const pj_rtp_hdr **hdr, 
    213                                         const void **payload, 
    214                                         unsigned *payloadlen); 
    215  
    216 /** 
    217  * \brief Update RTP session with an incoming RTP packet.  
    218  * Call this function everytime 
    219  * an RTP packet is received to check whether the packet can be received and to 
    220  * let the RTP session performs its internal calculations. 
     207 * @return              PJ_SUCCESS if successfull. 
     208 */ 
     209PJ_DECL(pj_status_t) pjmedia_rtp_decode_rtp( pjmedia_rtp_session *ses,  
     210                                             const void *pkt, int pkt_len, 
     211                                             const pjmedia_rtp_hdr **hdr, 
     212                                             const void **payload, 
     213                                             unsigned *payloadlen); 
     214 
     215/** 
     216 * Call this function everytime an RTP packet is received to check whether  
     217 * the packet can be received and to let the RTP session performs its internal 
     218 * calculations. 
    221219 * 
    222220 * @param ses       The session. 
    223221 * @param hdr       The RTP header of the incoming packet. 
    224222 * 
    225  * @return zero if the packet is valid and can be processed, otherwise will 
    226  *         return one of the error in #pj_rtp_error_t. 
    227  */ 
    228 PJ_DECL(pj_status_t) pj_rtp_session_update( pj_rtp_session *ses,  
    229                                             const pj_rtp_hdr *hdr); 
     223 * @return          PJ_SUCCESS if the packet is valid and can be processed,  
     224 *                  otherwise will return the appropriate status code. 
     225 */ 
     226PJ_DECL(pj_status_t) pjmedia_rtp_session_update( pjmedia_rtp_session *ses,  
     227                                                 const pjmedia_rtp_hdr *hdr); 
     228 
     229 
     230/* 
     231 * INTERNAL: 
     232 */ 
    230233 
    231234/**  
    232 * \brief Internal. 
    233  * Internal function for sequence control, shared by RTCP implementation.  
    234  */ 
    235 void pj_rtp_seq_init(pj_rtp_seq_session *seq_ctrl, pj_uint16_t seq); 
     235 * Internal function for creating sequence number control, shared by RTCP  
     236 * implementation.  
     237 * 
     238 * @param seq_ctrl  The sequence control instance. 
     239 * @param seq       Sequence number to initialize. 
     240 */ 
     241void pjmedia_rtp_seq_init(pjmedia_rtp_seq_session *seq_ctrl,  
     242                          pj_uint16_t seq); 
     243 
    236244 
    237245/**  
    238 * \brief Internal. 
    239  * Internal function for sequence control, shared by RTCP implementation.  
    240  */ 
    241 void pj_rtp_seq_restart(pj_rtp_seq_session *seq_ctrl, pj_uint16_t seq); 
     246 * Internal function to restart the sequence number control, shared by RTCP  
     247 * implementation.  
     248 * 
     249 * @param seq_ctrl  The sequence control instance. 
     250 * @param seq       Sequence number to restart. 
     251 */ 
     252void pjmedia_rtp_seq_restart(pjmedia_rtp_seq_session *seq_ctrl,  
     253                             pj_uint16_t seq); 
    242254 
    243255/**  
    244 * \brief Internal. 
    245  * Internal function for sequence control, shared by RTCP implementation.  
    246  */ 
    247 int  pj_rtp_seq_update(pj_rtp_seq_session *seq_ctrl, pj_uint16_t seq); 
     256 * Internal function update sequence control, shared by RTCP implementation. 
     257 * 
     258 * @param seq_ctrl  The sequence control instance. 
     259 * @param seq       Sequence number to update. 
     260 * 
     261 * @return          PJ_SUCCESS if the sequence number can be accepted. 
     262 */ 
     263pj_status_t pjmedia_rtp_seq_update(pjmedia_rtp_seq_session *seq_ctrl,  
     264                                   pj_uint16_t seq); 
    248265 
    249266/** 
  • pjproject/trunk/pjmedia/include/pjmedia/sdp.h

    r129 r188  
    2121 
    2222/** 
    23  * @defgroup PJSDP SDP Library 
    24  */ 
    25 /** 
    2623 * @file sdp.h 
    2724 * @brief SDP header file. 
    2825 */ 
    29 /** 
    30  * @defgroup PJ_SDP_H SDP stack. 
    31  * @ingroup PJSDP 
     26#include <pjmedia/types.h> 
     27 
     28 
     29/** 
     30 * @defgroup PJ_SDP SDP Parsing and Data Structure 
     31 * @ingroup PJMEDIA 
    3232 * @{ 
    3333 * 
    34  * This SDP module consists of SDP parser, SDP structure, and function to 
    35  * print back the structure as SDP message. 
    36  */ 
    37  
    38 #include <pjmedia/types.h> 
     34 * The basic SDP session descriptor and elements are described in header 
     35 * file <pre><pjmedia/sdp.h></pre>. This file contains declaration for 
     36 * SDP session descriptor and SDP media descriptor, along with their 
     37 * attributes. This file also declares functions to parse SDP message. 
     38 */ 
     39 
    3940 
    4041PJ_BEGIN_DECL 
    4142 
    42 #define PJSDP_MAX_FMT   32 
    43 #define PJSDP_MAX_ATTR  32 
    44 #define PJSDP_MAX_MEDIA 16 
    45  
    46  
    47 /**************************************************************************** 
     43/** 
     44 * The PJMEDIA_MAX_SDP_FMT macro defines maximum format in a media line. 
     45 */ 
     46#ifndef PJMEDIA_MAX_SDP_FMT 
     47#   define PJMEDIA_MAX_SDP_FMT          16 
     48#endif 
     49 
     50/** 
     51 * The PJMEDIA_MAX_SDP_ATTR macro defines maximum SDP attributes in media and 
     52 * session descriptor. 
     53 */ 
     54#ifndef PJMEDIA_MAX_SDP_ATTR 
     55#   define PJMEDIA_MAX_SDP_ATTR         (PJMEDIA_MAX_SDP_FMT*2 + 4) 
     56#endif 
     57 
     58/** 
     59 * The PJMEDIA_MAX_SDP_MEDIA macro defines maximum SDP media lines in a 
     60 * SDP session descriptor. 
     61 */ 
     62#ifndef PJMEDIA_MAX_SDP_MEDIA 
     63#   define PJMEDIA_MAX_SDP_MEDIA        16 
     64#endif 
     65 
     66 
     67/* ************************************************************************** 
    4868 * SDP ATTRIBUTES 
    49  **************************************************************************** 
     69 *************************************************************************** 
    5070 */ 
    5171 
    5272/**  
    53  * SDP generic attribute. 
     73 * Generic representation of attribute. 
    5474 */ 
    5575struct pjmedia_sdp_attr 
     
    91111 * @param name          Attribute name to find. 
    92112 * @param fmt           Optional string to indicate which payload format 
    93  *                      to find for rtpmap and fmt attributes. 
     113 *                      to find for \a rtpmap and \a fmt attributes. For other 
     114 *                      types of attributes, the value should be NULL. 
    94115 * 
    95116 * @return              The specified attribute, or NULL if it can't be found. 
    96117 * 
    97  * @see pjmedia_sdp_attr_find2, pjmedia_sdp_media_find_attr 
     118 * @see pjmedia_sdp_attr_find2, pjmedia_sdp_media_find_attr,  
     119 *      pjmedia_sdp_media_find_attr2 
    98120 */ 
    99121PJ_DECL(pjmedia_sdp_attr*)  
     
    109131 * @param name          Attribute name to find. 
    110132 * @param fmt           Optional string to indicate which payload format 
    111  *                      to find for rtpmap and fmt attributes. 
     133 *                      to find for \a rtpmap and \a fmt attributes. For other 
     134 *                      types of attributes, the value should be NULL. 
    112135 * 
    113136 * @return              The specified attribute, or NULL if it can't be found. 
    114137 * 
    115  * @see pjmedia_sdp_attr_find, pjmedia_sdp_media_find_attr2 
     138 * @see pjmedia_sdp_attr_find, pjmedia_sdp_media_find_attr, 
     139 *      pjmedia_sdp_media_find_attr2 
    116140 */ 
    117141PJ_DECL(pjmedia_sdp_attr*)  
     
    136160 
    137161/** 
    138  * Remove all attributes with the specified name when they present. 
     162 * Remove all attributes with the specified name in array of attributes. 
    139163 * 
    140164 * @param count         Number of attributes in the array. 
     
    156180 * @param count         Number of attributes in the array. 
    157181 * @param attr_array    Array of attributes. 
    158  * @param name          Attribute name to find. 
     182 * @param attr          The attribute instance to remove. 
    159183 * 
    160184 * @return              PJ_SUCCESS when attribute has been removed, or  
     
    169193 
    170194/** 
    171  * SDP \a rtpmap attribute. 
     195 * This structure declares SDP \a rtpmap attribute. 
    172196 */ 
    173197struct pjmedia_sdp_rtpmap 
     
    181205 
    182206/** 
    183  * Convert generic attribute to SDP rtpmap. 
     207 * Convert generic attribute to SDP \a rtpmap. This function allocates 
     208 * a new attribute and call #pjmedia_sdp_attr_get_rtpmap(). 
    184209 * 
    185210 * @param pool          Pool used to create the rtpmap attribute. 
     
    188213 * @param p_rtpmap      Pointer to receive SDP rtpmap attribute. 
    189214 * 
    190  * @return              PJ_SUCCESS on success. 
     215 * @return              PJ_SUCCESS if the attribute can be successfully 
     216 *                      converted to \a rtpmap type. 
     217 * 
     218 * @see pjmedia_sdp_attr_get_rtpmap 
    191219 */ 
    192220PJ_DECL(pj_status_t) pjmedia_sdp_attr_to_rtpmap(pj_pool_t *pool, 
     
    200228 * @param attr          Generic attribute to be converted to rtpmap, which 
    201229 *                      name must be "rtpmap". 
    202  * @param rtpmap        SDP rtpmap attribute to be initialized. 
    203  * 
    204  * @return              PJ_SUCCESS on success. 
     230 * @param rtpmap        SDP \a rtpmap attribute to be initialized. 
     231 * 
     232 * @return              PJ_SUCCESS if the attribute can be successfully 
     233 *                      converted to \a rtpmap attribute. 
     234 * 
     235 * @see pjmedia_sdp_attr_to_rtpmap 
    205236 */ 
    206237PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_rtpmap(const pjmedia_sdp_attr *attr, 
     
    209240 
    210241/** 
    211  * Convert rtpmap attribute to generic attribute. 
     242 * Convert \a rtpmap attribute to generic attribute. 
    212243 * 
    213244 * @param pool          Pool to be used. 
    214  * @param rtpmap        The rtpmap attribute. 
     245 * @param rtpmap        The \a rtpmap attribute. 
    215246 * @param p_attr        Pointer to receive the generic SDP attribute. 
    216247 * 
    217248 * @return              PJ_SUCCESS on success. 
    218249 */ 
    219 PJ_DECL(pj_status_t) pjmedia_sdp_rtpmap_to_attr(pj_pool_t *pool, 
    220                                                 const pjmedia_sdp_rtpmap *rtpmap, 
    221                                                 pjmedia_sdp_attr **p_attr); 
    222  
    223  
    224 /** 
    225  * SDP \a fmtp attribute. 
     250PJ_DECL(pj_status_t)  
     251pjmedia_sdp_rtpmap_to_attr( pj_pool_t *pool, 
     252                            const pjmedia_sdp_rtpmap *rtpmap, 
     253                            pjmedia_sdp_attr **p_attr); 
     254 
     255 
     256/** 
     257 * This structure describes SDP \a fmtp attribute. 
    226258 */ 
    227259struct pjmedia_sdp_fmtp 
     
    245277 
    246278 
    247 /**************************************************************************** 
     279/* ************************************************************************** 
    248280 * SDP CONNECTION INFO 
    249281 **************************************************************************** 
     
    251283 
    252284/** 
    253  * SDP connection info. 
     285 * This structure describes SDP connection info ("c=" line).  
    254286 */ 
    255287struct pjmedia_sdp_conn 
     
    262294 
    263295/**  
    264  *Clone connection info.  
     296 * Clone connection info.  
    265297 *  
    266298 * @param pool      Pool to allocate memory for the new connection info. 
    267299 * @param rhs       The connection into to clone. 
    268300 * 
    269  * @return the new connection info. 
     301 * @return          The new connection info. 
    270302 */ 
    271303PJ_DECL(pjmedia_sdp_conn*) pjmedia_sdp_conn_clone(pj_pool_t *pool,  
     
    274306 
    275307 
    276 /**************************************************************************** 
     308/* ************************************************************************** 
    277309 * SDP MEDIA INFO/LINE 
    278310 **************************************************************************** 
     
    280312 
    281313/** 
    282  * SDP media description. 
     314 * This structure describes SDP media descriptor. A SDP media descriptor 
     315 * starts with "m=" line and contains the media attributes and optional 
     316 * connection line. 
    283317 */ 
    284318struct pjmedia_sdp_media 
    285319{ 
     320    /** Media descriptor line ("m=" line) */ 
    286321    struct 
    287322    { 
     
    291326        pj_str_t    transport;          /**< Transport ("RTP/AVP")          */ 
    292327        unsigned    fmt_count;          /**< Number of formats.             */ 
    293         pj_str_t    fmt[PJSDP_MAX_FMT]; /**< Media formats.                 */ 
     328        pj_str_t    fmt[PJMEDIA_MAX_SDP_FMT];   /**< Media formats.         */ 
    294329    } desc; 
    295330 
    296331    pjmedia_sdp_conn *conn;             /**< Optional connection info.      */ 
    297332    unsigned         attr_count;        /**< Number of attributes.          */ 
    298     pjmedia_sdp_attr*attr[PJSDP_MAX_ATTR];  /**< Attributes.                */ 
     333    pjmedia_sdp_attr*attr[PJMEDIA_MAX_SDP_ATTR];  /**< Attributes.          */ 
    299334 
    300335}; 
     
    307342 * @param rhs       The media descriptin to clone. 
    308343 * 
    309  * @return a new media description. 
     344 * @return          New media description. 
    310345 */ 
    311346PJ_DECL(pjmedia_sdp_media*)  
     
    314349 
    315350/** 
    316  * Find the first occurence of the specified attribute name. 
     351 * Find the first occurence of the specified attribute name in the media  
     352 * descriptor. Optionally the format may be specified. 
    317353 * 
    318354 * @param m             The SDP media description. 
    319355 * @param name          Attribute name to find. 
    320  * @param fmt           Optional payload format type to find in the 
    321  *                      attribute list. The payload format type will be 
    322  *                      compared for attributes such as rtpmap and fmtp. 
     356 * @param fmt           Optional payload type to match in the 
     357 *                      attribute list, when the attribute is \a rtpmap 
     358 *                      or \a fmtp. For other types of SDP attributes, this 
     359 *                      value should be NULL. 
    323360 * 
    324361 * @return              The first instance of the specified attribute or NULL. 
     
    330367 
    331368/** 
    332  * Find the first occurence of the specified attribute name. 
     369 * Find the first occurence of the specified attribute name in the SDP media  
     370 * descriptor. Optionally the format may be specified. 
    333371 * 
    334372 * @param m             The SDP media description. 
    335373 * @param name          Attribute name to find. 
    336  * @param fmt           Optional payload format type to find in the 
    337  *                      attribute list. The payload format type will be 
    338  *                      compared for attributes such as rtpmap and fmtp. 
     374 * @param fmt           Optional payload type to match in the 
     375 *                      attribute list, when the attribute is \a rtpmap 
     376 *                      or \a fmtp. For other types of SDP attributes, this 
     377 *                      value should be NULL. 
    339378 * 
    340379 * @return              The first instance of the specified attribute or NULL. 
     
    348387 * 
    349388 * @param m             The SDP media description. 
    350  * @param name          Attribute to add. 
     389 * @param attr          Attribute to add. 
    351390 * 
    352391 * @return              PJ_SUCCESS or the appropriate error code. 
     
    356395 
    357396/** 
    358  * Remove all attributes with the specified name. 
     397 * Remove all attributes with the specified name from the SDP media 
     398 * descriptor. 
    359399 * 
    360400 * @param m             The SDP media description. 
     
    369409 
    370410/** 
    371  * Remove the occurence of the specified attribute. 
     411 * Remove the occurence of the specified attribute from the SDP media 
     412 * descriptor. 
     413 * 
     414 * @param m             The SDP media descriptor. 
     415 * @param attr          The attribute to find and remove. 
     416 * 
     417 * @return              PJ_SUCCESS if the attribute can be found and has 
     418 *                      been removed from the array. 
    372419 */ 
    373420PJ_DECL(pj_status_t) 
     
    381428 * @param sd1       The first SDP media to compare. 
    382429 * @param sd2       The second SDP media to compare. 
    383  * @param option    Comparison option. 
    384  * 
    385  * @return          PJ_SUCCESS when both SDP medias are equal. 
     430 * @param option    Comparison option, which should be zero for now. 
     431 * 
     432 * @return          PJ_SUCCESS when both SDP medias are equal, or the 
     433 *                  appropriate status code describing which part of 
     434 *                  the descriptors that are not equal. 
    386435 */ 
    387436PJ_DECL(pj_status_t) pjmedia_sdp_media_cmp(const pjmedia_sdp_media *sd1, 
     
    391440 
    392441 
    393 /**************************************************************************** 
     442/* ************************************************************************** 
    394443 * SDP SESSION DESCRIPTION 
    395444 **************************************************************************** 
     
    398447 
    399448/** 
    400  * This structure describes SDP session description. 
     449 * This structure describes SDP session description. A SDP session descriptor 
     450 * contains complete information about a session, and normally is exchanged 
     451 * with remote media peer using signaling protocol such as SIP. 
    401452 */ 
    402453struct pjmedia_sdp_session 
    403454{ 
    404     /** Origin (o= line) */ 
     455    /** Session origin (o= line) */ 
    405456    struct 
    406457    { 
     
    424475 
    425476    unsigned           attr_count;              /**< Number of attributes.  */ 
    426     pjmedia_sdp_attr  *attr[PJSDP_MAX_ATTR];    /**< Attributes array.      */ 
     477    pjmedia_sdp_attr  *attr[PJMEDIA_MAX_SDP_ATTR]; /**< Attributes array.   */ 
    427478 
    428479    unsigned           media_count;             /**< Number of media.       */ 
    429     pjmedia_sdp_media *media[PJSDP_MAX_MEDIA];  /**< Media array.           */ 
     480    pjmedia_sdp_media *media[PJMEDIA_MAX_SDP_MEDIA];    /**< Media array.   */ 
    430481 
    431482}; 
     
    435486 * Parse SDP message. 
    436487 * 
     488 * @param pool      The pool to allocate SDP session description. 
    437489 * @param buf       The message buffer. 
    438490 * @param len       The length of the message. 
    439  * @param pool      The pool to allocate SDP session description. 
    440  * 
    441  * @return SDP session description. 
     491 * @param p_sdp     Pointer to receive the SDP session descriptor. 
     492 * 
     493 * @return          PJ_SUCCESS if message was successfully parsed into 
     494 *                  SDP session descriptor. 
    442495 */ 
    443496PJ_DECL(pj_status_t) pjmedia_sdp_parse( pj_pool_t *pool, 
     
    448501 * Print SDP description to a buffer. 
    449502 * 
     503 * @param sdp       The SDP session description. 
    450504 * @param buf       The buffer. 
    451505 * @param size      The buffer length. 
    452  * @param desc      The SDP session description. 
    453  * 
    454  * @return the length printed, or -1. 
    455  */ 
    456 PJ_DECL(int) pjmedia_sdp_print( const pjmedia_sdp_session *desc,  
     506 * 
     507 * @return          the length printed, or -1 if the buffer is too 
     508 *                  short. 
     509 */ 
     510PJ_DECL(int) pjmedia_sdp_print( const pjmedia_sdp_session *sdp,  
    457511                                char *buf, pj_size_t size); 
    458512 
    459513 
    460514/** 
    461  * Validate SDP descriptor. 
     515 * Perform semantic validation for the specified SDP session descriptor. 
     516 * This function perform validation beyond just syntactic verification, 
     517 * such as to verify the value of network type and address type, check 
     518 * the connection line, and verify that \a rtpmap attribute is present 
     519 * when dynamic payload type is used. 
     520 * 
     521 * @param sdp       The SDP session descriptor to validate. 
     522 * 
     523 * @return          PJ_SUCCESS on success. 
    462524 */ 
    463525PJ_DECL(pj_status_t) pjmedia_sdp_validate(const pjmedia_sdp_session *sdp); 
     
    465527 
    466528/** 
    467  * Clone SDP session. 
     529 * Clone SDP session descriptor. 
    468530 * 
    469531 * @param pool      The pool used to clone the session. 
    470  * @param sess      The SDP session to clone. 
     532 * @param sdp       The SDP session to clone. 
    471533 * 
    472534 * @return          New SDP session. 
     
    474536PJ_DECL(pjmedia_sdp_session*)  
    475537pjmedia_sdp_session_clone( pj_pool_t *pool, 
    476                            const pjmedia_sdp_session *sess); 
     538                           const pjmedia_sdp_session *sdp); 
    477539 
    478540 
     
    482544 * @param sd1       The first SDP session to compare. 
    483545 * @param sd2       The second SDP session to compare. 
    484  * 
    485  * @return          PJ_SUCCESS when both SDPs are equal. 
     546 * @param option    Must be zero for now. 
     547 * 
     548 * @return          PJ_SUCCESS when both SDPs are equal, or otherwise 
     549 *                  the status code indicates which part of the session 
     550 *                  descriptors are not equal. 
    486551 */ 
    487552PJ_DECL(pj_status_t) pjmedia_sdp_session_cmp(const pjmedia_sdp_session *sd1, 
  • pjproject/trunk/pjmedia/include/pjmedia/sdp_neg.h

    r163 r188  
    2222 
    2323/** 
    24  * @defgroup PJSDP SDP Library 
    25  */ 
    26 /** 
    2724 * @file sdp_neg.h 
    2825 * @brief SDP negotiator header file. 
     
    3027/** 
    3128 * @defgroup PJ_SDP_NEG SDP Negotiator. 
    32  * @ingroup PJSDP 
     29 * @ingroup PJMEDIA 
    3330 * @{ 
    34  *. 
    35  */ 
    36  
    37 #include <pjmedia/types.h> 
    38  
    39 PJ_BEGIN_DECL 
    40  
    41 /** 
    42  * This enumeration describes SDP negotiation state. The negotiator state 
    43  * is illustrated in the following diagram. 
     31 * 
     32 * The header file <b><pjmedia/sdp_neg.h></b> contains the declaration 
     33 * of SDP offer and answer negotiator. SDP offer and answer model is described 
     34 * in RFC 3264 <b>"An Offer/Answer Model with Session Description Protocol  
     35 * (SDP)"</b>. 
     36 * 
     37 * The SDP negotiator is represented with opaque type \a pjmedia_sdp_neg. 
     38 * This structure contains negotiation state and several SDP session  
     39 * descriptors currently being used in the negotiation. 
     40 * 
     41 * 
     42 * \section sdpneg_state_dia SDP Negotiator State Diagram 
     43 * 
     44 * The following diagram describes the state transition diagram of the 
     45 * SDP negotiator. 
    4446 *  
    4547 * <pre> 
    46  *                                              reinit_local_offer() 
     48 *                                               
    4749 *                                              modify_local_offer() 
    4850 *     create_w_local_offer()  +-------------+  send_local_offer() 
     
    6365 * 
    6466 * </pre> 
     67 * 
     68 * 
     69 * 
     70 * \section sdpneg_offer_answer SDP Offer/Answer Model with Negotiator 
     71 * 
     72 * \subsection sdpneg_create_offer Creating Initial Offer 
     73 * 
     74 * Application creates an offer by manualy building the SDP session descriptor 
     75 * (pjmedia_sdp_session), or request PJMEDIA endpoint (pjmedia_endpt) to  
     76 * create SDP session descriptor based on capabilities that present in the 
     77 * endpoint by calling #pjmedia_endpt_create_sdp(). 
     78 * 
     79 * Application then creates SDP negotiator instance by calling 
     80 * #pjmedia_sdp_neg_create_w_local_offer(), passing the SDP offer in the 
     81 * function arguments. The SDP negotiator keeps a copy of current local offer, 
     82 * and update its state to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER. 
     83 * 
     84 * Application can then send the initial SDP offer that it creates to 
     85 * remote peer using signaling protocol such as SIP. 
     86 * 
     87 * 
     88 * \subsection sdpneg_subseq_offer Generating Subsequent Offer 
     89 * 
     90 * The negotiator can only create subsequent offer after it has finished 
     91 * the negotiation process of previous offer/answer session (i.e. the 
     92 * negotiator state is PJMEDIA_SDP_NEG_STATE_DONE). 
     93 * 
     94 * If any previous negotiation process was successfull (i.e. the return  
     95 * value of #pjmedia_sdp_neg_negotiate() was PJ_SUCCESS), the negotiator 
     96 * keeps both active local and active remote SDP. 
     97 * 
     98 * If application does not want send modified offer, it can just send 
     99 * the active local SDP as the offer. In this case, application calls 
     100 * #pjmedia_sdp_neg_send_local_offer() to get the active local SDP. 
     101 *  
     102 * If application wants to modify it's local offer, it MUST inform  
     103 * the negotiator about the modified SDP by calling  
     104 * #pjmedia_sdp_neg_modify_local_offer(). 
     105 * 
     106 * In both cases, the negotiator will internally create a copy of the offer, 
     107 * and move it's state to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, where it 
     108 * waits until application passes the remote answer. 
     109 * 
     110 * 
     111 * \subsection sdpneg_receive_offer Receiving Initial Offer 
     112 * 
     113 * Application receives an offer in the incoming request from remote to 
     114 * establish multimedia session, such as incoming INVITE message with SDP 
     115 * body.  
     116 * 
     117 * Initially, when the initial offer is received, application creates the  
     118 * SDP negotiator by calling #pjmedia_sdp_neg_create_w_remote_offer(), 
     119 * specifying the remote SDP offer in one of the argument.  
     120 * 
     121 * At this stage, application may or may not ready to create an answer. 
     122 * For example, a SIP B2BUA needs to make outgoing call and receive SDP 
     123 * from the outgoing call leg in order to create a SDP answer to the 
     124 * incoming call leg. 
     125 * 
     126 * If application is not ready to create an answer, it passes NULL as 
     127 * the local SDP when it calls #pjmedia_sdp_neg_create_w_remote_offer(). 
     128 * 
     129 * The section @ref sdpneg_create_answer describes the case when  
     130 * application is ready to create a SDP answer. 
     131 * 
     132 * 
     133 * \subsection sdpneg_subseq_offer Receiving Subsequent Offer 
     134 * 
     135 * Application passes subsequent SDP offer received from remote by 
     136 * calling #pjmedia_sdp_neg_set_remote_offer(). 
     137 * 
     138 * The negotiator can only receive subsequent offer after it has finished 
     139 * the negotiation process of previous offer/answer session (i.e. the 
     140 * negotiator state is PJMEDIA_SDP_NEG_STATE_DONE). 
     141 * 
     142 * 
     143 * \subsection sdpneg_recv_answer Receiving SDP Answer 
     144 * 
     145 * When application receives SDP answer from remote, it informs the 
     146 * negotiator by calling #pjmedia_sdp_neg_set_remote_answer(). The 
     147 * negotiator validates the answer (#pjmedia_sdp_validate()), and if 
     148 * succeeds, it moves it's state to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO. 
     149 * 
     150 * Application then instruct the negotiator to negotiate the remote 
     151 * answer by calling #pjmedia_sdp_neg_negotiate(). The purpose of 
     152 * this negotiation is to verify remote answer, and update the initial 
     153 * offer according to the answer. For example, the initial offer may 
     154 * specify that a stream is \a sendrecv, while the answer specifies 
     155 * that remote stream is \a inactive. In this case, the negotiator 
     156 * will update the stream in the local active media as \a inactive 
     157 * too. 
     158 * 
     159 * If #pjmedia_sdp_neg_negotiate() returns PJ_SUCCESS, the negotiator will 
     160 * keep the updated local answer and remote answer internally. These two  
     161 * SDPs are called active local SDP and active remote SDP, as it describes  
     162 * currently active session. 
     163 * 
     164 * Application can retrieve the active local SDP by calling 
     165 * #pjmedia_sdp_neg_get_active_local(), and active remote SDP by calling 
     166 * #pjmedia_sdp_neg_get_active_remote(). 
     167 * 
     168 * If #pjmedia_sdp_neg_negotiate() returns failure (i.e. not PJ_SUCCESS), 
     169 * it WILL NOT update its active local and active remote SDP. 
     170 * 
     171 * Regardless of the return status of the #pjmedia_sdp_neg_negotiate(),  
     172 * the negotiator state will move to PJMEDIA_SDP_NEG_STATE_DONE. 
     173 *  
     174 * 
     175 * \subsection sdpneg_create_answer Generating SDP Answer 
     176 * 
     177 * After remote offer has been set in the negotiator, application can  
     178 * request the SDP negotiator to generate appropriate answer based on local  
     179 * capability. 
     180 * 
     181 * To do this, first the application MUST have an SDP describing its local 
     182 * capabilities. This SDP can be built manually, or application can generate 
     183 * SDP to describe local media endpoint capability by calling  
     184 * #pjmedia_endpt_create_sdp(). When the application is a SIP B2BUA,  
     185 * application can treat the SDP received from the outgoing call leg as if 
     186 * it was it's local capability. 
     187 *  
     188 * The local SDP session descriptor DOES NOT have to match the SDP offer. 
     189 * For example, it can have more or less media lines than the offer, or 
     190 * their order may be different than the offer. The negotiator is capable 
     191 * to match and reorder local SDP according to remote offer, and create 
     192 * an answer that is suitable for the offer. 
     193 * 
     194 * After local SDP capability has been acquired, application can create 
     195 * a SDP answer. 
     196 * 
     197 * If application does not already have the negotiator instance, it creates 
     198 * one by calling #pjmedia_sdp_neg_create_w_remote_offer(), specifying  
     199 * both remote SDP offer and local SDP as the arguments. The SDP negotiator 
     200 * validates both remote and local SDP by calling #pjmedia_sdp_validate(), 
     201 * and if both SDPs are valid, the negotiator state will move to 
     202 * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO where it is ready to negotiate the 
     203 * offer and answer. 
     204 * 
     205 * If application already has the negotiator instance, it sets the local 
     206 * SDP in the negotiator by calling #pjmedia_sdp_neg_set_local_answer(). 
     207 * The SDP negotiator then validates local SDP (#pjmedia_sdp_validate() ), 
     208 * and if it is  valid, the negotiator state will move to 
     209 * PJMEDIA_SDP_NEG_STATE_WAIT_NEGO where it is ready to negotiate the 
     210 * offer and answer. 
     211 * 
     212 * After the SDP negotiator state has moved to PJMEDIA_SDP_NEG_STATE_WAIT_NEGO, 
     213 * application calls #pjmedia_sdp_neg_negotiate() to instruct the SDP 
     214 * negotiator to negotiate both offer and answer. This function returns 
     215 * PJ_SUCCESS if an answer can be generated AND at least one media stream 
     216 * is active in the session. 
     217 * 
     218 * If #pjmedia_sdp_neg_negotiate() returns PJ_SUCCESS, the negotiator will 
     219 * keep the remote offer and local answer internally. These two SDPs are 
     220 * called active local SDP and active remote SDP, as it describes currently 
     221 * active session. 
     222 * 
     223 * Application can retrieve the active local SDP by calling 
     224 * #pjmedia_sdp_neg_get_active_local(), and send this SDP to remote as the 
     225 * SDP answer. 
     226 * 
     227 * If #pjmedia_sdp_neg_negotiate() returns failure (i.e. not PJ_SUCCESS), 
     228 * it WILL NOT update its active local and active remote SDP. 
     229 * 
     230 * Regardless of the return status of the #pjmedia_sdp_neg_negotiate(),  
     231 * the negotiator state will move to PJMEDIA_SDP_NEG_STATE_DONE. 
     232 * 
     233 * 
     234 */ 
     235 
     236#include <pjmedia/types.h> 
     237 
     238PJ_BEGIN_DECL 
     239 
     240/** 
     241 * This enumeration describes SDP negotiation state.  
    65242 */ 
    66243enum pjmedia_sdp_neg_state 
     
    113290 * will move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER state, where it waits 
    114291 * until it receives answer from remote. When SDP answer from remote is 
    115  * received, application should call #pjmedia_sdp_neg_set_remote_answer(). 
     292 * received, application must call #pjmedia_sdp_neg_set_remote_answer(). 
    116293 * 
    117294 * After calling this function, application should send the local SDP offer 
    118  * to remote party using higher layer signaling protocol (e.g. SIP) and  
    119  * wait for SDP answer. 
     295 * to remote party using signaling protocol such as SIP and wait for SDP  
     296 * answer. 
    120297 * 
    121298 * @param pool          Pool to allocate memory. The pool's lifetime needs 
     
    135312 * Initialize the SDP negotiator with remote offer, and optionally 
    136313 * specify the initial local capability, if known. Application normally  
    137  * calls this function when it receives initial offer 
    138  * from remote.  
     314 * calls this function when it receives initial offer from remote.  
    139315 * 
    140316 * If local media capability is specified, this capability will be set as 
     
    243419 
    244420/** 
    245  * Completely replaces local offer with new SDP. After calling 
     421 * Modify local session with a new SDP and treat this as a new offer.  
    246422 * This function can only be called in state PJMEDIA_SDP_NEG_STATE_DONE. 
    247  * this function, application can send the modified offer to remote. 
     423 * After calling this function, application can send the SDP as offer  
     424 * to remote party, using signaling protocol such as SIP. 
    248425 * The negotiator state will move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, 
    249426 * where it waits for SDP answer from remote. 
     
    263440 
    264441/** 
    265  * Negotiate local and remote answer. Before calling this function, the 
    266  * SDP negotiator must be in PJMEDIA_SDP_NEG_STATE_WAIT_NEGO state. 
    267  * After calling this function, the negotiator state will move to 
    268  * PJMEDIA_SDP_NEG_STATE_DONE regardless whether the negotiation has 
    269  * been successfull or not. 
    270  * 
    271  * If the negotiation succeeds (i.e. the return value is PJ_SUCCESS), 
    272  * the active local and remote SDP will be replaced with the new SDP 
    273  * from the negotiation process. 
    274  * 
    275  * If the negotiation fails, the active local and remote SDP will not 
    276  * change. 
    277  * 
    278  * @param pool          Pool to allocate memory. The pool's lifetime needs 
    279  *                      to be valid for the duration of the negotiator. 
    280  * @param neg           The SDP negotiator instance. 
    281  * @param allow_asym    Should be zero. 
    282  * 
    283  * @return              PJ_SUCCESS when there is at least one media 
    284  *                      is actuve common in both offer and answer, or  
    285  *                      failure code when negotiation has failed. 
    286  */ 
    287 PJ_DECL(pj_status_t) pjmedia_sdp_neg_negotiate( pj_pool_t *pool, 
    288                                                 pjmedia_sdp_neg *neg, 
    289                                                 pj_bool_t allow_asym); 
    290  
    291  
    292 /** 
    293442 * This function can only be called in PJMEDIA_SDP_NEG_STATE_DONE state. 
    294443 * Application calls this function to retrieve currently active 
    295  * local SDP to be sent to remote. The negotiator state will then move 
    296  * to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, where it waits for SDP answer 
    297  * from remote. When SDP answer has been received from remote, application 
    298  * must call #pjmedia_sdp_neg_set_remote_answer(). 
     444 * local SDP, and then send the SDP to remote as an offer. The negotiator 
     445 * state will then move to PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER, where it waits 
     446 * for SDP answer from remote.  
     447 * 
     448 * When SDP answer has been received from remote, application must call  
     449 * #pjmedia_sdp_neg_set_remote_answer(). 
    299450 * 
    300451 * @param pool          Pool to allocate memory. The pool's lifetime needs 
     
    381532 
    382533 
     534/** 
     535 * Negotiate local and remote answer. Before calling this function, the 
     536 * SDP negotiator must be in PJMEDIA_SDP_NEG_STATE_WAIT_NEGO state. 
     537 * After calling this function, the negotiator state will move to 
     538 * PJMEDIA_SDP_NEG_STATE_DONE regardless whether the negotiation has 
     539 * been successfull or not. 
     540 * 
     541 * If the negotiation succeeds (i.e. the return value is PJ_SUCCESS), 
     542 * the active local and remote SDP will be replaced with the new SDP 
     543 * from the negotiation process. 
     544 * 
     545 * If the negotiation fails, the active local and remote SDP will not 
     546 * change. 
     547 * 
     548 * @param pool          Pool to allocate memory. The pool's lifetime needs 
     549 *                      to be valid for the duration of the negotiator. 
     550 * @param neg           The SDP negotiator instance. 
     551 * @param allow_asym    Should be zero. 
     552 * 
     553 * @return              PJ_SUCCESS when there is at least one media 
     554 *                      is actuve common in both offer and answer, or  
     555 *                      failure code when negotiation has failed. 
     556 */ 
     557PJ_DECL(pj_status_t) pjmedia_sdp_neg_negotiate( pj_pool_t *pool, 
     558                                                pjmedia_sdp_neg *neg, 
     559                                                pj_bool_t allow_asym); 
     560 
     561 
    383562 
    384563 
  • pjproject/trunk/pjmedia/include/pjmedia/session.h

    r169 r188  
    3636 * @ingroup PJMEDIA 
    3737 * @{ 
     38 * 
     39 * A media session represents multimedia communication between two 
     40 * parties. A media session represents the multimedia session that 
     41 * is described by SDP session descriptor. A media session consists  
     42 * of one or more media streams (pjmedia_stream), where each stream  
     43 * represents one media line (m= line) in SDP. 
     44 * 
     45 * This module provides functions to create and manage multimedia 
     46 * sessions. 
    3847 */ 
    3948 
     
    4554struct pjmedia_session_info 
    4655{ 
     56    /** Number of streams. */ 
    4757    unsigned            stream_cnt; 
    48     pjmedia_stream_info stream_info[PJSDP_MAX_MEDIA]; 
     58 
     59    /** Individual stream info. */ 
     60    pjmedia_stream_info stream_info[PJMEDIA_MAX_SDP_MEDIA]; 
    4961}; 
    5062 
     
    6981 *                      successfully. 
    7082 */ 
    71 PJ_DECL(pj_status_t) pjmedia_session_create( pjmedia_endpt *endpt,  
    72                                              unsigned stream_cnt, 
    73                                              const pjmedia_sock_info skinfo[], 
    74                                              const pjmedia_sdp_session *local_sdp, 
    75                                              const pjmedia_sdp_session *rem_sdp, 
    76                                              pjmedia_session **p_session ); 
     83PJ_DECL(pj_status_t)  
     84pjmedia_session_create( pjmedia_endpt *endpt,  
     85                        unsigned stream_cnt, 
     86                        const pjmedia_sock_info skinfo[], 
     87                        const pjmedia_sdp_session *local_sdp, 
     88                        const pjmedia_sdp_session *rem_sdp, 
     89                        pjmedia_session **p_session ); 
    7790 
    7891 
     
    151164 * @return              PJ_SUCCESS on success. 
    152165 */ 
    153 PJ_DECL(pj_status_t) pjmedia_session_enum_streams(const pjmedia_session *session, 
    154                                                   unsigned *count,  
    155                                                   pjmedia_stream_info strm_info[]); 
     166PJ_DECL(pj_status_t)  
     167pjmedia_session_enum_streams( const pjmedia_session *session, 
     168                              unsigned *count,  
     169                              pjmedia_stream_info strm_info[]); 
    156170 
    157171 
     
    162176 * @param session       The media session. 
    163177 * @param index         Stream index. 
    164  * @param stat          Stream statistic. 
     178 * @param sta           Stream statistic. 
    165179 * 
    166180 * @return              PJ_SUCCESS on success. 
     
    168182PJ_DECL(pj_status_t) pjmedia_session_get_stream_stat(pjmedia_session *session, 
    169183                                                     unsigned index, 
    170                                                      pjmedia_stream_stat *stat); 
     184                                                     pjmedia_stream_stat *sta); 
    171185 
    172186/** 
  • pjproject/trunk/pjmedia/include/pjmedia/sound.h

    r121 r188  
    5656typedef struct pj_snd_stream_info 
    5757{ 
    58     unsigned samples_per_sec;           /* Sampling rate.           */ 
    59     unsigned bits_per_sample;           /* No of bits per sample.   */ 
    60     unsigned samples_per_frame;         /* No of samples per frame. */ 
    61     unsigned bytes_per_frame;           /* No of bytes per frame.   */ 
    62     unsigned frames_per_packet;         /* No of frames per packet. */ 
     58    unsigned samples_per_sec;           /**< Sampling rate.             */ 
     59    unsigned bits_per_sample;           /**< No of bits per sample.     */ 
     60    unsigned samples_per_frame;         /**< No of samples per frame.   */ 
     61    unsigned bytes_per_frame;           /**< No of bytes per frame.     */ 
     62    unsigned frames_per_packet;         /**< No of frames per packet.   */ 
    6363} pj_snd_stream_info; 
    6464 
  • pjproject/trunk/pjmedia/include/pjmedia/stream.h

    r159 r188  
    2323/** 
    2424 * @file stream.h 
    25  * @brief Stream of media. 
     25 * @brief Media Stream. 
    2626 */ 
    2727 
     
    3535 
    3636/** 
    37  * @defgroup PJMED_SES Media session 
     37 * @defgroup PJMED_STRM Media Stream 
    3838 * @ingroup PJMEDIA 
    3939 * @{ 
     40 * 
     41 * A media stream is a bidirectional multimedia communication between two 
     42 * endpoints. It corresponds to a media description (m= line) in SDP. 
     43 * 
     44 * A media stream consists of two unidirectional channels: 
     45 *  - encoding channel, which transmits unidirectional media to remote, and 
     46 *  - decoding channel, which receives unidirectional media from remote. 
    4047 */ 
    4148 
     
    139146 * Pause the individual channel in the stream. 
    140147 * 
    141  * @param channel       The media channel. 
     148 * @param stream        The media channel. 
    142149 * @param dir           Which direction to pause. 
    143150 * 
     
    150157 * Resume the individual channel in the stream. 
    151158 * 
    152  * @param channel       The media channel. 
     159 * @param stream        The media channel. 
    153160 * @param dir           Which direction to resume. 
    154161 * 
  • pjproject/trunk/pjmedia/include/pjmedia/types.h

    r169 r188  
    133133{ 
    134134 
    135     pj_sock_t       rtp_sock; 
    136     pj_sockaddr_in  rtp_addr_name; 
    137     pj_sock_t       rtcp_sock; 
    138     pj_sockaddr_in  rtcp_addr_name; 
     135    pj_sock_t       rtp_sock;       /**< Socket for RTP.                    */ 
     136    pj_sockaddr_in  rtp_addr_name;  /**< Local RTP address to be advertised.*/ 
     137    pj_sock_t       rtcp_sock;      /**< Socket for RTCP.                   */ 
     138    pj_sockaddr_in  rtcp_addr_name; /**< Local RTCP addr to be advertised.  */ 
    139139 
    140140} pjmedia_sock_info; 
  • pjproject/trunk/pjmedia/src/pjmedia/errno.c

    r183 r188  
    8080    /* Codec errors. */ 
    8181    { PJMEDIA_CODEC_EUNSUP,         "Unsupported media codec" }, 
     82    { PJMEDIA_CODEC_EFAILED,        "Codec internal creation error" }, 
     83    { PJMEDIA_CODEC_EFRMTOOSHORT,   "Codec frame is too short" }, 
     84    { PJMEDIA_CODEC_EPCMTOOSHORT,   "PCM frame is too short" }, 
    8285 
    8386    /* Media errors. */ 
     
    8689    { PJMEDIA_EINVALIDPT,           "Invalid media payload type" }, 
    8790    { PJMEDIA_EMISSINGRTPMAP,       "Missing rtpmap in media description" }, 
     91    { PJMEDIA_EINVALIMEDIATYPE,     "Invalid media type" }, 
     92 
     93    /* RTP session errors. */ 
     94    { PJMEDIA_RTP_EINPKT,           "Invalid RTP packet" }, 
     95    { PJMEDIA_RTP_EINPACK,          "Invalid RTP packing (internal error)" }, 
     96    { PJMEDIA_RTP_EINVER,           "Invalid RTP version" }, 
     97    { PJMEDIA_RTP_EINSSRC,          "RTP packet SSRC id mismatch" }, 
     98    { PJMEDIA_RTP_EINPT,            "RTP packet payload type mismatch" }, 
     99    { PJMEDIA_RTP_EINLEN,           "Invalid RTP packet length" }, 
     100    { PJMEDIA_RTP_ESESSRESTART,     "RTP session restarted" }, 
     101    { PJMEDIA_RTP_ESESSPROBATION,   "RTP session in probation" }, 
     102    { PJMEDIA_RTP_EBADSEQ,          "Bad sequence number in RTP packet" }, 
     103 
    88104}; 
    89105 
  • pjproject/trunk/pjmedia/src/pjmedia/jbuf.c

    r169 r188  
    391391} 
    392392 
    393 PJ_DEF(unsigned) pjmedia_jbuf_get_prefetch_size(pjmedia_jbuf *jb) 
     393PJ_DEF(unsigned) pjmedia_jbuf_get_min_delay_size(pjmedia_jbuf *jb) 
    394394{ 
    395395    return jb->jb_prefetch; 
    396396} 
    397397 
    398 PJ_DEF(unsigned) pjmedia_jbuf_get_current_size(pjmedia_jbuf *jb) 
     398PJ_DEF(unsigned) pjmedia_jbuf_get_delay(pjmedia_jbuf *jb) 
    399399{ 
    400400    return jb_framelist_size(&jb->jb_framelist); 
  • pjproject/trunk/pjmedia/src/pjmedia/rtcp.c

    r164 r188  
    1818 */ 
    1919#include <pjmedia/rtcp.h> 
     20#include <pjmedia/errno.h> 
    2021#include <pj/os.h>      /* pj_gettimeofday */ 
    2122#include <pj/sock.h>    /* pj_htonx, pj_ntohx */ 
     
    8081    s->jitter = 0; 
    8182 
    82     pj_rtp_seq_restart(&s->seq_ctrl, seq); 
     83    pjmedia_rtp_seq_restart(&s->seq_ctrl, seq); 
    8384} 
    8485 
     
    9293 
    9394    /* Update sequence numbers (received, lost, etc). */ 
    94     status = pj_rtp_seq_update(&s->seq_ctrl, seq); 
    95     if (status == PJMEDIA_RTP_ERR_SESSION_RESTARTED) { 
     95    status = pjmedia_rtp_seq_update(&s->seq_ctrl, seq); 
     96    if (status == PJMEDIA_RTP_ESESSRESTART) { 
    9697        rtcp_init_seq(s, seq); 
    9798        status = 0; 
  • pjproject/trunk/pjmedia/src/pjmedia/rtp.c

    r164 r188  
    1818 */ 
    1919#include <pjmedia/rtp.h> 
     20#include <pjmedia/errno.h> 
    2021#include <pj/log.h> 
    2122#include <pj/os.h>      /* pj_gettimeofday() */ 
     
    3536 
    3637 
    37 PJ_DEF(pj_status_t) pj_rtp_session_init( pj_rtp_session *ses, 
     38PJ_DEF(pj_status_t) pjmedia_rtp_session_init( pjmedia_rtp_session *ses, 
    3839                                         int default_pt, pj_uint32_t sender_ssrc ) 
    3940{ 
    40     PJ_LOG(4, (THIS_FILE, "pj_rtp_session_init: ses=%p, default_pt=%d, ssrc=0x%x", 
     41    PJ_LOG(4, (THIS_FILE, "pjmedia_rtp_session_init: ses=%p, default_pt=%d, ssrc=0x%x", 
    4142               ses, default_pt, sender_ssrc)); 
    4243 
    4344    /* Check RTP header packing. */ 
    44     if (sizeof(struct pj_rtp_hdr) != 12) { 
     45    if (sizeof(struct pjmedia_rtp_hdr) != 12) { 
    4546        pj_assert(!"Wrong RTP header packing!"); 
    46         return PJMEDIA_RTP_ERR_RTP_PACKING; 
     47        return PJMEDIA_RTP_EINPACK; 
    4748    } 
    4849 
     
    8283 
    8384 
    84 PJ_DEF(pj_status_t) pj_rtp_encode_rtp( pj_rtp_session *ses, int pt, int m, 
     85PJ_DEF(pj_status_t) pjmedia_rtp_encode_rtp( pjmedia_rtp_session *ses, int pt, int m, 
    8586                                       int payload_len, int ts_len, 
    8687                                       const void **rtphdr, int *hdrlen ) 
     
    8990 
    9091    PJ_LOG(6, (THIS_FILE,  
    91               "pj_rtp_encode_rtp: ses=%p, pt=%d, m=%d, pt_len=%d, ts_len=%d", 
     92              "pjmedia_rtp_encode_rtp: ses=%p, pt=%d, m=%d, pt_len=%d, ts_len=%d", 
    9293              ses, pt, m, payload_len, ts_len)); 
    9394 
     
    103104    /* Return values */ 
    104105    *rtphdr = &ses->out_hdr; 
    105     *hdrlen = sizeof(pj_rtp_hdr); 
    106  
    107     return PJ_SUCCESS; 
    108 } 
    109  
    110  
    111 PJ_DEF(pj_status_t) pj_rtp_decode_rtp( pj_rtp_session *ses,  
     106    *hdrlen = sizeof(pjmedia_rtp_hdr); 
     107 
     108    return PJ_SUCCESS; 
     109} 
     110 
     111 
     112PJ_DEF(pj_status_t) pjmedia_rtp_decode_rtp( pjmedia_rtp_session *ses,  
    112113                                       const void *pkt, int pkt_len, 
    113                                        const pj_rtp_hdr **hdr, 
     114                                       const pjmedia_rtp_hdr **hdr, 
    114115                                       const void **payload, 
    115116                                       unsigned *payloadlen) 
     
    120121 
    121122    PJ_LOG(6, (THIS_FILE,  
    122               "pj_rtp_decode_rtp: ses=%p, pkt=%p, pkt_len=%d", 
     123              "pjmedia_rtp_decode_rtp: ses=%p, pkt=%p, pkt_len=%d", 
    123124              ses, pkt, pkt_len)); 
    124125 
    125126    /* Assume RTP header at the start of packet. We'll verify this later. */ 
    126     *hdr = (pj_rtp_hdr*)pkt; 
     127    *hdr = (pjmedia_rtp_hdr*)pkt; 
    127128 
    128129    /* Check RTP header sanity. */ 
    129130    if ((*hdr)->v != RTP_VERSION) { 
    130131        PJ_LOG(4, (THIS_FILE, "  invalid RTP version!")); 
    131         return PJMEDIA_RTP_ERR_INVALID_VERSION; 
     132        return PJMEDIA_RTP_EINVER; 
    132133    } 
    133134 
    134135    /* Payload is located right after header plus CSRC */ 
    135     offset = sizeof(pj_rtp_hdr) + ((*hdr)->cc * sizeof(pj_uint32_t)); 
     136    offset = sizeof(pjmedia_rtp_hdr) + ((*hdr)->cc * sizeof(pj_uint32_t)); 
    136137 
    137138    /* Adjust offset if RTP extension is used. */ 
    138139    if ((*hdr)->x) { 
    139         pj_rtp_ext_hdr *ext = (pj_rtp_ext_hdr*) (((pj_uint8_t*)pkt) + offset); 
     140        pjmedia_rtp_ext_hdr *ext = (pjmedia_rtp_ext_hdr*) (((pj_uint8_t*)pkt) + offset); 
    140141        offset += (pj_ntohs(ext->length) * sizeof(pj_uint32_t)); 
    141142    } 
     
    143144    /* Check that offset is less than packet size */ 
    144145    if (offset >= pkt_len) 
    145         return PJMEDIA_RTP_ERR_INVALID_PACKET; 
     146        return PJMEDIA_RTP_EINLEN; 
    146147 
    147148    /* Find and set payload. */ 
     
    153154 
    154155 
    155 PJ_DEF(pj_status_t) pj_rtp_session_update( pj_rtp_session *ses, const pj_rtp_hdr *hdr) 
     156PJ_DEF(pj_status_t) pjmedia_rtp_session_update( pjmedia_rtp_session *ses, const pjmedia_rtp_hdr *hdr) 
    156157{ 
    157158    int status; 
     
    161162    /* 
    162163    if (pj_ntohl(ses->peer_ssrc) != hdr->ssrc) { 
    163         PJ_LOG(4, (THIS_FILE, "pj_rtp_session_update: ses=%p, invalid ssrc 0x%p (!=0x%p)", 
     164        PJ_LOG(4, (THIS_FILE, "pjmedia_rtp_session_update: ses=%p, invalid ssrc 0x%p (!=0x%p)", 
    164165                   ses, pj_ntohl(hdr->ssrc), ses->peer_ssrc)); 
    165         return PJMEDIA_RTP_ERR_INVALID_SSRC; 
     166        return PJMEDIA_RTP_EINSSRC; 
    166167    } 
    167168    */ 
     
    169170    /* Check payload type. */ 
    170171    if (hdr->pt != ses->out_pt) { 
    171         PJ_LOG(4, (THIS_FILE, "pj_rtp_session_update: ses=%p, invalid payload type %d (!=%d)", 
     172        PJ_LOG(4, (THIS_FILE, "pjmedia_rtp_session_update: ses=%p, invalid payload type %d (!=%d)", 
    172173                   ses, hdr->pt, ses->out_pt)); 
    173         return PJMEDIA_RTP_ERR_INVALID_PT; 
     174        return PJMEDIA_RTP_EINPT; 
    174175    } 
    175176 
    176177    /* Initialize sequence number on first packet received. */ 
    177178    if (ses->received == 0) 
    178         pj_rtp_seq_init( &ses->seq_ctrl, pj_ntohs(hdr->seq) ); 
     179        pjmedia_rtp_seq_init( &ses->seq_ctrl, pj_ntohs(hdr->seq) ); 
    179180 
    180181    /* Check sequence number to see if remote session has been restarted. */ 
    181     status = pj_rtp_seq_update( &ses->seq_ctrl, pj_ntohs(hdr->seq)); 
    182     if (status == PJMEDIA_RTP_ERR_SESSION_RESTARTED) { 
    183         pj_rtp_seq_restart( &ses->seq_ctrl, pj_ntohs(hdr->seq)); 
     182    status = pjmedia_rtp_seq_update( &ses->seq_ctrl, pj_ntohs(hdr->seq)); 
     183    if (status == PJMEDIA_RTP_ESESSRESTART) { 
     184        pjmedia_rtp_seq_restart( &ses->seq_ctrl, pj_ntohs(hdr->seq)); 
    184185        ++ses->received; 
    185     } else if (status == 0 || status == PJMEDIA_RTP_ERR_SESSION_PROBATION) { 
     186    } else if (status == 0 || status == PJMEDIA_RTP_ESESSPROBATION) { 
    186187        ++ses->received; 
    187188    } 
     
    192193 
    193194 
    194 void pj_rtp_seq_restart(pj_rtp_seq_session *sctrl, pj_uint16_t seq) 
     195void pjmedia_rtp_seq_restart(pjmedia_rtp_seq_session *sctrl, pj_uint16_t seq) 
    195196{ 
    196197    sctrl->base_seq = seq; 
     
    201202 
    202203 
    203 void pj_rtp_seq_init(pj_rtp_seq_session *sctrl, pj_uint16_t seq) 
    204 { 
    205     pj_rtp_seq_restart(sctrl, seq); 
     204void pjmedia_rtp_seq_init(pjmedia_rtp_seq_session *sctrl, pj_uint16_t seq) 
     205{ 
     206    pjmedia_rtp_seq_restart(sctrl, seq); 
    206207 
    207208    sctrl->max_seq = (pj_uint16_t) (seq - 1); 
     
    210211 
    211212 
    212 int pj_rtp_seq_update(pj_rtp_seq_session *sctrl, pj_uint16_t seq) 
     213pj_status_t pjmedia_rtp_seq_update(pjmedia_rtp_seq_session *sctrl,  
     214                                   pj_uint16_t seq) 
    213215{ 
    214216    pj_uint16_t udelta = (pj_uint16_t) (seq - sctrl->max_seq); 
     
    224226            sctrl->max_seq = seq; 
    225227            if (sctrl->probation == 0) { 
    226                 return PJMEDIA_RTP_ERR_SESSION_RESTARTED; 
     228                return PJMEDIA_RTP_ESESSRESTART; 
    227229            } 
    228230        } else { 
     
    230232            sctrl->max_seq = seq; 
    231233        } 
    232         return PJMEDIA_RTP_ERR_SESSION_PROBATION; 
     234        return PJMEDIA_RTP_ESESSPROBATION; 
    233235 
    234236    } else if (udelta < MAX_DROPOUT) { 
     
    248250             * (i.e., pretend this was the first packet). 
    249251             */ 
    250             return PJMEDIA_RTP_ERR_SESSION_RESTARTED; 
     252            return PJMEDIA_RTP_ESESSRESTART; 
    251253        } 
    252254        else { 
    253255            sctrl->bad_seq = (seq + 1) & (RTP_SEQ_MOD-1); 
    254             return PJMEDIA_RTP_ERR_BAD_SEQUENCE; 
     256            return PJMEDIA_RTP_EBADSEQ; 
    255257        } 
    256258    } else { 
     
    258260    } 
    259261     
    260     return 0; 
    261 } 
    262  
    263  
     262    return PJ_SUCCESS; 
     263} 
     264 
     265 
  • pjproject/trunk/pjmedia/src/pjmedia/sdp.c

    r183 r188  
    180180{ 
    181181    PJ_ASSERT_RETURN(count && attr_array && attr, PJ_EINVAL); 
    182     PJ_ASSERT_RETURN(*count < PJSDP_MAX_ATTR, PJ_ETOOMANY); 
     182    PJ_ASSERT_RETURN(*count < PJMEDIA_MAX_SDP_ATTR, PJ_ETOOMANY); 
    183183 
    184184    attr_array[*count] = attr; 
  • pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c

    r163 r188  
    579579              found_matching_other = 0; 
    580580    unsigned pt_answer_count = 0; 
    581     pj_str_t pt_answer[PJSDP_MAX_FMT]; 
     581    pj_str_t pt_answer[PJMEDIA_MAX_SDP_FMT]; 
    582582    pjmedia_sdp_media *answer; 
    583583 
     
    757757    pj_bool_t has_active = PJ_FALSE; 
    758758    pjmedia_sdp_session *answer; 
    759     char media_used[PJSDP_MAX_MEDIA]; 
     759    char media_used[PJMEDIA_MAX_SDP_MEDIA]; 
    760760    unsigned i; 
    761761 
  • pjproject/trunk/pjmedia/src/pjmedia/session.c

    r169 r188  
    3232    pjmedia_endpt          *endpt; 
    3333    unsigned                stream_cnt; 
    34     pjmedia_stream_info     stream_info[PJSDP_MAX_MEDIA]; 
    35     pjmedia_stream         *stream[PJSDP_MAX_MEDIA]; 
     34    pjmedia_stream_info     stream_info[PJMEDIA_MAX_SDP_MEDIA]; 
     35    pjmedia_stream         *stream[PJMEDIA_MAX_SDP_MEDIA]; 
    3636}; 
    3737 
  • pjproject/trunk/pjmedia/src/pjmedia/stream.c

    r169 r188  
    1818 */ 
    1919#include <pjmedia/stream.h> 
     20#include <pjmedia/errno.h> 
    2021#include <pjmedia/rtp.h> 
    2122#include <pjmedia/rtcp.h> 
     
    5960    unsigned                pcm_buf_size;   /**< Size of PCM buffer.        */ 
    6061    void                   *pcm_buf;        /**< PCM buffer.                */ 
    61     pj_rtp_session          rtp;            /**< RTP session.               */ 
     62    pjmedia_rtp_session     rtp;            /**< RTP session.               */ 
    6263}; 
    6364 
     
    196197    frame_in.buf = (void*)frame; 
    197198    frame_in.size = size; 
    198     frame_out.buf = ((char*)channel->out_pkt) + sizeof(pj_rtp_hdr); 
     199    frame_out.buf = ((char*)channel->out_pkt) + sizeof(pjmedia_rtp_hdr); 
    199200    status = stream->codec->op->encode( stream->codec, &frame_in,  
    200                                         channel->out_pkt_size - sizeof(pj_rtp_hdr),  
     201                                        channel->out_pkt_size - sizeof(pjmedia_rtp_hdr),  
    201202                                        &frame_out); 
    202203    if (status != 0) { 
     
    208209    /* Encapsulate. */ 
    209210    ts_len = size / (channel->snd_info.bits_per_sample / 8); 
    210     status = pj_rtp_encode_rtp( &channel->rtp,  
     211    status = pjmedia_rtp_encode_rtp( &channel->rtp,  
    211212                                channel->pt, 0,  
    212213                                frame_out.size, ts_len,  
     
    218219    } 
    219220 
    220     if (rtphdrlen != sizeof(pj_rtp_hdr)) { 
     221    if (rtphdrlen != sizeof(pjmedia_rtp_hdr)) { 
    221222        /* We don't support RTP with extended header yet. */ 
    222223        PJ_TODO(SUPPORT_SENDING_RTP_WITH_EXTENDED_HEADER); 
     
    225226    } 
    226227 
    227     pj_memcpy(channel->out_pkt, rtphdr, sizeof(pj_rtp_hdr)); 
     228    pj_memcpy(channel->out_pkt, rtphdr, sizeof(pjmedia_rtp_hdr)); 
    228229 
    229230    /* Send. */ 
    230     sent = frame_out.size+sizeof(pj_rtp_hdr); 
     231    sent = frame_out.size+sizeof(pjmedia_rtp_hdr); 
    231232    status = pj_sock_sendto(stream->skinfo.rtp_sock, channel->out_pkt, &sent, 0,  
    232233                            &stream->rem_rtp_addr, sizeof(stream->rem_rtp_addr)); 
     
    236237    /* Update stat */ 
    237238    stream->stat.enc.pkt++; 
    238     stream->stat.enc.bytes += frame_out.size+sizeof(pj_rtp_hdr); 
     239    stream->stat.enc.bytes += frame_out.size+sizeof(pjmedia_rtp_hdr); 
    239240 
    240241    return 0; 
     
    254255    while (!stream->quit_flag) { 
    255256        pj_ssize_t len; 
    256         const pj_rtp_hdr *hdr; 
     257        const pjmedia_rtp_hdr *hdr; 
    257258        const void *payload; 
    258259        unsigned payloadlen; 
     
    300301 
    301302        /* Update RTP and RTCP session. */ 
    302         status = pj_rtp_decode_rtp(&channel->rtp, channel->in_pkt, len,  
     303        status = pjmedia_rtp_decode_rtp(&channel->rtp, channel->in_pkt, len,  
    303304                                   &hdr, &payload, &payloadlen); 
    304305        if (status != PJ_SUCCESS) { 
     
    308309        } 
    309310 
    310         status = pj_rtp_session_update(&channel->rtp, hdr); 
     311        status = pjmedia_rtp_session_update(&channel->rtp, hdr); 
    311312        if (status != 0 &&  
    312             status != PJMEDIA_RTP_ERR_SESSION_PROBATION &&  
    313             status != PJMEDIA_RTP_ERR_SESSION_RESTARTED)  
     313            status != PJMEDIA_RTP_ESESSPROBATION &&  
     314            status != PJMEDIA_RTP_ESESSRESTART)  
    314315        { 
    315316            TRACE_((THIS_FILE,  
     
    393394    /* Allocate buffer for outgoing packet. */ 
    394395 
    395     channel->out_pkt_size = sizeof(pj_rtp_hdr) +  
     396    channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) +  
    396397                            codec_param->avg_bps/8 *  
    397398                            PJMEDIA_MAX_FRAME_DURATION_MS /  
     
    416417    /* Create RTP and RTCP sessions: */ 
    417418 
    418     status = pj_rtp_session_init(&channel->rtp, param->fmt.pt,  
     419    status = pjmedia_rtp_session_init(&channel->rtp, param->fmt.pt,  
    419420                                 param->ssrc); 
    420421    if (status != PJ_SUCCESS) 
  • pjproject/trunk/pjmedia/src/test/rtp_test.c

    r65 r188  
    2222int rtp_test() 
    2323{ 
    24     pj_rtp_session rtp; 
     24    pjmedia_rtp_session rtp; 
    2525    FILE *fhnd = fopen("RTP.DAT", "wb"); 
    2626    const void *rtphdr; 
     
    3030        return -1; 
    3131 
    32     pj_rtp_session_init (&rtp, 4, 0x12345678); 
    33     pj_rtp_encode_rtp (&rtp, 4, 0, 0, 160, &rtphdr, &hdrlen); 
     32    pjmedia_rtp_session_init (&rtp, 4, 0x12345678); 
     33    pjmedia_rtp_encode_rtp (&rtp, 4, 0, 0, 160, &rtphdr, &hdrlen); 
    3434    fwrite (rtphdr, hdrlen, 1, fhnd); 
    3535    fclose(fhnd); 
Note: See TracChangeset for help on using the changeset viewer.