Move media_type to RtpTransceiverInterface
Media type is not part of the WebRTC spec for RtpTransceiver, but it is handy and the RtpSender/RtpReceiver also have it. Bug: webrtc:7600 Change-Id: I8350069502588bff478db4dc1318329626dcf9be Reviewed-on: https://webrtc-review.googlesource.com/50560 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Commit-Queue: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21988}
This commit is contained in:
parent
a4e72b7914
commit
6947025e95
@ -63,6 +63,10 @@ struct RtpTransceiverInit final {
|
||||
// https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver
|
||||
class RtpTransceiverInterface : public rtc::RefCountInterface {
|
||||
public:
|
||||
// Media type of the transceiver. Any sender(s)/receiver(s) will have this
|
||||
// type as well.
|
||||
virtual cricket::MediaType media_type() const = 0;
|
||||
|
||||
// The mid attribute is the mid negotiated and present in the local and
|
||||
// remote descriptions. Before negotiation is complete, the mid value may be
|
||||
// null. After rollbacks, the value may change from a non-null value to null.
|
||||
|
||||
@ -774,12 +774,12 @@ void PeerConnection::DestroyAllChannels() {
|
||||
// Destroy video channels first since they may have a pointer to a voice
|
||||
// channel.
|
||||
for (auto transceiver : transceivers_) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_VIDEO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_VIDEO) {
|
||||
DestroyTransceiverChannel(transceiver);
|
||||
}
|
||||
}
|
||||
for (auto transceiver : transceivers_) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
DestroyTransceiverChannel(transceiver);
|
||||
}
|
||||
}
|
||||
@ -1148,7 +1148,7 @@ PeerConnection::FindFirstTransceiverForAddedTrack(
|
||||
RTC_DCHECK(track);
|
||||
for (auto transceiver : transceivers_) {
|
||||
if (!transceiver->sender()->track() &&
|
||||
cricket::MediaTypeToString(transceiver->internal()->media_type()) ==
|
||||
cricket::MediaTypeToString(transceiver->media_type()) ==
|
||||
track->kind() &&
|
||||
!transceiver->internal()->has_ever_been_used_to_send()) {
|
||||
return transceiver;
|
||||
@ -1640,8 +1640,7 @@ PeerConnection::GetReceivingTransceiversOfType(cricket::MediaType media_type) {
|
||||
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
||||
receiving_transceivers;
|
||||
for (auto transceiver : transceivers_) {
|
||||
if (!transceiver->stopped() &&
|
||||
transceiver->internal()->media_type() == media_type &&
|
||||
if (!transceiver->stopped() && transceiver->media_type() == media_type &&
|
||||
RtpTransceiverDirectionHasRecv(transceiver->direction())) {
|
||||
receiving_transceivers.push_back(transceiver);
|
||||
}
|
||||
@ -2318,13 +2317,12 @@ RTCError PeerConnection::UpdateTransceiverChannel(
|
||||
}
|
||||
} else {
|
||||
if (!channel) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
channel = CreateVoiceChannel(
|
||||
content.name,
|
||||
GetTransportNameForMediaSection(content.name, bundle_group));
|
||||
} else {
|
||||
RTC_DCHECK_EQ(cricket::MEDIA_TYPE_VIDEO,
|
||||
transceiver->internal()->media_type());
|
||||
RTC_DCHECK_EQ(cricket::MEDIA_TYPE_VIDEO, transceiver->media_type());
|
||||
channel = CreateVideoChannel(
|
||||
content.name,
|
||||
GetTransportNameForMediaSection(content.name, bundle_group));
|
||||
@ -2425,7 +2423,7 @@ PeerConnection::AssociateTransceiver(cricket::ContentSource source,
|
||||
}
|
||||
}
|
||||
RTC_DCHECK(transceiver);
|
||||
if (transceiver->internal()->media_type() != media_desc->type()) {
|
||||
if (transceiver->media_type() != media_desc->type()) {
|
||||
LOG_AND_RETURN_ERROR(
|
||||
RTCErrorType::INVALID_PARAMETER,
|
||||
"Transceiver type does not match media description type.");
|
||||
@ -2471,7 +2469,7 @@ PeerConnection::FindAvailableTransceiverToReceive(
|
||||
// associated with any m= section and are not stopped, find the first such
|
||||
// RtpTransceiver.
|
||||
for (auto transceiver : transceivers_) {
|
||||
if (transceiver->internal()->media_type() == media_type &&
|
||||
if (transceiver->media_type() == media_type &&
|
||||
transceiver->internal()->created_by_addtrack() && !transceiver->mid() &&
|
||||
!transceiver->stopped()) {
|
||||
return transceiver;
|
||||
@ -2497,7 +2495,7 @@ const cricket::ContentInfo* PeerConnection::FindMediaSectionForTransceiver(
|
||||
// Plan B only allows at most one audio and one video section, so use the
|
||||
// first media section of that type.
|
||||
return cricket::GetFirstMediaContent(sdesc->description()->contents(),
|
||||
transceiver->internal()->media_type());
|
||||
transceiver->media_type());
|
||||
}
|
||||
}
|
||||
|
||||
@ -3318,7 +3316,7 @@ GetMediaDescriptionOptionsForTransceiver(
|
||||
transceiver,
|
||||
const std::string& mid) {
|
||||
cricket::MediaDescriptionOptions media_description_options(
|
||||
transceiver->internal()->media_type(), mid, transceiver->direction(),
|
||||
transceiver->media_type(), mid, transceiver->direction(),
|
||||
transceiver->stopped());
|
||||
// This behavior is specified in JSEP. The gist is that:
|
||||
// 1. The MSID is included if the RtpTransceiver's direction is sendonly or
|
||||
@ -3383,10 +3381,9 @@ void PeerConnection::GetOptionsForUnifiedPlanOffer(
|
||||
// rejected in either the local or remote description.
|
||||
if (had_been_rejected) {
|
||||
session_options->media_description_options.push_back(
|
||||
cricket::MediaDescriptionOptions(
|
||||
transceiver->internal()->media_type(), mid,
|
||||
RtpTransceiverDirection::kInactive,
|
||||
/*stopped=*/true));
|
||||
cricket::MediaDescriptionOptions(transceiver->media_type(), mid,
|
||||
RtpTransceiverDirection::kInactive,
|
||||
/*stopped=*/true));
|
||||
recycleable_mline_indices.push(i);
|
||||
} else {
|
||||
session_options->media_description_options.push_back(
|
||||
@ -4083,7 +4080,7 @@ PeerConnection::GetAudioTransceiver() const {
|
||||
// audio/video transceiver.
|
||||
RTC_DCHECK(!IsUnifiedPlan());
|
||||
for (auto transceiver : transceivers_) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
return transceiver;
|
||||
}
|
||||
}
|
||||
@ -4097,7 +4094,7 @@ PeerConnection::GetVideoTransceiver() const {
|
||||
// audio/video transceiver.
|
||||
RTC_DCHECK(!IsUnifiedPlan());
|
||||
for (auto transceiver : transceivers_) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_VIDEO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_VIDEO) {
|
||||
return transceiver;
|
||||
}
|
||||
}
|
||||
@ -5603,7 +5600,7 @@ void PeerConnection::ReportTransportStats() {
|
||||
const std::string& transport_name =
|
||||
transceiver->internal()->channel()->transport_name();
|
||||
media_types_by_transport_name[transport_name].insert(
|
||||
transceiver->internal()->media_type());
|
||||
transceiver->media_type());
|
||||
}
|
||||
}
|
||||
if (rtp_data_channel()) {
|
||||
|
||||
@ -79,7 +79,7 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper {
|
||||
auto transceivers =
|
||||
GetInternalPeerConnection()->GetTransceiversForTesting();
|
||||
for (auto transceiver : transceivers) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
return static_cast<cricket::VoiceChannel*>(
|
||||
transceiver->internal()->channel());
|
||||
}
|
||||
@ -99,7 +99,7 @@ class PeerConnectionWrapperForBundleTest : public PeerConnectionWrapper {
|
||||
auto transceivers =
|
||||
GetInternalPeerConnection()->GetTransceiversForTesting();
|
||||
for (auto transceiver : transceivers) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_VIDEO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_VIDEO) {
|
||||
return static_cast<cricket::VideoChannel*>(
|
||||
transceiver->internal()->channel());
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ class PeerConnectionIceBaseTest : public ::testing::Test {
|
||||
pc_wrapper_ptr->pc());
|
||||
PeerConnection* pc = static_cast<PeerConnection*>(pc_proxy->internal());
|
||||
for (auto transceiver : pc->GetTransceiversForTesting()) {
|
||||
if (transceiver->internal()->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
if (transceiver->media_type() == cricket::MEDIA_TYPE_AUDIO) {
|
||||
cricket::BaseChannel* channel = transceiver->internal()->channel();
|
||||
if (channel) {
|
||||
return channel->rtp_dtls_transport()->ice_transport()->GetIceRole();
|
||||
|
||||
@ -257,12 +257,10 @@ TEST_F(PeerConnectionJsepTest, SetRemoteOfferCreatesTransceivers) {
|
||||
|
||||
auto transceivers = callee->pc()->GetTransceivers();
|
||||
ASSERT_EQ(2u, transceivers.size());
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_AUDIO,
|
||||
transceivers[0]->receiver()->media_type());
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_AUDIO, transceivers[0]->media_type());
|
||||
EXPECT_EQ(caller_audio->mid(), transceivers[0]->mid());
|
||||
EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, transceivers[0]->direction());
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_VIDEO,
|
||||
transceivers[1]->receiver()->media_type());
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_VIDEO, transceivers[1]->media_type());
|
||||
EXPECT_EQ(caller_video->mid(), transceivers[1]->mid());
|
||||
EXPECT_EQ(RtpTransceiverDirection::kRecvOnly, transceivers[1]->direction());
|
||||
}
|
||||
@ -645,9 +643,9 @@ TEST_P(RecycleMediaSectionTest, VerifyOfferAnswerAndTransceivers) {
|
||||
auto callee_transceivers = callee->pc()->GetTransceivers();
|
||||
ASSERT_EQ(2u, callee_transceivers.size());
|
||||
EXPECT_EQ(rtc::nullopt, callee_transceivers[0]->mid());
|
||||
EXPECT_EQ(first_type_, callee_transceivers[0]->receiver()->media_type());
|
||||
EXPECT_EQ(first_type_, callee_transceivers[0]->media_type());
|
||||
EXPECT_EQ(second_mid, callee_transceivers[1]->mid());
|
||||
EXPECT_EQ(second_type_, callee_transceivers[1]->receiver()->media_type());
|
||||
EXPECT_EQ(second_type_, callee_transceivers[1]->media_type());
|
||||
|
||||
// The answer should have only one media section for the new transceiver.
|
||||
auto answer = callee->CreateAnswer();
|
||||
|
||||
@ -462,6 +462,7 @@ TEST_F(PeerConnectionRtpTest,
|
||||
auto caller = CreatePeerConnectionWithUnifiedPlan();
|
||||
|
||||
auto transceiver = caller->AddTransceiver(cricket::MEDIA_TYPE_AUDIO);
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_AUDIO, transceiver->media_type());
|
||||
|
||||
ASSERT_TRUE(transceiver->sender());
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_AUDIO, transceiver->sender()->media_type());
|
||||
@ -482,6 +483,7 @@ TEST_F(PeerConnectionRtpTest,
|
||||
auto caller = CreatePeerConnectionWithUnifiedPlan();
|
||||
|
||||
auto transceiver = caller->AddTransceiver(cricket::MEDIA_TYPE_VIDEO);
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_VIDEO, transceiver->media_type());
|
||||
|
||||
ASSERT_TRUE(transceiver->sender());
|
||||
EXPECT_EQ(cricket::MEDIA_TYPE_VIDEO, transceiver->sender()->media_type());
|
||||
|
||||
@ -94,7 +94,7 @@ void RtpTransceiver::AddSender(
|
||||
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender) {
|
||||
RTC_DCHECK(!unified_plan_);
|
||||
RTC_DCHECK(sender);
|
||||
RTC_DCHECK_EQ(media_type(), sender->internal()->media_type());
|
||||
RTC_DCHECK_EQ(media_type(), sender->media_type());
|
||||
RTC_DCHECK(std::find(senders_.begin(), senders_.end(), sender) ==
|
||||
senders_.end());
|
||||
senders_.push_back(sender);
|
||||
@ -119,7 +119,7 @@ void RtpTransceiver::AddReceiver(
|
||||
receiver) {
|
||||
RTC_DCHECK(!unified_plan_);
|
||||
RTC_DCHECK(receiver);
|
||||
RTC_DCHECK_EQ(media_type(), receiver->internal()->media_type());
|
||||
RTC_DCHECK_EQ(media_type(), receiver->media_type());
|
||||
RTC_DCHECK(std::find(receivers_.begin(), receivers_.end(), receiver) ==
|
||||
receivers_.end());
|
||||
receivers_.push_back(receiver);
|
||||
@ -152,6 +152,10 @@ rtc::scoped_refptr<RtpReceiverInternal> RtpTransceiver::receiver_internal()
|
||||
return receivers_[0]->internal();
|
||||
}
|
||||
|
||||
cricket::MediaType RtpTransceiver::media_type() const {
|
||||
return media_type_;
|
||||
}
|
||||
|
||||
rtc::Optional<std::string> RtpTransceiver::mid() const {
|
||||
return mid_;
|
||||
}
|
||||
|
||||
@ -68,8 +68,6 @@ class RtpTransceiver final
|
||||
receiver);
|
||||
~RtpTransceiver() override;
|
||||
|
||||
cricket::MediaType media_type() const { return media_type_; }
|
||||
|
||||
// Returns the Voice/VideoChannel set for this transceiver. May be null if
|
||||
// the transceiver is not in the currently set local/remote description.
|
||||
cricket::BaseChannel* channel() const { return channel_; }
|
||||
@ -157,6 +155,7 @@ class RtpTransceiver final
|
||||
}
|
||||
|
||||
// RtpTransceiverInterface implementation.
|
||||
cricket::MediaType media_type() const override;
|
||||
rtc::Optional<std::string> mid() const override;
|
||||
rtc::scoped_refptr<RtpSenderInterface> sender() const override;
|
||||
rtc::scoped_refptr<RtpReceiverInterface> receiver() const override;
|
||||
@ -191,6 +190,7 @@ class RtpTransceiver final
|
||||
|
||||
BEGIN_SIGNALING_PROXY_MAP(RtpTransceiver)
|
||||
PROXY_SIGNALING_THREAD_DESTRUCTOR()
|
||||
PROXY_CONSTMETHOD0(cricket::MediaType, media_type);
|
||||
PROXY_CONSTMETHOD0(rtc::Optional<std::string>, mid);
|
||||
PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpSenderInterface>, sender);
|
||||
PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpReceiverInterface>, receiver);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user