Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 428432d

Browse files
timnaCommit Bot
authored andcommitted
Name change on channel and channel_id for consistency.
Bug: webrtc:12111 Change-Id: I5ea5f7b73ab8493bcbb67bc0144e0c261aedc1ed Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192000 Reviewed-by: Karl Wiberg <[email protected]> Commit-Queue: Tim Na <[email protected]> Cr-Commit-Position: refs/heads/master@{#32597}
1 parent 5d55597 commit 428432d

File tree

2 files changed

+89
-77
lines changed

2 files changed

+89
-77
lines changed

audio/voip/voip_core.cc

Lines changed: 76 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ bool VoipCore::Init(rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
117117
absl::optional<ChannelId> VoipCore::CreateChannel(
118118
Transport* transport,
119119
absl::optional<uint32_t> local_ssrc) {
120-
absl::optional<ChannelId> channel;
120+
absl::optional<ChannelId> channel_id;
121121

122122
// Set local ssrc to random if not set by caller.
123123
if (!local_ssrc) {
124124
Random random(rtc::TimeMicros());
125125
local_ssrc = random.Rand<uint32_t>();
126126
}
127127

128-
rtc::scoped_refptr<AudioChannel> audio_channel =
128+
rtc::scoped_refptr<AudioChannel> channel =
129129
new rtc::RefCountedObject<AudioChannel>(
130130
transport, local_ssrc.value(), task_queue_factory_.get(),
131131
process_thread_.get(), audio_mixer_.get(), decoder_factory_);
@@ -139,49 +139,49 @@ absl::optional<ChannelId> VoipCore::CreateChannel(
139139
// Start process thread if the channel is the first one.
140140
start_process_thread = channels_.empty();
141141

142-
channel = static_cast<ChannelId>(next_channel_id_);
143-
channels_[*channel] = audio_channel;
142+
channel_id = static_cast<ChannelId>(next_channel_id_);
143+
channels_[*channel_id] = channel;
144144
next_channel_id_++;
145145
if (next_channel_id_ >= kMaxChannelId) {
146146
next_channel_id_ = 0;
147147
}
148148
}
149149

150150
// Set ChannelId in audio channel for logging/debugging purpose.
151-
audio_channel->SetId(*channel);
151+
channel->SetId(*channel_id);
152152

153153
if (start_process_thread) {
154154
process_thread_->Start();
155155
}
156156

157-
return channel;
157+
return channel_id;
158158
}
159159

160-
void VoipCore::ReleaseChannel(ChannelId channel) {
160+
void VoipCore::ReleaseChannel(ChannelId channel_id) {
161161
// Destroy channel outside of the lock.
162-
rtc::scoped_refptr<AudioChannel> audio_channel;
162+
rtc::scoped_refptr<AudioChannel> channel;
163163

164164
bool no_channels_after_release = false;
165165

166166
{
167167
MutexLock lock(&lock_);
168168

169-
auto iter = channels_.find(channel);
169+
auto iter = channels_.find(channel_id);
170170
if (iter != channels_.end()) {
171-
audio_channel = std::move(iter->second);
171+
channel = std::move(iter->second);
172172
channels_.erase(iter);
173173
}
174174

175175
no_channels_after_release = channels_.empty();
176176
}
177177

178-
if (!audio_channel) {
179-
RTC_LOG(LS_WARNING) << "Channel " << channel << " not found";
178+
if (!channel) {
179+
RTC_LOG(LS_WARNING) << "Channel " << channel_id << " not found";
180180
}
181181

182182
if (no_channels_after_release) {
183183
// Release audio channel first to have it DeRegisterModule first.
184-
audio_channel = nullptr;
184+
channel = nullptr;
185185
process_thread_->Stop();
186186

187187
// Make sure to stop playout on ADM if it is playing.
@@ -193,19 +193,19 @@ void VoipCore::ReleaseChannel(ChannelId channel) {
193193
}
194194
}
195195

196-
rtc::scoped_refptr<AudioChannel> VoipCore::GetChannel(ChannelId channel) {
197-
rtc::scoped_refptr<AudioChannel> audio_channel;
196+
rtc::scoped_refptr<AudioChannel> VoipCore::GetChannel(ChannelId channel_id) {
197+
rtc::scoped_refptr<AudioChannel> channel;
198198
{
199199
MutexLock lock(&lock_);
200-
auto iter = channels_.find(channel);
200+
auto iter = channels_.find(channel_id);
201201
if (iter != channels_.end()) {
202-
audio_channel = iter->second;
202+
channel = iter->second;
203203
}
204204
}
205-
if (!audio_channel) {
206-
RTC_LOG(LS_ERROR) << "Channel " << channel << " not found";
205+
if (!channel) {
206+
RTC_LOG(LS_ERROR) << "Channel " << channel_id << " not found";
207207
}
208-
return audio_channel;
208+
return channel;
209209
}
210210

211211
bool VoipCore::UpdateAudioTransportWithSenders() {
@@ -263,37 +263,40 @@ bool VoipCore::UpdateAudioTransportWithSenders() {
263263
return true;
264264
}
265265

266-
bool VoipCore::StartSend(ChannelId channel) {
267-
auto audio_channel = GetChannel(channel);
268-
if (!audio_channel || !audio_channel->StartSend()) {
266+
bool VoipCore::StartSend(ChannelId channel_id) {
267+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
268+
269+
if (!channel || !channel->StartSend()) {
269270
return false;
270271
}
271272

272273
return UpdateAudioTransportWithSenders();
273274
}
274275

275-
bool VoipCore::StopSend(ChannelId channel) {
276-
auto audio_channel = GetChannel(channel);
277-
if (!audio_channel) {
276+
bool VoipCore::StopSend(ChannelId channel_id) {
277+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
278+
279+
if (!channel) {
278280
return false;
279281
}
280282

281-
audio_channel->StopSend();
283+
channel->StopSend();
282284

283285
return UpdateAudioTransportWithSenders();
284286
}
285287

286-
bool VoipCore::StartPlayout(ChannelId channel) {
287-
auto audio_channel = GetChannel(channel);
288-
if (!audio_channel) {
288+
bool VoipCore::StartPlayout(ChannelId channel_id) {
289+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
290+
291+
if (!channel) {
289292
return false;
290293
}
291294

292-
if (audio_channel->IsPlaying()) {
295+
if (channel->IsPlaying()) {
293296
return true;
294297
}
295298

296-
if (!audio_channel->StartPlay()) {
299+
if (!channel->StartPlay()) {
297300
return false;
298301
}
299302

@@ -310,77 +313,86 @@ bool VoipCore::StartPlayout(ChannelId channel) {
310313
return true;
311314
}
312315

313-
bool VoipCore::StopPlayout(ChannelId channel) {
314-
auto audio_channel = GetChannel(channel);
315-
if (!audio_channel) {
316+
bool VoipCore::StopPlayout(ChannelId channel_id) {
317+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
318+
319+
if (!channel) {
316320
return false;
317321
}
318322

319-
audio_channel->StopPlay();
323+
channel->StopPlay();
320324

321325
return true;
322326
}
323327

324-
void VoipCore::ReceivedRTPPacket(ChannelId channel,
328+
void VoipCore::ReceivedRTPPacket(ChannelId channel_id,
325329
rtc::ArrayView<const uint8_t> rtp_packet) {
326-
// Failure to locate channel is logged internally in GetChannel.
327-
if (auto audio_channel = GetChannel(channel)) {
328-
audio_channel->ReceivedRTPPacket(rtp_packet);
330+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
331+
332+
if (channel) {
333+
channel->ReceivedRTPPacket(rtp_packet);
329334
}
330335
}
331336

332-
void VoipCore::ReceivedRTCPPacket(ChannelId channel,
337+
void VoipCore::ReceivedRTCPPacket(ChannelId channel_id,
333338
rtc::ArrayView<const uint8_t> rtcp_packet) {
334-
// Failure to locate channel is logged internally in GetChannel.
335-
if (auto audio_channel = GetChannel(channel)) {
336-
audio_channel->ReceivedRTCPPacket(rtcp_packet);
339+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
340+
341+
if (channel) {
342+
channel->ReceivedRTCPPacket(rtcp_packet);
337343
}
338344
}
339345

340-
void VoipCore::SetSendCodec(ChannelId channel,
346+
void VoipCore::SetSendCodec(ChannelId channel_id,
341347
int payload_type,
342348
const SdpAudioFormat& encoder_format) {
343-
// Failure to locate channel is logged internally in GetChannel.
344-
if (auto audio_channel = GetChannel(channel)) {
349+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
350+
351+
if (channel) {
345352
auto encoder = encoder_factory_->MakeAudioEncoder(
346353
payload_type, encoder_format, absl::nullopt);
347-
audio_channel->SetEncoder(payload_type, encoder_format, std::move(encoder));
354+
channel->SetEncoder(payload_type, encoder_format, std::move(encoder));
348355
}
349356
}
350357

351358
void VoipCore::SetReceiveCodecs(
352-
ChannelId channel,
359+
ChannelId channel_id,
353360
const std::map<int, SdpAudioFormat>& decoder_specs) {
354-
// Failure to locate channel is logged internally in GetChannel.
355-
if (auto audio_channel = GetChannel(channel)) {
356-
audio_channel->SetReceiveCodecs(decoder_specs);
361+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
362+
363+
if (channel) {
364+
channel->SetReceiveCodecs(decoder_specs);
357365
}
358366
}
359367

360-
void VoipCore::RegisterTelephoneEventType(ChannelId channel,
368+
void VoipCore::RegisterTelephoneEventType(ChannelId channel_id,
361369
int rtp_payload_type,
362370
int sample_rate_hz) {
363-
// Failure to locate channel is logged internally in GetChannel.
364-
if (auto audio_channel = GetChannel(channel)) {
365-
audio_channel->RegisterTelephoneEventType(rtp_payload_type, sample_rate_hz);
371+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
372+
373+
if (channel) {
374+
channel->RegisterTelephoneEventType(rtp_payload_type, sample_rate_hz);
366375
}
367376
}
368377

369-
bool VoipCore::SendDtmfEvent(ChannelId channel,
378+
bool VoipCore::SendDtmfEvent(ChannelId channel_id,
370379
DtmfEvent dtmf_event,
371380
int duration_ms) {
372-
// Failure to locate channel is logged internally in GetChannel.
373-
if (auto audio_channel = GetChannel(channel)) {
374-
return audio_channel->SendTelephoneEvent(static_cast<int>(dtmf_event),
375-
duration_ms);
381+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
382+
383+
if (channel) {
384+
return channel->SendTelephoneEvent(static_cast<int>(dtmf_event),
385+
duration_ms);
376386
}
377387
return false;
378388
}
379389

380390
absl::optional<IngressStatistics> VoipCore::GetIngressStatistics(
381-
ChannelId channel) {
382-
if (auto audio_channel = GetChannel(channel)) {
383-
return audio_channel->GetIngressStatistics();
391+
ChannelId channel_id) {
392+
rtc::scoped_refptr<AudioChannel> channel = GetChannel(channel_id);
393+
394+
if (channel) {
395+
return channel->GetIngressStatistics();
384396
}
385397
return absl::nullopt;
386398
}

audio/voip/voip_core.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,42 +78,42 @@ class VoipCore : public VoipEngine,
7878
absl::optional<ChannelId> CreateChannel(
7979
Transport* transport,
8080
absl::optional<uint32_t> local_ssrc) override;
81-
void ReleaseChannel(ChannelId channel) override;
82-
bool StartSend(ChannelId channel) override;
83-
bool StopSend(ChannelId channel) override;
84-
bool StartPlayout(ChannelId channel) override;
85-
bool StopPlayout(ChannelId channel) override;
81+
void ReleaseChannel(ChannelId channel_id) override;
82+
bool StartSend(ChannelId channel_id) override;
83+
bool StopSend(ChannelId channel_id) override;
84+
bool StartPlayout(ChannelId channel_id) override;
85+
bool StopPlayout(ChannelId channel_id) override;
8686

8787
// Implements VoipNetwork interfaces.
88-
void ReceivedRTPPacket(ChannelId channel,
88+
void ReceivedRTPPacket(ChannelId channel_id,
8989
rtc::ArrayView<const uint8_t> rtp_packet) override;
90-
void ReceivedRTCPPacket(ChannelId channel,
90+
void ReceivedRTCPPacket(ChannelId channel_id,
9191
rtc::ArrayView<const uint8_t> rtcp_packet) override;
9292

9393
// Implements VoipCodec interfaces.
94-
void SetSendCodec(ChannelId channel,
94+
void SetSendCodec(ChannelId channel_id,
9595
int payload_type,
9696
const SdpAudioFormat& encoder_format) override;
9797
void SetReceiveCodecs(
98-
ChannelId channel,
98+
ChannelId channel_id,
9999
const std::map<int, SdpAudioFormat>& decoder_specs) override;
100100

101101
// Implements VoipDtmf interfaces.
102-
void RegisterTelephoneEventType(ChannelId channel,
102+
void RegisterTelephoneEventType(ChannelId channel_id,
103103
int rtp_payload_type,
104104
int sample_rate_hz) override;
105-
bool SendDtmfEvent(ChannelId channel,
105+
bool SendDtmfEvent(ChannelId channel_id,
106106
DtmfEvent dtmf_event,
107107
int duration_ms) override;
108108

109109
// Implements VoipStatistics interfaces.
110110
absl::optional<IngressStatistics> GetIngressStatistics(
111-
ChannelId channel) override;
111+
ChannelId channel_id) override;
112112

113113
private:
114114
// Fetches the corresponding AudioChannel assigned with given |channel|.
115115
// Returns nullptr if not found.
116-
rtc::scoped_refptr<AudioChannel> GetChannel(ChannelId channel);
116+
rtc::scoped_refptr<AudioChannel> GetChannel(ChannelId channel_id);
117117

118118
// Updates AudioTransportImpl with a new set of actively sending AudioSender
119119
// (AudioEgress). This needs to be invoked whenever StartSend/StopSend is

0 commit comments

Comments
 (0)