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

« back to all changes in this revision

Viewing changes to sflphone-common/src/iax/iaxcall.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:
39
39
 
40
40
IAXCall::~IAXCall()
41
41
{
42
 
        _session = NULL; // just to be sure to don't have unknown pointer, do not delete it!
 
42
    _session = NULL; // just to be sure to don't have unknown pointer, do not delete it!
43
43
}
44
44
 
45
 
        void
 
45
void
46
46
IAXCall::setFormat (int format)
47
47
{
48
 
        _format = format;
49
 
 
50
 
        _info ("IAX set supported format: ");
51
 
 
52
 
        switch (format) {
53
 
 
54
 
                case AST_FORMAT_ULAW:
55
 
                        _info("PCMU");
56
 
                        setAudioCodec (PAYLOAD_CODEC_ULAW);
57
 
                        break;
58
 
 
59
 
                case AST_FORMAT_GSM:
60
 
                        _info ("GSM");
61
 
                        setAudioCodec (PAYLOAD_CODEC_GSM);
62
 
                        break;
63
 
 
64
 
                case AST_FORMAT_ALAW:
65
 
                        _info ("ALAW");
66
 
                        setAudioCodec (PAYLOAD_CODEC_ALAW);
67
 
                        break;
68
 
 
69
 
                case AST_FORMAT_ILBC:
70
 
                        _info ("ILBC");
71
 
                        setAudioCodec (PAYLOAD_CODEC_ILBC_20);
72
 
                        break;
73
 
 
74
 
                case AST_FORMAT_SPEEX:
75
 
                        _info ("SPEEX");
76
 
                        setAudioCodec (PAYLOAD_CODEC_SPEEX_8000);
77
 
                        break;
78
 
 
79
 
                default:
80
 
                        _info ("Error audio codec type %i not supported!", format);
81
 
                        setAudioCodec ( (AudioCodecType) -1);
82
 
                        break;
83
 
        }
 
48
    _format = format;
 
49
 
 
50
    _info ("IAX set supported format: ");
 
51
 
 
52
    switch (format) {
 
53
 
 
54
        case AST_FORMAT_ULAW:
 
55
            _info ("PCMU");
 
56
            setAudioCodec (PAYLOAD_CODEC_ULAW);
 
57
            break;
 
58
 
 
59
        case AST_FORMAT_GSM:
 
60
            _info ("GSM");
 
61
            setAudioCodec (PAYLOAD_CODEC_GSM);
 
62
            break;
 
63
 
 
64
        case AST_FORMAT_ALAW:
 
65
            _info ("ALAW");
 
66
            setAudioCodec (PAYLOAD_CODEC_ALAW);
 
67
            break;
 
68
 
 
69
        case AST_FORMAT_ILBC:
 
70
            _info ("ILBC");
 
71
            setAudioCodec (PAYLOAD_CODEC_ILBC_20);
 
72
            break;
 
73
 
 
74
        case AST_FORMAT_SPEEX:
 
75
            _info ("SPEEX");
 
76
            setAudioCodec (PAYLOAD_CODEC_SPEEX_8000);
 
77
            break;
 
78
 
 
79
        default:
 
80
            _info ("Error audio codec type %i not supported!", format);
 
81
            setAudioCodec ( (AudioCodecType) -1);
 
82
            break;
 
83
    }
84
84
}
85
85
 
86
86
 
87
 
        int
 
87
int
88
88
IAXCall::getSupportedFormat (std::string accountID)
89
89
{
90
 
        CodecOrder map;
91
 
        int format = 0;
92
 
        unsigned int iter;
93
 
        Account *account;
94
 
 
95
 
        _info ("IAX get supported format: ");
96
 
 
97
 
        account = Manager::instance().getAccount (accountID);
98
 
        if (account != NULL) {
99
 
                map = account->getActiveCodecs();
100
 
        }
101
 
        else {
102
 
                _error ("No IAx account could be found");
103
 
        }
104
 
 
105
 
        for (iter=0 ; iter < map.size() ; iter++) {
106
 
                switch (map[iter]) {
107
 
 
108
 
                        case PAYLOAD_CODEC_ULAW:
109
 
                                _info ("PCMU ");
110
 
                                format |= AST_FORMAT_ULAW;
111
 
                                break;
112
 
 
113
 
                        case PAYLOAD_CODEC_GSM:
114
 
                                _info ("GSM ");
115
 
                                format |= AST_FORMAT_GSM;
116
 
                                break;
117
 
 
118
 
                        case PAYLOAD_CODEC_ALAW:
119
 
                                _info ("PCMA ");
120
 
                                format |= AST_FORMAT_ALAW;
121
 
                                break;
122
 
 
123
 
                        case PAYLOAD_CODEC_ILBC_20:
124
 
                                _info ("ILBC ");
125
 
                                format |= AST_FORMAT_ILBC;
126
 
                                break;
127
 
 
128
 
                        case PAYLOAD_CODEC_SPEEX_8000:
129
 
                                _info ("SPEEX ");
130
 
                                format |= AST_FORMAT_SPEEX;
131
 
                                break;
132
 
 
133
 
                        default:
134
 
                                break;
135
 
                }
136
 
        }
137
 
 
138
 
        return format;
 
90
    CodecOrder map;
 
91
    int format = 0;
 
92
    unsigned int iter;
 
93
    Account *account;
 
94
 
 
95
    _info ("IAX get supported format: ");
 
96
 
 
97
    account = Manager::instance().getAccount (accountID);
 
98
 
 
99
    if (account != NULL) {
 
100
        map = account->getActiveCodecs();
 
101
    } else {
 
102
        _error ("No IAx account could be found");
 
103
    }
 
104
 
 
105
    for (iter=0 ; iter < map.size() ; iter++) {
 
106
        switch (map[iter]) {
 
107
 
 
108
            case PAYLOAD_CODEC_ULAW:
 
109
                _info ("PCMU ");
 
110
                format |= AST_FORMAT_ULAW;
 
111
                break;
 
112
 
 
113
            case PAYLOAD_CODEC_GSM:
 
114
                _info ("GSM ");
 
115
                format |= AST_FORMAT_GSM;
 
116
                break;
 
117
 
 
118
            case PAYLOAD_CODEC_ALAW:
 
119
                _info ("PCMA ");
 
120
                format |= AST_FORMAT_ALAW;
 
121
                break;
 
122
 
 
123
            case PAYLOAD_CODEC_ILBC_20:
 
124
                _info ("ILBC ");
 
125
                format |= AST_FORMAT_ILBC;
 
126
                break;
 
127
 
 
128
            case PAYLOAD_CODEC_SPEEX_8000:
 
129
                _info ("SPEEX ");
 
130
                format |= AST_FORMAT_SPEEX;
 
131
                break;
 
132
 
 
133
            default:
 
134
                break;
 
135
        }
 
136
    }
 
137
 
 
138
    return format;
139
139
 
140
140
}
141
141
 
