Ignore:
Timestamp:
Jul 19, 2011 3:42:28 AM (13 years ago)
Author:
nanang
Message:

Re #1326: Initial code integration from branch 2.0-dev to trunk as "2.0-pre-alpha-svn".

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk

  • pjproject/trunk/pjmedia/include/pjmedia/port.h

    r3553 r3664  
    2525 * @brief Port interface declaration 
    2626 */ 
    27 #include <pjmedia/types.h> 
     27#include <pjmedia/clock.h> 
     28#include <pjmedia/event.h> 
     29#include <pjmedia/format.h> 
     30#include <pjmedia/frame.h> 
     31#include <pjmedia/signatures.h> 
    2832#include <pj/assert.h> 
    2933#include <pj/os.h> 
     
    185189 
    186190/** 
     191 * Create 32bit port signature from ASCII characters. 
     192 */ 
     193#define PJMEDIA_PORT_SIG(a,b,c,d)               PJMEDIA_OBJ_SIG(a,b,c,d) 
     194 
     195 
     196/** 
    187197 * Port operation setting. 
    188198 */ 
     
    221231    pj_str_t        name;               /**< Port name.                     */ 
    222232    pj_uint32_t     signature;          /**< Port signature.                */ 
    223     pjmedia_type    type;               /**< Media type.                    */ 
    224     pj_bool_t       has_info;           /**< Has info?                      */ 
    225     pj_bool_t       need_info;          /**< Need info on connect?          */ 
    226     unsigned        pt;                 /**< Payload type (can be dynamic). */ 
    227     pjmedia_format  format;             /**< Format.                        */ 
    228     pj_str_t        encoding_name;      /**< Encoding name.                 */ 
    229     unsigned        clock_rate;         /**< Sampling rate.                 */ 
    230     unsigned        channel_count;      /**< Number of channels.            */ 
    231     unsigned        bits_per_sample;    /**< Bits/sample                    */ 
    232     unsigned        samples_per_frame;  /**< No of samples per frame.       */ 
    233     unsigned        bytes_per_frame;    /**< No of bytes per frame.         */ 
     233    pjmedia_dir     dir;                /**< Port direction.                */ 
     234    pjmedia_format  fmt;                /**< Format.                        */ 
    234235} pjmedia_port_info; 
    235236 
     237/** 
     238 * Utility to retrieve audio clock rate/sampling rate value from 
     239 * pjmedia_port_info. 
     240 * 
     241 * @param pia           Pointer to port info containing audio format. 
     242 * @return              Audio clock rate. 
     243 */ 
     244PJ_INLINE(unsigned) PJMEDIA_PIA_SRATE(const pjmedia_port_info *pia) 
     245{ 
     246    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     247              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     248    return pia->fmt.det.aud.clock_rate; 
     249} 
     250 
     251/** 
     252 * Utility to retrieve audio channel count value from pjmedia_port_info. 
     253 * 
     254 * @param pia           Pointer to port info containing audio format. 
     255 * @return              Audio channel count. 
     256 */ 
     257PJ_INLINE(unsigned) PJMEDIA_PIA_CCNT(const pjmedia_port_info *pia) 
     258{ 
     259    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     260              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     261    return pia->fmt.det.aud.channel_count; 
     262} 
     263 
     264/** 
     265 * Utility to retrieve audio bits per sample value from pjmedia_port_info. 
     266 * 
     267 * @param pia           Pointer to port info containing audio format. 
     268 * @return              Number of bits per sample. 
     269 */ 
     270PJ_INLINE(unsigned) PJMEDIA_PIA_BITS(const pjmedia_port_info *pia) 
     271{ 
     272    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     273              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     274    return pia->fmt.det.aud.bits_per_sample; 
     275} 
     276 
     277/** 
     278 * Utility to retrieve audio frame interval (ptime) value from 
     279 * pjmedia_port_info. 
     280 * 
     281 * @param pia           Pointer to port info containing audio format. 
     282 * @return              Frame interval in msec. 
     283 */ 
     284PJ_INLINE(unsigned) PJMEDIA_PIA_PTIME(const pjmedia_port_info *pia) 
     285{ 
     286    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     287              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     288    return pia->fmt.det.aud.frame_time_usec / 1000; 
     289} 
     290 
     291/** 
     292 * This is a utility routine to retrieve the audio samples_per_frame value 
     293 * from port info. 
     294 * 
     295 * @param pia           Pointer to port info containing audio format. 
     296 * @return              Samples per frame value. 
     297 */ 
     298PJ_INLINE(unsigned) PJMEDIA_PIA_SPF(const pjmedia_port_info *pia) 
     299{ 
     300    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     301              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     302    return PJMEDIA_AFD_SPF(&pia->fmt.det.aud); 
     303} 
     304 
     305/** 
     306 * This is a utility routine to retrieve the average bitrate value 
     307 * from port info. 
     308 * 
     309 * @param pia           Pointer to port info containing audio format. 
     310 * @return              Bitrate, in bits per second. 
     311 */ 
     312PJ_INLINE(unsigned) PJMEDIA_PIA_AVG_BPS(const pjmedia_port_info *pia) 
     313{ 
     314    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     315              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     316    return pia->fmt.det.aud.avg_bps; 
     317} 
     318 
     319/** 
     320 * This is a utility routine to retrieve the maximum bitrate value 
     321 * from port info. 
     322 * 
     323 * @param pia           Pointer to port info containing audio format. 
     324 * @return              Bitrate, in bits per second. 
     325 */ 
     326PJ_INLINE(unsigned) PJMEDIA_PIA_MAX_BPS(const pjmedia_port_info *pia) 
     327{ 
     328    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     329              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     330    return pia->fmt.det.aud.max_bps; 
     331} 
     332 
     333/** 
     334 * This is a utility routine to retrieve the average audio frame size value 
     335 * from pjmedia_port_info. 
     336 * 
     337 * @param pia           Pointer to port info containing audio format. 
     338 * @return              Frame size in bytes. 
     339 */ 
     340PJ_INLINE(unsigned) PJMEDIA_PIA_AVG_FSZ(const pjmedia_port_info *pia) 
     341{ 
     342    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     343              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     344    return PJMEDIA_AFD_AVG_FSZ(&pia->fmt.det.aud); 
     345} 
     346 
     347/** 
     348 * Utility to retrieve audio frame size from maximum bitrate from 
     349 * pjmedia_port_info. 
     350 * 
     351 * @param pia           Pointer to port info containing audio format. 
     352 * @return              Frame size in bytes. 
     353 */ 
     354PJ_INLINE(unsigned) PJMEDIA_PIA_MAX_FSZ(const pjmedia_port_info *pia) 
     355{ 
     356    pj_assert(pia->fmt.type==PJMEDIA_TYPE_AUDIO && 
     357              pia->fmt.detail_type==PJMEDIA_FORMAT_DETAIL_AUDIO); 
     358    return PJMEDIA_AFD_MAX_FSZ(&pia->fmt.det.aud); 
     359} 
    236360 
    237361/** 
     
    251375 
    252376    /** 
     377     * Get clock source. 
     378     * This should only be called by #pjmedia_port_get_clock_src(). 
     379     */ 
     380    pjmedia_clock_src* (*get_clock_src)(struct pjmedia_port *this_port, 
     381                                        pjmedia_dir dir); 
     382 
     383    /** 
    253384     * Sink interface.  
    254385     * This should only be called by #pjmedia_port_put_frame(). 
    255386     */ 
    256387    pj_status_t (*put_frame)(struct pjmedia_port *this_port,  
    257                              const pjmedia_frame *frame); 
     388                             pjmedia_frame *frame); 
    258389 
    259390    /** 
     
    268399     */ 
    269400    pj_status_t (*on_destroy)(struct pjmedia_port *this_port); 
     401 
     402    /** 
     403     * Get event publisher for this media port, if any. 
     404     */ 
     405    pjmedia_event_publisher *(*get_event_pub)(struct pjmedia_port *this_port); 
    270406 
    271407} pjmedia_port; 
     
    294430                                             unsigned samples_per_frame); 
    295431 
     432/** 
     433 * This is an auxiliary function to initialize port info for 
     434 * ports which deal with PCM audio. 
     435 * 
     436 * @param info              The port info to be initialized. 
     437 * @param name              Port name. 
     438 * @param signature         Port signature. 
     439 * @param dir               Port's direction. 
     440 * @param fmt               Port's media format. 
     441 * 
     442 * @return                  PJ_SUCCESS on success. 
     443 */ 
     444PJ_DECL(pj_status_t) pjmedia_port_info_init2(pjmedia_port_info *info, 
     445                                             const pj_str_t *name, 
     446                                             unsigned signature, 
     447                                             pjmedia_dir dir, 
     448                                             const pjmedia_format *fmt); 
     449 
     450 
     451/** 
     452 * Get a clock source from the port. 
     453 * 
     454 * @param port      The media port. 
     455 * @param dir       Media port's direction. 
     456 * 
     457 * @return          The clock source or NULL if clock source is not present 
     458 *                  in the port. 
     459 */ 
     460PJ_DECL(pjmedia_clock_src *) pjmedia_port_get_clock_src( pjmedia_port *port, 
     461                                                         pjmedia_dir dir ); 
     462 
    296463 
    297464/** 
     
    315482 */ 
    316483PJ_DECL(pj_status_t) pjmedia_port_put_frame( pjmedia_port *port, 
    317                                              const pjmedia_frame *frame ); 
    318  
     484                                             pjmedia_frame *frame ); 
     485 
     486/** 
     487 * Get the event publisher for the media port, if any. 
     488 * 
     489 * @param port      The media port. 
     490 * 
     491 * @return          The event publisher, or NULL if the port does not publish 
     492 *                  events. 
     493 */ 
     494PJ_DECL(pjmedia_event_publisher*) 
     495pjmedia_port_get_event_publisher(pjmedia_port *port); 
    319496 
    320497/** 
Note: See TracChangeset for help on using the changeset viewer.