Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Unified Diff: media/cast/net/rtp/frame_buffer.cc

Issue 540713002: Cast: Get rid of frame_id_map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed unused variable Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/net/rtp/frame_buffer.h ('k') | media/cast/net/rtp/frame_id_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/net/rtp/frame_buffer.cc
diff --git a/media/cast/net/rtp/frame_buffer.cc b/media/cast/net/rtp/frame_buffer.cc
index 4a911635f9ca7f52547f1720ec1ed832b55267d6..319aad2502a494a6aaeb45ffabd235a0a736b218 100644
--- a/media/cast/net/rtp/frame_buffer.cc
+++ b/media/cast/net/rtp/frame_buffer.cc
@@ -13,6 +13,7 @@ FrameBuffer::FrameBuffer()
: frame_id_(0),
max_packet_id_(0),
num_packets_received_(0),
+ max_seen_packet_id_(0),
new_playout_delay_ms_(0),
is_key_frame_(false),
total_data_size_(0),
@@ -21,7 +22,7 @@ FrameBuffer::FrameBuffer()
FrameBuffer::~FrameBuffer() {}
-void FrameBuffer::InsertPacket(const uint8* payload_data,
+bool FrameBuffer::InsertPacket(const uint8* payload_data,
size_t payload_size,
const RtpCastHeader& rtp_header) {
// Is this the first packet in the frame?
@@ -37,11 +38,11 @@ void FrameBuffer::InsertPacket(const uint8* payload_data,
}
// Is this the correct frame?
if (rtp_header.frame_id != frame_id_)
- return;
+ return false;
// Insert every packet only once.
if (packets_.find(rtp_header.packet_id) != packets_.end()) {
- return;
+ return false;
}
std::vector<uint8> data;
@@ -54,7 +55,9 @@ void FrameBuffer::InsertPacket(const uint8* payload_data,
payload_data, payload_data + payload_size, retval.first->second.begin());
++num_packets_received_;
+ max_seen_packet_id_ = std::max(max_seen_packet_id_, rtp_header.packet_id);
total_data_size_ += payload_size;
+ return true;
}
bool FrameBuffer::Complete() const {
@@ -86,5 +89,28 @@ bool FrameBuffer::AssembleEncodedFrame(EncodedFrame* frame) const {
return true;
}
+void FrameBuffer::GetMissingPackets(bool newest_frame,
+ PacketIdSet* missing_packets) const {
+ // Missing packets capped by max_seen_packet_id_.
+ // (Iff it's the latest frame)
+ int maximum = newest_frame ? max_seen_packet_id_ : max_packet_id_;
+ int packet = 0;
+ for (PacketMap::const_iterator i = packets_.begin();
+ i != packets_.end() && packet <= maximum;
+ ++i) {
+ int end = std::min<int>(i->first, maximum + 1);
+ while (packet < end) {
+ missing_packets->insert(packet);
+ packet++;
+ }
+ packet++;
+ }
+ while (packet <= maximum) {
+ missing_packets->insert(packet);
+ packet++;
+ }
+}
+
+
} // namespace cast
} // namespace media
« no previous file with comments | « media/cast/net/rtp/frame_buffer.h ('k') | media/cast/net/rtp/frame_id_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698