RtpReceiverInterface::stream_ids() added.
This is the first step to removing streams from third_party/webrtc. RtpReceiverInterface::streams() will have to be removed separately. See https://crbug.com/webrtc/9480 for more information. Bug: webrtc:9480 Change-Id: I6f9e6ddcda5e2245cc601d2cc6205b7b363f73ef Reviewed-on: https://webrtc-review.googlesource.com/86840 Reviewed-by: Seth Hampson <shampson@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23929}
This commit is contained in:

committed by
Commit Bot

parent
f957dd9c7f
commit
199e27bb63
@ -32,6 +32,10 @@ RtpSource::RtpSource(const RtpSource&) = default;
|
||||
RtpSource& RtpSource::operator=(const RtpSource&) = default;
|
||||
RtpSource::~RtpSource() = default;
|
||||
|
||||
std::vector<std::string> RtpReceiverInterface::stream_ids() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>>
|
||||
RtpReceiverInterface::streams() const {
|
||||
return {};
|
||||
|
@ -93,8 +93,12 @@ class RtpReceiverInterface : public rtc::RefCountInterface {
|
||||
virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
|
||||
// The list of streams that |track| is associated with. This is the same as
|
||||
// the [[AssociatedRemoteMediaStreams]] internal slot in the spec.
|
||||
// https://w3c.github.io/webrtc-pc/#dfn-x%5B%5Bassociatedremotemediastreams%5D%5D
|
||||
// https://w3c.github.io/webrtc-pc/#dfn-associatedremotemediastreams
|
||||
// TODO(hbos): Make pure virtual as soon as Chromium's mock implements this.
|
||||
// TODO(https://crbug.com/webrtc/9480): Remove streams() in favor of
|
||||
// stream_ids() as soon as downstream projects are no longer dependent on
|
||||
// stream objects.
|
||||
virtual std::vector<std::string> stream_ids() const;
|
||||
virtual std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams() const;
|
||||
|
||||
// Audio or video receiver?
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
#include "ortc/ortcrtpreceiveradapter.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "media/base/mediaconstants.h"
|
||||
#include "ortc/rtptransportadapter.h"
|
||||
@ -151,9 +153,9 @@ void OrtcRtpReceiverAdapter::MaybeRecreateInternalReceiver() {
|
||||
internal_receiver_ = nullptr;
|
||||
switch (kind_) {
|
||||
case cricket::MEDIA_TYPE_AUDIO: {
|
||||
auto* audio_receiver =
|
||||
new AudioRtpReceiver(rtp_transport_controller_->worker_thread(),
|
||||
rtc::CreateRandomUuid(), {});
|
||||
auto* audio_receiver = new AudioRtpReceiver(
|
||||
rtp_transport_controller_->worker_thread(), rtc::CreateRandomUuid(),
|
||||
std::vector<std::string>({}));
|
||||
auto* voice_channel = rtp_transport_controller_->voice_channel();
|
||||
RTC_DCHECK(voice_channel);
|
||||
audio_receiver->SetVoiceMediaChannel(voice_channel->media_channel());
|
||||
@ -161,9 +163,9 @@ void OrtcRtpReceiverAdapter::MaybeRecreateInternalReceiver() {
|
||||
break;
|
||||
}
|
||||
case cricket::MEDIA_TYPE_VIDEO: {
|
||||
auto* video_receiver =
|
||||
new VideoRtpReceiver(rtp_transport_controller_->worker_thread(),
|
||||
rtc::CreateRandomUuid(), {});
|
||||
auto* video_receiver = new VideoRtpReceiver(
|
||||
rtp_transport_controller_->worker_thread(), rtc::CreateRandomUuid(),
|
||||
std::vector<std::string>({}));
|
||||
auto* video_channel = rtp_transport_controller_->video_channel();
|
||||
RTC_DCHECK(video_channel);
|
||||
video_receiver->SetVideoMediaChannel(video_channel->media_channel());
|
||||
|
@ -1478,14 +1478,14 @@ PeerConnection::CreateReceiver(cricket::MediaType media_type,
|
||||
receiver;
|
||||
if (media_type == cricket::MEDIA_TYPE_AUDIO) {
|
||||
receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
|
||||
signaling_thread(),
|
||||
new AudioRtpReceiver(worker_thread(), receiver_id, {}));
|
||||
signaling_thread(), new AudioRtpReceiver(worker_thread(), receiver_id,
|
||||
std::vector<std::string>({})));
|
||||
NoteUsageEvent(UsageEvent::AUDIO_ADDED);
|
||||
} else {
|
||||
RTC_DCHECK_EQ(media_type, cricket::MEDIA_TYPE_VIDEO);
|
||||
receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
|
||||
signaling_thread(),
|
||||
new VideoRtpReceiver(worker_thread(), receiver_id, {}));
|
||||
signaling_thread(), new VideoRtpReceiver(worker_thread(), receiver_id,
|
||||
std::vector<std::string>({})));
|
||||
NoteUsageEvent(UsageEvent::VIDEO_ADDED);
|
||||
}
|
||||
return receiver;
|
||||
@ -2442,6 +2442,8 @@ RTCError PeerConnection::ApplyRemoteDescription(
|
||||
media_streams.push_back(stream);
|
||||
}
|
||||
// This will add the remote track to the streams.
|
||||
// TODO(hbos): When we remove remote_streams(), use set_stream_ids()
|
||||
// instead. https://crbug.com/webrtc/9480
|
||||
transceiver->internal()->receiver_internal()->SetStreams(media_streams);
|
||||
now_receiving_transceivers.push_back(transceiver);
|
||||
}
|
||||
@ -2456,9 +2458,12 @@ RTCError PeerConnection::ApplyRemoteDescription(
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> media_streams =
|
||||
transceiver->internal()->receiver_internal()->streams();
|
||||
// This will remove the remote track from the streams.
|
||||
transceiver->internal()->receiver_internal()->SetStreams({});
|
||||
transceiver->internal()->receiver_internal()->set_stream_ids({});
|
||||
no_longer_receiving_transceivers.push_back(transceiver);
|
||||
// Remove any streams that no longer have tracks.
|
||||
// TODO(https://crbug.com/webrtc/9480): When we use stream IDs instead
|
||||
// of streams, see if the stream was removed by checking if this was the
|
||||
// last receiver with that stream ID.
|
||||
for (auto stream : media_streams) {
|
||||
if (stream->GetAudioTracks().empty() &&
|
||||
stream->GetVideoTracks().empty()) {
|
||||
@ -3370,6 +3375,8 @@ void PeerConnection::CreateAudioReceiver(
|
||||
const RtpSenderInfo& remote_sender_info) {
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams;
|
||||
streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream));
|
||||
// TODO(https://crbug.com/webrtc/9480): When we remove remote_streams(), use
|
||||
// the constructor taking stream IDs instead.
|
||||
auto* audio_receiver = new AudioRtpReceiver(
|
||||
worker_thread(), remote_sender_info.sender_id, streams);
|
||||
audio_receiver->SetVoiceMediaChannel(voice_media_channel());
|
||||
@ -3386,6 +3393,8 @@ void PeerConnection::CreateVideoReceiver(
|
||||
const RtpSenderInfo& remote_sender_info) {
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams;
|
||||
streams.push_back(rtc::scoped_refptr<MediaStreamInterface>(stream));
|
||||
// TODO(https://crbug.com/webrtc/9480): When we remove remote_streams(), use
|
||||
// the constructor taking stream IDs instead.
|
||||
auto* video_receiver = new VideoRtpReceiver(
|
||||
worker_thread(), remote_sender_info.sender_id, streams);
|
||||
video_receiver->SetVideoMediaChannel(video_media_channel());
|
||||
|
@ -13,9 +13,11 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "api/mediastreamproxy.h"
|
||||
#include "api/mediastreamtrackproxy.h"
|
||||
#include "api/videosourceproxy.h"
|
||||
#include "pc/audiotrack.h"
|
||||
#include "pc/mediastream.h"
|
||||
#include "pc/videotrack.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
|
||||
@ -30,8 +32,26 @@ int GenerateUniqueId() {
|
||||
return ++g_unique_id;
|
||||
}
|
||||
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> CreateStreamsFromIds(
|
||||
std::vector<std::string> stream_ids) {
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams(
|
||||
stream_ids.size());
|
||||
for (size_t i = 0; i < stream_ids.size(); ++i) {
|
||||
streams[i] = MediaStreamProxy::Create(
|
||||
rtc::Thread::Current(), MediaStream::Create(std::move(stream_ids[i])));
|
||||
}
|
||||
return streams;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AudioRtpReceiver::AudioRtpReceiver(rtc::Thread* worker_thread,
|
||||
std::string receiver_id,
|
||||
std::vector<std::string> stream_ids)
|
||||
: AudioRtpReceiver(worker_thread,
|
||||
receiver_id,
|
||||
CreateStreamsFromIds(std::move(stream_ids))) {}
|
||||
|
||||
AudioRtpReceiver::AudioRtpReceiver(
|
||||
rtc::Thread* worker_thread,
|
||||
const std::string& receiver_id,
|
||||
@ -92,6 +112,13 @@ void AudioRtpReceiver::OnSetVolume(double volume) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> AudioRtpReceiver::stream_ids() const {
|
||||
std::vector<std::string> stream_ids(streams_.size());
|
||||
for (size_t i = 0; i < streams_.size(); ++i)
|
||||
stream_ids[i] = streams_[i]->id();
|
||||
return stream_ids;
|
||||
}
|
||||
|
||||
RtpParameters AudioRtpReceiver::GetParameters() const {
|
||||
if (!media_channel_ || !ssrc_ || stopped_) {
|
||||
return RtpParameters();
|
||||
@ -141,6 +168,10 @@ void AudioRtpReceiver::SetupMediaChannel(uint32_t ssrc) {
|
||||
Reconfigure();
|
||||
}
|
||||
|
||||
void AudioRtpReceiver::set_stream_ids(std::vector<std::string> stream_ids) {
|
||||
SetStreams(CreateStreamsFromIds(std::move(stream_ids)));
|
||||
}
|
||||
|
||||
void AudioRtpReceiver::SetStreams(
|
||||
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {
|
||||
// Remove remote track from any streams that are going away.
|
||||
@ -209,6 +240,13 @@ void AudioRtpReceiver::NotifyFirstPacketReceived() {
|
||||
received_first_packet_ = true;
|
||||
}
|
||||
|
||||
VideoRtpReceiver::VideoRtpReceiver(rtc::Thread* worker_thread,
|
||||
std::string receiver_id,
|
||||
std::vector<std::string> stream_ids)
|
||||
: VideoRtpReceiver(worker_thread,
|
||||
receiver_id,
|
||||
CreateStreamsFromIds(std::move(stream_ids))) {}
|
||||
|
||||
VideoRtpReceiver::VideoRtpReceiver(
|
||||
rtc::Thread* worker_thread,
|
||||
const std::string& receiver_id,
|
||||
@ -237,6 +275,13 @@ VideoRtpReceiver::~VideoRtpReceiver() {
|
||||
Stop();
|
||||
}
|
||||
|
||||
std::vector<std::string> VideoRtpReceiver::stream_ids() const {
|
||||
std::vector<std::string> stream_ids(streams_.size());
|
||||
for (size_t i = 0; i < streams_.size(); ++i)
|
||||
stream_ids[i] = streams_[i]->id();
|
||||
return stream_ids;
|
||||
}
|
||||
|
||||
bool VideoRtpReceiver::SetSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
|
||||
RTC_DCHECK(media_channel_);
|
||||
RTC_DCHECK(ssrc_);
|
||||
@ -294,6 +339,10 @@ void VideoRtpReceiver::SetupMediaChannel(uint32_t ssrc) {
|
||||
SetSink(source_->sink());
|
||||
}
|
||||
|
||||
void VideoRtpReceiver::set_stream_ids(std::vector<std::string> stream_ids) {
|
||||
SetStreams(CreateStreamsFromIds(std::move(stream_ids)));
|
||||
}
|
||||
|
||||
void VideoRtpReceiver::SetStreams(
|
||||
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {
|
||||
// Remove remote track from any streams that are going away.
|
||||
|
@ -59,6 +59,10 @@ class RtpReceiverInternal : public RtpReceiverInterface {
|
||||
// Set the associated remote media streams for this receiver. The remote track
|
||||
// will be removed from any streams that are no longer present and added to
|
||||
// any new streams.
|
||||
virtual void set_stream_ids(std::vector<std::string> stream_ids) = 0;
|
||||
// TODO(https://crbug.com/webrtc/9480): Remove SetStreams() in favor of
|
||||
// set_stream_ids() as soon as downstream projects are no longer dependent on
|
||||
// stream objects.
|
||||
virtual void SetStreams(
|
||||
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) = 0;
|
||||
|
||||
@ -72,6 +76,10 @@ class AudioRtpReceiver : public ObserverInterface,
|
||||
public AudioSourceInterface::AudioObserver,
|
||||
public rtc::RefCountedObject<RtpReceiverInternal> {
|
||||
public:
|
||||
AudioRtpReceiver(rtc::Thread* worker_thread,
|
||||
std::string receiver_id,
|
||||
std::vector<std::string> stream_ids);
|
||||
// TODO(https://crbug.com/webrtc/9480): Remove this when streams() is removed.
|
||||
AudioRtpReceiver(
|
||||
rtc::Thread* worker_thread,
|
||||
const std::string& receiver_id,
|
||||
@ -92,6 +100,7 @@ class AudioRtpReceiver : public ObserverInterface,
|
||||
rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
|
||||
return track_.get();
|
||||
}
|
||||
std::vector<std::string> stream_ids() const override;
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams()
|
||||
const override {
|
||||
return streams_;
|
||||
@ -111,6 +120,7 @@ class AudioRtpReceiver : public ObserverInterface,
|
||||
void SetupMediaChannel(uint32_t ssrc) override;
|
||||
uint32_t ssrc() const override { return ssrc_.value_or(0); }
|
||||
void NotifyFirstPacketReceived() override;
|
||||
void set_stream_ids(std::vector<std::string> stream_ids) override;
|
||||
void SetStreams(const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&
|
||||
streams) override;
|
||||
|
||||
@ -151,6 +161,11 @@ class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> {
|
||||
public:
|
||||
// An SSRC of 0 will create a receiver that will match the first SSRC it
|
||||
// sees.
|
||||
VideoRtpReceiver(rtc::Thread* worker_thread,
|
||||
std::string receiver_id,
|
||||
std::vector<std::string> streams_ids);
|
||||
// TODO(hbos): Remove this when streams() is removed.
|
||||
// https://crbug.com/webrtc/9480
|
||||
VideoRtpReceiver(
|
||||
rtc::Thread* worker_thread,
|
||||
const std::string& receiver_id,
|
||||
@ -166,6 +181,7 @@ class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> {
|
||||
rtc::scoped_refptr<MediaStreamTrackInterface> track() const override {
|
||||
return track_.get();
|
||||
}
|
||||
std::vector<std::string> stream_ids() const override;
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams()
|
||||
const override {
|
||||
return streams_;
|
||||
@ -185,6 +201,7 @@ class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> {
|
||||
void SetupMediaChannel(uint32_t ssrc) override;
|
||||
uint32_t ssrc() const override { return ssrc_.value_or(0); }
|
||||
void NotifyFirstPacketReceived() override;
|
||||
void set_stream_ids(std::vector<std::string> stream_ids) override;
|
||||
void SetStreams(const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&
|
||||
streams) override;
|
||||
|
||||
|
@ -25,6 +25,7 @@ class MockRtpReceiverInternal : public RtpReceiverInternal {
|
||||
// RtpReceiverInterface methods.
|
||||
MOCK_METHOD1(SetTrack, void(MediaStreamTrackInterface*));
|
||||
MOCK_CONST_METHOD0(track, rtc::scoped_refptr<MediaStreamTrackInterface>());
|
||||
MOCK_CONST_METHOD0(stream_ids, std::vector<std::string>());
|
||||
MOCK_CONST_METHOD0(streams,
|
||||
std::vector<rtc::scoped_refptr<MediaStreamInterface>>());
|
||||
MOCK_CONST_METHOD0(media_type, cricket::MediaType());
|
||||
@ -41,6 +42,7 @@ class MockRtpReceiverInternal : public RtpReceiverInternal {
|
||||
MOCK_METHOD1(SetupMediaChannel, void(uint32_t));
|
||||
MOCK_CONST_METHOD0(ssrc, uint32_t());
|
||||
MOCK_METHOD0(NotifyFirstPacketReceived, void());
|
||||
MOCK_METHOD1(set_stream_ids, void(std::vector<std::string>));
|
||||
MOCK_METHOD1(
|
||||
SetStreams,
|
||||
void(const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&));
|
||||
|
Reference in New Issue
Block a user