Changes between Version 4 and Version 5 of Python_SIP/Media


Ignore:
Timestamp:
Jul 23, 2008 6:35:50 PM (16 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Python_SIP/Media

    v4 v5  
    1 = Working with Media = 
     1= Media Concept = 
    22 
    33[[TracNav(Python_SIP/TOC)]] 
    44 
    55 
    6 == The Concept == 
     6== Media Objects == 
    77 
    8 Media objects are objects that are capable to process media. There are several type of media objects supported in pjsua: 
     8Media objects are objects that are capable to process media. In [http://www.pjsip.org/pjmedia/docs/html/index.htm PJMEDIA] terms, these objects re implemented as media ports (or [http://www.pjsip.org/pjmedia/docs/html/group__PJMEDIA__PORT.htm pjmedia_port]).  
     9 
     10There are several type of media objects supported in pjsua: 
    911 * call, obviously, to transmit and receive media from remote person. 
    1012 * WAV file player to play WAV file 
     
    1416More media objects may be added in the future. 
    1517 
     18== The Conference Bridge == 
     19 
    1620In pjsua Python module and in [http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB.htm PJSUA API] in general, all media objects are terminated in the central conference bridge so that they are easier to manipulate. When objects are plugged-in to the conference bridge, they will be given a ''slot number'' that identifies the objects in the bridge. 
     21 
     22Each object provides different API to fetch the slot number associated with it: 
     23 * for [http://www.pjsip.org/python/pjsua.htm#Call Call] object, the slot number is in the [http://www.pjsip.org/python/pjsua.htm#CallInfo CallInfo] structure, so it can be fetch with {{{call.info().conf_slot}}} (once the media is active of course). 
     24 * for WAV file player, use [http://www.pjsip.org/python/pjsua.htm#Lib-player_get_slot lib.player_get_slot()] 
     25 * for WAV playlist, use [http://www.pjsip.org/python/pjsua.htm#Lib-playlist_get_slot lib.playlist_get_slot()] 
     26 * for WAV file recorder, use [http://www.pjsip.org/python/pjsua.htm#Lib-recorder_get_slot lib.recorder_get_slot()] 
     27 
    1728 
    1829The conference bridge provides a simple but yet powerful API to manage audio routing between the audio objects. The principle is very simple, that is you connect audio source to audio destination, and the bridge will make the audio flows from the source to destination, and that's it. If more than one sources are transmitting to the same destination, then the audio will be mixed. If one source is transmitting to more than one destinations, the bridge will take care of duplicating the audio from the source to the multiple destinations. 
     
    3344=== Sample: WAV File Playback === 
    3445 
    35 To playback the WAV file to the speaker, just connect the WAV playback object to the sound device, and that's it. Simple isn't it! 
     46To playback the WAV file to the speaker, just connect the WAV playback object to the sound device, with the snippet below: 
    3647 
    3748[[Image(conference-bridge-wav-playback.jpg)]] 
    3849 
    39 The diagram above shows the media flow from the WAV playback object to the sound device (see the red arrow). 
     50The red line in the diagram above shows the media flow from the WAV playback object to the sound device. 
    4051 
    4152Here's the code to connect the WAV playback object to the speaker: 
     
    6778 }}} 
    6879 
    69 And the media will flow from the sound device to the WAV record file, as shown in the diagram below: 
     80And the media will flow from the sound device to the WAV record file, as shown as brown line in the diagram below: 
    7081 
    7182[[Image(conference-bridge-snd-rec.jpg)]] 
     
    7889 }}} 
    7990 
    80 (Note that disconnecting the WAV recorder as above does not close the WAV file, and you can resume recording by connecting a source to the WAV recorder again.) 
     91(Note that disconnecting the WAV recorder as above does not close the WAV file, and you can resume recording by connecting a source to the WAV recorder again. You cannot playback the recorded WAV file before you close it.) 
    8192 
    8293 
    8394=== Sample: Normal Call === 
    8495 
    85 For a normal call, we'd want to establish bidirectional audio with the remote person, which can be done easily by establishing bidirectional connection between the call (with Alice, in this case) and the sound device: 
     96For a normal call, we would want to establish bidirectional audio with the remote person (with Alice, in this case), which can be done easily by connecting the sound device and the call and vice versa: 
    8697 
    8798 {{{ 
    8899#!python 
    89100 
     101 # This will connect the sound device/mic to the call 
    90102 lib.conf_connect(0, 3) 
     103 
     104 # And this will connect the call to the sound device/speaker 
    91105 lib.conf_connect(3, 0) 
    92106 }}} 
     
    101115=== Sample: Second Call === 
    102116 
    103 Suppose we want to talk with Alice and Bob at the same time. Since we already have bidirectional media connection with Alice, we just need to add the code below to establish bidirectional connection with Bob. 
     117Suppose we want to talk with Alice and Bob at the same time. Since we already have bidirectional media connection with Alice, we just need to add  bidirectional connection with Bob using the code below. 
    104118 
    105119 {{{ 
     
    110124 }}} 
    111125 
    112 Now we can talk to Alice and Bob at the same time, and we will hear audio from either party. The interconnection diagram in the bridge will be like this: 
     126The interconnection diagram in the bridge will be like this, with the code above adds the blue lines below: 
    113127 
    114128[[Image(conference-bridge-2-calls.jpg)]] 
    115129 
    116 At this stage, we can talk to both Alice and Bob, but Alice and Bob can't talk or hear each other. 
     130Now we can talk to Alice and Bob at the same time, and we will hear audio from either party. But at this stage, Alice and Bob can't talk or hear each other (i.e. we're not in full conference mode yet). 
    117131 
    118132=== Sample: Conference Call === 
     
    127141 }}} 
    128142 
    129 The snippet above will add the new connections as shown as lines with black color below: 
     143The snippet above will add the new connections as shown as black lines below: 
    130144 
    131145[[Image(conference-bridge-conf-call.jpg)]] 
    132146 
     147Now the three parties (us, Alice, and Bob) will be able to talk to each other. 
    133148 
    134149=== Sample: Recording the Conference === 
     
    148163[[Image(conference-bridge-conf-call-record.jpg)]] 
    149164 
     165That looks like a pretty intricate connections indeed, but the good thing is we don't need to worry about it as all will be taken care of by the bridge. We only need to care about what the audio routings that we want to achieve.