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"
|
|
|
|
|
#include "audio/audio_state.h"
|
|
|
|
|
#include "call/audio_receive_stream.h"
|
|
|
|
|
#include "call/rtp_packet_sink_interface.h"
|
|
|
|
|
#include "call/syncable.h"
|
|
|
|
|
#include "rtc_base/constructormagic.h"
|
|
|
|
|
#include "rtc_base/thread_checker.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-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 {
|
|
|
|
|
class ChannelProxy;
|
|
|
|
|
} // 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:
|
2017-06-21 01:05:22 -07:00
|
|
|
AudioReceiveStream(RtpStreamReceiverControllerInterface* receiver_controller,
|
|
|
|
|
PacketRouter* packet_router,
|
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);
|
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.
|
2015-07-16 09:30:09 +02:00
|
|
|
void Start() override;
|
|
|
|
|
void Stop() override;
|
2015-06-08 13:04:56 +02:00
|
|
|
webrtc::AudioReceiveStream::Stats GetStats() const override;
|
2017-03-01 17:02:23 -08:00
|
|
|
int GetOutputLevel() const override;
|
2016-02-23 10:46:32 -08:00
|
|
|
void SetSink(std::unique_ptr<AudioSinkInterface> sink) override;
|
2016-06-17 08:30:54 -07:00
|
|
|
void SetGain(float gain) 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-06-21 01:05:22 -07:00
|
|
|
// TODO(nisse): We don't formally implement RtpPacketSinkInterface, and this
|
|
|
|
|
// method shouldn't be needed. But it's currently used by the
|
|
|
|
|
// AudioReceiveStreamTest.ReceiveRtpPacket unittest. Figure out if that test
|
|
|
|
|
// shuld be refactored or deleted, and then delete this method.
|
|
|
|
|
void OnRtpPacket(const RtpPacketReceived& packet);
|
2017-02-21 06:28:10 -08: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
|
|
|
|
|
int id() const override;
|
|
|
|
|
rtc::Optional<Syncable::Info> GetInfo() const override;
|
|
|
|
|
uint32_t GetPlayoutTimestamp() const override;
|
|
|
|
|
void SetMinimumPlayoutDelay(int delay_ms) override;
|
|
|
|
|
|
2016-11-14 11:30:07 -08:00
|
|
|
void AssociateSendStream(AudioSendStream* send_stream);
|
2016-05-01 20:18:34 -07:00
|
|
|
void SignalNetworkState(NetworkState state);
|
|
|
|
|
bool DeliverRtcp(const uint8_t* packet, size_t length);
|
2015-10-15 05:22:13 -07:00
|
|
|
const webrtc::AudioReceiveStream::Config& config() const;
|
2015-04-29 15:24:01 +02:00
|
|
|
|
|
|
|
|
private:
|
2015-11-20 09:59:34 -08:00
|
|
|
VoiceEngine* voice_engine() const;
|
2016-11-22 06:42:53 -08:00
|
|
|
AudioState* audio_state() const;
|
|
|
|
|
int SetVoiceEnginePlayout(bool playout);
|
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_;
|
2015-04-29 15:24:01 +02:00
|
|
|
const webrtc::AudioReceiveStream::Config config_;
|
2015-11-06 15:34:49 -08:00
|
|
|
rtc::scoped_refptr<webrtc::AudioState> audio_state_;
|
2016-02-23 10:46:32 -08:00
|
|
|
std::unique_ptr<voe::ChannelProxy> channel_proxy_;
|
2015-10-27 03:35:21 -07:00
|
|
|
|
2017-09-09 04:17:22 -07:00
|
|
|
bool playing_ RTC_ACCESS_ON(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-10-27 03:35:21 -07:00
|
|
|
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AudioReceiveStream);
|
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_
|