summaryrefslogtreecommitdiff
path: root/voice_engine/channel_manager.h
blob: 49e7bf769d3b64d4507e6859a945f53b96d34e87 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H
#define WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H

#include "webrtc/typedefs.h"
#include "webrtc/voice_engine/channel_manager_base.h"

namespace webrtc
{

namespace voe
{

class ScopedChannel;
class Channel;

class ChannelManager: private ChannelManagerBase
{
    friend class ScopedChannel;

public:
    bool CreateChannel(int32_t& channelId);

    int32_t DestroyChannel(int32_t channelId);

    int32_t MaxNumOfChannels() const;

    int32_t NumOfChannels() const;

    void GetChannelIds(int32_t* channelsArray,
                       int32_t& numOfChannels) const;

    ChannelManager(uint32_t instanceId);

    ~ChannelManager();

private:
    ChannelManager(const ChannelManager&);

    ChannelManager& operator=(const ChannelManager&);

    Channel* GetChannel(int32_t channelId) const;

    void GetChannels(MapWrapper& channels) const;

    void ReleaseChannel();

    virtual void* NewItem(int32_t itemID);

    virtual void DeleteItem(void* item);

    uint32_t _instanceId;
};

class ScopedChannel
{
public:
    // Can only be created by the channel manager
    ScopedChannel(ChannelManager& chManager);

    ScopedChannel(ChannelManager& chManager, int32_t channelId);

    Channel* ChannelPtr();

    Channel* GetFirstChannel(void*& iterator) const;

    Channel* GetNextChannel(void*& iterator) const;

    ~ScopedChannel();
private:
    ChannelManager& _chManager;
    Channel* _channelPtr;
    MapWrapper _channels;
};

} // namespace voe

} // namespace webrtc

#endif  // WEBRTC_VOICE_ENGINE_CHANNEL_MANAGER_H