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

Unified Diff: media/cast/rtcp/rtcp_receiver.cc

Issue 266373008: Cast: Fix rtcp event dedup logic in rtcp_receiver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 7 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/rtcp/rtcp_receiver.h ('k') | media/cast/rtcp/rtcp_receiver_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/rtcp/rtcp_receiver.cc
diff --git a/media/cast/rtcp/rtcp_receiver.cc b/media/cast/rtcp/rtcp_receiver.cc
index 8c0e593d6e22a2c7332ad8aa2d8b309466901b15..9345d5850ae2377698ff4deb2b8cbe761dcb80ad 100644
--- a/media/cast/rtcp/rtcp_receiver.cc
+++ b/media/cast/rtcp/rtcp_receiver.cc
@@ -10,35 +10,11 @@
namespace {
-media::cast::CastLoggingEvent TranslateToLogEventFromWireFormat(uint8 event) {
- switch (event) {
- case 1:
- return media::cast::kAudioAckSent;
- case 2:
- return media::cast::kAudioPlayoutDelay;
- case 3:
- return media::cast::kAudioFrameDecoded;
- case 4:
- return media::cast::kAudioPacketReceived;
- case 5:
- return media::cast::kVideoAckSent;
- case 6:
- return media::cast::kVideoFrameDecoded;
- case 7:
- return media::cast::kVideoRenderDelay;
- case 8:
- return media::cast::kVideoPacketReceived;
- case 9:
- return media::cast::kDuplicateAudioPacketReceived;
- case 10:
- return media::cast::kDuplicateVideoPacketReceived;
- default:
- // If the sender adds new log messages we will end up here until we add
- // the new messages in the receiver.
- VLOG(1) << "Unexpected log message received: " << static_cast<int>(event);
- NOTREACHED();
- return media::cast::kUnknown;
- }
+bool IsRtcpPacketEvent(media::cast::CastLoggingEvent event_type) {
+ return event_type == media::cast::kAudioPacketReceived ||
+ event_type == media::cast::kVideoPacketReceived ||
+ event_type == media::cast::kDuplicateAudioPacketReceived ||
+ event_type == media::cast::kDuplicateVideoPacketReceived;
}
media::cast::transport::RtcpSenderFrameStatus
@@ -61,15 +37,26 @@ TranslateToFrameStatusFromWireFormat(uint8 status) {
}
}
-// A receiver event is identified by frame RTP timestamp, event timestamp and
-// event type.
-size_t HashReceiverEvent(uint32 frame_rtp_timestamp,
- const base::TimeTicks& event_timestamp,
- media::cast::CastLoggingEvent event_type) {
+// A receiver frame event is identified by frame RTP timestamp, event timestamp
+// and event type.
+// A receiver packet event is identified by all of the above plus packet id.
+// The key format is as follows:
+// First uint64:
+// bits 0-11: zeroes (unused).
+// bits 12-15: event type ID.
+// bits 16-31: packet ID if packet event, 0 otherwise.
+// bits 32-63: RTP timestamp.
+// Second uint64:
+// bits 0-63: event TimeTicks internal value.
+std::pair<uint64, uint64> GetReceiverEventKey(
+ uint32 frame_rtp_timestamp, const base::TimeTicks& event_timestamp,
+ uint8 event_type, uint16 packet_id_or_zero) {
uint64 value1 = event_type;
+ value1 <<= 16;
+ value1 |= packet_id_or_zero;
value1 <<= 32;
value1 |= frame_rtp_timestamp;
- return base::HashInts64(
+ return std::make_pair(
value1, static_cast<uint64>(event_timestamp.ToInternalValue()));
}
@@ -490,8 +477,10 @@ void RtcpReceiver::HandleApplicationSpecificCastReceiverEventLog(
RtcpReceiverEventLogMessages* event_log_messages) {
const RtcpField& rtcp_field = rtcp_parser->Field();
- const CastLoggingEvent event_type =
- TranslateToLogEventFromWireFormat(rtcp_field.cast_receiver_log.event);
+ const uint8 event = rtcp_field.cast_receiver_log.event;
+ const CastLoggingEvent event_type = TranslateToLogEventFromWireFormat(event);
+ uint16 packet_id = IsRtcpPacketEvent(event_type) ?
+ rtcp_field.cast_receiver_log.delay_delta_or_packet_id.packet_id : 0;
const base::TimeTicks event_timestamp =
base::TimeTicks() +
base::TimeDelta::FromMilliseconds(
@@ -503,21 +492,19 @@ void RtcpReceiver::HandleApplicationSpecificCastReceiverEventLog(
// a queue and a set of events. We enqueue every new event and insert it
// into the set. When the queue becomes too big we remove the oldest event
// from both the queue and the set.
- // Different events may have the same hash value. That's okay because full
- // accuracy is not important in this case.
- const size_t event_hash =
- HashReceiverEvent(frame_rtp_timestamp, event_timestamp, event_type);
- if (receiver_event_hash_set_.find(event_hash) !=
- receiver_event_hash_set_.end()) {
+ ReceiverEventKey key =
+ GetReceiverEventKey(
+ frame_rtp_timestamp, event_timestamp, event, packet_id);
+ if (receiver_event_key_set_.find(key) != receiver_event_key_set_.end()) {
return;
} else {
- receiver_event_hash_set_.insert(event_hash);
- receiver_event_hash_queue_.push(event_hash);
+ receiver_event_key_set_.insert(key);
+ receiver_event_key_queue_.push(key);
- if (receiver_event_hash_queue_.size() > receiver_event_history_size_) {
- const size_t oldest_hash = receiver_event_hash_queue_.front();
- receiver_event_hash_queue_.pop();
- receiver_event_hash_set_.erase(oldest_hash);
+ if (receiver_event_key_queue_.size() > receiver_event_history_size_) {
+ const ReceiverEventKey oldest_key = receiver_event_key_queue_.front();
+ receiver_event_key_queue_.pop();
+ receiver_event_key_set_.erase(oldest_key);
}
}
« no previous file with comments | « media/cast/rtcp/rtcp_receiver.h ('k') | media/cast/rtcp/rtcp_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698