2015-04-29 15:24:01 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef AUDIO_AUDIO_RECEIVE_STREAM_H_
|
|
|
|
|
#define AUDIO_AUDIO_RECEIVE_STREAM_H_
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2021-06-09 13:46:28 +02:00
|
|
|
#include <map>
|
2016-02-23 10:46:32 -08:00
|
|
|
#include <memory>
|
2021-06-16 16:31:18 +02:00
|
|
|
#include <string>
|
Reland of Implemented the GetSources() in native code. (patchset #1 id:1 of https://codereview.webrtc.org/2809613002/ )
Reason for revert:
Re-land, reverting did not fix bug.
https://bugs.chromium.org/p/webrtc/issues/detail?id=7465
Original issue's description:
> Revert of Implemented the GetSources() in native code. (patchset #11 id:510001 of https://codereview.webrtc.org/2770233003/ )
>
> Reason for revert:
> Suspected of WebRtcApprtcBrowserTest.MANUAL_WorksOnApprtc breakage, see
>
> https://bugs.chromium.org/p/webrtc/issues/detail?id=7465
>
> Original issue's description:
> > Added the GetSources() to the RtpReceiverInterface and implemented
> > it for the AudioRtpReceiver.
> >
> > This method returns a vector of RtpSource(both CSRC source and SSRC
> > source) which contains the ID of a source, the timestamp, the source
> > type (SSRC or CSRC) and the audio level.
> >
> > The RtpSource objects are buffered and maintained by the
> > RtpReceiver in webrtc/modules/rtp_rtcp/. When the method is called,
> > the info of the contributing source will be pulled along the object
> > chain:
> > AudioRtpReceiver -> VoiceChannel -> WebRtcVoiceMediaChannel ->
> > AudioReceiveStream -> voe::Channel -> RtpRtcp module
> >
> > Spec:https://w3c.github.io/webrtc-pc/archives/20151006/webrtc.html#widl-RTCRtpReceiver-getContributingSources-sequence-RTCRtpContributingSource
> >
> > BUG=chromium:703122
> > TBR=stefan@webrtc.org, danilchap@webrtc.org
> >
> > Review-Url: https://codereview.webrtc.org/2770233003
> > Cr-Commit-Position: refs/heads/master@{#17591}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/292084c3765d9f3ee406ca2ec86eae206b540053
>
> TBR=deadbeef@webrtc.org,solenberg@webrtc.org,hbos@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=chromium:703122
>
> Review-Url: https://codereview.webrtc.org/2809613002
> Cr-Commit-Position: refs/heads/master@{#17616}
> Committed: https://chromium.googlesource.com/external/webrtc/+/fbcc5cb3869d1370008e40f24fc03ac8fb69c675
TBR=deadbeef@webrtc.org,solenberg@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org,olka@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:703122
Review-Url: https://codereview.webrtc.org/2810623003
Cr-Commit-Position: refs/heads/master@{#17621}
2017-04-10 07:39:05 -07:00
|
|
|
#include <vector>
|
2016-02-23 10:46:32 -08:00
|
|
|
|
2022-03-01 10:32:20 +01:00
|
|
|
#include "absl/strings/string_view.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio/audio_mixer.h"
|
2019-11-01 11:47:51 +01:00
|
|
|
#include "api/neteq/neteq_factory.h"
|
2018-04-12 22:44:09 +02:00
|
|
|
#include "api/rtp_headers.h"
|
2021-02-10 14:31:24 +01:00
|
|
|
#include "api/sequence_checker.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "audio/audio_state.h"
|
|
|
|
|
#include "call/audio_receive_stream.h"
|
|
|
|
|
#include "call/syncable.h"
|
2019-08-02 10:29:26 +00:00
|
|
|
#include "modules/rtp_rtcp/source/source_tracker.h"
|
2021-05-31 12:57:53 +02:00
|
|
|
#include "rtc_base/system/no_unique_address.h"
|
2019-03-04 17:43:34 +01:00
|
|
|
#include "system_wrappers/include/clock.h"
|
2015-04-29 15:24:01 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2017-01-31 03:58:40 -08:00
|
|
|
class PacketRouter;
|
2016-07-04 07:06:55 -07:00
|
|
|
class RtcEventLog;
|
2017-06-21 01:05:22 -07:00
|
|
|
class RtpStreamReceiverControllerInterface;
|
|
|
|
|
class RtpStreamReceiverInterface;
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2015-11-25 08:16:52 -08:00
|
|
|
namespace voe {
|
2018-11-16 09:50:42 +01:00
|
|
|
class ChannelReceiveInterface;
|
2015-11-25 08:16:52 -08:00
|
|
|
} // namespace voe
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2015-11-25 08:16:52 -08:00
|
|
|
namespace internal {
|
2016-11-14 11:30:07 -08:00
|
|
|
class AudioSendStream;
|
2022-05-20 15:21:33 +02:00
|
|
|
} // namespace internal
|
2015-12-12 01:37:01 +01:00
|
|
|
|
2022-05-22 20:47:28 +02:00
|
|
|
class AudioReceiveStreamImpl final : public webrtc::AudioReceiveStreamInterface,
|
2022-05-20 15:21:33 +02:00
|
|
|
public AudioMixer::Source,
|
|
|
|
|
public Syncable {
|
2015-04-29 15:24:01 +02:00
|
|
|
public:
|
2022-05-20 15:21:33 +02:00
|
|
|
AudioReceiveStreamImpl(
|
|
|
|
|
Clock* clock,
|
|
|
|
|
PacketRouter* packet_router,
|
|
|
|
|
NetEqFactory* neteq_factory,
|
2022-05-22 20:47:28 +02:00
|
|
|
const webrtc::AudioReceiveStreamInterface::Config& config,
|
2022-05-20 15:21:33 +02:00
|
|
|
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
|
|
|
|
webrtc::RtcEventLog* event_log);
|
2018-11-16 09:50:42 +01:00
|
|
|
// For unit tests, which need to supply a mock channel receive.
|
2022-05-20 15:21:33 +02:00
|
|
|
AudioReceiveStreamImpl(
|
2019-03-04 17:43:34 +01:00
|
|
|
Clock* clock,
|
2018-11-16 09:50:42 +01:00
|
|
|
PacketRouter* packet_router,
|
2022-05-22 20:47:28 +02:00
|
|
|
const webrtc::AudioReceiveStreamInterface::Config& config,
|
2018-11-16 09:50:42 +01:00
|
|
|
const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
|
|
|
|
|
webrtc::RtcEventLog* event_log,
|
|
|
|
|
std::unique_ptr<voe::ChannelReceiveInterface> channel_receive);
|
2020-09-29 09:46:21 +02:00
|
|
|
|
2022-05-20 15:21:33 +02:00
|
|
|
AudioReceiveStreamImpl() = delete;
|
|
|
|
|
AudioReceiveStreamImpl(const AudioReceiveStreamImpl&) = delete;
|
|
|
|
|
AudioReceiveStreamImpl& operator=(const AudioReceiveStreamImpl&) = delete;
|
2020-09-29 09:46:21 +02:00
|
|
|
|
2021-05-31 12:57:53 +02:00
|
|
|
// Destruction happens on the worker thread. Prior to destruction the caller
|
|
|
|
|
// must ensure that a registration with the transport has been cleared. See
|
|
|
|
|
// `RegisterWithTransport` for details.
|
|
|
|
|
// TODO(tommi): As a further improvement to this, performing the full
|
|
|
|
|
// destruction on the network thread could be made the default.
|
2022-05-20 15:21:33 +02:00
|
|
|
~AudioReceiveStreamImpl() override;
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2021-05-31 12:57:53 +02:00
|
|
|
// Called on the network thread to register/unregister with the network
|
|
|
|
|
// transport.
|
|
|
|
|
void RegisterWithTransport(
|
|
|
|
|
RtpStreamReceiverControllerInterface* receiver_controller);
|
|
|
|
|
// If registration has previously been done (via `RegisterWithTransport`) then
|
|
|
|
|
// `UnregisterFromTransport` must be called prior to destruction, on the
|
|
|
|
|
// network thread.
|
|
|
|
|
void UnregisterFromTransport();
|
|
|
|
|
|
2022-05-22 20:47:28 +02:00
|
|
|
// webrtc::AudioReceiveStreamInterface implementation.
|
2015-07-16 09:30:09 +02:00
|
|
|
void Start() override;
|
|
|
|
|
void Stop() override;
|
2021-01-17 14:36:44 +01:00
|
|
|
bool IsRunning() const override;
|
2021-06-09 13:46:28 +02:00
|
|
|
void SetDepacketizerToDecoderFrameTransformer(
|
|
|
|
|
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer)
|
|
|
|
|
override;
|
|
|
|
|
void SetDecoderMap(std::map<int, SdpAudioFormat> decoder_map) override;
|
2022-05-30 15:08:13 +02:00
|
|
|
void SetNackHistory(int history_ms) override;
|
2021-09-03 14:51:22 +00:00
|
|
|
void SetNonSenderRttMeasurement(bool enabled) override;
|
2021-06-14 08:11:10 +02:00
|
|
|
void SetFrameDecryptor(rtc::scoped_refptr<webrtc::FrameDecryptorInterface>
|
|
|
|
|
frame_decryptor) override;
|
2021-01-17 14:36:44 +01:00
|
|
|
|
2022-05-22 20:47:28 +02:00
|
|
|
webrtc::AudioReceiveStreamInterface::Stats GetStats(
|
2020-09-14 10:47:50 +02:00
|
|
|
bool get_and_clear_legacy_stats) const override;
|
2018-01-11 13:52:30 +01:00
|
|
|
void SetSink(AudioSinkInterface* sink) override;
|
2016-06-17 08:30:54 -07:00
|
|
|
void SetGain(float gain) override;
|
2019-02-06 09:45:56 +01:00
|
|
|
bool SetBaseMinimumPlayoutDelayMs(int delay_ms) override;
|
|
|
|
|
int GetBaseMinimumPlayoutDelayMs() const override;
|
Reland of Implemented the GetSources() in native code. (patchset #1 id:1 of https://codereview.webrtc.org/2809613002/ )
Reason for revert:
Re-land, reverting did not fix bug.
https://bugs.chromium.org/p/webrtc/issues/detail?id=7465
Original issue's description:
> Revert of Implemented the GetSources() in native code. (patchset #11 id:510001 of https://codereview.webrtc.org/2770233003/ )
>
> Reason for revert:
> Suspected of WebRtcApprtcBrowserTest.MANUAL_WorksOnApprtc breakage, see
>
> https://bugs.chromium.org/p/webrtc/issues/detail?id=7465
>
> Original issue's description:
> > Added the GetSources() to the RtpReceiverInterface and implemented
> > it for the AudioRtpReceiver.
> >
> > This method returns a vector of RtpSource(both CSRC source and SSRC
> > source) which contains the ID of a source, the timestamp, the source
> > type (SSRC or CSRC) and the audio level.
> >
> > The RtpSource objects are buffered and maintained by the
> > RtpReceiver in webrtc/modules/rtp_rtcp/. When the method is called,
> > the info of the contributing source will be pulled along the object
> > chain:
> > AudioRtpReceiver -> VoiceChannel -> WebRtcVoiceMediaChannel ->
> > AudioReceiveStream -> voe::Channel -> RtpRtcp module
> >
> > Spec:https://w3c.github.io/webrtc-pc/archives/20151006/webrtc.html#widl-RTCRtpReceiver-getContributingSources-sequence-RTCRtpContributingSource
> >
> > BUG=chromium:703122
> > TBR=stefan@webrtc.org, danilchap@webrtc.org
> >
> > Review-Url: https://codereview.webrtc.org/2770233003
> > Cr-Commit-Position: refs/heads/master@{#17591}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/292084c3765d9f3ee406ca2ec86eae206b540053
>
> TBR=deadbeef@webrtc.org,solenberg@webrtc.org,hbos@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=chromium:703122
>
> Review-Url: https://codereview.webrtc.org/2809613002
> Cr-Commit-Position: refs/heads/master@{#17616}
> Committed: https://chromium.googlesource.com/external/webrtc/+/fbcc5cb3869d1370008e40f24fc03ac8fb69c675
TBR=deadbeef@webrtc.org,solenberg@webrtc.org,philipel@webrtc.org,stefan@webrtc.org,danilchap@webrtc.org,zhihuang@webrtc.org,olka@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:703122
Review-Url: https://codereview.webrtc.org/2810623003
Cr-Commit-Position: refs/heads/master@{#17621}
2017-04-10 07:39:05 -07:00
|
|
|
std::vector<webrtc::RtpSource> GetSources() const override;
|
2015-12-12 01:37:01 +01:00
|
|
|
|
2017-01-31 03:58:40 -08:00
|
|
|
// AudioMixer::Source
|
|
|
|
|
AudioFrameInfo GetAudioFrameWithInfo(int sample_rate_hz,
|
|
|
|
|
AudioFrame* audio_frame) override;
|
|
|
|
|
int Ssrc() const override;
|
|
|
|
|
int PreferredSampleRate() const override;
|
|
|
|
|
|
|
|
|
|
// Syncable
|
2020-02-10 16:33:29 +01:00
|
|
|
uint32_t id() const override;
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<Syncable::Info> GetInfo() const override;
|
2019-10-22 15:23:44 +02:00
|
|
|
bool GetPlayoutRtpTimestamp(uint32_t* rtp_timestamp,
|
|
|
|
|
int64_t* time_ms) const override;
|
|
|
|
|
void SetEstimatedPlayoutNtpTimestampMs(int64_t ntp_timestamp_ms,
|
|
|
|
|
int64_t time_ms) override;
|
2020-09-08 16:30:25 +02:00
|
|
|
bool SetMinimumPlayoutDelay(int delay_ms) override;
|
2017-01-31 03:58:40 -08:00
|
|
|
|
2022-05-20 15:21:33 +02:00
|
|
|
void AssociateSendStream(internal::AudioSendStream* send_stream);
|
2019-03-05 14:29:42 +01:00
|
|
|
void DeliverRtcp(const uint8_t* packet, size_t length);
|
2021-06-09 13:46:28 +02:00
|
|
|
|
2022-03-01 10:32:20 +01:00
|
|
|
void SetSyncGroup(absl::string_view sync_group);
|
2021-06-16 16:31:18 +02:00
|
|
|
|
2021-06-15 23:01:57 +02:00
|
|
|
void SetLocalSsrc(uint32_t local_ssrc);
|
|
|
|
|
|
|
|
|
|
uint32_t local_ssrc() const;
|
2021-06-09 13:46:28 +02:00
|
|
|
|
2022-05-09 14:49:37 +00:00
|
|
|
uint32_t remote_ssrc() const override {
|
2021-06-09 13:46:28 +02:00
|
|
|
// The remote_ssrc member variable of config_ will never change and can be
|
|
|
|
|
// considered const.
|
|
|
|
|
return config_.rtp.remote_ssrc;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-09 10:22:48 +00:00
|
|
|
// Returns a reference to the currently set sync group of the stream.
|
|
|
|
|
// Must be called on the packet delivery thread.
|
|
|
|
|
const std::string& sync_group() const;
|
|
|
|
|
|
2018-01-11 13:52:30 +01:00
|
|
|
const AudioSendStream* GetAssociatedSendStreamForTesting() const;
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2021-06-09 13:46:28 +02:00
|
|
|
// TODO(tommi): Remove this method.
|
2022-05-22 20:47:28 +02:00
|
|
|
void ReconfigureForTesting(
|
|
|
|
|
const webrtc::AudioReceiveStreamInterface::Config& config);
|
2021-06-09 13:46:28 +02:00
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
private:
|
2022-05-20 15:21:33 +02:00
|
|
|
internal::AudioState* audio_state() const;
|
2015-11-20 09:59:34 -08:00
|
|
|
|
2021-05-31 12:57:53 +02:00
|
|
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_;
|
|
|
|
|
// TODO(bugs.webrtc.org/11993): This checker conceptually represents
|
|
|
|
|
// operations that belong to the network thread. The Call class is currently
|
|
|
|
|
// moving towards handling network packets on the network thread and while
|
|
|
|
|
// that work is ongoing, this checker may in practice represent the worker
|
|
|
|
|
// thread, but still serves as a mechanism of grouping together concepts
|
|
|
|
|
// that belong to the network thread. Once the packets are fully delivered
|
|
|
|
|
// on the network thread, this comment will be deleted.
|
2021-05-31 17:36:47 +02:00
|
|
|
RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
|
2022-05-22 20:47:28 +02:00
|
|
|
webrtc::AudioReceiveStreamInterface::Config config_;
|
2015-11-06 15:34:49 -08:00
|
|
|
rtc::scoped_refptr<webrtc::AudioState> audio_state_;
|
2019-08-02 10:29:26 +00:00
|
|
|
SourceTracker source_tracker_;
|
2021-01-23 12:27:19 +05:30
|
|
|
const std::unique_ptr<voe::ChannelReceiveInterface> channel_receive_;
|
2021-05-31 12:57:53 +02:00
|
|
|
AudioSendStream* associated_send_stream_
|
2021-05-31 17:36:47 +02:00
|
|
|
RTC_GUARDED_BY(packet_sequence_checker_) = nullptr;
|
2015-10-27 03:35:21 -07:00
|
|
|
|
2018-02-07 10:18:32 +01:00
|
|
|
bool playing_ RTC_GUARDED_BY(worker_thread_checker_) = false;
|
2016-11-22 06:42:53 -08:00
|
|
|
|
2021-05-31 12:57:53 +02:00
|
|
|
std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_
|
2021-05-31 17:36:47 +02:00
|
|
|
RTC_GUARDED_BY(packet_sequence_checker_);
|
2015-04-29 15:24:01 +02:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // AUDIO_AUDIO_RECEIVE_STREAM_H_
|