| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/rtcp/rtcp_sender.h" | 5 #include "media/cast/rtcp/rtcp_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "media/cast/cast_environment.h" | 12 #include "media/cast/cast_environment.h" |
| 13 #include "media/cast/rtcp/rtcp_defines.h" | 13 #include "media/cast/rtcp/rtcp_defines.h" |
| 14 #include "media/cast/rtcp/rtcp_utility.h" | 14 #include "media/cast/rtcp/rtcp_utility.h" |
| 15 #include "media/cast/transport/cast_transport_defines.h" | 15 #include "media/cast/transport/cast_transport_defines.h" |
| 16 #include "media/cast/transport/pacing/paced_sender.h" | 16 #include "media/cast/transport/pacing/paced_sender.h" |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 namespace cast { | 19 namespace cast { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Max delta is 4095 milliseconds because we need to be able to encode it in | 22 // Max delta is 4095 milliseconds because we need to be able to encode it in |
| 23 // 12 bits. | 23 // 12 bits. |
| 24 const int64 kMaxWireFormatTimeDeltaMs = GG_INT64_C(0xfff); | 24 const int64 kMaxWireFormatTimeDeltaMs = GG_INT64_C(0xfff); |
| 25 | 25 |
| 26 // We limit the size of receiver logs to avoid queuing up packets. We also | |
| 27 // do not need the amount of redundancy that results from filling up every | |
| 28 // RTCP packet with log messages. This number should give a redundancy of | |
| 29 // about 2-3 per log message. | |
| 30 const size_t kMaxReceiverLogBytes = 200; | |
| 31 | |
| 32 // Converts a log event type to an integer value. | 26 // Converts a log event type to an integer value. |
| 33 // NOTE: We have only allocated 4 bits to represent the type of event over the | 27 // NOTE: We have only allocated 4 bits to represent the type of event over the |
| 34 // wire. Therefore, this function can only return values from 0 to 15. | 28 // wire. Therefore, this function can only return values from 0 to 15. |
| 35 int ConvertEventTypeToWireFormat(const CastLoggingEvent& event) { | 29 int ConvertEventTypeToWireFormat(const CastLoggingEvent& event) { |
| 36 switch (event) { | 30 switch (event) { |
| 37 case kAudioAckSent: | 31 case kAudioAckSent: |
| 38 return 1; | 32 return 1; |
| 39 case kAudioPlayoutDelay: | 33 case kAudioPlayoutDelay: |
| 40 return 2; | 34 return 2; |
| 41 case kAudioFrameDecoded: | 35 case kAudioFrameDecoded: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return lhs.event_timestamp < rhs.event_timestamp; | 75 return lhs.event_timestamp < rhs.event_timestamp; |
| 82 } | 76 } |
| 83 | 77 |
| 84 bool BuildRtcpReceiverLogMessage( | 78 bool BuildRtcpReceiverLogMessage( |
| 85 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events, | 79 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap& rtcp_events, |
| 86 size_t start_size, | 80 size_t start_size, |
| 87 RtcpReceiverLogMessage* receiver_log_message, | 81 RtcpReceiverLogMessage* receiver_log_message, |
| 88 size_t* number_of_frames, | 82 size_t* number_of_frames, |
| 89 size_t* total_number_of_messages_to_send, | 83 size_t* total_number_of_messages_to_send, |
| 90 size_t* rtcp_log_size) { | 84 size_t* rtcp_log_size) { |
| 91 size_t remaining_space = | 85 size_t remaining_space = kMaxIpPacketSize - start_size; |
| 92 std::min(kMaxReceiverLogBytes, kMaxIpPacketSize - start_size); | |
| 93 if (remaining_space < kRtcpCastLogHeaderSize + kRtcpReceiverFrameLogSize + | 86 if (remaining_space < kRtcpCastLogHeaderSize + kRtcpReceiverFrameLogSize + |
| 94 kRtcpReceiverEventLogSize) { | 87 kRtcpReceiverEventLogSize) { |
| 95 return false; | 88 return false; |
| 96 } | 89 } |
| 97 | 90 |
| 98 // We use this to do event timestamp sorting and truncating for events of | 91 // We use this to do event timestamp sorting and truncating for events of |
| 99 // a single frame. | 92 // a single frame. |
| 100 std::vector<RtcpReceiverEventLogMessage> sorted_log_messages; | 93 std::vector<RtcpReceiverEventLogMessage> sorted_log_messages; |
| 101 | 94 |
| 102 // Account for the RTCP header for an application-defined packet. | 95 // Account for the RTCP header for an application-defined packet. |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 if (frame_log_messages.event_log_messages_.empty()) { | 701 if (frame_log_messages.event_log_messages_.empty()) { |
| 709 // We sent all messages on this frame; pop the frame header. | 702 // We sent all messages on this frame; pop the frame header. |
| 710 receiver_log_message.pop_front(); | 703 receiver_log_message.pop_front(); |
| 711 } | 704 } |
| 712 } | 705 } |
| 713 DCHECK_EQ(total_number_of_messages_to_send, 0); | 706 DCHECK_EQ(total_number_of_messages_to_send, 0); |
| 714 } | 707 } |
| 715 | 708 |
| 716 } // namespace cast | 709 } // namespace cast |
| 717 } // namespace media | 710 } // namespace media |
| OLD | NEW |