检索默认音频设备参数时出错

检索默认音频设备参数时出错

我是新手。我试图用 Python 创建一个简单的 Hello 程序来使用 pjsip 实现 SIP。我使用的代码是:


#

import sys

import pjsua as pj

#Logging callback
def log_cb(level, str, len):
    print str,

# Callback to receive events from Call
class MyCallCallback(pj.CallCallback):
    def __init__(self, call=None):
        pj.CallCallback.__init__(self, call)

    # Notification when call state has changed
    def on_state(self):
        print "Call is ", self.call.info().state_text,
        print "last code =", self.call.info().last_code, 
        print "(" + self.call.info().last_reason + ")"

    # Notification when call's media state has changed.
    def on_media_state(self):
        global lib
        if self.call.info().media_state == pj.MediaState.ACTIVE:
            # Connect the call to sound device
            call_slot = self.call.info().conf_slot
            lib.conf_connect(call_slot, 0)
            lib.conf_connect(0, call_slot)
            print "Hello world, I can talk!"


# Check command line argument
if len(sys.argv) != 2:
    print "Usage: simplecall.py <dst-URI>"
    sys.exit(1)
try:
    # Create library instance
    lib = pj.Lib()

    # Init library with default config
    lib.init(log_cfg = pj.LogConfig(level=3, callback=log_cb))

    # Create UDP transport which listens to any available port
    transport = lib.create_transport(pj.TransportType.UDP)

    # Start the library
    lib.start()

    # Create local/user-less account
    acc = lib.create_account_for_transport(transport)

    # Make call
    call = acc.make_call(sys.argv[1], MyCallCallback())

    # Wait for ENTER before quitting
    print "Press <ENTER> to quit"
    input = sys.stdin.readline().rstrip("\r\n")

    # We're done, shutdown the library
    lib.destroy()
    lib = None

except pj.Error, e:
    print "Exception: " + str(e)
    lib.destroy()
    lib = None
    sys.exit(1)

但是当我这样运行它时:

python simpleHello.py 192.168.15.66

它打印出:

11:25:46.555 os_core_unix.c !pjlib 2.2.1 for POSIX initialized
11:25:46.562 sip_endpoint.c  .Creating endpoint instance...
11:25:46.564          pjlib  .select() I/O Queue created (0x89ade80)
11:25:46.570 sip_endpoint.c  .Module "mod-msg-print" registered
11:25:46.572 sip_transport.  .Transport manager created.
11:25:46.572   pjsua_core.c  .PJSUA state changed: NULL --> CREATED
11:25:46.627   pjsua_core.c  .pjsua version 2.2.1 for Linux-3.11.0.15/i686/glibc-2.15 initialized
11:25:46.640    pjsua_aud.c  ..Error retrieving default audio device parameters: Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV) [status=420006]
Exception: Object: {Account <sip:10.0.2.15:51342>}, operation=make_call(), error=Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV)

请提供任何帮助.. :(

相关内容