/* * Copyright 2014 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.
*/
// This proxy is passed to the underlying media engine to receive audio data as // they come in. The data will then be passed back up to the RemoteAudioSource // which will fan it out to all the sinks that have been added to it. class RemoteAudioSource::AudioDataProxy : public AudioSinkInterface { public: explicit AudioDataProxy(RemoteAudioSource* source) : source_(source) {
RTC_DCHECK(source);
}
// Register for callbacks immediately before AddSink so that we always get // notified when a channel goes out of scope (signaled when "AudioDataProxy" // is destroyed).
RTC_DCHECK(media_channel);
ssrc ? media_channel->SetRawAudioSink(*ssrc,
std::make_unique<AudioDataProxy>(this))
: media_channel->SetDefaultRawAudioSink(
std::make_unique<AudioDataProxy>(this));
}
void RemoteAudioSource::OnData(const AudioSinkInterface::Data& audio) { // Called on the externally-owned audio callback thread, via/from webrtc.
TRACE_EVENT0("webrtc", "RemoteAudioSource::OnData");
MutexLock lock(&sink_lock_); for (auto* sink : sinks_) { // When peerconnection acts as an audio source, it should not provide // absolute capture timestamp.
sink->OnData(audio.data, 16, audio.sample_rate, audio.channels,
audio.samples_per_channel, /*absolute_capture_timestamp_ms=*/std::nullopt);
}
}
void RemoteAudioSource::OnAudioChannelGone() { if (on_audio_channel_gone_action_ != OnAudioChannelGoneAction::kEnd) { return;
} // Called when the audio channel is deleted. It may be the worker thread or // may be a different task queue. // This object needs to live long enough for the cleanup logic in the posted // task to run, so take a reference to it. Sometimes the task may not be // processed (because the task queue was destroyed shortly after this call), // but that is fine because the task queue destructor will take care of // destroying task which will release the reference on RemoteAudioSource.
rtc::scoped_refptr<RemoteAudioSource> thiz(this);
main_thread_->PostTask([thiz = std::move(thiz)] {
thiz->sinks_.clear();
thiz->SetState(MediaSourceInterface::kEnded);
});
}
} // namespace webrtc
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.