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

« back to all changes in this revision

Viewing changes to sflphone-common/src/sip/sdp.h

  • 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:
49
49
 
50
50
class sdpException: public std::exception
51
51
{
52
 
  virtual const char* what() const throw()
53
 
  {
54
 
    return "An sdpException Occured";
55
 
  }
 
52
        virtual const char* what() const throw() {
 
53
            return "An sdpException Occured";
 
54
        }
56
55
};
57
56
 
58
57
typedef std::vector<std::string> CryptoOffer;
59
58
 
60
 
class Sdp {
 
59
class Sdp
 
60
{
61
61
 
62
62
    public:
63
 
        
 
63
 
64
64
        /*
65
65
         * Class Constructor.
66
66
         *
67
67
         * @param ip_addr
68
68
         */
69
 
        Sdp(pj_pool_t *pool);
 
69
        Sdp (pj_pool_t *pool);
70
70
 
71
71
        /* Class destructor */
72
72
        ~Sdp();
73
73
 
74
74
        /*
75
 
         * Read accessor. Get the list of the local media capabilities. 
 
75
         * Read accessor. Get the list of the local media capabilities.
76
76
         *
77
77
         * @return std::vector<sdpMedia*>   the vector containing the different media
78
78
         */
79
 
        std::vector<sdpMedia*> get_local_media_cap( void ) { return _local_media_cap; }
 
79
        std::vector<sdpMedia*> get_local_media_cap (void) {
 
80
            return _local_media_cap;
 
81
        }
80
82
 
81
 
         /*
82
 
         *  Read accessor. Get the sdp session information
83
 
         *
84
 
         *  @return pjmedia_sdp_session   The structure that describes a SDP session
85
 
         */
86
 
        pjmedia_sdp_session* get_local_sdp_session( void ) { return _local_offer; }
 
83
        /*
 
84
        *  Read accessor. Get the sdp session information
 
85
        *
 
86
        *  @return pjmedia_sdp_session   The structure that describes a SDP session
 
87
        */
 
88
        pjmedia_sdp_session* get_local_sdp_session (void) {
 
89
            return _local_offer;
 
90
        }
87
91
 
88
92
        /*
89
93
         * Write accessor. Set the local IP address that will be used in the sdp session
90
94
         */
91
 
        void set_ip_address( std::string ip_addr ) { _ip_addr = ip_addr; }
 
95
        void set_ip_address (std::string ip_addr) {
 
96
            _ip_addr = ip_addr;
 
97
        }
92
98
 
93
99
        /*
94
100
         * Read accessor. Get the local IP address
95
101
         */
96
 
        std::string get_ip_address( void ) { return _ip_addr; }
97
 
        
 
102
        std::string get_ip_address (void) {
 
103
            return _ip_addr;
 
104
        }
 
105
 
98
106
        /*
99
107
         * Build the local SDP offer
100
108
         */
107
115
         * @param media The media to add to SDP
108
116
         * @param med   The structure to receive the media section
109
117
         */
110
 
        void set_media_descriptor_line( sdpMedia* media, pjmedia_sdp_media** p_med );
 
118
        void set_media_descriptor_line (sdpMedia* media, pjmedia_sdp_media** p_med);
111
119
 
112
120
        /* Set the zrtp hash that was previously calculated from the hello message in the zrtp layer.
113
121
         * This hash value is unique at the media level. Therefore, if video support is added, one would
114
122
         * have to set the correct zrtp-hash value in the corresponding media section.
115
123
         * @param hash The hello hash of a rtp session. (Only audio at the moment)
116
124
         */
117
 
        inline void set_zrtp_hash(const std::string& hash) { _zrtp_hello_hash = hash; _debug("Zrtp hash set with %s\n", hash.c_str()); }
118
 
 
119
 
        /* Set the srtp _master_key
120
 
         * @param mk The Master Key of a srtp session.
121
 
         */
122
 
        inline void set_srtp_crypto(const std::vector<std::string> lc) { _srtp_crypto = lc; }
123
 
        
 
125
        inline void set_zrtp_hash (const std::string& hash) {
 
126
            _zrtp_hello_hash = hash;
 
127
            _debug ("Zrtp hash set with %s\n", hash.c_str());
 
128
        }
 
129
 
 
130
        /* Set the srtp _master_key
 
131
             * @param mk The Master Key of a srtp session.
 
132
             */
 
133
        inline void set_srtp_crypto (const std::vector<std::string> lc) {
 
134
            _srtp_crypto = lc;
 
135
        }
 
136
 
124
137
        /*
125
138
         * On building an invite outside a dialog, build the local offer and create the
126
139
         * SDP negociator instance with it.
127
140
         */
128
141
        int create_initial_offer (CodecOrder selectedCodecs);
129
142
 
130
 
         /*
131
 
         * On receiving an invite outside a dialog, build the local offer and create the
132
 
         * SDP negociator instance with the remote offer.
133
 
         *
134
 
         * @param remote    The remote offer
135
 
         */
 
143
        /*
 
144
        * On receiving an invite outside a dialog, build the local offer and create the
 
145
        * SDP negociator instance with the remote offer.
 
146
        *
 
147
        * @param remote    The remote offer
 
148
        */
136
149
        int receiving_initial_offer (pjmedia_sdp_session* remote, CodecOrder selectedCodecs);
137
 
        
 
150
 
138
151
        /*
139
152
         * On receiving a message, check if it contains SDP and negotiate. Should be used for
140
153
         * SDP answer and offer but currently is only used for answer.
143
156
         * @param inv       The  the invitation
144
157
         * @param rdata     The remote data
145
158
         */
146
 
        
147
 
        pj_status_t check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata);
148
 
        
 
159
 
 
160
        pj_status_t check_sdp_answer (pjsip_inv_session *inv, pjsip_rx_data *rdata);
 
161
 
149
162
        /**
150
163
         * Remove all media in the session media vector.
151
164
         */
152
 
