sipcall.h 4.07 KB
Newer Older
yanmorin's avatar
   
yanmorin committed
1
2
3
4
/*
 *  Copyright (C) 2004-2006 Savoir-Faire Linux inc.
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
 *  Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com>
jpbl's avatar
jpbl committed
5
 *
yanmorin's avatar
   
yanmorin committed
6
7
8
9
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
jpbl's avatar
jpbl committed
10
 *
yanmorin's avatar
   
yanmorin committed
11
12
13
14
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
jpbl's avatar
jpbl committed
15
 *
yanmorin's avatar
   
yanmorin committed
16
17
18
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
jpbl's avatar
jpbl committed
19
 */
yanmorin's avatar
   
yanmorin committed
20
21
#ifndef SIPCALL_H
#define SIPCALL_H
jpbl's avatar
jpbl committed
22
23

#include "call.h"
yanmorin's avatar
   
yanmorin committed
24
25
#include "audio/codecDescriptor.h"
#include <eXosip2/eXosip.h>
jpbl's avatar
jpbl committed
26
27
28

class AudioCodec;

yanmorin's avatar
   
yanmorin committed
29
/**
yanmorin's avatar
   
yanmorin committed
30
31
32
 * SIPCall are SIP implementation of a normal Call 
 * @author Yan Morin <yan.morin@gmail.com>
 */
yanmorin's avatar
   
yanmorin committed
33
34
class SIPCall : public Call
{
jpbl's avatar
jpbl committed
35
public:
yanmorin's avatar
   
yanmorin committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    SIPCall(const CallID& id, Call::CallType type);

    ~SIPCall();

  /** @return SIP call id : protected by eXosip lock */
  int  getCid() { return _cid; }
  /** @param cid SIP call id : protected by eXosip lock */
  void setCid(int cid) { _cid = cid ; } 
  /** @return SIP domain id : protected by eXosip lock  */
  int  getDid() { return _did; }
  /** @param did SIP domain id : protected by eXosip lock */
  void setDid(int did) { _did = did; } 
  /** @return SIP transaction id : protected by eXosip lock  */
  int  getTid() { return _tid; }
  /** @param did SIP transaction id : protected by eXosip lock */
  void setTid(int tid) { _tid = tid; } 

jpbl's avatar
jpbl committed
53
  /**
Alexandre Bourget's avatar
Alexandre Bourget committed
54
   * Setup incoming call, and verify for errors, before ringing the user.
yanmorin's avatar
   
yanmorin committed
55
   * @param event eXosip Event
jpbl's avatar
jpbl committed
56
   */
yanmorin's avatar
   
yanmorin committed
57
58
59
60
61
62
63
64
  bool SIPCallInvite(eXosip_event_t *event);

  /**
   * newReinviteCall is called when the IP-Phone user receives a change in the call
   * it's almost an newIncomingCall but we send a 200 OK
   * See: 3.7.  Session with re-INVITE (IP Address Change)
   * @param event eXosip Event
   * @return true if ok
jpbl's avatar
jpbl committed
65
   */
yanmorin's avatar
   
yanmorin committed
66
  bool SIPCallReinvite(eXosip_event_t *event);
jpbl's avatar
jpbl committed
67

yanmorin's avatar
   
yanmorin committed
68
69
70
71
72
73
  /**
   * Peer answered to a call (on hold or not)
   * @param event eXosip Event
   * @return true if ok
   */
  bool SIPCallAnswered(eXosip_event_t *event);
Alexandre Bourget's avatar
Alexandre Bourget committed
74

yanmorin's avatar
   
yanmorin committed
75
76
77
78
  /**
   * We retreive final SDP info if they changed
   * @param event eXosip Event
   * @return true if ok (change / no change) or false on error
jpbl's avatar
jpbl committed
79
   */
yanmorin's avatar
   
yanmorin committed
80
  bool SIPCallAnsweredWithoutHold(eXosip_event_t *event);
jpbl's avatar
jpbl committed
81

yanmorin's avatar
   
yanmorin committed
82
  //TODO: humm?
jpbl's avatar
jpbl committed
83
84
  int sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg);

yanmorin's avatar
   
yanmorin committed
85

jpbl's avatar
jpbl committed
86
87
private:

yanmorin's avatar
   
yanmorin committed
88
  // TODO: hum???
jpbl's avatar
jpbl committed
89
  int sdp_analyse_attribute (sdp_message_t * sdp, sdp_media_t * med);
yanmorin's avatar
   
yanmorin committed
90
91
92
93
94
  /**
   * Set peer name and number with event->request->from
   * @param event eXosip event
   * @return false the event is invalid
   */
95

yanmorin's avatar
   
yanmorin committed
96
97
98
  bool setPeerInfoFromRequest(eXosip_event_t *event);
  /**
   * Get a valid remote SDP or return a 400 bad request response if invalid
99
   *
yanmorin's avatar
   
yanmorin committed
100
101
102
103
104
105
106
   * @param event eXosip event
   * @return valid remote_sdp or 0
   */
  sdp_message_t* getRemoteSDPFromRequest(eXosip_event_t *event);

  /**
   * Get a valid remote media or return a 415 unsupported media type
107
   *
yanmorin's avatar
   
yanmorin committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
   * @param tid transaction id
   * @param remote_sdp Remote SDP pointer
   * @return valid sdp_media_t or 0
   */
  sdp_media_t* getRemoteMedia(int tid, sdp_message_t* remote_sdp);

  /**
   * Set Audio Port and Audio IP from Remote SDP Info
   * @param remote_med Remote Media info
   * @param remote_sdp Remote SDP pointer
   * @return true if everything is set correctly
   */
  bool setRemoteAudioFromSDP(sdp_media_t* remote_med, sdp_message_t* remote_sdp);

  /**
   * Set Audio Codec with the remote choice
   * @param remote_med Remote Media info
   * @return true if everything is set correctly
   */
  bool setAudioCodecFromSDP(sdp_media_t* remote_med, int tid);

 
  /** SIP call id */
  int _cid;
  /** SIP domain id */
  int _did;
  /** SIP transaction id */
  int _tid;

jpbl's avatar
jpbl committed
137
138
};

yanmorin's avatar
   
yanmorin committed
139
#endif