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/src/pjmedia/sound_port.c

    r3392 r3402  
    4545    pjmedia_port        *port; 
    4646 
     47    pjmedia_clock_src    cap_clocksrc, 
     48                         play_clocksrc; 
     49 
    4750    unsigned             clock_rate; 
    4851    unsigned             channel_count; 
     
    7073    pj_status_t status; 
    7174 
     75    pjmedia_clock_src_update(&snd_port->play_clocksrc, &frame->timestamp); 
     76 
    7277    port = snd_port->port; 
    7378    if (port == NULL) 
     
    127132    pjmedia_port *port; 
    128133 
     134    pjmedia_clock_src_update(&snd_port->cap_clocksrc, &frame->timestamp); 
     135 
    129136    port = snd_port->port; 
    130137    if (port == NULL) 
     
    137144 
    138145    pjmedia_port_put_frame(port, frame); 
     146 
    139147 
    140148    return PJ_SUCCESS; 
     
    418426    pjmedia_snd_port *snd_port; 
    419427    pj_status_t status; 
     428    unsigned ptime_usec; 
    420429 
    421430    PJ_ASSERT_RETURN(pool && prm && p_port, PJ_EINVAL); 
     
    433442    snd_port->bits_per_sample = prm->bits_per_sample; 
    434443    pj_memcpy(&snd_port->aud_param, prm, sizeof(*prm)); 
     444 
     445    ptime_usec = prm->samples_per_frame * 1000 / prm->channel_count / 
     446                 prm->clock_rate * 1000; 
     447    pjmedia_clock_src_init(&snd_port->cap_clocksrc, PJMEDIA_TYPE_AUDIO, 
     448                           snd_port->clock_rate, ptime_usec); 
     449    pjmedia_clock_src_init(&snd_port->play_clocksrc, PJMEDIA_TYPE_AUDIO, 
     450                           snd_port->clock_rate, ptime_usec); 
    435451     
    436452    /* Start sound device immediately. 
     
    633649 
    634650/* 
     651 * Get clock source. 
     652 */ 
     653PJ_DEF(pjmedia_clock_src *) 
     654pjmedia_snd_port_get_clock_src( pjmedia_snd_port *snd_port, 
     655                                pjmedia_dir dir ) 
     656{ 
     657    return (dir == PJMEDIA_DIR_CAPTURE? &snd_port->cap_clocksrc: 
     658            &snd_port->play_clocksrc); 
     659} 
     660 
     661 
     662/* 
    635663 * Connect a port. 
    636664 */ 
Note: See TracChangeset for help on using the changeset viewer.