~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/test/rtptest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
#include <unistd.h>
48
48
 
49
 
void RtpTest::setUp() {
50
 
 
51
 
        pjsipInit();
52
 
 
53
 
        CallID cid = "123456";
54
 
 
55
 
        sipcall = new SIPCall(cid, Call::Incoming, _pool);
56
 
 
57
 
        sipcall->setLocalIp("127.0.0.1");
58
 
        sipcall->setLocalAudioPort(RANDOM_LOCAL_PORT);
59
 
        sipcall->setLocalExternAudioPort(RANDOM_LOCAL_PORT);
60
 
}
61
 
 
62
 
bool RtpTest::pjsipInit() {
63
 
        // Create memory cache for pool
64
 
        pj_caching_pool_init(&_cp, &pj_pool_factory_default_policy, 0);
65
 
 
66
 
        // Create memory pool for application.
67
 
        _pool = pj_pool_create(&_cp.factory, "rtpTest", 4000, 4000, NULL);
68
 
 
69
 
        if (!_pool) {
70
 
                _debug ("----- RtpTest: Could not initialize pjsip memory pool ------");
71
 
                return PJ_ENOMEM;
72
 
        }
73
 
 
74
 
        return true;
75
 
}
76
 
 
77
 
void RtpTest::testRtpInitClose() {
78
 
        _debug ("-------------------- RtpTest::testRtpInitClose --------------------\n");
79
 
 
80
 
        audiortp = new AudioRtpFactory();
81
 
 
82
 
        try {
83
 
                _debug ("-------- Open Rtp Session ----------");
84
 
                audiortp->initAudioRtpConfig(sipcall);
85
 
                audiortp->initAudioRtpSession(sipcall);
86
 
                //AudioCodecType codecType = PAYLOAD_CODEC_ULAW;
87
 
                //AudioCodec* audioCodec = Manager::instance().getCodecDescriptorMap().instantiateCodec(codecType);
88
 
                //audiortp->start(audioCodec);
89
 
 
90
 
        } catch (...) {
91
 
                _debug ("!!! Exception occured while Oppenning Rtp !!!");
92
 
                CPPUNIT_ASSERT(false);
93
 
 
94
 
        }
95
 
 
96
 
        CPPUNIT_ASSERT (audiortp != NULL);
97
 
 
98
 
        sleep(1);
99
 
 
100
 
        _debug ("------ RtpTest::testRtpClose() ------");
101
 
 
102
 
        try {
103
 
                _debug ("------ Close Rtp Session -------");
104
 
                audiortp->stop();
105
 
 
106
 
        } catch (...) {
107
 
 
108
 
                _debug ("!!! Exception occured while closing Rtp !!!");
109
 
                CPPUNIT_ASSERT(false);
110
 
 
111
 
        }
112
 
 
113
 
        delete audiortp;
114
 
 
115
 
        audiortp = NULL;
116
 
}
117
 
 
118
 
void RtpTest::tearDown() {
119
 
        delete sipcall;
120
 
        sipcall = NULL;
 
49
void RtpTest::setUp()
 
50
{
 
51
 
 
52
    pjsipInit();
 
53
 
 
54
    CallID cid = "123456";
 
55
 
 
56
    sipcall = new SIPCall (cid, Call::Incoming, _pool);
 
57
 
 
58
    sipcall->setLocalIp ("127.0.0.1");
 
59
    sipcall->setLocalAudioPort (RANDOM_LOCAL_PORT);
 
60
    sipcall->setLocalExternAudioPort (RANDOM_LOCAL_PORT);
 
61
}
 
62
 
 
63
bool RtpTest::pjsipInit()
 
64
{
 
65
    // Create memory cache for pool
 
66
    pj_caching_pool_init (&_cp, &pj_pool_factory_default_policy, 0);
 
67
 
 
68
    // Create memory pool for application.
 
69
    _pool = pj_pool_create (&_cp.factory, "rtpTest", 4000, 4000, NULL);
 
70
 
 
71
    if (!_pool) {
 
72
        _debug ("----- RtpTest: Could not initialize pjsip memory pool ------");
 
73
        return PJ_ENOMEM;
 
74
    }
 
75
 
 
76
    return true;
 
77
}
 
78
 
 
79
void RtpTest::testRtpInitClose()
 
80
{
 
81
    _debug ("-------------------- RtpTest::testRtpInitClose --------------------\n");
 
82
 
 
83
    audiortp = new AudioRtpFactory();
 
84
 
 
85
    try {
 
86
        _debug ("-------- Open Rtp Session ----------");
 
87
        audiortp->initAudioRtpConfig (sipcall);
 
88
        audiortp->initAudioRtpSession (sipcall);
 
89
        //AudioCodecType codecType = PAYLOAD_CODEC_ULAW;
 
90
        //AudioCodec* audioCodec = Manager::instance().getCodecDescriptorMap().instantiateCodec(codecType);
 
91
        //audiortp->start(audioCodec);
 
92
 
 
93
    } catch (...) {
 
94
        _debug ("!!! Exception occured while Oppenning Rtp !!!");
 
95
        CPPUNIT_ASSERT (false);
 
96
 
 
97
    }
 
98
 
 
99
    CPPUNIT_ASSERT (audiortp != NULL);
 
100
 
 
101
    sleep (1);
 
102
 
 
103
    _debug ("------ RtpTest::testRtpClose() ------");
 
104
 
 
105
    try {
 
106
        _debug ("------ Close Rtp Session -------");
 
107
        audiortp->stop();
 
108
 
 
109
    } catch (...) {
 
110
 
 
111
        _debug ("!!! Exception occured while closing Rtp !!!");
 
112
        CPPUNIT_ASSERT (false);
 
113
 
 
114
    }
 
115
 
 
116
    delete audiortp;
 
117
 
 
118
    audiortp = NULL;
 
119
}
 
120
 
 
121
void RtpTest::tearDown()
 
122
{
 
123
    delete sipcall;
 
124
    sipcall = NULL;
121
125
}