Revert "Replace the implementation of GetContributingSources()
on the audio side."
This reverts commit 8fa7151e4bbad40fec1f964fe0c003b8787bb78a. Reason for revert: Speculative revert to fix roll of webrtc into chrome. Right now tests related to RTCRtpReceiver failing and looks like it is main candidate, who can affect that behavior. Original change's description: > Replace the implementation of `GetContributingSources()` on the audio side. > > This change replaces the `ContributingSources`-implementation of `GetContributingSources()` and `GetSynchronizationSources()` on the audio side with the spec-compliant `SourceTracker`-implementation. > > The most noticeable impact is that the per-frame dictionaries are now updated when frames are delivered to the RTCRtpReceiver's MediaStreamTrack rather than when RTP packets are received on the network. > > This change is almost identical to the previous video side change at: https://webrtc-review.googlesource.com/c/src/+/143177 > > Bug: webrtc:10545 > Change-Id: Ife7f08ee8ca1346099b7466837a3756947085fc5 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144422 > Reviewed-by: Oskar Sundbom <ossu@webrtc.org> > Commit-Queue: Chen Xing <chxg@google.com> > Cr-Commit-Position: refs/heads/master@{#28459} TBR=ossu@webrtc.org,chxg@google.com Change-Id: I5c631d4dcfb39601055ffce9b104f45eea871fd3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:10545 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144562 Reviewed-by: Artem Titov <titovartem@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28478}
This commit is contained in:
@ -113,9 +113,7 @@ AudioReceiveStream::AudioReceiveStream(
|
|||||||
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
||||||
webrtc::RtcEventLog* event_log,
|
webrtc::RtcEventLog* event_log,
|
||||||
std::unique_ptr<voe::ChannelReceiveInterface> channel_receive)
|
std::unique_ptr<voe::ChannelReceiveInterface> channel_receive)
|
||||||
: audio_state_(audio_state),
|
: audio_state_(audio_state), channel_receive_(std::move(channel_receive)) {
|
||||||
channel_receive_(std::move(channel_receive)),
|
|
||||||
source_tracker_(clock) {
|
|
||||||
RTC_LOG(LS_INFO) << "AudioReceiveStream: " << config.rtp.remote_ssrc;
|
RTC_LOG(LS_INFO) << "AudioReceiveStream: " << config.rtp.remote_ssrc;
|
||||||
RTC_DCHECK(config.decoder_factory);
|
RTC_DCHECK(config.decoder_factory);
|
||||||
RTC_DCHECK(config.rtcp_send_transport);
|
RTC_DCHECK(config.rtcp_send_transport);
|
||||||
@ -269,18 +267,13 @@ int AudioReceiveStream::GetBaseMinimumPlayoutDelayMs() const {
|
|||||||
|
|
||||||
std::vector<RtpSource> AudioReceiveStream::GetSources() const {
|
std::vector<RtpSource> AudioReceiveStream::GetSources() const {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
return source_tracker_.GetSources();
|
return channel_receive_->GetSources();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
|
AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
|
||||||
int sample_rate_hz,
|
int sample_rate_hz,
|
||||||
AudioFrame* audio_frame) {
|
AudioFrame* audio_frame) {
|
||||||
AudioMixer::Source::AudioFrameInfo audio_frame_info =
|
return channel_receive_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
|
||||||
channel_receive_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
|
|
||||||
if (audio_frame_info != AudioMixer::Source::AudioFrameInfo::kError) {
|
|
||||||
source_tracker_.OnFrameDelivered(audio_frame->packet_infos_);
|
|
||||||
}
|
|
||||||
return audio_frame_info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioReceiveStream::Ssrc() const {
|
int AudioReceiveStream::Ssrc() const {
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "audio/audio_state.h"
|
#include "audio/audio_state.h"
|
||||||
#include "call/audio_receive_stream.h"
|
#include "call/audio_receive_stream.h"
|
||||||
#include "call/syncable.h"
|
#include "call/syncable.h"
|
||||||
#include "modules/rtp_rtcp/source/source_tracker.h"
|
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
#include "rtc_base/thread_checker.h"
|
#include "rtc_base/thread_checker.h"
|
||||||
#include "system_wrappers/include/clock.h"
|
#include "system_wrappers/include/clock.h"
|
||||||
@ -108,7 +107,6 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream,
|
|||||||
webrtc::AudioReceiveStream::Config config_;
|
webrtc::AudioReceiveStream::Config config_;
|
||||||
rtc::scoped_refptr<webrtc::AudioState> audio_state_;
|
rtc::scoped_refptr<webrtc::AudioState> audio_state_;
|
||||||
const std::unique_ptr<voe::ChannelReceiveInterface> channel_receive_;
|
const std::unique_ptr<voe::ChannelReceiveInterface> channel_receive_;
|
||||||
SourceTracker source_tracker_;
|
|
||||||
AudioSendStream* associated_send_stream_ = nullptr;
|
AudioSendStream* associated_send_stream_ = nullptr;
|
||||||
|
|
||||||
bool playing_ RTC_GUARDED_BY(worker_thread_checker_) = false;
|
bool playing_ RTC_GUARDED_BY(worker_thread_checker_) = false;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "modules/rtp_rtcp/include/receive_statistics.h"
|
#include "modules/rtp_rtcp/include/receive_statistics.h"
|
||||||
#include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
#include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
|
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||||
|
#include "modules/rtp_rtcp/source/contributing_sources.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
||||||
#include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
#include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
||||||
@ -154,6 +155,8 @@ class ChannelReceive : public ChannelReceiveInterface,
|
|||||||
// Used for obtaining RTT for a receive-only channel.
|
// Used for obtaining RTT for a receive-only channel.
|
||||||
void SetAssociatedSendChannel(const ChannelSendInterface* channel) override;
|
void SetAssociatedSendChannel(const ChannelSendInterface* channel) override;
|
||||||
|
|
||||||
|
std::vector<RtpSource> GetSources() const override;
|
||||||
|
|
||||||
// TODO(sukhanov): Return const pointer. It requires making media transport
|
// TODO(sukhanov): Return const pointer. It requires making media transport
|
||||||
// getters like GetLatestTargetTransferRate to be also const.
|
// getters like GetLatestTargetTransferRate to be also const.
|
||||||
MediaTransportInterface* media_transport() const {
|
MediaTransportInterface* media_transport() const {
|
||||||
@ -210,13 +213,16 @@ class ChannelReceive : public ChannelReceiveInterface,
|
|||||||
std::unique_ptr<RtpRtcp> _rtpRtcpModule;
|
std::unique_ptr<RtpRtcp> _rtpRtcpModule;
|
||||||
const uint32_t remote_ssrc_;
|
const uint32_t remote_ssrc_;
|
||||||
|
|
||||||
// Info for GetSyncInfo is updated on network or worker thread, and queried on
|
// Info for GetSources and GetSyncInfo is updated on network or worker thread,
|
||||||
// the worker thread.
|
// queried on the worker thread.
|
||||||
rtc::CriticalSection sync_info_lock_;
|
rtc::CriticalSection rtp_sources_lock_;
|
||||||
|
ContributingSources contributing_sources_ RTC_GUARDED_BY(&rtp_sources_lock_);
|
||||||
absl::optional<uint32_t> last_received_rtp_timestamp_
|
absl::optional<uint32_t> last_received_rtp_timestamp_
|
||||||
RTC_GUARDED_BY(&sync_info_lock_);
|
RTC_GUARDED_BY(&rtp_sources_lock_);
|
||||||
absl::optional<int64_t> last_received_rtp_system_time_ms_
|
absl::optional<int64_t> last_received_rtp_system_time_ms_
|
||||||
RTC_GUARDED_BY(&sync_info_lock_);
|
RTC_GUARDED_BY(&rtp_sources_lock_);
|
||||||
|
absl::optional<uint8_t> last_received_rtp_audio_level_
|
||||||
|
RTC_GUARDED_BY(&rtp_sources_lock_);
|
||||||
|
|
||||||
std::unique_ptr<AudioCodingModule> audio_coding_;
|
std::unique_ptr<AudioCodingModule> audio_coding_;
|
||||||
AudioSinkInterface* audio_sink_ = nullptr;
|
AudioSinkInterface* audio_sink_ = nullptr;
|
||||||
@ -549,6 +555,24 @@ absl::optional<std::pair<int, SdpAudioFormat>>
|
|||||||
return audio_coding_->ReceiveCodec();
|
return audio_coding_->ReceiveCodec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<webrtc::RtpSource> ChannelReceive::GetSources() const {
|
||||||
|
RTC_DCHECK(worker_thread_checker_.IsCurrent());
|
||||||
|
int64_t now_ms = rtc::TimeMillis();
|
||||||
|
std::vector<RtpSource> sources;
|
||||||
|
{
|
||||||
|
rtc::CritScope cs(&rtp_sources_lock_);
|
||||||
|
sources = contributing_sources_.GetSources(now_ms);
|
||||||
|
if (last_received_rtp_system_time_ms_ >=
|
||||||
|
now_ms - ContributingSources::kHistoryMs) {
|
||||||
|
RTC_DCHECK(last_received_rtp_timestamp_.has_value());
|
||||||
|
sources.emplace_back(*last_received_rtp_system_time_ms_, remote_ssrc_,
|
||||||
|
RtpSourceType::SSRC, last_received_rtp_audio_level_,
|
||||||
|
*last_received_rtp_timestamp_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelReceive::SetReceiveCodecs(
|
void ChannelReceive::SetReceiveCodecs(
|
||||||
const std::map<int, SdpAudioFormat>& codecs) {
|
const std::map<int, SdpAudioFormat>& codecs) {
|
||||||
RTC_DCHECK(worker_thread_checker_.IsCurrent());
|
RTC_DCHECK(worker_thread_checker_.IsCurrent());
|
||||||
@ -562,11 +586,22 @@ void ChannelReceive::SetReceiveCodecs(
|
|||||||
// May be called on either worker thread or network thread.
|
// May be called on either worker thread or network thread.
|
||||||
void ChannelReceive::OnRtpPacket(const RtpPacketReceived& packet) {
|
void ChannelReceive::OnRtpPacket(const RtpPacketReceived& packet) {
|
||||||
int64_t now_ms = rtc::TimeMillis();
|
int64_t now_ms = rtc::TimeMillis();
|
||||||
|
uint8_t audio_level;
|
||||||
|
bool voice_activity;
|
||||||
|
bool has_audio_level =
|
||||||
|
packet.GetExtension<::webrtc::AudioLevel>(&voice_activity, &audio_level);
|
||||||
|
|
||||||
{
|
{
|
||||||
rtc::CritScope cs(&sync_info_lock_);
|
rtc::CritScope cs(&rtp_sources_lock_);
|
||||||
last_received_rtp_timestamp_ = packet.Timestamp();
|
last_received_rtp_timestamp_ = packet.Timestamp();
|
||||||
last_received_rtp_system_time_ms_ = now_ms;
|
last_received_rtp_system_time_ms_ = now_ms;
|
||||||
|
if (has_audio_level)
|
||||||
|
last_received_rtp_audio_level_ = audio_level;
|
||||||
|
std::vector<uint32_t> csrcs = packet.Csrcs();
|
||||||
|
contributing_sources_.Update(
|
||||||
|
now_ms, csrcs,
|
||||||
|
has_audio_level ? absl::optional<uint8_t>(audio_level) : absl::nullopt,
|
||||||
|
packet.Timestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store playout timestamp for the received RTP packet
|
// Store playout timestamp for the received RTP packet
|
||||||
@ -840,7 +875,7 @@ absl::optional<Syncable::Info> ChannelReceive::GetSyncInfo() const {
|
|||||||
return absl::nullopt;
|
return absl::nullopt;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
rtc::CritScope cs(&sync_info_lock_);
|
rtc::CritScope cs(&rtp_sources_lock_);
|
||||||
if (!last_received_rtp_timestamp_ || !last_received_rtp_system_time_ms_) {
|
if (!last_received_rtp_timestamp_ || !last_received_rtp_system_time_ms_) {
|
||||||
return absl::nullopt;
|
return absl::nullopt;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,8 @@ class ChannelReceiveInterface : public RtpPacketSinkInterface {
|
|||||||
// Used for obtaining RTT for a receive-only channel.
|
// Used for obtaining RTT for a receive-only channel.
|
||||||
virtual void SetAssociatedSendChannel(
|
virtual void SetAssociatedSendChannel(
|
||||||
const ChannelSendInterface* channel) = 0;
|
const ChannelSendInterface* channel) = 0;
|
||||||
|
|
||||||
|
virtual std::vector<RtpSource> GetSources() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
|
std::unique_ptr<ChannelReceiveInterface> CreateChannelReceive(
|
||||||
|
Reference in New Issue
Block a user