summaryrefslogtreecommitdiff
path: root/orkbasecxx/EventStreaming.h
blob: da0daa3d909bd9b64176a2daecfae99cc67441de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Oreka -- A media capture and retrieval platform
 * 
 * Copyright (C) 2005, orecx LLC
 *
 * http://www.orecx.com
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License.
 * Please refer to http://www.gnu.org/copyleft/gpl.html
 *
 */
#include "LogManager.h"
#include "Filter.h"
#include <math.h>
#include "Utils.h"
#include <queue>
#include <list>
#include "boost/shared_ptr.hpp"
#include "ace/Singleton.h"
#include "ace/Thread_Mutex.h"
#include "ace/Thread_Semaphore.h"
#include "AudioCapture.h"
#include "ConfigManager.h"
#include "CapturePluginProxy.h"
#include "AudioTape.h"

//==========================================================

class EventStreamingSession
{
public:
	EventStreamingSession();

	void AddTapeMessage(MessageRef& message);
	void GetTapeMessage(MessageRef& message);
	int GetNumMessages();
	void WaitForMessages();
private:
	std::list<MessageRef> m_messages;
	ACE_Thread_Mutex m_mutex;
	ACE_Thread_Semaphore m_semaphore;
};
typedef boost::shared_ptr<EventStreamingSession> EventStreamingSessionRef;

//==========================================================

class EventStreaming
{
public:
	EventStreaming();

	void GetLiveSessions(std::list<EventStreamingSessionRef>& sessions);
	void AddSession(EventStreamingSessionRef& session);
	void RemoveSession(EventStreamingSessionRef& session);
	int GetNumSessions();
	CStdString GetNewSessionId();
	void AddTapeMessage(MessageRef& message);

private:
	AlphaCounter m_alphaCounter;
	ACE_Thread_Mutex m_mutex;
	std::list<EventStreamingSessionRef> m_sessions;
};
typedef ACE_Singleton<EventStreaming, ACE_Thread_Mutex> EventStreamingSingleton;

//==========================================================