endpoint.cpp ..Error: cannot find Account instance for account id 0 in on_reg_started()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greeting ,

I write the following programs :
/*********************/

#include <pjsua2.hpp>
#include <iostream>
using namespace pj;
// Subclass to extend the Account and get notifications etc.


class MyCall : public Call
{
??? public:
??? ??? MyCall(Account &acc, int call_id = PJSUA_INVALID_ID): Call(acc, call_id){ }
??? ??? ~MyCall(){ }
??? ??? // Notification when call?s state has changed.
??? ??? //virtual void onCallState(OnCallStateParam &prm);
??? ??? // Notification when call?s media state has changed.
??? ??? //virtual void onCallMediaState(OnCallMediaStateParam &prm);
};
class MyAccount : public Account 
{
??? 
??? public:
??? ??? MyAccount() {}
??? ??? ~MyAccount() {}
??? ??? virtual void onRegState(OnRegStateParam &prm) 
??? ??? {
??? ??? ??? std::cout << " Marwan " << std::endl;
??? ??? ??? AccountInfo ai = getInfo();
??? ??? ??? std::cout << (ai.regIsActive? "*** Register:" : "*** Unregister:")
??? ??? ??? << " code=" << prm.code << std::endl;
??? ??? ??? try
??? ??? ??? {
??? ??? ??? ??? pj_thread_sleep(10000);
??? ??? ??? }
??? ??? ??? catch(Error& err) 
??? ??? ??? {
??? ??? ??? ??? std::cout << " Error in Sleep Thread: " << err.info() << std::endl;
??? ??? ??? }
??? ??? }
??? ??? virtual void onIncomingCall(OnIncomingCallParam &iprm)
??? ??? {
??? ??? ??? std::cout << " Get Incoming Call !!!! " << std::endl;
??? ??? ??? Call *call = new MyCall(*this, iprm.callId);
??? ??? ??? AudioMediaPlayer player;
??? ??? ??? AudioMedia& play_med = Endpoint::instance().audDevManager().getPlaybackDevMedia();
??? ??? ??? try {
??? ??? ??? ??? player.createPlayer("file.wav", PJMEDIA_FILE_NO_LOOP);
??? ??? ??? ??? player.startTransmit(play_med);
??? ??? ??? ????? } 
??? ??? ??? catch(Error& err)
??? ??? ??? ?{
??? ??? ??? ??? std::cout << "Player creation error: " << err.info() << std::endl;
??? ??? ??? ?}
??? ??? ??? try
??? ??? ??? {
??? ??? ??? ??? pj_thread_sleep(10000);
??? ??? ??? }
??? ??? ??? catch(Error& err) 
??? ??? ??? {
??? ??? ??? ??? std::cout << " Error in Sleep Thread: " << err.info() << std::endl;
??? ??? ??? }
??? ??? ??? try {
??? ??? ??? ??? player.stopTransmit(play_med);
??? ??? ????????????????????? }
??? ??? ??? ?catch(Error& err)
??? ??? ??? ?{
??? ??? ??? ??? std::cout << "Error in Stoping Play Transmit: " << err.info() << std::endl;
??? ??? ??? }
??? ??? ??? // Just hangup for now
??? ??? ??? CallOpParam op;
??? ??? ??? op.statusCode = PJSIP_SC_DECLINE;
??? ??? ??? call->hangup(op);
??? ??? ??? delete call;
??? ??? }
};

int mainRun()
{
??? ??? Endpoint ep;
??? ep.libCreate();
??? // Initialize endpoint
??? EpConfig ep_cfg;
??? ep.libInit( ep_cfg );

??? // Create SIP transport. Error handling sample is shown
??? 
??? 
??? try 
??? {
??? ??? TransportConfig tcfg;
??? ??? tcfg.port = 8001;
??? ??? ep.transportCreate(PJSIP_TRANSPORT_UDP, tcfg);
??? } 
??? catch (Error &err) 
??? {
??? ??? std::cout << err.info() << std::endl;
??? ??? return 1;
??? }
??? // Start the library (worker threads etc)
??? ep.libStart();
??? std::cout << "*** PJSUA2 STARTED ***" << std::endl;
??? // Configure an AccountConfig
??? AccountConfig acfg;
??? acfg.idUri = "sip:1020 at 192.168.10.1";
??? acfg.regConfig.registrarUri = "sip:192.168.10.238";
??? AuthCredInfo cred("digest", "*", "1020", 0, "1020");
??? acfg.sipConfig.authCreds.push_back( cred );
??? // Create the account
??? MyAccount *acc = new MyAccount;
??? try
??? {
??? ??? acc->create(acfg);
??? }
??? catch(Error& err) 
??? {
??? ??? std::cout << "Account creation error: " << err.info() << std::endl;
??? }
??? std::cout << " Idriss " <<std::endl;
??? // Here we don?t have anything else to do..
??? try
??? {
??? ??? pj_thread_sleep(10000);
??? }
??? catch(Error& err) 
??? {
??? ??? std::cout << " Error in Sleep Thread: " << err.info() << std::endl;
??? }
??? std::cout << " MIdriss " <<std::endl;
??? // Delete the account. This will unregister from server
??? try
??? {
??? ??? delete acc;
??? }
??? catch(Error& err) 
??? {
??? ??? std::cout << " Error in Deleting the account: " << err.info() << std::endl;
??? }
??? // This will implicitly shutdown the library
??? return 0;
}
int main()
{
??? try
??? {
??? ??? return mainRun();
??? }
??? catch(Error& err) 
??? {
??? ??? std::cout << " Error In Main " << err.info() << std::endl;
??? ??? return 0;
??? }

}

/**********************/

In the First run I am getting this error : endpoint.cpp? ..Error: cannot find Account instance for account id 0 in on_reg_started()

I find out it is related to this function at endpoint.cpp :

Account *Endpoint::lookupAcc(int acc_id, const char *op)
{
??? Account *acc = Account::lookup(acc_id);
??? if (!acc) {
??? PJ_LOG(1,(THIS_FILE,
??? ??? ? "Error: cannot find Account instance for account id %d in "
??? ??? ? "%s", acc_id, op));
??? }

??? return acc;
}


Now what is this Function lookupAcc and why it is used ?

how I can Stop ?

It is happening after registration ...

my Email marwan.idriss at yahoo.com

Regards

Marwan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20140417/25bfc104/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux