Changes between Version 104 and Version 105 of FAQ

Dec 3, 2010 6:47:35 AM (9 years ago)



  • FAQ

    v104 v105  
    529529The second option has some drawbacks though. First, despite the fact that the sound device is opened in stereo, you will not be able to playback stereo media in stereo, since the conference bridge is instantiated in mono, hence it will convert the stereo media ports into mono when it's connected to the bridge. And second, since you manage the sound device manually, it won't be opened/closed automatically by PJSUA-LIB as it would normally. 
     531=== How can I support new audio device that is plugged-in after the application is running?  === #snd-hot-plug 
     533PJSIP currently does not detect new audio devices that are plugged-in after the library has been initialized. The sound device list simply will not update itself. 
     535To support these new audio devices, you'd need to do the following. 
     537First you need to detect that new sound device has been inserted into the system. The methods vary, and it is outside the scope of PJSIP (for now). For Windows XP for example, you can follow the generic hardware detection procedure in, replacing the device interface class ID with audio device interface below (you can use any of it):  
     539    GUID = { 0x65E8773D, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} }, 
     540    //{ 0x65E8773E, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} }, 
     541    //{ 0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} } 
     544The next task is to update the sound device list in pjmedia. As we currently do not have an API to do this, what we can do is to shutdown and reinitialize the audio subsystem (pjmedia_aud_subsys_shutdown() and pjmedia_aud_subsys_init()) to make the backends update their device list. But you should only do this when the sound device is not being used. You can check this by using {{{pjsua_snd_is_active()}}} API. Though having said that, I briefly checked our native WMME implementation to see if opened streams are affected if the audio subsystem is shutdown, and it doesn't appear to be so. But the general behavior is undefined.  
     546Alternatively, you can manage the sound device yourself, using {{{pjsua_set_no_snd_dev()}}} facility. Using this approach, you can even change the sound device on the fly even when the media is active! Just disconnect the sound device from the bridge's port, reinitialize audio subsystem, open the new sound device, reconnect to the bridge, and voila! The newly inserted sound device is active. 
     548As yet another alternative, and this is probably the best alternative, you can let PJSIP manage the sound device (the default behavior) so that it's automatically opened/closed on demand, and call {{{pjsua_set_no_snd_dev()}}} only when you're about to reinitialize the audio subsystem, to forcefully close the currently opened sound device (if any). Once the reinitialization is complete, you can tell PJSIP to manage the sound device again with {{{pjsua_set_snd_dev()}}}.