Changeset 2120
- Timestamp:
- Jul 11, 2008 12:55:22 AM (16 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/python
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/python
- Property svn:ignore
-
old new 1 1 *.pyc 2 build 3 *.html 4
-
- Property svn:ignore
-
pjproject/trunk/pjsip-apps/src/python/pjsua.py
r2119 r2120 1 # $Id :$1 # $Id$ 2 2 # 3 3 # Object oriented PJSUA wrapper. … … 39 39 40 40 class Error: 41 "Error exception class" 41 """Error exception class. 42 43 Member documentation: 44 45 op_name -- name of the operation that generated this error. 46 obj -- the object that generated this error. 47 err_code -- the error code. 48 49 """ 42 50 op_name = "" 43 51 obj = None … … 67 75 68 76 class TransportType: 69 "SIP transport type constants" 77 """SIP transport type constants. 78 79 Member documentation: 80 UNSPECIFIED -- transport type is unknown or unspecified 81 UDP -- UDP transport 82 TCP -- TCP transport 83 TLS -- TLS transport 84 IPV6 -- this is not a transport type but rather a flag 85 to select the IPv6 version of a transport 86 UDP_IPV6 -- IPv6 UDP transport 87 TCP_IPV6 -- IPv6 TCP transport 88 """ 70 89 UNSPECIFIED = 0 71 90 UDP = 1 … … 77 96 78 97 class TransportFlag: 79 "Transport flags" 98 """Transport flags to indicate the characteristics of the transport. 99 100 Member documentation: 101 102 RELIABLE -- transport is reliable. 103 SECURE -- transport is secure. 104 DATAGRAM -- transport is datagram based. 105 106 """ 80 107 RELIABLE = 1 81 108 SECURE = 2 … … 83 110 84 111 class CallRole: 85 "Call role constants" 112 """Call role constants. 113 114 Member documentation: 115 116 CALLER -- role is caller 117 CALLEE -- role is callee 118 119 """ 86 120 CALLER = 0 87 121 CALLEE = 1 88 122 89 123 class CallState: 90 "Call state constants" 124 """Call state constants. 125 126 Member documentation: 127 128 NULL -- call is not initialized. 129 CALLING -- initial INVITE is sent. 130 INCOMING -- initial INVITE is received. 131 EARLY -- provisional response has been sent or received. 132 CONNECTING -- 200/OK response has been sent or received. 133 CONFIRMED -- ACK has been sent or received. 134 DISCONNECTED -- call is disconnected. 135 """ 91 136 NULL = 0 92 137 CALLING = 1 … … 99 144 100 145 class MediaState: 101 "Call media state constants" 146 """Call media state constants. 147 148 Member documentation: 149 150 NONE -- media is not available. 151 ACTIVE -- media is active. 152 LOCAL_HOLD -- media is put on-hold by local party. 153 REMOTE_HOLD -- media is put on-hold by remote party. 154 ERROR -- media error (e.g. ICE negotiation failure). 155 """ 102 156 NONE = 0 103 157 ACTIVE = 1 … … 108 162 109 163 class MediaDir: 110 "Media direction constants" 164 """Media direction constants. 165 166 Member documentation: 167 168 NONE -- media is not active 169 ENCODING -- media is active in transmit/encoding direction only. 170 DECODING -- media is active in receive/decoding direction only 171 ENCODING_DECODING -- media is active in both directions. 172 """ 111 173 NONE = 0 112 174 ENCODING = 1 … … 116 178 117 179 class PresenceActivity: 118 "Presence activities constants" 180 """Presence activities constants. 181 182 Member documentation: 183 184 UNKNOWN -- the person activity is unknown 185 AWAY -- the person is currently away 186 BUSY -- the person is currently engaging in other activity 187 """ 119 188 UNKNOWN = 0 120 189 AWAY = 1 … … 122 191 123 192 class TURNConnType: 124 "TURN connection type constants" 193 """These constants specifies the connection type to TURN server. 194 195 Member documentation: 196 UDP -- use UDP transport. 197 TCP -- use TCP transport. 198 TLS -- use TLS transport. 199 """ 125 200 UDP = 17 126 201 TCP = 6 … … 129 204 130 205 class UAConfig: 131 "User agent configuration class" 206 """User agent configuration to be specified in Lib.init(). 207 208 Member documentation: 209 210 max_calls -- maximum number of calls to be supported. 211 nameserver -- array of nameserver hostnames or IP addresses. Nameserver 212 must be configured if DNS SRV resolution is desired. 213 stun_domain -- if nameserver is configured, this can be used to query 214 the STUN server with DNS SRV. 215 stun_host -- the hostname or IP address of the STUN server. This will 216 also be used if DNS SRV resolution for stun_domain fails. 217 user_agent -- Optionally specify the user agent name. 218 """ 132 219 max_calls = 4 133 220 nameserver = [] … … 156 243 157 244 class LogConfig: 158 "Logging configuration class." 245 """Logging configuration to be specified in Lib.init(). 246 247 Member documentation: 248 249 msg_logging -- specify if SIP messages should be logged. Set to 250 True. 251 level -- specify the input verbosity level. 252 console_level -- specify the output verbosity level. 253 decor -- specify log decoration. 254 filename -- specify the log filename. 255 callback -- specify callback to be called to write the logging 256 messages. Sample function: 257 258 def log_cb(level, str, len): 259 print str, 260 261 """ 159 262 msg_logging = True 160 263 level = 5 … … 196 299 197 300 class MediaConfig: 198 "Media configuration class." 301 """Media configuration to be specified in Lib.init(). 302 303 Member documentation: 304 305 clock_rate -- specify the core clock rate of the audio, 306 most notably the conference bridge. 307 snd_clock_rate -- optionally specify different clock rate for 308 the sound device. 309 snd_auto_close_time -- specify the duration in seconds when the 310 sound device should be closed after inactivity 311 period. 312 channel_count -- specify the number of channels to open the sound 313 device and the conference bridge. 314 audio_frame_ptime -- specify the length of audio frames in millisecond. 315 max_media_ports -- specify maximum number of audio ports to be 316 supported by the conference bridge. 317 quality -- specify the audio quality setting (1-10) 318 ptime -- specify the audio packet length of transmitted 319 RTP packet. 320 no_vad -- disable Voice Activity Detector (VAD) or Silence 321 Detector (SD) 322 ilbc_mode -- specify iLBC codec mode (must be 30 for now) 323 tx_drop_pct -- randomly drop transmitted RTP packets (for 324 simulation). Number is in percent. 325 rx_drop_pct -- randomly drop received RTP packets (for 326 simulation). Number is in percent. 327 ec_options -- Echo Canceller option (specify zero). 328 ec_tail_len -- specify Echo Canceller tail length in milliseconds. 329 Value zero will disable the echo canceller. 330 jb_min -- specify the minimum jitter buffer size in 331 milliseconds. Put -1 for default. 332 jb_max -- specify the maximum jitter buffer size in 333 milliseconds. Put -1 for default. 334 enable_ice -- enable Interactive Connectivity Establishment (ICE) 335 enable_turn -- enable TURN relay. TURN server settings must also 336 be configured. 337 turn_server -- specify the domain or hostname or IP address of 338 the TURN server, in "host[:port]" format. 339 turn_conn_type -- specify connection type to the TURN server, from 340 the TURNConnType constant. 341 turn_cred -- specify AuthCred for the TURN credential. 342 """ 199 343 clock_rate = 16000 200 344 snd_clock_rate = 0 … … 281 425 282 426 class TransportConfig: 283 "SIP transport configuration class." 427 """SIP transport configuration class. 428 429 Member configuration: 430 431 port -- port number. 432 bound_addr -- optionally specify the address to bind the socket to. 433 Default is empty to bind to INADDR_ANY. 434 public_addr -- optionally override the published address for this 435 transport. If empty, the default behavior is to get 436 the public address from STUN or from the selected 437 local interface. Format is "host:port". 438 """ 284 439 port = 0 285 440 bound_addr = "" … … 302 457 class TransportInfo: 303 458 """SIP transport info. 459 460 Member documentation: 461 462 type -- transport type, from TransportType constants. 463 description -- longer description for this transport. 464 is_reliable -- True if transport is reliable. 465 is_secure -- True if transport is secure. 466 is_datagram -- True if transport is datagram based. 467 host -- the IP address of this transport. 468 port -- the port number. 469 ref_cnt -- number of objects referencing this transport. 304 470 """ 305 471 type = "" … … 346 512 347 513 def enable(self): 514 """Enable this transport.""" 348 515 err = _pjsua.transport_set_enable(self._id, True) 349 516 self._lib._err_check("enable()", self, err) 350 517 351 518 def disable(self): 519 """Disable this transport.""" 352 520 err = _pjsua.transport_set_enable(self._id, 0) 353 521 self._lib._err_check("disable()", self, err) 354 522 355 523 def close(self, force=False): 524 """Close and destroy this transport. 525 526 Keyword argument: 527 force -- force deletion of this transport (not recommended). 528 """ 356 529 err = _pjsua.transport_close(self._id, force) 357 530 self._lib._err_check("close()", self, err) … … 359 532 360 533 class SIPUri: 534 """Helper class to parse the most important components of SIP URI. 535 536 Member documentation: 537 538 scheme -- URI scheme ("sip" or "sips") 539 user -- user part of the URI (may be empty) 540 host -- host name part 541 port -- optional port number (zero if port is not specified). 542 transport -- transport parameter, or empty if transport is not 543 specified. 544 545 """ 361 546 scheme = "" 362 547 user = "" … … 365 550 transport = "" 366 551 367 def __init__(self, uri): 368 self.decode(uri) 552 def __init__(self, uri=None): 553 if uri: 554 self.decode(uri) 369 555 370 556 def decode(self, uri): 557 """Parse SIP URL. 558 559 Keyword argument: 560 uri -- the URI string. 561 562 """ 371 563 self.scheme, self.user, self.host, self.port, self.transport = \ 372 564 _pjsua.parse_simple_uri(uri) 373 565 374 566 def encode(self): 567 """Encode this object into SIP URI string. 568 569 Return: 570 URI string. 571 572 """ 375 573 output = self.scheme + ":" 376 574 if self.user and len(self.user): … … 383 581 return output 384 582 583 385 584 class AuthCred: 386 "Authentication credential." 585 """Authentication credential for SIP or TURN account. 586 587 Member documentation: 588 589 scheme -- authentication scheme (default is "Digest") 590 realm -- realm 591 username -- username 592 passwd_type -- password encoding (zero for plain-text) 593 passwd -- the password 594 """ 387 595 scheme = "Digest" 388 596 realm = "*" … … 400 608 401 609 class AccountConfig: 402 """ This describes account configuration. 610 """ This describes account configuration to create an account. 611 612 Member documentation: 613 614 priority -- account priority for matching incoming 615 messages. 616 id -- SIP URI of this account. This setting is 617 mandatory. 618 force_contact -- force to use this URI as Contact URI. Setting 619 this value is generally not recommended. 620 reg_uri -- specify the registrar URI. Mandatory if 621 registration is required. 622 reg_timeout -- specify the SIP registration refresh interval 623 in seconds. 624 require_100rel -- specify if reliable provisional response is 625 to be enforced (with Require header). 626 publish_enabled -- specify if PUBLISH should be used. When 627 enabled, the PUBLISH will be sent to the 628 registrar. 629 pidf_tuple_id -- optionally specify the tuple ID in outgoing 630 PIDF document. 631 proxy -- list of proxy URI. 632 auth_cred -- list of AuthCred containing credentials to 633 authenticate against the registrars and 634 the proxies. 635 auth_initial_send -- specify if empty Authorization header should be 636 sent. May be needed for IMS. 637 auth_initial_algorithm -- when auth_initial_send is enabled, optionally 638 specify the authentication algorithm to use. 639 Valid values are "md5", "akav1-md5", or 640 "akav2-md5". 641 transport_id -- optionally specify the transport ID to be used 642 by this account. Shouldn't be needed unless 643 for specific requirements (e.g. in multi-homed 644 scenario). 645 allow_contact_rewrite -- specify whether the account should learn its 646 Contact address from REGISTER response and 647 update the registration accordingly. Default is 648 True. 649 ka_interval -- specify the interval to send NAT keep-alive 650 packet. 651 ka_data -- specify the NAT keep-alive packet contents. 652 use_srtp -- specify the SRTP usage policy. Valid values 653 are: 0=disable, 1=optional, 2=mandatory. 654 Default is 0. 655 srtp_secure_signaling -- specify the signaling security level required 656 by SRTP. Valid values are: 0=no secure 657 transport is required, 1=hop-by-hop secure 658 transport such as TLS is required, 2=end-to- 659 end secure transport is required (i.e. "sips"). 403 660 """ 404 661 priority = 0 … … 540 797 with Account.info(). 541 798 799 Member documentation: 800 801 is_default -- True if this is the default account. 802 uri -- the account URI. 803 reg_active -- True if registration is active for this account. 804 reg_expires -- contains the current registration expiration value, 805 in seconds. 806 reg_status -- the registration status. If the value is less than 807 700, it specifies SIP status code. Value greater than 808 this specifies the error code. 809 reg_reason -- contains the registration status text (e.g. the 810 error message). 811 online_status -- the account's presence online status, True if it's 812 publishing itself as online. 813 online_text -- the account's presence status text. 814 542 815 """ 543 816 is_default = False … … 567 840 using Account.set_callback() to start receiving events from the Account 568 841 object. 842 843 Member documentation: 844 845 account -- the Account object. 846 569 847 """ 570 848 account = None … … 830 1108 Use Call.set_callback() method to install instance of this callback 831 1109 class to receive event notifications from the call object. 1110 1111 Member documentation: 1112 1113 call -- the Call object. 1114 832 1115 """ 833 1116 call = None … … 962 1245 963 1246 Application may retrieve this information with Call.info(). 1247 1248 Member documentation: 1249 1250 role -- CallRole 1251 account -- Account object. 1252 uri -- SIP URI of local account. 1253 contact -- local Contact URI. 1254 remote_uri -- remote SIP URI. 1255 remote_contact -- remote Contact URI 1256 sip_call_id -- call's Call-ID identification 1257 state -- CallState 1258 state_text -- state text. 1259 last_code -- last SIP status code 1260 last_reason -- text phrase for last_code 1261 media_state -- MediaState 1262 media_dir -- MediaDir 1263 conf_slot -- conference slot number for this call. 1264 call_time -- call's connected duration in seconds. 1265 total_time -- total call duration in seconds. 964 1266 """ 965 1267 role = CallRole.CALLER … … 1218 1520 """This class contains information about Buddy. Application may 1219 1521 retrieve this information by calling Buddy.info(). 1522 1523 Member documentation: 1524 1525 uri -- the Buddy URI. 1526 contact -- the Buddy Contact URI, if available. 1527 online_status -- the presence online status. 1528 online_text -- the presence online status text. 1529 activity -- the PresenceActivity 1530 subscribed -- specify whether buddy's presence status is currently 1531 being subscribed. 1220 1532 """ 1221 1533 uri = "" … … 1243 1555 presence status change. Application needs to derive a class from 1244 1556 this class, and register the instance with Buddy.set_callback(). 1557 1558 Member documentation: 1559 1560 buddy -- the Buddy object. 1245 1561 """ 1246 1562 buddy = None … … 1392 1708 # Sound device info 1393 1709 class SoundDeviceInfo: 1710 """This described the sound device info. 1711 1712 Member documentation: 1713 name -- device name. 1714 input_channels -- number of capture channels supported. 1715 output_channels -- number of playback channels supported. 1716 default_clock_rate -- default sampling rate. 1717 """ 1394 1718 name = "" 1395 1719 input_channels = 0 1396 output_ output_channels = 01720 output_channels = 0 1397 1721 default_clock_rate = 0 1398 1722 … … 1406 1730 # Codec info 1407 1731 class CodecInfo: 1732 """This describes codec info. 1733 1734 Member documentation: 1735 name -- codec name 1736 priority -- codec priority (0-255) 1737 clock_rate -- clock rate 1738 channel_count -- number of channels 1739 avg_bps -- average bandwidth in bits per second 1740 frm_ptime -- base frame length in milliseconds 1741 ptime -- RTP frame length in milliseconds. 1742 pt -- payload type. 1743 vad_enabled -- specify if Voice Activity Detection is currently 1744 enabled. 1745 plc_enabled -- specify if Packet Lost Concealment is currently 1746 enabled. 1747 """ 1408 1748 name = "" 1409 1749 priority = 0 … … 1439 1779 # Codec parameter 1440 1780 class CodecParameter: 1781 """This specifies various parameters that can be configured for codec. 1782 1783 Member documentation: 1784 1785 ptime -- specify the outgoing RTP packet length in milliseconds. 1786 vad_enabled -- specify if VAD should be enabled. 1787 plc_enabled -- specify if PLC should be enabled. 1788 """ 1441 1789 ptime = 0 1442 1790 vad_enabled = False -
pjproject/trunk/pjsip-apps/src/python/samples/presence.py
r2119 r2120 1 # $Id :$1 # $Id$ 2 2 # 3 3 # Presence and instant messaging … … 7 7 import sys 8 8 import pjsua as pj 9 import threading10 9 11 10 LOG_LEVEL = 3 -
pjproject/trunk/pjsip-apps/src/python/setup.py
r2119 r2120 2 2 import os 3 3 import sys 4 5 VERSION = "0.9.0" 4 6 5 7 # Fill in pj_inc_dirs … … 32 34 33 35 34 setup(name="_pjsua", version= "0.9",36 setup(name="_pjsua", version=VERSION, 35 37 ext_modules = [ 36 38 Extension("_pjsua", … … 43 45 ]) 44 46 47 setup(name="pjsua", version=VERSION, py_modules=["pjsua"]) 48 49
Note: See TracChangeset
for help on using the changeset viewer.