Ignore:
Timestamp:
Dec 30, 2010 4:31:16 PM (11 years ago)
Author:
ming
Message:

Re #1184: Adding pjmedia_clock_src for the purpose of audio and video synchronization and also to provide synchronization mechanism between two medias in general.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia/clock.h

    r3392 r3402  
    7979 
    8080PJ_BEGIN_DECL 
     81 
     82/** 
     83 * Media clock source. 
     84 */ 
     85typedef struct pjmedia_clock_src 
     86{ 
     87    pjmedia_type    media_type;     /**< Media type.                */ 
     88    unsigned        clock_rate;     /**< Clock rate.                */ 
     89    unsigned        ptime_usec;     /**< Frame interval (in usec).  */ 
     90    /** 
     91     * The timestamp field holds an increasing value in samples and its 
     92     * value is expected to be increased by clock_rate samples per second. 
     93     */ 
     94    pj_timestamp    timestamp; 
     95    /** 
     96     * Timestamp's last update. The last_update field contains a value in 
     97     * ticks, and it is expected to be increased by pj_get_timestamp_freq() 
     98     * ticks per second. 
     99     */ 
     100    pj_timestamp    last_update; 
     101} pjmedia_clock_src; 
     102 
     103/** 
     104 * This is an auxiliary function to initialize the media clock source. 
     105 * 
     106 * @param clocksrc          The clock source to be initialized. 
     107 * @param media_type        The media type. 
     108 * @param clock_rate        The clock rate. 
     109 * @param ptime_usec        Media frame interval (in usec). 
     110 * 
     111 * @return                  PJ_SUCCESS on success. 
     112 */ 
     113PJ_DECL(pj_status_t) pjmedia_clock_src_init( pjmedia_clock_src *clocksrc, 
     114                                             pjmedia_type media_type, 
     115                                             unsigned clock_rate, 
     116                                             unsigned ptime_usec ); 
     117 
     118/** 
     119 * This function updates the clock source's timestamp. Application should 
     120 * use this function instead of updating the timestamp directly since this 
     121 * function will also update the last_update field of the clock source. 
     122 * 
     123 * @param clocksrc          The clock source to be updated. 
     124 * @param timestamp         The new timestamp, can be NULL if the current 
     125 *                          timestamp does not change (in this case it 
     126 *                          will only update the last_update field). 
     127 * 
     128 * @return                  PJ_SUCCESS on success. 
     129 */ 
     130PJ_DECL(pj_status_t) pjmedia_clock_src_update( pjmedia_clock_src *clocksrc, 
     131                                               const pj_timestamp *timestamp ); 
     132 
     133/** 
     134 * This function gets the clock source's current timestamp. Application 
     135 * should use this function instead of accessing the timestamp directly 
     136 * since this function will calculate the predicted timestamp for current 
     137 * time, based on the values of timestamp, last_update, and clock_rate. 
     138 * 
     139 * @param clocksrc          The clock source. 
     140 * @param timestamp         Argument to receive the current timestamp 
     141 * 
     142 * @return                  PJ_SUCCESS on success. 
     143 */ 
     144PJ_DECL(pj_status_t) 
     145pjmedia_clock_src_get_current_timestamp( const pjmedia_clock_src *clocksrc, 
     146                                         pj_timestamp *timestamp); 
     147 
     148/** 
     149 * This function gets the clock source's time in msec. 
     150 * 
     151 * @param clocksrc          The clock source. 
     152 * 
     153 * @return                  The clock source's time (in msec). 
     154 */ 
     155PJ_DECL(pj_uint32_t) 
     156pjmedia_clock_src_get_time_msec( const pjmedia_clock_src *clocksrc ); 
    81157 
    82158 
Note: See TracChangeset for help on using the changeset viewer.