Permalink
Browse files

checking if linphone is initialized in methods + cleaned code

  • Loading branch information...
1 parent a0fb27d commit f28877ca908cc81a84075139f4616aa67b572f15 @juzna committed May 22, 2011
Showing with 29 additions and 23 deletions.
  1. +1 −1 AddressAPI.cpp
  2. +2 −2 CallAPI.cpp
  3. +5 −1 linphone.cpp
  4. +17 −15 linphoneAPI.cpp
  5. +1 −1 lock.cpp
  6. +2 −2 lock.h
  7. +1 −1 test.html
View
@@ -18,7 +18,7 @@
AddressAPI::AddressAPI(const FB::BrowserHostPtr& host, pthread_mutex_t *mutex, LinphoneAddress *address, bool isOwner)
: m_host(host), _mutex(mutex), _address(address), _isOwner(isOwner)
{
- printf("AddressAPI instance: %u\n", (void *) address);
+ printf("AddressAPI instance: %p\n", address);
// Register exported methods
rmethod(toString);
View
@@ -17,7 +17,7 @@
CallAPI::CallAPI(const FB::BrowserHostPtr& host, pthread_mutex_t *mutex, LinphoneCore **lin, LinphoneCall *call)
: m_host(host), _mutex(mutex), _lin(lin), _call(call), _remote()
{
- printf("CallAPI instance: %u\n", (void *) call);
+ printf("CallAPI instance: %p\n", call);
linphone_call_ref(call);
// Register exported methods
@@ -81,7 +81,7 @@ FB::JSAPIPtr CallAPI::get_remote(void) {
if(!_remote.use_count()) {
const LinphoneAddress* addr = linphone_call_get_remote_address(_call);
addr = linphone_address_clone(addr);
- printf("Got original addr pointer: %u\n", (void*) addr);
+ printf("Got original addr pointer: %p\n", addr);
_remote = boost::make_shared<AddressAPI>(m_host, _mutex, (LinphoneAddress*) addr, true);
printf("Got object addr pointer\n");
}
View
@@ -17,6 +17,7 @@
#include <sstream>
#include <string>
#include <cstdio>
+#include <stdio.h>
///////////////////////////////////////////////////////////////////////////////
/// @fn linphone::StaticInitialize()
@@ -29,6 +30,8 @@ void linphone::StaticInitialize()
{
// Place one-time initialization stuff here; As of FireBreath 1.4 this should only
// be called once per process
+
+ printf("static init\n");
}
///////////////////////////////////////////////////////////////////////////////
@@ -42,6 +45,7 @@ void linphone::StaticDeinitialize()
{
// Place one-time deinitialization stuff here. As of FireBreath 1.4 this should
// always be called just before the plugin library is unloaded
+ printf("static de-init\n");
}
///////////////////////////////////////////////////////////////////////////////
@@ -126,7 +130,7 @@ bool linphone::onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow *win)
// Assume it's X11 win (we can do it now) TODO: change this!
FB::PluginWindowX11 *win2 = (FB::PluginWindowX11*) win;
Window w3 = win2->getWindow();
- printf("Window ID is %lu\n", w3);
+ printf("Window ID is %p\n", w3);
return false;
}
View
@@ -216,10 +216,12 @@ bool linphoneAPI::call_quit(void) {
if(!lin) return false;
{
- Lo("terminate call");
+ Lo("terminate last call if necessary");
// Terminate call
- linphone_core_terminate_call(lin, NULL);
+ if(linphone_core_in_call(lin)) {
+ linphone_core_terminate_call(lin, NULL);
+ }
}
// Stop iterating
@@ -248,6 +250,7 @@ bool linphoneAPI::get_running(void) {
* Disable logging
*/
void linphoneAPI::call_disableLogs(void) {
+ CheckAndLock(NULL);
linphone_core_disable_logs();
_logging = "";
}
@@ -305,7 +308,7 @@ unsigned long linphoneAPI::get_pluginWindowId(void) {
* Add authentication info
*/
void linphoneAPI::call_addAuthInfo(std::string username, std::string realm, std::string passwd) {
- Lock lck(&mutex, "add auth info");
+ CheckAndLock("add auth info");
return addAuthInfo(username, realm, passwd);
}
@@ -321,7 +324,7 @@ void linphoneAPI::addAuthInfo(std::string username, std::string realm, std::stri
* Add proxy server
*/
void linphoneAPI::call_addProxy(std::string proxy, std::string identity) {
- Lock lck(&mutex, "add proxy");
+ CheckAndLock("add proxy");
return addProxy(proxy, identity);
}
@@ -344,24 +347,23 @@ void linphoneAPI::addProxy(std::string proxy, std::string identity) {
* Accept incoming call
*/
bool linphoneAPI::call_accept(void) {
- Lock lck(&mutex, "accept");
+ CheckAndLock("accept");
return linphone_core_accept_call(lin, NULL) != -1;
}
/**
* Terminate actual call
*/
bool linphoneAPI::call_terminate(void) {
- Lock lck(&mutex, "terminate");
+ CheckAndLock("terminate");
return linphone_core_terminate_call(lin, NULL) != -1;
}
/**
* Check whether we're registered to proxy
*/
bool linphoneAPI::get_registered(void) {
- Lock lck(&mutex, "get-registered");
- if(!lin) return false;
+ CheckAndLock("get-registered");
LinphoneProxyConfig *cfg;
int ret;
@@ -373,7 +375,7 @@ bool linphoneAPI::get_registered(void) {
}
ret = linphone_proxy_config_is_registered(cfg);
- printf("get registered: got cfg %u; %d\n", (void *) cfg, ret);
+ printf("get registered: got cfg %p; %d\n", cfg, ret);
if(cfg) return ret > 0;
else return false;
@@ -392,7 +394,7 @@ FB::JSAPIPtr linphoneAPI::_add_call(LinphoneCall *call) {
}
index = ++_call_list_counter;
- printf("Creating new call under index %u\n", index);
+ printf("Creating new call under index %lu\n", index);
CallAPIPtr cptr = boost::make_shared<CallAPI>(m_host, &mutex, &lin, call);
@@ -412,7 +414,7 @@ FB::JSAPIPtr linphoneAPI::_add_call(LinphoneCall *call) {
* Initialize new call
*/
FB::JSAPIPtr linphoneAPI::call_call(std::string uri) {
- Lock lck(&mutex, "call");
+ CheckAndLock("call");
LinphoneCall *call = linphone_core_invite(lin, uri.c_str());
if(!call) {
@@ -421,7 +423,7 @@ FB::JSAPIPtr linphoneAPI::call_call(std::string uri) {
//return (FB::JSAPIPtr) NULL; //boost::make_shared<CallAPI>(m_host, &_lin, call); // NULL;
}
else {
- printf("Call initialized, storing to map %lu\n", linphone_call_get_user_pointer(call));
+ printf("Call initialized, storing to map %p\n", linphone_call_get_user_pointer(call));
return _add_call(call);//boost::make_shared<CallAPI>(m_host, &mutex, &lin, call);
}
}
@@ -451,17 +453,17 @@ void linphoneAPI::lcb_call_state_changed(LinphoneCall *call, LinphoneCallState c
cptr = _call_list[index];
}
else {
- printf("CallAPI %d not found in registry\n", index);
+ printf("CallAPI %lu not found in registry\n", index);
return;
}
}
else {
- printf("Call %lu has no stored index to CallAPI saving\n", call);
+ printf("Call %p has no stored index to CallAPI saving\n", call);
cptr = _add_call(call);
}
// Fire event
- printf("Call %d state changed to %d - %s\n", index, cstate, message);
+ printf("Call %lu state changed to %d - %s\n", index, cstate, message);
fire_callStateChanged(cptr, cstate, message);
View
@@ -3,7 +3,7 @@
#include "lock.h"
// Initialize a lock
-Lock::Lock(pthread_mutex_t *plock, char *from) {
+Lock::Lock(pthread_mutex_t *plock, const char *from) {
if(from) {
printf("locking mutex: ");
}
View
4 lock.h
@@ -8,12 +8,12 @@
/* Lock class */
class Lock {
public:
- Lock(pthread_mutex_t *plock, char *from);
+ Lock(pthread_mutex_t *plock, const char *from);
virtual ~Lock();
private:
pthread_mutex_t* _lock;
- char *_from;
+ const char *_from;
};
View
@@ -4,7 +4,7 @@
<param name="enableVideo" value="1" />
<param name="enableVideoPreview" value="1" />
- <param name="embedVideo" value="1" />
+ <param name="embedVideo" value="0" />
<param name="autoStart" value="0" />
<param name="autoAccept" value="1" />

0 comments on commit f28877c

Please sign in to comment.