Using different sequence numbers for different SSRCs

This seems to solve the unexpected behavior when selecting lower layers.
Also, this replaces https://codereview.webrtc.org/1327153002/

Review URL: https://codereview.webrtc.org/1350383004

Cr-Commit-Position: refs/heads/master@{#10206}
This commit is contained in:
ivica 2015-10-07 23:44:29 -07:00 committed by Commit bot
parent fddf6e526c
commit e78e2c714b
2 changed files with 17 additions and 9 deletions

View File

@ -29,9 +29,15 @@ LayerFilteringTransport::LayerFilteringTransport(
vp8_video_payload_type_(vp8_video_payload_type),
vp9_video_payload_type_(vp9_video_payload_type),
tl_discard_threshold_(tl_discard_threshold),
sl_discard_threshold_(sl_discard_threshold),
current_seq_num_(10000) {
} // TODO(ivica): random seq num?
sl_discard_threshold_(sl_discard_threshold) {
}
uint16_t LayerFilteringTransport::NextSequenceNumber(uint32_t ssrc) {
auto it = current_seq_nums_.find(ssrc);
if (it == current_seq_nums_.end())
return current_seq_nums_[ssrc] = 10000;
return ++it->second;
}
bool LayerFilteringTransport::SendRtp(const uint8_t* packet,
size_t length,
@ -88,13 +94,11 @@ bool LayerFilteringTransport::SendRtp(const uint8_t* packet,
// We are discarding some of the packets (specifically, whole layers), so
// make sure the marker bit is set properly, and that sequence numbers are
// continuous.
if (set_marker_bit) {
if (set_marker_bit)
temp_buffer[1] |= kRtpMarkerBitMask;
}
ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], current_seq_num_);
++current_seq_num_; // Increase only if packet not discarded.
uint16_t seq_num = NextSequenceNumber(header.ssrc);
ByteWriter<uint16_t>::WriteBigEndian(&temp_buffer[2], seq_num);
return test::DirectTransport::SendRtp(temp_buffer, length, options);
}

View File

@ -13,6 +13,8 @@
#include "webrtc/test/direct_transport.h"
#include "webrtc/test/fake_network_pipe.h"
#include <map>
namespace webrtc {
namespace test {
@ -29,6 +31,7 @@ class LayerFilteringTransport : public test::DirectTransport {
const PacketOptions& options) override;
private:
uint16_t NextSequenceNumber(uint32_t ssrc);
// Used to distinguish between VP8 and VP9.
const uint8_t vp8_video_payload_type_;
const uint8_t vp9_video_payload_type_;
@ -36,7 +39,8 @@ class LayerFilteringTransport : public test::DirectTransport {
// threshold. 0 to disable.
const uint8_t tl_discard_threshold_;
const uint8_t sl_discard_threshold_;
uint16_t current_seq_num_;
// Current sequence number for each SSRC separately.
std::map<uint32_t, uint16_t> current_seq_nums_;
};
} // namespace test