50
50
class sdpException: public std::exception
52
virtual const char* what() const throw()
54
return "An sdpException Occured";
52
virtual const char* what() const throw() {
53
return "An sdpException Occured";
58
57
typedef std::vector<std::string> CryptoOffer;
65
65
* Class Constructor.
69
Sdp (pj_pool_t *pool);
71
71
/* Class destructor */
75
* Read accessor. Get the list of the local media capabilities.
75
* Read accessor. Get the list of the local media capabilities.
77
77
* @return std::vector<sdpMedia*> the vector containing the different media
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;
82
* Read accessor. Get the sdp session information
84
* @return pjmedia_sdp_session The structure that describes a SDP session
86
pjmedia_sdp_session* get_local_sdp_session( void ) { return _local_offer; }
84
* Read accessor. Get the sdp session information
86
* @return pjmedia_sdp_session The structure that describes a SDP session
88
pjmedia_sdp_session* get_local_sdp_session (void) {
89
93
* Write accessor. Set the local IP address that will be used in the sdp session
91
void set_ip_address( std::string ip_addr ) { _ip_addr = ip_addr; }
95
void set_ip_address (std::string ip_addr) {
94
100
* Read accessor. Get the local IP address
96
std::string get_ip_address( void ) { return _ip_addr; }
102
std::string get_ip_address (void) {
99
107
* Build the local SDP offer
107
115
* @param media The media to add to SDP
108
116
* @param med The structure to receive the media section
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);
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)
117
inline void set_zrtp_hash(const std::string& hash) { _zrtp_hello_hash = hash; _debug("Zrtp hash set with %s\n", hash.c_str()); }
119
/* Set the srtp _master_key
120
* @param mk The Master Key of a srtp session.
122
inline void set_srtp_crypto(const std::vector<std::string> lc) { _srtp_crypto = lc; }
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());
130
/* Set the srtp _master_key
131
* @param mk The Master Key of a srtp session.
133
inline void set_srtp_crypto (const std::vector<std::string> lc) {
125
138
* On building an invite outside a dialog, build the local offer and create the
126
139
* SDP negociator instance with it.
128
141
int create_initial_offer (CodecOrder selectedCodecs);
131
* On receiving an invite outside a dialog, build the local offer and create the
132
* SDP negociator instance with the remote offer.
134
* @param remote The remote offer
144
* On receiving an invite outside a dialog, build the local offer and create the
145
* SDP negociator instance with the remote offer.
147
* @param remote The remote offer
136
149
int receiving_initial_offer (pjmedia_sdp_session* remote, CodecOrder selectedCodecs);
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
147
pj_status_t check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata);
160
pj_status_t check_sdp_answer (pjsip_inv_session *inv, pjsip_rx_data *rdata);
150
163
* Remove all media in the session media vector.
152
void clean_session_media(void);
165
void clean_session_media (void);
155
168
* Remove all media in local media capability vector
157
void clean_local_media_capabilities(void);
170
void clean_local_media_capabilities (void);
160
173
* Return a string description of the media added to the session,
161
174
* ie the local media capabilities
163
std::string media_to_string( void );
176
std::string media_to_string (void);
166
179
* Return the codec of the first media after negociation
168
AudioCodec* get_session_media( void );
181
AudioCodec* get_session_media (void);
171
184
* read accessor. Return the negociated offer
173
186
* @return pjmedia_sdp_session The negociated offer
175
pjmedia_sdp_session* get_negociated_offer( void ){
188
pjmedia_sdp_session* get_negociated_offer (void) {
176
189
return _negociated_offer;
180
* Start the sdp negociation.
182
* @return pj_status_t 0 on success
185
pj_status_t start_negociation( void );
193
* Start the sdp negociation.
195
* @return pj_status_t 0 on success
198
pj_status_t start_negociation (void);
188
* Retrieve the negociated sdp offer from the sip payload.
190
* @param sdp the negociated offer
192
void set_negotiated_sdp ( const pjmedia_sdp_session *sdp );
201
* Retrieve the negociated sdp offer from the sip payload.
203
* @param sdp the negociated offer
205
void set_negotiated_sdp (const pjmedia_sdp_session *sdp);
195
208
* Attribute the specified port to every medias provided
201
214
void attribute_port_to_all_media (int port);
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;
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;
207
224
void toString (void);
210
227
* Set remote's IP addr. [not protected]
211
228
* @param ip The remote IP address
213
void set_remote_ip(const std::string& ip) { _remote_ip_addr = ip; }
230
void set_remote_ip (const std::string& ip) {
231
_remote_ip_addr = ip;
216
235
* Return IP of destination [mutex protected]
217
236
* @return const std:string The remote IP address
219
const std::string& get_remote_ip() { return _remote_ip_addr; }
238
const std::string& get_remote_ip() {
239
return _remote_ip_addr;
222
243
* Set remote's audio port. [not protected]
223
244
* @param port The remote audio port
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;
228
* Return audio port at destination [mutex protected]
251
* Return audio port at destination [mutex protected]
229
252
* @return unsigned int The remote audio port
231
unsigned int get_remote_audio_port() { return _remote_audio_port; }
254
unsigned int get_remote_audio_port() {
255
return _remote_audio_port;
233
258
void set_media_transport_info_from_remote_sdp (const pjmedia_sdp_session *remote_sdp);
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;
237
264
void get_remote_sdp_crypto_from_offer (const pjmedia_sdp_session* remote_sdp, CryptoOffer& crypto_offer);
252
279
/** Remote's IP address */
253
280
std::string _remote_ip_addr;
256
283
pjmedia_sdp_session *_local_offer;
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;
263
290
// The pool to allocate memory
274
301
/** "a=crypto" sdes local attributes obtained from AudioSrtpSession */
275
302
std::vector<std::string> _srtp_crypto;
277
Sdp(const Sdp&); //No Copy Constructor
278
Sdp& operator=(const Sdp&); //No Assignment Operator
304
Sdp (const Sdp&); //No Copy Constructor
305
Sdp& operator= (const Sdp&); //No Assignment Operator
280
307
void set_local_media_capabilities (CodecOrder selectedCodecs);
284
311
* Gives the originator of the session.
285
312
* Serves as a globally unique identifier for this version of this session description.
287
void sdp_add_origin( void );
314
void sdp_add_origin (void);
290
317
* Mandatory field: Protocol version ("v=")
291
318
* Add the protocol version in the SDP session description
293
void sdp_add_protocol( void );
320
void sdp_add_protocol (void);
296
323
* Optional field: Connection data ("c=")
297
324
* Contains connection data.
299
void sdp_add_connection_info( void );
326
void sdp_add_connection_info (void);
302
329
* Mandatory field: Session name ("s=")
303
330
* Add a textual session name.
305
void sdp_add_session_name( void );
332
void sdp_add_session_name (void);
308
335
* Optional field: Session information ("s=")
309
336
* Provides textual information about the session.
311
void sdp_add_session_info( void ){}
338
void sdp_add_session_info (void) {}
314
341
* Optional field: Uri ("u=")
315
342
* Add a pointer to additional information about the session.
317
void sdp_add_uri( void ) {}
344
void sdp_add_uri (void) {}
320
347
* Optional fields: Email address and phone number ("e=" and "p=")
321
348
* Add contact information for the person responsible for the conference.
323
void sdp_add_email( void ) {}
350
void sdp_add_email (void) {}
326
353
* Optional field: Bandwidth ("b=")
327
354
* Denotes the proposed bandwidth to be used by the session or the media .
329
void sdp_add_bandwidth( void ) {}
356
void sdp_add_bandwidth (void) {}
332
359
* Mandatory field: Timing ("t=")
333
360
* Specify the start and the stop time for a session.
335
void sdp_add_timing( void );
362
void sdp_add_timing (void);
338
365
* Optional field: Time zones ("z=")
340
void sdp_add_time_zone( void ) {}
367
void sdp_add_time_zone (void) {}
343
370
* Optional field: Encryption keys ("k=")
345
void sdp_add_encryption_key( void ) {}
372
void sdp_add_encryption_key (void) {}
348
375
* Optional field: Attributes ("a=")
350
void sdp_add_attributes( );
377
void sdp_add_attributes();
353
380
* Mandatory field: Media descriptions ("m=")
357
384
std::string convert_int_to_string (int value);
359
386
void set_remote_ip_from_sdp (const pjmedia_sdp_session *r_sdp);
361
388
void set_remote_audio_port_from_sdp (pjmedia_sdp_media *r_media);
363
390
void get_remote_sdp_media_from_offer (const pjmedia_sdp_session* r_sdp, pjmedia_sdp_media** r_media);
367
394
* Adds a sdes attribute to the given media section.
369
* @param media The media to add the srtp attribute to
396
* @param media The media to add the srtp attribute to
371
void sdp_add_sdes_attribute(std::vector<std::string>& crypto);
398
void sdp_add_sdes_attribute (std::vector<std::string>& crypto);
374
* Adds a zrtp-hash attribute to
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.
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
382
void sdp_add_zrtp_attribute(pjmedia_sdp_media* media, std::string hash);
409
void sdp_add_zrtp_attribute (pjmedia_sdp_media* media, std::string hash);