        void clean_session_media(void);
 
165
        void clean_session_media (void);
153
166
 
154
167
        /**
155
168
         * Remove all media in local media capability vector
156
169
         */
157
 
                void clean_local_media_capabilities(void);
 
170
        void clean_local_media_capabilities (void);
158
171
 
159
172
        /*
160
173
         * Return a string description of the media added to the session,
161
174
         * ie the local media capabilities
162
175
         */
163
 
        std::string media_to_string( void );
 
176
        std::string media_to_string (void);
164
177
 
165
178
        /*
166
179
         * Return the codec of the first media after negociation
167
180
         */
168
 
        AudioCodec* get_session_media( void );
 
181
        AudioCodec* get_session_media (void);
169
182
 
170
183
        /*
171
184
         * read accessor. Return the negociated offer
172
185
         *
173
186
         * @return pjmedia_sdp_session  The negociated offer
174
187
         */
175
 
        pjmedia_sdp_session* get_negociated_offer( void ){
 
188
        pjmedia_sdp_session* get_negociated_offer (void) {
176
189
            return _negociated_offer;
177
190
        }
178
191
 
179
 
         /*
180
 
         * Start the sdp negociation.
181
 
         *
182
 
         * @return pj_status_t  0 on success
183
 
         *                      1 otherwise
184
 
         */
185
 
        pj_status_t start_negociation( void );
 
192
        /*
 
193
        * Start the sdp negociation.
 
194
        *
 
195
        * @return pj_status_t  0 on success
 
196
        *                      1 otherwise
 
197
        */
 
198
        pj_status_t start_negociation (void);
186
199
 
187
 
         /*
188
 
         * Retrieve the negociated sdp offer from the sip payload.
189
 
         *
190
 
         * @param sdp   the negociated offer
191
 
         */
192
 
        void set_negotiated_sdp ( const pjmedia_sdp_session *sdp );
 
200
        /*
 
201
        * Retrieve the negociated sdp offer from the sip payload.
 
202
        *
 
203
        * @param sdp   the negociated offer
 
204
        */
 
205
        void set_negotiated_sdp (const pjmedia_sdp_session *sdp);
193
206
 
194
207
        /*
195
208
         * Attribute the specified port to every medias provided
200
213
         */
201
214
        void attribute_port_to_all_media (int port);
202
215
 
203
 
        void  set_local_extern_audio_port(int port){ _local_extern_audio_port = port; }
 
216
        void  set_local_extern_audio_port (int port) {
 
217
            _local_extern_audio_port = port;
 
218
        }
204
219
 
205
 
        int  get_local_extern_audio_port (void){ return _local_extern_audio_port; }
 
220
        int  get_local_extern_audio_port (void) {
 
221
            return _local_extern_audio_port;
 
222
        }
206
223
 
207
224
        void toString (void);
208
225
 
209
 
        /** 
 
226
        /**
210
227
         * Set remote's IP addr. [not protected]
211
228
         * @param ip  The remote IP address
212
229
         */
213
 
        void set_remote_ip(const std::string& ip) { _remote_ip_addr = ip; }
214
 
        
215
 
        /** 
 
230
        void set_remote_ip (const std::string& ip) {
 
231
            _remote_ip_addr = ip;
 
232
        }
 
233
 
 
234
        /**
216
235
         * Return IP of destination [mutex protected]
217
236
         * @return const std:string     The remote IP address
218
237
         */
219
 
        const std::string& get_remote_ip() { return _remote_ip_addr; }
 
238
        const std::string& get_remote_ip() {
 
239
            return _remote_ip_addr;
 
240
        }
220
241
 
221
 
        /** 
 
242
        /**
222
243
         * Set remote's audio port. [not protected]
223
244
         * @param port  The remote audio port
224
245
         */
225
 
        void set_remote_audio_port(unsigned int port) { _remote_audio_port = port; }
 
246
        void set_remote_audio_port (unsigned int port) {
 
247
            _remote_audio_port = port;
 
248
        }
226
249
 
227
 
        /** 
228
 
         * Return audio port at destination [mutex protected] 
 
250
        /**
 
251
         * Return audio port at destination [mutex protected]
229
252
         * @return unsigned int The remote audio port
230
253
         */
231
 
        unsigned int get_remote_audio_port() { return _remote_audio_port; }
 
254
        unsigned int get_remote_audio_port() {
 
255
            return _remote_audio_port;
 
256
        }
232
257
 
233
258
        void set_media_transport_info_from_remote_sdp (const pjmedia_sdp_session *remote_sdp);
234
259
 
235
 
        std::vector<sdpMedia*> get_session_media_list (void) { return _session_media; }
 
260
        std::vector<sdpMedia*> get_session_media_list (void) {
 
261
            return _session_media;
 
262
        }
236
263
 
237
264
        void get_remote_sdp_crypto_from_offer (const pjmedia_sdp_session* remote_sdp, CryptoOffer& crypto_offer);
238
265
 
251
278
 
252
279
        /** Remote's IP address */
253
280
        std::string  _remote_ip_addr;
254
 
        
 
281
 
255
282
        /** Local SDP */
256
283
        pjmedia_sdp_session *_local_offer;
257
284
 
258
285
        /* The negociated SDP offer */
259
286
        // Explanation: each endpoint's offer is negociated, and a new sdp offer results from this
260
 
        // negociation, with the compatible media from each part 
 
287
        // negociation, with the compatible media from each part
261
288
        pjmedia_sdp_session *_negociated_offer;
262
289
 
263
290
        // The pool to allocate memory
273
300
 
274
301
        /** "a=crypto" sdes local attributes obtained from AudioSrtpSession */
275
302
        std::vector<std::string> _srtp_crypto;
276
 
        
277
 
        Sdp(const Sdp&); //No Copy Constructor
278
 
        Sdp& operator=(const Sdp&); //No Assignment Operator
 
303
 
 
304
        Sdp (const Sdp&); //No Copy Constructor
 
305
        Sdp& operator= (const Sdp&); //No Assignment Operator
279
306
 
280
307
        void set_local_media_capabilities (CodecOrder selectedCodecs);
281
308
 
284
311
         *  Gives the originator of the session.
285
312
         *  Serves as a globally unique identifier for this version of this session description.
286
313
         */
287
 
        void sdp_add_origin( void );
 
314
        void sdp_add_origin (void);
288
315
 
289
316
        /*
290
317
         *  Mandatory field: Protocol version ("v=")
291
318
         *  Add the protocol version in the SDP session description
292
319
         */
293
 
        void sdp_add_protocol( void );
 
320
        void sdp_add_protocol (void);
294
321
 
295
322
        /*
296
323
         *  Optional field: Connection data ("c=")
297
324
         *  Contains connection data.
298
325
         */
299
 
        void sdp_add_connection_info( void );
300
 
        
 
326
        void sdp_add_connection_info (void);
 
327
 
301
328
        /*
302
329
         *  Mandatory field: Session name ("s=")
303
330
         *  Add a textual session name.
304
331
         */
305
 
        void sdp_add_session_name( void );
 
332
        void sdp_add_session_name (void);
306
333
 
307
334
        /*
308
335
         *  Optional field: Session information ("s=")
309
336
         *  Provides textual information about the session.
310
337
         */
311
 
        void sdp_add_session_info( void ){}
 
338
        void sdp_add_session_info (void) {}
312
339
 
313
340
        /*
314
341
         *  Optional field: Uri ("u=")
315
342
         *  Add a pointer to additional information about the session.
316
343
         */
317
 
        void sdp_add_uri( void ) {}
 
344
        void sdp_add_uri (void) {}
318
345
 
319
346
        /*
320
347
         *  Optional fields: Email address and phone number ("e=" and "p=")
321
348
         *  Add contact information for the person responsible for the conference.
322
349
         */
323
 
        void sdp_add_email( void ) {}
 
350
        void sdp_add_email (void) {}
324
351
 
325
352
        /*
326
353
         *  Optional field: Bandwidth ("b=")
327
354
         *  Denotes the proposed bandwidth to be used by the session or the media .
328
355
         */
329
 
        void sdp_add_bandwidth( void ) {}
 
356
        void sdp_add_bandwidth (void) {}
330
357
 
331
358
        /*
332
359
         *  Mandatory field: Timing ("t=")
333
360
         *  Specify the start and the stop time for a session.
334
361
         */
335
 
        void sdp_add_timing( void );
 
362
        void sdp_add_timing (void);
336
363
 
337
364
        /*
338
365
         * Optional field: Time zones ("z=")
339
366
         */
340
 
        void sdp_add_time_zone( void ) {}
 
367
        void sdp_add_time_zone (void) {}
341
368
 
342
369
        /*
343
370
         * Optional field: Encryption keys ("k=")
344
371
         */
345
 
        void sdp_add_encryption_key( void ) {}
 
372
        void sdp_add_encryption_key (void) {}
346
373
 
347
374
        /*
348
375
         * Optional field: Attributes ("a=")
349
376
         */
350
 
        void sdp_add_attributes( );
 
377
        void sdp_add_attributes();
351
378
 
352
379
        /*
353
380
         * Mandatory field: Media descriptions ("m=")
357
384
        std::string convert_int_to_string (int value);
358
385
 
359
386
        void set_remote_ip_from_sdp (const pjmedia_sdp_session *r_sdp);
360
 
        
 
387
 
361
388
        void set_remote_audio_port_from_sdp (pjmedia_sdp_media *r_media);
362
389
 
363
390
        void get_remote_sdp_media_from_offer (const pjmedia_sdp_session* r_sdp, pjmedia_sdp_media** r_media);
364
391
 
365
 
        
 
392
 
366
393
        /*
367
394
         * Adds a sdes attribute to the given media section.
368
395
         *
369
 
         * @param media The media to add the srtp attribute to 
 
396
         * @param media The media to add the srtp attribute to
370
397
         */
371
 
        void sdp_add_sdes_attribute(std::vector<std::string>& crypto);
 
398
        void sdp_add_sdes_attribute (std::vector<std::string>& crypto);
372
399
 
373
 
        /* 
374
 
         * Adds a zrtp-hash  attribute to 
 
400
        /*
 
401
         * Adds a zrtp-hash  attribute to
375
402
         * the given media section. The hello hash is
376
403
         * available only after is has been computed
377
 
         * in the AudioZrtpSession constructor. 
 
404
         * in the AudioZrtpSession constructor.
378
405
         *
379
 
         * @param media The media to add the zrtp-hash attribute to 
 
406
         * @param media The media to add the zrtp-hash attribute to
380
407
         * @param hash  The hash to which the attribute should be set to
381
 
         */ 
382
 
        void sdp_add_zrtp_attribute(pjmedia_sdp_media* media, std::string hash);
383
 
              
 
408
         */
 
409
        void sdp_add_zrtp_attribute (pjmedia_sdp_media* media, std::string hash);
 
410
 
384
411
};
385
412
 
386
413