Ignore:
Timestamp:
Jan 28, 2009 6:03:12 PM (15 years ago)
Author:
nanang
Message:

Initial sources of APS-direct.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/port.h

    r2394 r2434  
    2626 */ 
    2727#include <pjmedia/types.h> 
     28#include <pj/assert.h> 
    2829#include <pj/os.h> 
    2930 
     
    212213    pj_bool_t       need_info;          /**< Need info on connect?          */ 
    213214    unsigned        pt;                 /**< Payload type (can be dynamic). */ 
     215    pjmedia_fourcc  format;             /**< Format (FourCC identifier)     */ 
    214216    pj_str_t        encoding_name;      /**< Encoding name.                 */ 
    215217    unsigned        clock_rate;         /**< Sampling rate.                 */ 
     
    227229{ 
    228230    PJMEDIA_FRAME_TYPE_NONE,        /**< No frame.              */ 
    229     PJMEDIA_FRAME_TYPE_AUDIO        /**< Normal audio frame.    */ 
     231    PJMEDIA_FRAME_TYPE_AUDIO,       /**< Normal audio frame.    */ 
     232    PJMEDIA_FRAME_TYPE_EXTENDED     /**< Extended audio frame.  */ 
    230233 
    231234} pjmedia_frame_type; 
     
    250253 
    251254/** 
     255 * The pjmedia_frame_ext is used to carry a more complex audio frames than 
     256 * the typical PCM audio frames, and it is signaled by setting the "type" 
     257 * field of a pjmedia_frame to PJMEDIA_FRAME_TYPE_EXTENDED. With this set, 
     258 * application may typecast pjmedia_frame to pjmedia_frame_ext. 
     259 * 
     260 * This structure may contain more than one audio frames, which subsequently 
     261 * will be called subframes in this structure. The subframes section 
     262 * immediately follows the end of this structure, and each subframe is 
     263 * represented by pjmedia_frame_ext_subframe structure. Every next 
     264 * subframe immediately follows the previous subframe, and all subframes 
     265 * are byte-aligned although its payload may not be byte-aligned. 
     266 */ 
     267typedef struct pjmedia_frame_ext { 
     268    pjmedia_frame   base;           /**< Base frame info */ 
     269    pj_uint16_t     samples_cnt;    /**< Number of samples in this frame */ 
     270    pj_uint16_t     subframe_cnt;   /**< Number of (sub)frames in this frame */ 
     271 
     272    /* Zero or more (sub)frames follows immediately after this, 
     273     * each will be represented by pjmedia_frame_ext_subframe 
     274     */ 
     275} pjmedia_frame_ext; 
     276 
     277/** 
     278 * This structure represents the individual subframes in the 
     279 * pjmedia_frame_ext structure. 
     280 */ 
     281typedef struct pjmedia_frame_ext_subframe { 
     282    pj_uint16_t     bitlen;         /**< Number of bits in the data */ 
     283    pj_uint8_t      data[1];        /**< Start of encoded data */ 
     284} pjmedia_frame_ext_subframe; 
     285 
     286 
     287/* Append one subframe to the frame_ext */ 
     288PJ_INLINE(void) pjmedia_frame_ext_append_subframe(pjmedia_frame_ext *frm, 
     289                                                  const void *src, 
     290                                                  pj_uint16_t bitlen, 
     291                                                  pj_uint16_t samples_cnt) 
     292{ 
     293    pj_uint8_t *p; 
     294    unsigned i, tmp; 
     295 
     296    p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext); 
     297    for (i = 0; i < frm->subframe_cnt; ++i) { 
     298        pjmedia_frame_ext_subframe *fsub; 
     299        fsub = (pjmedia_frame_ext_subframe*) p; 
     300        p += fsub->bitlen / 8; 
     301        if (fsub->bitlen % 8) 
     302            ++p; 
     303    } 
     304 
     305    tmp = bitlen / 8; 
     306    if (bitlen % 8) ++tmp; 
     307    pj_memcpy(p, &bitlen, sizeof(bitlen)); 
     308    pj_memcpy(p + sizeof(bitlen), src, tmp); 
     309    frm->subframe_cnt++; 
     310    frm->samples_cnt = frm->samples_cnt + samples_cnt; 
     311} 
     312 
     313/* Get the pointer and length of the n-th subframe */ 
     314PJ_INLINE(pjmedia_frame_ext_subframe*)  
     315          pjmedia_frame_ext_get_subframe(const pjmedia_frame_ext *frm, 
     316                                         unsigned n) 
     317{ 
     318    pj_uint8_t *p; 
     319    unsigned i; 
     320    pjmedia_frame_ext_subframe *tmp; 
     321 
     322    pj_assert(n < frm->subframe_cnt); 
     323 
     324    p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext); 
     325    for (i = 0; i < n; ++i) {    
     326        tmp = (pjmedia_frame_ext_subframe*) p; 
     327        p += tmp->bitlen / 8; 
     328        if (tmp->bitlen % 8) 
     329            ++p; 
     330    } 
     331     
     332    tmp = (pjmedia_frame_ext_subframe*) p; 
     333    return tmp; 
     334} 
     335         
     336/** 
    252337 * Port interface. 
    253338 */ 
Note: See TracChangeset for help on using the changeset viewer.