blob: 91247d6a2be145f679079c3918b415d0c78225ff [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H
12#define WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H
13
14#include "channel_manager_base.h"
15#include "typedefs.h"
16
17namespace webrtc
18{
19
20namespace voe
21{
22
23class ScopedChannel;
24class Channel;
25
26class ChannelManager: private ChannelManagerBase
27{
28 friend class ScopedChannel;
29
30public:
pbos@webrtc.org6141e132013-04-09 10:09:10 +000031 bool CreateChannel(int32_t& channelId);
niklase@google.com470e71d2011-07-07 08:21:25 +000032
pbos@webrtc.org92135212013-05-14 08:31:39 +000033 int32_t DestroyChannel(int32_t channelId);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
pbos@webrtc.org6141e132013-04-09 10:09:10 +000035 int32_t MaxNumOfChannels() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000036
pbos@webrtc.org6141e132013-04-09 10:09:10 +000037 int32_t NumOfChannels() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000038
pbos@webrtc.org6141e132013-04-09 10:09:10 +000039 void GetChannelIds(int32_t* channelsArray,
40 int32_t& numOfChannels) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000041
pbos@webrtc.org92135212013-05-14 08:31:39 +000042 ChannelManager(uint32_t instanceId);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
44 ~ChannelManager();
45
46private:
47 ChannelManager(const ChannelManager&);
48
49 ChannelManager& operator=(const ChannelManager&);
50
pbos@webrtc.org92135212013-05-14 08:31:39 +000051 Channel* GetChannel(int32_t channelId) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000052
53 void GetChannels(MapWrapper& channels) const;
54
55 void ReleaseChannel();
56
pbos@webrtc.org6141e132013-04-09 10:09:10 +000057 virtual void* NewItem(int32_t itemID);
niklase@google.com470e71d2011-07-07 08:21:25 +000058
59 virtual void DeleteItem(void* item);
60
pbos@webrtc.org6141e132013-04-09 10:09:10 +000061 uint32_t _instanceId;
niklase@google.com470e71d2011-07-07 08:21:25 +000062};
63
64class ScopedChannel
65{
66public:
67 // Can only be created by the channel manager
68 ScopedChannel(ChannelManager& chManager);
69
pbos@webrtc.org6141e132013-04-09 10:09:10 +000070 ScopedChannel(ChannelManager& chManager, int32_t channelId);
niklase@google.com470e71d2011-07-07 08:21:25 +000071
72 Channel* ChannelPtr();
73
74 Channel* GetFirstChannel(void*& iterator) const;
75
76 Channel* GetNextChannel(void*& iterator) const;
77
78 ~ScopedChannel();
79private:
80 ChannelManager& _chManager;
81 Channel* _channelPtr;
82 MapWrapper _channels;
83};
84
85} // namespace voe
86
87} // namespace webrtc
88
89#endif // WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H