blob: 6c40ef117530adbb6806991b6a57d19f90511eeb [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:
31 bool CreateChannel(WebRtc_Word32& channelId);
32
33 WebRtc_Word32 DestroyChannel(const WebRtc_Word32 channelId);
34
35 WebRtc_Word32 MaxNumOfChannels() const;
36
37 WebRtc_Word32 NumOfChannels() const;
38
39 void GetChannelIds(WebRtc_Word32* channelsArray,
40 WebRtc_Word32& numOfChannels) const;
41
42 ChannelManager(const WebRtc_UWord32 instanceId);
43
44 ~ChannelManager();
45
46private:
47 ChannelManager(const ChannelManager&);
48
49 ChannelManager& operator=(const ChannelManager&);
50
51 Channel* GetChannel(const WebRtc_Word32 channelId) const;
52
53 void GetChannels(MapWrapper& channels) const;
54
55 void ReleaseChannel();
56
57 virtual void* NewItem(WebRtc_Word32 itemID);
58
59 virtual void DeleteItem(void* item);
60
61 WebRtc_UWord32 _instanceId;
62};
63
64class ScopedChannel
65{
66public:
67 // Can only be created by the channel manager
68 ScopedChannel(ChannelManager& chManager);
69
70 ScopedChannel(ChannelManager& chManager, WebRtc_Word32 channelId);
71
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