audiortp.h 2.5 KB
Newer Older
savoirfairelinux's avatar
savoirfairelinux committed
1
/**
yanmorin's avatar
   
yanmorin committed
2
3
 *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
savoirfairelinux's avatar
savoirfairelinux committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *  Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
 *                                                                              
 *  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.
 *  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.
 *                                                                              
 *  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.
 */

#ifndef __AUDIO_RTP_H__
#define __AUDIO_RTP_H__

#include <cstdio>
#include <cstdlib>

#include <ccrtp/rtp.h>
llea's avatar
llea committed
27
#include <cc++/numbers.h>
yanmorin's avatar
   
yanmorin committed
28
#include "codecDescriptor.h"
savoirfairelinux's avatar
savoirfairelinux committed
29
30


jpbl's avatar
jpbl committed
31
#define RTP_FRAMES2SEND	160
savoirfairelinux's avatar
savoirfairelinux committed
32

jpbl's avatar
jpbl committed
33
class AudioLayer;
llea's avatar
llea committed
34
class SipCall;
savoirfairelinux's avatar
savoirfairelinux committed
35
36
37
38

///////////////////////////////////////////////////////////////////////////////
// Two pair of sockets
///////////////////////////////////////////////////////////////////////////////
39
class AudioRtpRTX : public ost::Thread, public ost::TimerPort {
savoirfairelinux's avatar
savoirfairelinux committed
40
public:
jpbl's avatar
jpbl committed
41
	AudioRtpRTX (SipCall *, AudioLayer*, bool);
savoirfairelinux's avatar
savoirfairelinux committed
42
	~AudioRtpRTX();
llea's avatar
llea committed
43

44
	ost::Time *time; 	// For incoming call notification 
savoirfairelinux's avatar
savoirfairelinux committed
45
46
47
	virtual void run ();

private:
48
49
50
51
52
53
	SipCall* _ca;
	AudioLayer* _audioDevice;
	ost::RTPSession *_sessionSend;
	ost::RTPSession *_sessionRecv;
	ost::SymmetricRTPSession *_session;
	bool _sym;
jpbl's avatar
jpbl committed
54

yanmorin's avatar
   
yanmorin committed
55
56
57
  // build codec...
  CodecDescriptor _codecBuilder;

jpbl's avatar
jpbl committed
58
	void initAudioRtpSession (void);
yanmorin's avatar
   
yanmorin committed
59
60
61
62
//  void sendSessionFromMic (unsigned char*, int16*, int16*, int, int);
  void sendSessionFromMic (unsigned char*, int16*, int16*, int);
//	void receiveSessionForSpkr (int16*, int16*, int, int&);
  void receiveSessionForSpkr (int16*, int16*, int&);
savoirfairelinux's avatar
savoirfairelinux committed
63
64
65
66
67
68
69
};

///////////////////////////////////////////////////////////////////////////////
// Main class rtp
///////////////////////////////////////////////////////////////////////////////
class AudioRtp {
public:
jpbl's avatar
jpbl committed
70
71
	AudioRtp();
	~AudioRtp();
savoirfairelinux's avatar
savoirfairelinux committed
72

llea's avatar
llea committed
73
	int 			createNewSession (SipCall *);
yanmorin's avatar
   
yanmorin committed
74
	void			closeRtpSession	 ();
savoirfairelinux's avatar
savoirfairelinux committed
75
76

private:
llea's avatar
llea committed
77
	AudioRtpRTX*	_RTXThread;
yanmorin's avatar
   
yanmorin committed
78
	bool			_symmetric;
savoirfairelinux's avatar
savoirfairelinux committed
79
80
81
};

#endif // __AUDIO_RTP_H__