def on_call_media_state(call_id): ci = py_pjsua.call_get_info(call_id) if ci.media_status == py_pjsua.PJSUA_CALL_MEDIA_ACTIVE: py_pjsua.conf_connect(ci.conf_slot, 0) py_pjsua.conf_connect(0, ci.conf_slot) write_log(3, call_name(call_id) + ": media is active") else: write_log(3, call_name(call_id) + ": media is inactive")
def connect_port(): src_port = 0 dst_port = 0 print "Connect src port # (empty to cancel): " src_port = sys.stdin.readline() if src_port == "\n": return src_port = src_port.replace("\n", "") src_port = int(src_port) print "To dst port # (empty to cancel): " dst_port = sys.stdin.readline() if dst_port == "\n": return dst_port = dst_port.replace("\n", "") dst_port = int(dst_port) status = py_pjsua.conf_connect(src_port, dst_port) if status != 0: py_pjsua.perror(THIS_FILE, "Error connecting port ", status) else: write_log(3, "Port connected from " + `src_port` + " to " + `dst_port`)
ids = py_pjsua.enum_conf_ports() for id in ids: print "py media conf ports " + ` id ` cp_info = py_pjsua.conf_get_port_info(id) print "port info name " + cp_info.name pool = py_pjsua.PJ_Pool() port = py_pjsua.PJMedia_Port() status, id = py_pjsua.conf_add_port(pool, port) print "py media conf add port status " + ` status ` + " id " + ` id ` if status != 0: py_pjsua.perror("py_pjsua", "add port", status) status = py_pjsua.conf_remove_port(id) print "py media conf remove port status " + ` status ` if status != 0: py_pjsua.perror("py_pjsua", "remove port", status) status = py_pjsua.conf_connect(id, id) print "py media conf connect status " + ` status ` if status != 0: py_pjsua.perror("py_pjsua", "connect", status) status = py_pjsua.conf_disconnect(id, id) print "py media conf disconnect status " + ` status ` if status != 0: py_pjsua.perror("py_pjsua", "disconnect", status) status, id = py_pjsua.player_create("test.wav", 0) print "py media player create status " + ` status ` + " id " + ` id ` if status != 0: py_pjsua.perror("py_pjsua", "player create", status) c_id = py_pjsua.player_get_conf_port(id) print "py media player get conf port id " + ` c_id ` status = py_pjsua.player_set_pos(id, 10) if status != 0:
ids = py_pjsua.enum_conf_ports() for id in ids: print "py media conf ports " + `id` cp_info = py_pjsua.conf_get_port_info(id) print "port info name " + cp_info.name pool = py_pjsua.PJ_Pool() port = py_pjsua.PJMedia_Port() status, id = py_pjsua.conf_add_port(pool,port) print "py media conf add port status " + `status` + " id " + `id` if status != 0 : py_pjsua.perror("py_pjsua","add port",status) status = py_pjsua.conf_remove_port(id) print "py media conf remove port status " + `status` if status != 0 : py_pjsua.perror("py_pjsua","remove port",status) status = py_pjsua.conf_connect(id, id) print "py media conf connect status " + `status` if status != 0 : py_pjsua.perror("py_pjsua","connect",status) status = py_pjsua.conf_disconnect(id, id) print "py media conf disconnect status " + `status` if status != 0 : py_pjsua.perror("py_pjsua","disconnect",status) status, id = py_pjsua.player_create("test.wav", 0) print "py media player create status " + `status` + " id " + `id` if status != 0 : py_pjsua.perror("py_pjsua","player create",status) c_id = py_pjsua.player_get_conf_port(id) print "py media player get conf port id " + `c_id` status = py_pjsua.player_set_pos(id, 10) if status != 0 :