142
 
int IAXCall::getFirstMatchingFormat (int needles, std::string accountID) {
143
 
 
144
 
        Account *account;
145
 
        CodecOrder map;
146
 
        int format = 0;
147
 
        unsigned int iter;
148
 
 
149
 
        _debug ("IAX get first matching codec: ");
150
 
 
151
 
        account = Manager::instance().getAccount (accountID);
152
 
        if (account != NULL) {
153
 
                map = account->getActiveCodecs();
154
 
        }
155
 
        else {
156
 
                _error ("No IAx account could be found");
157
 
        }
158
 
 
159
 
        for (iter=0 ; iter < map.size() ; iter++) {
160
 
                switch (map[iter]) {
161
 
 
162
 
                        case PAYLOAD_CODEC_ULAW:
163
 
                                _debug ("PCMU");
164
 
                                format = AST_FORMAT_ULAW;
165
 
                                break;
166
 
 
167
 
                        case PAYLOAD_CODEC_GSM:
168
 
                                _debug ("GSM");
169
 
                                format = AST_FORMAT_GSM;
170
 
                                break;
171
 
 
172
 
                        case PAYLOAD_CODEC_ALAW:
173
 
                                _debug ("PCMA");
174
 
                                format = AST_FORMAT_ALAW;
175
 
                                break;
176
 
 
177
 
                        case PAYLOAD_CODEC_ILBC_20:
178
 
                                _debug ("ILBC");
179
 
                                format = AST_FORMAT_ILBC;
180
 
                                break;
181
 
 
182
 
                        case PAYLOAD_CODEC_SPEEX_8000:
183
 
                                _debug ("SPEEX");
184
 
                                format = AST_FORMAT_SPEEX;
185
 
                                break;
186
 
 
187
 
                        default:
188
 
                                break;
189
 
                }
190
 
 
191
 
                // Return the first that matches
192
 
                if (format & needles)
193
 
                        return format;
194
 
 
195
 
        }
196
 
 
197
 
        return 0;
 
142
int IAXCall::getFirstMatchingFormat (int needles, std::string accountID)
 
143
{
 
144
 
 
145
    Account *account;
 
146
    CodecOrder map;
 
147
    int format = 0;
 
148
    unsigned int iter;
 
149
 
 
150
    _debug ("IAX get first matching codec: ");
 
151
 
 
152
    account = Manager::instance().getAccount (accountID);
 
153
 
 
154
    if (account != NULL) {
 
155
        map = account->getActiveCodecs();
 
156
    } else {
 
157
        _error ("No IAx account could be found");
 
158
    }
 
159
 
 
160
    for (iter=0 ; iter < map.size() ; iter++) {
 
161
        switch (map[iter]) {
 
162
 
 
163
            case PAYLOAD_CODEC_ULAW:
 
164
                _debug ("PCMU");
 
165
                format = AST_FORMAT_ULAW;
 
166
                break;
 
167
 
 
168
            case PAYLOAD_CODEC_GSM:
 
169
                _debug ("GSM");
 
170
                format = AST_FORMAT_GSM;
 
171
                break;
 
172
 
 
173
            case PAYLOAD_CODEC_ALAW:
 
174
                _debug ("PCMA");
 
175
                format = AST_FORMAT_ALAW;
 
176
                break;
 
177
 
 
178
            case PAYLOAD_CODEC_ILBC_20:
 
179
                _debug ("ILBC");
 
180
                format = AST_FORMAT_ILBC;
 
181
                break;
 
182
 
 
183
            case PAYLOAD_CODEC_SPEEX_8000:
 
184
                _debug ("SPEEX");
 
185
                format = AST_FORMAT_SPEEX;
 
186
                break;
 
187
 
 
188
            default:
 
189
                break;
 
190
        }
 
191
 
 
192
        // Return the first that matches
 
193
        if (format & needles)
 
194
            return format;
 
195
 
 
196
    }
 
197
 
 
198
    return 0;
198
199
}
199
200
 
200
201
CodecDescriptor& IAXCall::getCodecMap()
201
202
{
202
 
        return _codecMap;
 
203
    return _codecMap;
203
204
}
204
205
 
205
206
AudioCodecType IAXCall::getAudioCodec()
206
207
{
207
 
        return _audioCodec;
 
208
    return _audioCodec;
208
209
}
209
210
 
210
211