Make payload type demux conditional on media direction

Bug: webrtc:10139
Change-Id: I6803f4325e7c34915a9ae79e3360a787a7a9df5c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149173
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29105}
This commit is contained in:
Steve Anton
2019-09-06 16:26:02 -07:00
committed by Commit Bot
parent 3146ea01ae
commit be2e5f78b3
2 changed files with 46 additions and 14 deletions

View File

@ -770,6 +770,10 @@ void BaseChannel::AddHandledPayloadType(int payload_type) {
demuxer_criteria_.payload_types.insert(static_cast<uint8_t>(payload_type));
}
void BaseChannel::ClearHandledPayloadTypes() {
demuxer_criteria_.payload_types.clear();
}
void BaseChannel::FlushRtcpMessages_n() {
// Flush all remaining RTCP messages. This should only be called in
// destructor.
@ -889,13 +893,16 @@ bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content,
error_desc);
return false;
}
for (const AudioCodec& codec : audio->codecs()) {
AddHandledPayloadType(codec.id);
}
// Need to re-register the sink to update the handled payload.
if (!RegisterRtpDemuxerSink()) {
RTC_LOG(LS_ERROR) << "Failed to set up audio demuxing.";
return false;
if (webrtc::RtpTransceiverDirectionHasRecv(audio->direction())) {
for (const AudioCodec& codec : audio->codecs()) {
AddHandledPayloadType(codec.id);
}
// Need to re-register the sink to update the handled payload.
if (!RegisterRtpDemuxerSink()) {
RTC_LOG(LS_ERROR) << "Failed to set up audio demuxing.";
return false;
}
}
last_recv_params_ = recv_params;
@ -945,6 +952,16 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
}
last_send_params_ = send_params;
if (!webrtc::RtpTransceiverDirectionHasSend(content->direction())) {
RTC_DLOG(LS_VERBOSE) << "SetRemoteContent_w: remote side will not send - "
"disable payload type demuxing";
ClearHandledPayloadTypes();
if (!RegisterRtpDemuxerSink()) {
RTC_LOG(LS_ERROR) << "Failed to update audio demuxing.";
return false;
}
}
// TODO(pthatcher): Move remote streams into AudioRecvParameters,
// and only give it to the media channel once we have a local
// description too (without a local description, we won't be able to
@ -1047,13 +1064,16 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
error_desc);
return false;
}
for (const VideoCodec& codec : video->codecs()) {
AddHandledPayloadType(codec.id);
}
// Need to re-register the sink to update the handled payload.
if (!RegisterRtpDemuxerSink()) {
RTC_LOG(LS_ERROR) << "Failed to set up video demuxing.";
return false;
if (webrtc::RtpTransceiverDirectionHasRecv(video->direction())) {
for (const VideoCodec& codec : video->codecs()) {
AddHandledPayloadType(codec.id);
}
// Need to re-register the sink to update the handled payload.
if (!RegisterRtpDemuxerSink()) {
RTC_LOG(LS_ERROR) << "Failed to set up video demuxing.";
return false;
}
}
last_recv_params_ = recv_params;
@ -1140,6 +1160,16 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
last_recv_params_ = recv_params;
}
if (!webrtc::RtpTransceiverDirectionHasSend(content->direction())) {
RTC_DLOG(LS_VERBOSE) << "SetRemoteContent_w: remote side will not send - "
"disable payload type demuxing";
ClearHandledPayloadTypes();
if (!RegisterRtpDemuxerSink()) {
RTC_LOG(LS_ERROR) << "Failed to update video demuxing.";
return false;
}
}
// TODO(pthatcher): Move remote streams into VideoRecvParameters,
// and only give it to the media channel once we have a local
// description too (without a local description, we won't be able to

View File

@ -281,6 +281,8 @@ class BaseChannel : public ChannelInterface,
void AddHandledPayloadType(int payload_type);
void ClearHandledPayloadTypes();
void UpdateRtpHeaderExtensionMap(
const RtpHeaderExtensions& header_extensions);