Changeset 2120


Ignore:
Timestamp:
Jul 11, 2008 12:55:22 AM (16 years ago)
Author:
bennylp
Message:

Updated setup.py for Linux and written more docstrings documentation

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  
        11*.pyc 
         2build 
         3*.html 
         4 
  • pjproject/trunk/pjsip-apps/src/python/pjsua.py

    r2119 r2120  
    1 # $Id:$ 
     1# $Id$ 
    22# 
    33# Object oriented PJSUA wrapper. 
     
    3939 
    4040class 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    """ 
    4250    op_name = "" 
    4351    obj = None 
     
    6775 
    6876class 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    """ 
    7089    UNSPECIFIED = 0 
    7190    UDP = 1 
     
    7796 
    7897class 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    """ 
    80107    RELIABLE = 1 
    81108    SECURE = 2 
     
    83110 
    84111class 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    """ 
    86120    CALLER = 0 
    87121    CALLEE = 1 
    88122 
    89123class 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    """ 
    91136    NULL = 0 
    92137    CALLING = 1 
     
    99144 
    100145class 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    """ 
    102156    NONE = 0 
    103157    ACTIVE = 1 
     
    108162 
    109163class 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    """ 
    111173    NONE = 0 
    112174    ENCODING = 1 
     
    116178 
    117179class 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    """ 
    119188    UNKNOWN = 0 
    120189    AWAY = 1 
     
    122191 
    123192class 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    """ 
    125200    UDP = 17 
    126201    TCP = 6 
     
    129204 
    130205class 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    """ 
    132219    max_calls = 4 
    133220    nameserver = [] 
     
    156243 
    157244class 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    """ 
    159262    msg_logging = True 
    160263    level = 5 
     
    196299 
    197300class 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    """ 
    199343    clock_rate = 16000 
    200344    snd_clock_rate = 0 
     
    281425 
    282426class 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    """ 
    284439    port = 0 
    285440    bound_addr = "" 
     
    302457class TransportInfo: 
    303458    """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. 
    304470    """ 
    305471    type = "" 
     
    346512 
    347513    def enable(self): 
     514        """Enable this transport.""" 
    348515        err = _pjsua.transport_set_enable(self._id, True) 
    349516        self._lib._err_check("enable()", self, err) 
    350517 
    351518    def disable(self): 
     519        """Disable this transport.""" 
    352520        err = _pjsua.transport_set_enable(self._id, 0) 
    353521        self._lib._err_check("disable()", self, err) 
    354522 
    355523    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        """ 
    356529        err = _pjsua.transport_close(self._id, force) 
    357530        self._lib._err_check("close()", self, err) 
     
    359532 
    360533class 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    """ 
    361546    scheme = "" 
    362547    user = "" 
     
    365550    transport = "" 
    366551 
    367     def __init__(self, uri): 
    368         self.decode(uri) 
     552    def __init__(self, uri=None): 
     553        if uri: 
     554            self.decode(uri) 
    369555 
    370556    def decode(self, uri): 
     557        """Parse SIP URL. 
     558 
     559        Keyword argument: 
     560        uri -- the URI string. 
     561 
     562        """ 
    371563        self.scheme, self.user, self.host, self.port, self.transport = \ 
    372564            _pjsua.parse_simple_uri(uri) 
    373565 
    374566    def encode(self): 
     567        """Encode this object into SIP URI string. 
     568 
     569        Return: 
     570            URI string. 
     571 
     572        """ 
    375573        output = self.scheme + ":" 
    376574        if self.user and len(self.user): 
     
    383581        return output 
    384582 
     583 
    385584class 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    """ 
    387595    scheme = "Digest" 
    388596    realm = "*" 
     
    400608 
    401609class 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"). 
    403660    """ 
    404661    priority = 0 
     
    540797    with Account.info(). 
    541798 
     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 
    542815    """ 
    543816    is_default = False 
     
    567840    using Account.set_callback() to start receiving events from the Account 
    568841    object. 
     842 
     843    Member documentation: 
     844 
     845    account     -- the Account object. 
     846 
    569847    """ 
    570848    account = None 
     
    8301108    Use Call.set_callback() method to install instance of this callback  
    8311109    class to receive event notifications from the call object. 
     1110 
     1111    Member documentation: 
     1112 
     1113    call    -- the Call object. 
     1114 
    8321115    """ 
    8331116    call = None 
     
    9621245 
    9631246    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. 
    9641266    """ 
    9651267    role = CallRole.CALLER 
     
    12181520    """This class contains information about Buddy. Application may  
    12191521    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. 
    12201532    """ 
    12211533    uri = "" 
     
    12431555    presence status change. Application needs to derive a class from 
    12441556    this class, and register the instance with Buddy.set_callback(). 
     1557 
     1558    Member documentation: 
     1559 
     1560    buddy   -- the Buddy object. 
    12451561    """ 
    12461562    buddy = None 
     
    13921708# Sound device info 
    13931709class 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    """ 
    13941718    name = "" 
    13951719    input_channels = 0 
    1396     output_output_channels = 0 
     1720    output_channels = 0 
    13971721    default_clock_rate = 0 
    13981722 
     
    14061730# Codec info 
    14071731class 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    """ 
    14081748    name = "" 
    14091749    priority = 0 
     
    14391779# Codec parameter 
    14401780class 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    """ 
    14411789    ptime = 0 
    14421790    vad_enabled = False 
  • pjproject/trunk/pjsip-apps/src/python/samples/presence.py

    r2119 r2120  
    1 # $Id:$ 
     1# $Id$ 
    22# 
    33# Presence and instant messaging 
     
    77import sys 
    88import pjsua as pj 
    9 import threading 
    109 
    1110LOG_LEVEL = 3 
  • pjproject/trunk/pjsip-apps/src/python/setup.py

    r2119 r2120  
    22import os 
    33import sys 
     4 
     5VERSION = "0.9.0" 
    46 
    57# Fill in pj_inc_dirs 
     
    3234 
    3335 
    34 setup(name="_pjsua", version="0.9", 
     36setup(name="_pjsua", version=VERSION, 
    3537        ext_modules = [ 
    3638                Extension("_pjsua",  
     
    4345        ]) 
    4446 
     47setup(name="pjsua", version=VERSION, py_modules=["pjsua"]) 
     48 
     49 
Note: See TracChangeset for help on using the changeset viewer.