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
|
|
|
|
2016-02-23 10:46:32 -08:00
|
|
|
#include <memory>
|
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
|
|
|
|
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"
|
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"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/thread_checker.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;
|
2018-01-11 13:52:30 +01:00
|
|
|
class ProcessThread;
|
2016-07-04 07:06:55 -07:00
|
|
|
class RtcEventLog;
|
2017-02-21 06:28:10 -08:00
|
|
|
class RtpPacketReceived;
|
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;
|
2015-12-12 01:37:01 +01:00
|
|
|
|
2016-10-20 06:32:39 -07:00
|
|
|
class AudioReceiveStream final : public webrtc::AudioReceiveStream,
|
2017-01-31 03:58:40 -08:00
|
|
|
public AudioMixer::Source,
|
2017-06-21 01:05:22 -07:00
|
|
|
public Syncable {
|
2015-04-29 15:24:01 +02:00
|
|
|
public:
|
2019-03-04 17:43:34 +01:00
|
|
|
AudioReceiveStream(Clock* clock,
|
|
|
|
|
RtpStreamReceiverControllerInterface* receiver_controller,
|
2017-06-21 01:05:22 -07:00
|
|
|
PacketRouter* packet_router,
|
2018-01-11 13:52:30 +01:00
|
|
|
ProcessThread* module_process_thread,
|
2019-11-01 11:47:51 +01:00
|
|
|
NetEqFactory* neteq_factory,
|
2015-10-22 10:49:27 +02:00
|
|
|
const webrtc::AudioReceiveStream::Config& config,
|
2016-07-04 07:06:55 -07: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.
|
|
|
|
|
AudioReceiveStream(
|
2019-03-04 17:43:34 +01:00
|
|
|
Clock* clock,
|
2018-11-16 09:50:42 +01:00
|
|
|
RtpStreamReceiverControllerInterface* receiver_controller,
|
|
|
|
|
PacketRouter* packet_router,
|
|
|
|
|
const webrtc::AudioReceiveStream::Config& config,
|
|
|
|
|
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
|
|
|
|
|
|
|
|
AudioReceiveStream() = delete;
|
|
|
|
|
AudioReceiveStream(const AudioReceiveStream&) = delete;
|
|
|
|
|
AudioReceiveStream& operator=(const AudioReceiveStream&) = delete;
|
|
|
|
|
|
2015-10-15 05:22:13 -07:00
|
|
|
~AudioReceiveStream() override;
|
2015-04-29 15:24:01 +02:00
|
|
|
|
2016-05-01 20:18:34 -07:00
|
|
|
// webrtc::AudioReceiveStream implementation.
|
2018-01-10 15:17:10 +01:00
|
|
|
void Reconfigure(const webrtc::AudioReceiveStream::Config& config) override;
|
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;
|
|
|
|
|
|
2020-09-14 10:47:50 +02:00
|
|
|
webrtc::AudioReceiveStream::Stats GetStats(
|
|
|
|
|
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
|
|
|
|
2016-11-14 11:30:07 -08:00
|
|
|
void AssociateSendStream(AudioSendStream* send_stream);
|
2019-03-05 14:29:42 +01:00
|
|
|
void DeliverRtcp(const uint8_t* packet, size_t length);
|
2015-10-15 05:22:13 -07:00
|
|
|
const webrtc::AudioReceiveStream::Config& config() const;
|
2018-01-11 13:52:30 +01:00
|
|
|
const AudioSendStream* GetAssociatedSendStreamForTesting() const;
|
2015-04-29 15:24:01 +02:00
|
|
|
|
|
|
|
|
private:
|
2018-01-10 15:17:10 +01:00
|
|
|
static void ConfigureStream(AudioReceiveStream* stream,
|
|
|
|
|
const Config& new_config,
|
|
|
|
|
bool first_time);
|
|
|
|
|
|
2016-11-22 06:42:53 -08:00
|
|
|
AudioState* audio_state() const;
|
2015-11-20 09:59:34 -08:00
|
|
|
|
2017-01-31 03:58:40 -08:00
|
|
|
rtc::ThreadChecker worker_thread_checker_;
|
|
|
|
|
rtc::ThreadChecker module_process_thread_checker_;
|
2018-01-10 15:17:10 +01:00
|
|
|
webrtc::AudioReceiveStream::Config config_;
|
2015-11-06 15:34:49 -08:00
|
|
|
rtc::scoped_refptr<webrtc::AudioState> audio_state_;
|
2018-11-19 10:27:07 +01:00
|
|
|
const std::unique_ptr<voe::ChannelReceiveInterface> channel_receive_;
|
2019-08-02 10:29:26 +00:00
|
|
|
SourceTracker source_tracker_;
|
2018-01-11 13:52:30 +01:00
|
|
|
AudioSendStream* associated_send_stream_ = 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
|
|
|
|
2017-06-21 01:05:22 -07:00
|
|
|
std::unique_ptr<RtpStreamReceiverInterface> rtp_stream_receiver_;
|
2015-04-29 15:24:01 +02:00
|
|
|
};
|
|
|
|
|
} // namespace internal
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // AUDIO_AUDIO_RECEIVE_STREAM_H_
|