How I can Comple This Code

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

 



I have this code and I need to compile it :
what include and lib I should add, and I should name the class name? ?


#include <pjsua2.hpp>
#include <iostream>
using namespace pj;
// Subclass to extend the Account and get notifications etc.
class MyAccount : public Account 
{
??? //MyAccount() {}
??? //~MyAccount() {}
??? public:
??? ??? virtual void onRegState(OnRegStateParam &prm) 
??? ??? {
??? ??? ??? AccountInfo ai = getInfo();
??? ??? ??? std::cout << (ai.regIsActive? "*** Register:" : "*** Unregister:")
??? ??? ??? << " code=" << prm.code << std::endl;
??? ??? }
??? ??? virtual void onIncomingCall(OnIncomingCallParam &iprm)
??? ??? {
??? ??? ??? Call *call = new MyCall(*this, iprm.callId);
??? ??? ??? AudioMediaPlayer player;
??? ??? ??? AudioMedia& play_med = Endpoint::instance().audDevManager().getPlaybackDevMedia();
??? ??? ??? try {
??? ??? ??? ??? player.createPlayer("file.wav");
??? ??? ??? ??? player.startTransmit(play_med);
??? ??? ??? ????? } 
??? ??? ??? catch(Error& err)
??? ??? ??? ?{
??? ??? ??? ??? cout << "Player creation error: " << err.info() << endl;
??? ??? ??? ?}
??? ??? ??? pj_thread_sleep(1000);
??? ??? ??? try {
??? ??? ??? ??? player.stopTransmit(play_med);
??? ??? ????????????????????? }
??? ??? ??? ?catch(Error& err)
??? ??? ??? ?{
??? ??? ??? ??? cout << "Error in Stoping Play Transmit: " << err.info() << endl;
??? ??? ??? }
??? ??? ??? // Just hangup for now
??? ??? ??? CallOpParam op;
??? ??? ??? op.statusCode = PJSIP_SC_DECLINE;
??? ??? ??? call->hangup(op);
??? ??? ??? delete call;
??? ??? }
};
int main()
{
??? Endpoint ep;
??? ep.libCreate();
??? // Initialize endpoint
??? EpConfig ep_cfg;
??? ep.libInit( ep_cfg );
??? // Create SIP transport. Error handling sample is shown
??? TransportConfig tcfg;
??? tcfg.port = 5060;
??? try 
??? {
??? ??? 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:test at pjsip.org";
??? acfg.regConfig.registrarUri = "sip:pjsip.org";
??? AuthCredInfo cred("digest", "*", "test", 0, "secret");
??? acfg.sipConfig.authCreds.push_back( cred );
??? // Create the account
??? MyAccount *acc = new MyAccount;
??? try
??? {
??? ??? acc->create(acfg);
??? }
??? catch(Error& err) 
??? {
??? ??? cout << "Account creation error: " << err.info() << endl;
??? }
??? // Here we don?t have anything else to do..
??? pj_thread_sleep(10000);
??? // Delete the account. This will unregister from server
??? delete acc;
??? // This will implicitly shutdown the library
??? return 0;
}

My email is 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/20140416/c109a286/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