Fix setting of recovered flag in RtxReceiveStream.

BUG=webrtc:7135

Review-Url: https://codereview.webrtc.org/3005793002
Cr-Commit-Position: refs/heads/master@{#19599}
This commit is contained in:
nisse 2017-08-30 04:16:40 -07:00 committed by Commit Bot
parent 6d5b4d6fe1
commit 386449971a
3 changed files with 42 additions and 14 deletions

View File

@ -12,16 +12,21 @@
#include "webrtc/call/rtx_receive_stream.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
#include "webrtc/rtc_base/logging.h"
namespace webrtc {
RtxReceiveStream::RtxReceiveStream(
RtpPacketSinkInterface* media_sink,
std::map<int, int> rtx_payload_type_map,
uint32_t media_ssrc)
RtxReceiveStream::RtxReceiveStream(RtpPacketSinkInterface* media_sink,
std::map<int, int> associated_payload_types,
uint32_t media_ssrc)
: media_sink_(media_sink),
rtx_payload_type_map_(std::move(rtx_payload_type_map)),
media_ssrc_(media_ssrc) {}
associated_payload_types_(std::move(associated_payload_types)),
media_ssrc_(media_ssrc) {
if (associated_payload_types_.empty()) {
LOG(LS_WARNING)
<< "RtxReceiveStream created with empty payload type mapping.";
}
}
RtxReceiveStream::~RtxReceiveStream() = default;
@ -32,8 +37,11 @@ void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) {
return;
}
auto it = rtx_payload_type_map_.find(rtx_packet.PayloadType());
if (it == rtx_payload_type_map_.end()) {
auto it = associated_payload_types_.find(rtx_packet.PayloadType());
if (it == associated_payload_types_.end()) {
LOG(LS_VERBOSE) << "Unknown payload type "
<< static_cast<int>(rtx_packet.PayloadType())
<< " on rtx ssrc " << rtx_packet.Ssrc();
return;
}
RtpPacketReceived media_packet;
@ -42,6 +50,7 @@ void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) {
media_packet.SetSsrc(media_ssrc_);
media_packet.SetSequenceNumber((payload[0] << 8) + payload[1]);
media_packet.SetPayloadType(it->second);
media_packet.set_recovered(true);
// Skip the RTX header.
rtc::ArrayView<const uint8_t> rtx_payload =

View File

@ -17,10 +17,12 @@
namespace webrtc {
// This class is responsible for RTX decapsulation. The resulting media packets
// are passed on to a sink representing the associated media stream.
class RtxReceiveStream : public RtpPacketSinkInterface {
public:
RtxReceiveStream(RtpPacketSinkInterface* media_sink,
std::map<int, int> rtx_payload_type_map,
std::map<int, int> associated_payload_types,
uint32_t media_ssrc);
~RtxReceiveStream() override;
// RtpPacketSinkInterface.
@ -28,8 +30,8 @@ class RtxReceiveStream : public RtpPacketSinkInterface {
private:
RtpPacketSinkInterface* const media_sink_;
// Mapping rtx_payload_type_map_[rtx] = associated.
const std::map<int, int> rtx_payload_type_map_;
// Map from rtx payload type -> media payload type.
const std::map<int, int> associated_payload_types_;
// TODO(nisse): Ultimately, the media receive stream shouldn't care about the
// ssrc, and we should delete this.
const uint32_t media_ssrc_;

View File

@ -25,6 +25,7 @@ using ::testing::StrictMock;
constexpr int kMediaPayloadType = 100;
constexpr int kRtxPayloadType = 98;
constexpr int kUnknownPayloadType = 90;
constexpr uint32_t kMediaSSRC = 0x3333333;
constexpr uint16_t kMediaSeqno = 0x5657;
@ -55,8 +56,7 @@ constexpr uint8_t kRtxPacketWithCVO[] = {
};
std::map<int, int> PayloadTypeMapping() {
std::map<int, int> m;
m[kRtxPayloadType] = kMediaPayloadType;
const std::map<int, int> m = {{kRtxPayloadType, kMediaPayloadType}};
return m;
}
@ -84,9 +84,26 @@ TEST(RtxReceiveStreamTest, RestoresPacketPayload) {
rtx_sink.OnRtpPacket(rtx_packet);
}
TEST(RtxReceiveStreamTest, SetsRecoveredFlag) {
StrictMock<MockRtpPacketSink> media_sink;
RtxReceiveStream rtx_sink(&media_sink, PayloadTypeMapping(), kMediaSSRC);
RtpPacketReceived rtx_packet;
EXPECT_TRUE(rtx_packet.Parse(rtc::ArrayView<const uint8_t>(kRtxPacket)));
EXPECT_FALSE(rtx_packet.recovered());
EXPECT_CALL(media_sink, OnRtpPacket(_))
.WillOnce(testing::Invoke([](const RtpPacketReceived& packet) {
EXPECT_TRUE(packet.recovered());
}));
rtx_sink.OnRtpPacket(rtx_packet);
}
TEST(RtxReceiveStreamTest, IgnoresUnknownPayloadType) {
StrictMock<MockRtpPacketSink> media_sink;
RtxReceiveStream rtx_sink(&media_sink, std::map<int, int>(), kMediaSSRC);
const std::map<int, int> payload_type_mapping = {
{kUnknownPayloadType, kMediaPayloadType}};
RtxReceiveStream rtx_sink(&media_sink, payload_type_mapping, kMediaSSRC);
RtpPacketReceived rtx_packet;
EXPECT_TRUE(rtx_packet.Parse(rtc::ArrayView<const uint8_t>(kRtxPacket)));
rtx_sink.OnRtpPacket(rtx_packet);