提交 573e9676 authored 作者: Anthony Minessale's avatar Anthony Minessale

update esl

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12111 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 4af5bf96
差异被折叠。
......@@ -49,23 +49,24 @@ sub this {
package ESL;
*eslSetLogLevel = *ESLc::eslSetLogLevel;
############# Class : ESL::eslEvent ##############
############# Class : ESL::ESLevent ##############
package ESL::eslEvent;
package ESL::ESLevent;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( ESL );
%OWNER = ();
%ITERATORS = ();
*swig_event_get = *ESLc::eslEvent_event_get;
*swig_event_set = *ESLc::eslEvent_event_set;
*swig_serialized_string_get = *ESLc::eslEvent_serialized_string_get;
*swig_serialized_string_set = *ESLc::eslEvent_serialized_string_set;
*swig_mine_get = *ESLc::eslEvent_mine_get;
*swig_mine_set = *ESLc::eslEvent_mine_set;
*swig_event_get = *ESLc::ESLevent_event_get;
*swig_event_set = *ESLc::ESLevent_event_set;
*swig_serialized_string_get = *ESLc::ESLevent_serialized_string_get;
*swig_serialized_string_set = *ESLc::ESLevent_serialized_string_set;
*swig_mine_get = *ESLc::ESLevent_mine_get;
*swig_mine_set = *ESLc::ESLevent_mine_set;
sub new {
my $pkg = shift;
my $self = ESLc::new_eslEvent(@_);
my $self = ESLc::new_ESLevent(@_);
bless $self, $pkg if defined($self);
}
......@@ -75,19 +76,19 @@ sub DESTROY {
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
ESLc::delete_eslEvent($self);
ESLc::delete_ESLevent($self);
delete $OWNER{$self};
}
}
*serialize = *ESLc::eslEvent_serialize;
*setPriority = *ESLc::eslEvent_setPriority;
*getHeader = *ESLc::eslEvent_getHeader;
*getBody = *ESLc::eslEvent_getBody;
*getType = *ESLc::eslEvent_getType;
*addBody = *ESLc::eslEvent_addBody;
*addHeader = *ESLc::eslEvent_addHeader;
*delHeader = *ESLc::eslEvent_delHeader;
*serialize = *ESLc::ESLevent_serialize;
*setPriority = *ESLc::ESLevent_setPriority;
*getHeader = *ESLc::ESLevent_getHeader;
*getBody = *ESLc::ESLevent_getBody;
*getType = *ESLc::ESLevent_getType;
*addBody = *ESLc::ESLevent_addBody;
*addHeader = *ESLc::ESLevent_addHeader;
*delHeader = *ESLc::ESLevent_delHeader;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
......@@ -101,16 +102,16 @@ sub ACQUIRE {
}
############# Class : ESL::eslConnection ##############
############# Class : ESL::ESLconnection ##############
package ESL::eslConnection;
package ESL::ESLconnection;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( ESL );
%OWNER = ();
%ITERATORS = ();
sub new {
my $pkg = shift;
my $self = ESLc::new_eslConnection(@_);
my $self = ESLc::new_ESLconnection(@_);
bless $self, $pkg if defined($self);
}
......@@ -120,23 +121,23 @@ sub DESTROY {
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
ESLc::delete_eslConnection($self);
ESLc::delete_ESLconnection($self);
delete $OWNER{$self};
}
}
*connected = *ESLc::eslConnection_connected;
*getInfo = *ESLc::eslConnection_getInfo;
*send = *ESLc::eslConnection_send;
*sendRecv = *ESLc::eslConnection_sendRecv;
*sendEvent = *ESLc::eslConnection_sendEvent;
*recvEvent = *ESLc::eslConnection_recvEvent;
*recvEventTimed = *ESLc::eslConnection_recvEventTimed;
*filter = *ESLc::eslConnection_filter;
*events = *ESLc::eslConnection_events;
*execute = *ESLc::eslConnection_execute;
*setBlockingExecute = *ESLc::eslConnection_setBlockingExecute;
*setEventLock = *ESLc::eslConnection_setEventLock;
*connected = *ESLc::ESLconnection_connected;
*getInfo = *ESLc::ESLconnection_getInfo;
*send = *ESLc::ESLconnection_send;
*sendRecv = *ESLc::ESLconnection_sendRecv;
*sendEvent = *ESLc::ESLconnection_sendEvent;
*recvEvent = *ESLc::ESLconnection_recvEvent;
*recvEventTimed = *ESLc::ESLconnection_recvEventTimed;
*filter = *ESLc::ESLconnection_filter;
*events = *ESLc::ESLconnection_events;
*execute = *ESLc::ESLconnection_execute;
*setBlockingExecute = *ESLc::ESLconnection_setBlockingExecute;
*setEventLock = *ESLc::ESLconnection_setEventLock;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
......
差异被折叠。
......@@ -16,7 +16,7 @@ for(;;) {
my $host = $new_sock->sockhost();
my $fd = fileno($new_sock);
my $con = new ESL::eslConnection($fd);
my $con = new ESL::ESLconnection($fd);
my $info = $con->getInfo();
print $info->serialize();
......
require ESL;
use IO::Socket::INET;
#ESL::eslSetLogLevel(7);
my $ip = "127.0.0.1";
my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '8040', Proto => 'tcp', Listen => 1, Reuse => 1 );
die "Could not create socket: $!\n" unless $sock;
for(;;) {
my $new_sock = $sock->accept();
my $pid = fork();
if ($pid) {
close($new_sock);
next;
}
my $host = $new_sock->sockhost();
my $fd = fileno($new_sock);
my $con = new ESL::ESLconnection($fd);
my $info = $con->getInfo();
#print $info->serialize();
my $uuid = $info->getHeader("unique-id");
printf "Connected call %s, from %s\n", $uuid, $info->getHeader("caller-caller-id-number");
$con->sendRecv("myevents");
$con->execute("answer");
$con->execute("playback", "/ram/swimp.raw");
while($con->connected()) {
#my $e = $con->recvEventTimed(100);
my $e = $con->recvEvent();
if ($e) {
my $name = $e->getHeader("event-name");
print "EVENT [$name]\n";
if ($name eq "DTMF") {
my $digit = $e->getHeader("dtmf-digit");
my $duration = $e->getHeader("dtmf-duration");
print "DTMF digit $digit ($duration)\n";
}
}
}
print "BYE\n";
close($new_sock);
}
require ESL;
my $command = join(" ", @ARGV);
my $con = new ESL::eslConnection("localhost", "8021", "ClueCon");
my $con = new ESL::ESLconnection("localhost", "8021", "ClueCon");
my $e = $con->sendRecv("api $command");
print $e->getBody();
......@@ -27,141 +27,147 @@ if (!extension_loaded("ESL")) {
abstract class ESL {
static function eslSetLogLevel($level) {
eslSetLogLevel($level);
}
}
/* PHP Proxy Classes */
class eslEvent {
class ESLevent {
public $_cPtr=null;
function __set($var,$value) {
$func = 'eslEvent_'.$var.'_set';
$func = 'ESLevent_'.$var.'_set';
if (function_exists($func)) call_user_func($func,$this->_cPtr,$value);
}
function __isset($var) {
return function_exists('eslEvent_'.$var.'_set');
return function_exists('ESLevent_'.$var.'_set');
}
function __get($var) {
$func = 'eslEvent_'.$var.'_get';
$func = 'ESLevent_'.$var.'_get';
if (function_exists($func)) return call_user_func($func,$this->_cPtr);
return null;
}
function __construct($type_or_wrap_me,$subclass_name_or_free_me=null) {
switch (func_num_args()) {
case 1: $r=new_eslEvent($type_or_wrap_me); break;
default: $r=new_eslEvent($type_or_wrap_me,$subclass_name_or_free_me);
case 1: $r=new_ESLevent($type_or_wrap_me); break;
default: $r=new_ESLevent($type_or_wrap_me,$subclass_name_or_free_me);
}
$this->_cPtr=$r;
}
function serialize($format=null) {
switch (func_num_args()) {
case 0: $r=eslEvent_serialize($this->_cPtr); break;
default: $r=eslEvent_serialize($this->_cPtr,$format);
case 0: $r=ESLevent_serialize($this->_cPtr); break;
default: $r=ESLevent_serialize($this->_cPtr,$format);
}
return $r;
}
function setPriority($priority=null) {
switch (func_num_args()) {
case 0: $r=eslEvent_setPriority($this->_cPtr); break;
default: $r=eslEvent_setPriority($this->_cPtr,$priority);
case 0: $r=ESLevent_setPriority($this->_cPtr); break;
default: $r=ESLevent_setPriority($this->_cPtr,$priority);
}
return $r;
}
function getHeader($header_name) {
return eslEvent_getHeader($this->_cPtr,$header_name);
return ESLevent_getHeader($this->_cPtr,$header_name);
}
function getBody() {
return eslEvent_getBody($this->_cPtr);
return ESLevent_getBody($this->_cPtr);
}
function getType() {
return eslEvent_getType($this->_cPtr);
return ESLevent_getType($this->_cPtr);
}
function addBody($value) {
return eslEvent_addBody($this->_cPtr,$value);
return ESLevent_addBody($this->_cPtr,$value);
}
function addHeader($header_name,$value) {
return eslEvent_addHeader($this->_cPtr,$header_name,$value);
return ESLevent_addHeader($this->_cPtr,$header_name,$value);
}
function delHeader($header_name) {
return eslEvent_delHeader($this->_cPtr,$header_name);
return ESLevent_delHeader($this->_cPtr,$header_name);
}
}
class eslConnection {
class ESLconnection {
public $_cPtr=null;
function __construct($host_or_socket,$port=null,$password=null) {
switch (func_num_args()) {
case 1: $r=new_eslConnection($host_or_socket); break;
case 2: $r=new_eslConnection($host_or_socket,$port); break;
default: $r=new_eslConnection($host_or_socket,$port,$password);
case 1: $r=new_ESLconnection($host_or_socket); break;
case 2: $r=new_ESLconnection($host_or_socket,$port); break;
default: $r=new_ESLconnection($host_or_socket,$port,$password);
}
$this->_cPtr=$r;
}
function connected() {
return eslConnection_connected($this->_cPtr);
return ESLconnection_connected($this->_cPtr);
}
function getInfo() {
$r=eslConnection_getInfo($this->_cPtr);
return is_resource($r) ? new eslEvent($r) : $r;
$r=ESLconnection_getInfo($this->_cPtr);
return is_resource($r) ? new ESLevent($r) : $r;
}
function send($cmd) {
return eslConnection_send($this->_cPtr,$cmd);
return ESLconnection_send($this->_cPtr,$cmd);
}
function sendRecv($cmd) {
$r=eslConnection_sendRecv($this->_cPtr,$cmd);
return is_resource($r) ? new eslEvent($r) : $r;
$r=ESLconnection_sendRecv($this->_cPtr,$cmd);
return is_resource($r) ? new ESLevent($r) : $r;
}
function sendEvent($send_me) {
return eslConnection_sendEvent($this->_cPtr,$send_me);
return ESLconnection_sendEvent($this->_cPtr,$send_me);
}
function recvEvent() {
$r=eslConnection_recvEvent($this->_cPtr);
return is_resource($r) ? new eslEvent($r) : $r;
$r=ESLconnection_recvEvent($this->_cPtr);
return is_resource($r) ? new ESLevent($r) : $r;
}
function recvEventTimed($ms) {
$r=eslConnection_recvEventTimed($this->_cPtr,$ms);
return is_resource($r) ? new eslEvent($r) : $r;
$r=ESLconnection_recvEventTimed($this->_cPtr,$ms);
return is_resource($r) ? new ESLevent($r) : $r;
}
function filter($header,$value) {
return eslConnection_filter($this->_cPtr,$header,$value);
return ESLconnection_filter($this->_cPtr,$header,$value);
}
function events($etype,$value) {
return eslConnection_events($this->_cPtr,$etype,$value);
return ESLconnection_events($this->_cPtr,$etype,$value);
}
function execute($app,$arg=null,$uuid=null) {
switch (func_num_args()) {
case 1: $r=eslConnection_execute($this->_cPtr,$app); break;
case 2: $r=eslConnection_execute($this->_cPtr,$app,$arg); break;
default: $r=eslConnection_execute($this->_cPtr,$app,$arg,$uuid);
case 1: $r=ESLconnection_execute($this->_cPtr,$app); break;
case 2: $r=ESLconnection_execute($this->_cPtr,$app,$arg); break;
default: $r=ESLconnection_execute($this->_cPtr,$app,$arg,$uuid);
}
return $r;
}
function setBlockingExecute($val) {
return eslConnection_setBlockingExecute($this->_cPtr,$val);
return ESLconnection_setBlockingExecute($this->_cPtr,$val);
}
function setEventLock($val) {
return eslConnection_setEventLock($this->_cPtr,$val);
return ESLconnection_setEventLock($this->_cPtr,$val);
}
}
......
差异被折叠。
......@@ -32,32 +32,33 @@ PHP_RINIT_FUNCTION(ESL);
PHP_RSHUTDOWN_FUNCTION(ESL);
PHP_MINFO_FUNCTION(ESL);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_event_set);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_event_get);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_serialized_string_set);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_serialized_string_get);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_mine_set);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_mine_get);
ZEND_NAMED_FUNCTION(_wrap_new_eslEvent);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_serialize);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_setPriority);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_getHeader);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_getBody);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_getType);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_addBody);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_addHeader);
ZEND_NAMED_FUNCTION(_wrap_eslEvent_delHeader);
ZEND_NAMED_FUNCTION(_wrap_new_eslConnection);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_connected);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_getInfo);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_send);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_sendRecv);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_sendEvent);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_recvEvent);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_recvEventTimed);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_filter);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_events);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_execute);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_setBlockingExecute);
ZEND_NAMED_FUNCTION(_wrap_eslConnection_setEventLock);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_set);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_event_get);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_set);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialized_string_get);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_mine_set);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_mine_get);
ZEND_NAMED_FUNCTION(_wrap_new_ESLevent);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_serialize);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_setPriority);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_getHeader);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_getBody);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_getType);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_addBody);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_addHeader);
ZEND_NAMED_FUNCTION(_wrap_ESLevent_delHeader);
ZEND_NAMED_FUNCTION(_wrap_new_ESLconnection);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_connected);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_getInfo);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_send);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendRecv);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_sendEvent);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_recvEvent);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_recvEventTimed);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_events);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_execute);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setBlockingExecute);
ZEND_NAMED_FUNCTION(_wrap_ESLconnection_setEventLock);
ZEND_NAMED_FUNCTION(_wrap_eslSetLogLevel);
#endif /* PHP_ESL_H */
LOCAL_CFLAGS=
LOCAL_CFLAGS=-I/usr/include/python2.4
LOCAL_LDFLAGS=-lpython2.4
all: ESL.so
esl_wrap.cpp:
swig -module ESL -python -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
swig -module ESL -classic -python -c++ -DMULTIPLICITY -I../src/include -o esl_wrap.cpp ../ESL.i
esl_wrap.o: esl_wrap.cpp
$(CXX) $(CXX_CFLAGS) $(CXXFLAGS) $(LOCAL_CFLAGS) -c esl_wrap.cpp -o esl_wrap.o
......
## no idea how to simply ask ruby which one to use
LOCAL_CFLAGS=-I/usr/lib64/ruby/1.8/x86_64-linux
#LOCAL_CFLAGS=-I/usr/lib/ruby/1.8/i386-linux/
LOCAL_CFLAGS=-I$(shell ruby -e 'require "rbconfig"; puts RbConfig::CONFIG["topdir"]')
LOCAL_LDFLAGS=-lruby
all: ESL.so
......
差异被折叠。
差异被折叠。
......@@ -43,16 +43,16 @@ EXTERN_C
#define this_check_void() do { if (!this) { esl_log(ESL_LOG_ERROR, "object is not initalized\n"); return;}} while(0)
class eslEvent {
class ESLevent {
protected:
public:
esl_event_t *event;
char *serialized_string;
int mine;
eslEvent(const char *type, const char *subclass_name = NULL);
eslEvent(esl_event_t *wrap_me, int free_me = 0);
virtual ~eslEvent();
ESLevent(const char *type, const char *subclass_name = NULL);
ESLevent(esl_event_t *wrap_me, int free_me = 0);
virtual ~ESLevent();
const char *serialize(const char *format = NULL);
bool setPriority(esl_priority_t priority = ESL_PRIORITY_NORMAL);
const char *getHeader(char *header_name);
......@@ -65,22 +65,21 @@ class eslEvent {
class eslConnection {
class ESLconnection {
private:
esl_handle_t handle;
esl_event_t *last_event;
eslEvent *last_event_obj;
ESLevent *last_event_obj;
public:
eslConnection(const char *host, const char *port, const char *password);
eslConnection(int socket);
virtual ~eslConnection();
ESLconnection(const char *host, const char *port, const char *password);
ESLconnection(int socket);
virtual ~ESLconnection();
int connected();
eslEvent *getInfo();
ESLevent *getInfo();
esl_status_t send(const char *cmd);
eslEvent *sendRecv(const char *cmd);
esl_status_t sendEvent(eslEvent *send_me);
eslEvent *recvEvent();
eslEvent *recvEventTimed(int ms);
ESLevent *sendRecv(const char *cmd);
esl_status_t sendEvent(ESLevent *send_me);
ESLevent *recvEvent();
ESLevent *recvEventTimed(int ms);
esl_status_t filter(const char *header, const char *value);
esl_status_t events(const char *etype, const char *value);
esl_status_t execute(const char *app, const char *arg = NULL, const char *uuid = NULL);
......@@ -88,7 +87,7 @@ class eslConnection {
int setEventLock(const char *val);
};
void eslSetLogLevel(int level);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论