Changes between Version 6 and Version 7 of Python_SIP/Media
- Timestamp:
- Jul 24, 2008 5:07:52 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Python_SIP/Media
v6 v7 1 = Media Concept =1 = Media Concepts = 2 2 3 3 [[TracNav(Python_SIP/TOC)]] … … 6 6 == Media Objects == 7 7 8 Media 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]).8 Media objects are objects that are capable to either produce media or takes media, with media in this case is audio. In [http://www.pjsip.org/pjmedia/docs/html/index.htm PJMEDIA] terms, these objects are implemented as media ports ([http://www.pjsip.org/pjmedia/docs/html/group__PJMEDIA__PORT.htm pjmedia_port]). 9 9 10 10 There are several type of media objects supported in pjsua: 11 * call, obviously, to transmit and receive media from remote person.11 * call, obviously, to transmit and receive media to/from remote person. 12 12 * WAV file player to play WAV file 13 13 * WAV file recorder to record audio to a WAV file … … 16 16 More media objects may be added in the future. 17 17 18 Operations about these media objects will be explained on laterchapter.18 We will only discuss the basic concept about media in this chapter. Detailed operations on these media objects will be explained on the next chapter. 19 19 20 20 == The Conference Bridge == … … 23 23 24 24 Each object provides different API to fetch the slot number associated with it: 25 * 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).25 * for [http://www.pjsip.org/python/pjsua.htm#Call Call] object, the slot number is in ''conf_slot'' of 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). 26 26 * for WAV file player, use [http://www.pjsip.org/python/pjsua.htm#Lib-player_get_slot lib.player_get_slot()] 27 27 * for WAV playlist, use [http://www.pjsip.org/python/pjsua.htm#Lib-playlist_get_slot lib.playlist_get_slot()] … … 29 29 30 30 31 The 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.31 The 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 from the sources 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. 32 32 33 33 Lets see a diagram of a conference bridge with several media objects. … … 42 42 * an active call to Bob at slot 4 43 43 44 When a media object is plugged-in to the bridge, it will not be connected to anything, so media will not flow from/to the object. When no connections are made in the bridge (like the diagram above), then no media will be flowing in the bridge at all.44 When a media object is plugged-in to the bridge, it will not be connected to anything, so media will not flow from/to any objects. 45 45 46 === Sample:WAV File Playback ===46 === WAV File Playback === 47 47 48 To playback the WAV file to the speaker, just connect the WAV playback object to the sound device, with the snippet below:48 To playback the WAV file to the speaker, just connect the WAV playback object to the sound device, to make a connection like this: 49 49 50 50 [[Image(conference-bridge-wav-playback.jpg)]] … … 71 71 72 72 73 === Sample:Recording to WAV File ===73 === Recording to WAV File === 74 74 75 75 Or if you want to record the microphone to the WAV file, simply do this: … … 94 94 95 95 96 === Sample:Normal Call ===96 === Normal Call === 97 97 98 98 For 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: … … 108 108 }}} 109 109 110 Of course on a real application, you would replace the number "3" above with the slot number of the call, which youcan get with {{{call.info().conf_slot}}}.110 Of course on a real application, we will replace the number "3" above with the slot number of the call, which we can get with {{{call.info().conf_slot}}}. 111 111 112 112 The diagram below shows the interconnection in the bridge now: … … 114 114 [[Image(conference-bridge-call.jpg)]] 115 115 116 You can see in the diagram above the bidirectional audio between sound device and the call as shown in red lines. 116 117 117 === S ample: Second Call ===118 === Second Call === 118 119 119 120 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 bidirectional connection with Bob using the code below. … … 132 133 Now 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). 133 134 134 === Sample:Conference Call ===135 === Conference Call === 135 136 136 137 To make Alice and Bob talk to each other, just establish bidirectional media between them: … … 149 150 Now the three parties (us, Alice, and Bob) will be able to talk to each other. 150 151 151 === Sample:Recording the Conference ===152 === Recording the Conference === 152 153 153 154 While doing the conference, it perfectly makes sense to want to record the conference to a WAV file, and all we need to do is to connect the microphone and both calls to the WAV recorder: … … 166 167 167 168 That 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. 169