blob: 0dd84b063ec68a8ff8f5122829ca369340a495e7 [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001// Copyright (C) 2000-2005 Open Source Telecom Corporation.
2// Copyright (C) 2006-2008 David Sugar, Tycho Softworks.
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#include <cc++/slog.h>
19#include "server.h"
20
21using namespace std;
22
23#ifdef CCXX_NAMESPACES
24namespace ost {
25using namespace std;
26#endif
27
28RTPEvent *RTPEvent::first = NULL;
29
30RTPEvent::RTPEvent()
31{
32 next = first;
33 first = this;
34}
35
36RTPAudio::RTPAudio() :
37RTPSocket(keyrtp.getInterface(), keyrtp.getPort(), keythreads.priRTP())
38{
39 rtp = this;
40 setSchedulingTimeout(keyrtp.getTimer());
41 setExpireTimeout(keyrtp.getExpire());
42 groups = 0;
43 unicast = false;
44 shutdown = false;
45}
46
47void RTPAudio::exit(const char *reason)
48{
49 shutdown = true;
50 dispatchBYE(reason);
51 sleep(500);
52 delete rtp;
53 rtp = NULL;
54}
55
56void RTPAudio::onGotHello(const SyncSource &src)
57{
58 RTPEvent *event = RTPEvent::first;
59
60 slog(Slog::levelDebug) << "hello(" << src.getID() << ") ";
61 Participant* p = src.getParticipant();
62 slog() << p->getSDESItem(SDESItemTypeCNAME) << std::endl;
63
64 while(event)
65 {
66 event->gotHello(src);
67 event = event->next;
68 }
69}
70
71void RTPAudio::onGotGoodbye(const SyncSource &src, const string& reason)
72{
73 RTPEvent *event = RTPEvent::first;
74
75 slog(Slog::levelDebug) << "bye(" << src.getID() << ") ";
76 Participant* p = src.getParticipant();
77 slog() << p->getSDESItem(SDESItemTypeCNAME) << "; " << reason;
78 slog() << std::endl;
79
80 while(event)
81 {
82 event->gotGoodbye(src, reason);
83 event = event->next;
84 }
85}
86
87RTPAudio *rtp;
88
89#ifdef CCXX_NAMESPACES
90}
91#endif