| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MEDIA_CAST_RTCP_RTCP_RECEIVER_H_ | 5 #ifndef MEDIA_CAST_RTCP_RTCP_RECEIVER_H_ |
| 6 #define MEDIA_CAST_RTCP_RTCP_RECEIVER_H_ | 6 #define MEDIA_CAST_RTCP_RTCP_RECEIVER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "media/cast/net/cast_transport_defines.h" | 11 #include "media/cast/net/cast_transport_defines.h" |
| 12 #include "media/cast/net/rtcp/rtcp.h" | 12 #include "media/cast/net/rtcp/rtcp.h" |
| 13 #include "media/cast/net/rtcp/rtcp_defines.h" | 13 #include "media/cast/net/rtcp/rtcp_defines.h" |
| 14 #include "media/cast/net/rtcp/rtcp_utility.h" | 14 #include "media/cast/net/rtcp/rtcp_utility.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 namespace cast { | 17 namespace cast { |
| 18 | 18 |
| 19 class RtcpReceiverFeedback { | 19 // Interface for receiving RTCP messages. |
| 20 class RtcpMessageHandler { |
| 20 public: | 21 public: |
| 21 virtual void OnReceivedSenderReport( | 22 virtual void OnReceivedSenderReport( |
| 22 const RtcpSenderInfo& remote_sender_info) = 0; | 23 const RtcpSenderInfo& remote_sender_info) = 0; |
| 23 | 24 |
| 24 virtual void OnReceiverReferenceTimeReport( | 25 virtual void OnReceiverReferenceTimeReport( |
| 25 const RtcpReceiverReferenceTimeReport& remote_time_report) = 0; | 26 const RtcpReceiverReferenceTimeReport& remote_time_report) = 0; |
| 26 | 27 |
| 27 virtual void OnReceivedSendReportRequest() = 0; | |
| 28 | |
| 29 virtual void OnReceivedReceiverLog( | 28 virtual void OnReceivedReceiverLog( |
| 30 const RtcpReceiverLogMessage& receiver_log) = 0; | 29 const RtcpReceiverLogMessage& receiver_log) = 0; |
| 31 | 30 |
| 32 virtual ~RtcpReceiverFeedback() {} | |
| 33 }; | |
| 34 | |
| 35 class RtcpRttFeedback { | |
| 36 public: | |
| 37 virtual void OnReceivedDelaySinceLastReport( | 31 virtual void OnReceivedDelaySinceLastReport( |
| 38 uint32 receivers_ssrc, | |
| 39 uint32 last_report, | 32 uint32 last_report, |
| 40 uint32 delay_since_last_report) = 0; | 33 uint32 delay_since_last_report) = 0; |
| 41 | 34 |
| 42 virtual ~RtcpRttFeedback() {} | 35 virtual void OnReceivedCastFeedback( |
| 36 const RtcpCastMessage& cast_message) = 0; |
| 37 |
| 38 virtual ~RtcpMessageHandler() {} |
| 43 }; | 39 }; |
| 44 | 40 |
| 45 class RtcpReceiver { | 41 class RtcpReceiver { |
| 46 public: | 42 public: |
| 47 explicit RtcpReceiver(scoped_refptr<CastEnvironment> cast_environment, | 43 RtcpReceiver(RtcpMessageHandler* handler, uint32 local_ssrc); |
| 48 RtcpSenderFeedback* sender_feedback, | |
| 49 RtcpReceiverFeedback* receiver_feedback, | |
| 50 RtcpRttFeedback* rtt_feedback, | |
| 51 uint32 local_ssrc); | |
| 52 virtual ~RtcpReceiver(); | 44 virtual ~RtcpReceiver(); |
| 53 | 45 |
| 46 static bool IsRtcpPacket(const uint8* rtcp_buffer, size_t length); |
| 47 |
| 48 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); |
| 49 |
| 54 void SetRemoteSSRC(uint32 ssrc); | 50 void SetRemoteSSRC(uint32 ssrc); |
| 55 | 51 |
| 56 // Set the history size to record Cast receiver events. Event history is | 52 // Set the history size to record Cast receiver events. Event history is |
| 57 // used to remove duplicates. The history has no more than |size| events. | 53 // used to remove duplicates. The history has no more than |size| events. |
| 58 void SetCastReceiverEventHistorySize(size_t size); | 54 void SetCastReceiverEventHistorySize(size_t size); |
| 59 | 55 |
| 60 void IncomingRtcpPacket(RtcpParser* rtcp_parser); | 56 void IncomingRtcpPacket(RtcpParser* rtcp_parser); |
| 61 | 57 |
| 62 private: | 58 private: |
| 63 void HandleSenderReport(RtcpParser* rtcp_parser); | 59 void HandleSenderReport(RtcpParser* rtcp_parser); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void HandleApplicationSpecificCastSenderLog(RtcpParser* rtcp_parser); | 100 void HandleApplicationSpecificCastSenderLog(RtcpParser* rtcp_parser); |
| 105 void HandleApplicationSpecificCastReceiverEventLog( | 101 void HandleApplicationSpecificCastReceiverEventLog( |
| 106 uint32 frame_rtp_timestamp, | 102 uint32 frame_rtp_timestamp, |
| 107 RtcpParser* rtcp_parser, | 103 RtcpParser* rtcp_parser, |
| 108 RtcpReceiverEventLogMessages* event_log_messages); | 104 RtcpReceiverEventLogMessages* event_log_messages); |
| 109 | 105 |
| 110 const uint32 ssrc_; | 106 const uint32 ssrc_; |
| 111 uint32 remote_ssrc_; | 107 uint32 remote_ssrc_; |
| 112 | 108 |
| 113 // Not owned by this class. | 109 // Not owned by this class. |
| 114 RtcpSenderFeedback* const sender_feedback_; | 110 RtcpMessageHandler* const handler_; |
| 115 RtcpReceiverFeedback* const receiver_feedback_; | |
| 116 RtcpRttFeedback* const rtt_feedback_; | |
| 117 scoped_refptr<CastEnvironment> cast_environment_; | |
| 118 | 111 |
| 119 FrameIdWrapHelper ack_frame_id_wrap_helper_; | 112 FrameIdWrapHelper ack_frame_id_wrap_helper_; |
| 120 | 113 |
| 121 // Maintains a history of receiver events. | 114 // Maintains a history of receiver events. |
| 122 size_t receiver_event_history_size_; | 115 size_t receiver_event_history_size_; |
| 123 typedef std::pair<uint64, uint64> ReceiverEventKey; | 116 typedef std::pair<uint64, uint64> ReceiverEventKey; |
| 124 base::hash_set<ReceiverEventKey> receiver_event_key_set_; | 117 base::hash_set<ReceiverEventKey> receiver_event_key_set_; |
| 125 std::queue<ReceiverEventKey> receiver_event_key_queue_; | 118 std::queue<ReceiverEventKey> receiver_event_key_queue_; |
| 126 | 119 |
| 127 DISALLOW_COPY_AND_ASSIGN(RtcpReceiver); | 120 DISALLOW_COPY_AND_ASSIGN(RtcpReceiver); |
| 128 }; | 121 }; |
| 129 | 122 |
| 130 } // namespace cast | 123 } // namespace cast |
| 131 } // namespace media | 124 } // namespace media |
| 132 | 125 |
| 133 #endif // MEDIA_CAST_RTCP_RTCP_RECEIVER_H_ | 126 #endif // MEDIA_CAST_RTCP_RTCP_RECEIVER_H_ |
| OLD | NEW |