niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | namespace webrtc |
| 18 | { |
| 19 | |
| 20 | namespace voe |
| 21 | { |
| 22 | |
| 23 | class ScopedChannel; |
| 24 | class Channel; |
| 25 | |
| 26 | class ChannelManager: private ChannelManagerBase |
| 27 | { |
| 28 | friend class ScopedChannel; |
| 29 | |
| 30 | public: |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 31 | bool CreateChannel(int32_t& channelId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 33 | int32_t DestroyChannel(const int32_t channelId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 35 | int32_t MaxNumOfChannels() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 37 | int32_t NumOfChannels() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 39 | void GetChannelIds(int32_t* channelsArray, |
| 40 | int32_t& numOfChannels) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 42 | ChannelManager(const uint32_t instanceId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
| 44 | ~ChannelManager(); |
| 45 | |
| 46 | private: |
| 47 | ChannelManager(const ChannelManager&); |
| 48 | |
| 49 | ChannelManager& operator=(const ChannelManager&); |
| 50 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 51 | Channel* GetChannel(const int32_t channelId) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
| 53 | void GetChannels(MapWrapper& channels) const; |
| 54 | |
| 55 | void ReleaseChannel(); |
| 56 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 57 | virtual void* NewItem(int32_t itemID); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
| 59 | virtual void DeleteItem(void* item); |
| 60 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 61 | uint32_t _instanceId; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | class ScopedChannel |
| 65 | { |
| 66 | public: |
| 67 | // Can only be created by the channel manager |
| 68 | ScopedChannel(ChannelManager& chManager); |
| 69 | |
pbos@webrtc.org | 6141e13 | 2013-04-09 10:09:10 +0000 | [diff] [blame^] | 70 | ScopedChannel(ChannelManager& chManager, int32_t channelId); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
| 72 | Channel* ChannelPtr(); |
| 73 | |
| 74 | Channel* GetFirstChannel(void*& iterator) const; |
| 75 | |
| 76 | Channel* GetNextChannel(void*& iterator) const; |
| 77 | |
| 78 | ~ScopedChannel(); |
| 79 | private: |
| 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 |