OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/voice_engine/channel_manager.h" | 11 #include "webrtc/voice_engine/channel_manager.h" |
12 | 12 |
13 #include "webrtc/base/timeutils.h" | |
14 #include "webrtc/voice_engine/channel.h" | 13 #include "webrtc/voice_engine/channel.h" |
15 | 14 |
16 namespace webrtc { | 15 namespace webrtc { |
17 namespace voe { | 16 namespace voe { |
18 | 17 |
19 ChannelOwner::ChannelOwner(class Channel* channel) | 18 ChannelOwner::ChannelOwner(class Channel* channel) |
20 : channel_ref_(new ChannelRef(channel)) {} | 19 : channel_ref_(new ChannelRef(channel)) {} |
21 | 20 |
22 ChannelOwner::ChannelOwner(const ChannelOwner& channel_owner) | 21 ChannelOwner::ChannelOwner(const ChannelOwner& channel_owner) |
23 : channel_ref_(channel_owner.channel_ref_) { | 22 : channel_ref_(channel_owner.channel_ref_) { |
(...skipping 15 matching lines...) Expand all Loading... |
39 channel_ref_ = other.channel_ref_; | 38 channel_ref_ = other.channel_ref_; |
40 ++channel_ref_->ref_count; | 39 ++channel_ref_->ref_count; |
41 | 40 |
42 return *this; | 41 return *this; |
43 } | 42 } |
44 | 43 |
45 ChannelOwner::ChannelRef::ChannelRef(class Channel* channel) | 44 ChannelOwner::ChannelRef::ChannelRef(class Channel* channel) |
46 : channel(channel), ref_count(1) {} | 45 : channel(channel), ref_count(1) {} |
47 | 46 |
48 ChannelManager::ChannelManager(uint32_t instance_id) | 47 ChannelManager::ChannelManager(uint32_t instance_id) |
49 : instance_id_(instance_id), | 48 : instance_id_(instance_id), last_channel_id_(-1) {} |
50 last_channel_id_(-1), | |
51 random_(rtc::TimeNanos()) {} | |
52 | 49 |
53 ChannelOwner ChannelManager::CreateChannel( | 50 ChannelOwner ChannelManager::CreateChannel( |
54 const VoEBase::ChannelConfig& config) { | 51 const VoEBase::ChannelConfig& config) { |
55 Channel* channel; | 52 Channel* channel; |
56 Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config); | 53 Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config); |
57 // TODO(solenberg): Delete this, users should configure ssrc | |
58 // explicitly. | |
59 channel->SetLocalSSRC(random_.Rand<uint32_t>()); | |
60 | |
61 ChannelOwner channel_owner(channel); | 54 ChannelOwner channel_owner(channel); |
62 | 55 |
63 rtc::CritScope crit(&lock_); | 56 rtc::CritScope crit(&lock_); |
64 | 57 |
65 channels_.push_back(channel_owner); | 58 channels_.push_back(channel_owner); |
66 | 59 |
67 return channel_owner; | 60 return channel_owner; |
68 } | 61 } |
69 | 62 |
70 ChannelOwner ChannelManager::GetChannel(int32_t channel_id) { | 63 ChannelOwner ChannelManager::GetChannel(int32_t channel_id) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 bool ChannelManager::Iterator::IsValid() { | 131 bool ChannelManager::Iterator::IsValid() { |
139 return iterator_pos_ < channels_.size(); | 132 return iterator_pos_ < channels_.size(); |
140 } | 133 } |
141 | 134 |
142 void ChannelManager::Iterator::Increment() { | 135 void ChannelManager::Iterator::Increment() { |
143 ++iterator_pos_; | 136 ++iterator_pos_; |
144 } | 137 } |
145 | 138 |
146 } // namespace voe | 139 } // namespace voe |
147 } // namespace webrtc | 140 } // namespace webrtc |
OLD | NEW |