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 // This is the base class for an object that send frames to a receiver. | 5 // This is the base class for an object that send frames to a receiver. |
6 // TODO(hclam): Refactor such that there is no separate AudioSender vs. | 6 // TODO(hclam): Refactor such that there is no separate AudioSender vs. |
7 // VideoSender, and the functionality of both is rolled into this class. | 7 // VideoSender, and the functionality of both is rolled into this class. |
8 | 8 |
9 #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 9 #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
10 #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 10 #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 RtpTimestampHelper rtp_timestamp_helper_; | 67 RtpTimestampHelper rtp_timestamp_helper_; |
68 | 68 |
69 // RTT information from RTCP. | 69 // RTT information from RTCP. |
70 bool rtt_available_; | 70 bool rtt_available_; |
71 base::TimeDelta rtt_; | 71 base::TimeDelta rtt_; |
72 base::TimeDelta avg_rtt_; | 72 base::TimeDelta avg_rtt_; |
73 base::TimeDelta min_rtt_; | 73 base::TimeDelta min_rtt_; |
74 base::TimeDelta max_rtt_; | 74 base::TimeDelta max_rtt_; |
75 | 75 |
76 protected: | 76 protected: |
| 77 // Schedule and execute periodic checks for re-sending packets. If no |
| 78 // acknowledgements have been received for "too long," AudioSender will |
| 79 // speculatively re-send certain packets of an unacked frame to kick-start |
| 80 // re-transmission. This is a last resort tactic to prevent the session from |
| 81 // getting stuck after a long outage. |
| 82 void ScheduleNextResendCheck(); |
| 83 void ResendCheck(); |
| 84 void ResendForKickstart(); |
| 85 |
77 const base::TimeDelta rtcp_interval_; | 86 const base::TimeDelta rtcp_interval_; |
78 | 87 |
79 // The total amount of time between a frame's capture/recording on the sender | 88 // The total amount of time between a frame's capture/recording on the sender |
80 // and its playback on the receiver (i.e., shown to a user). This is fixed as | 89 // and its playback on the receiver (i.e., shown to a user). This is fixed as |
81 // a value large enough to give the system sufficient time to encode, | 90 // a value large enough to give the system sufficient time to encode, |
82 // transmit/retransmit, receive, decode, and render; given its run-time | 91 // transmit/retransmit, receive, decode, and render; given its run-time |
83 // environment (sender/receiver hardware performance, network conditions, | 92 // environment (sender/receiver hardware performance, network conditions, |
84 // etc.). | 93 // etc.). |
85 base::TimeDelta target_playout_delay_; | 94 base::TimeDelta target_playout_delay_; |
86 | 95 |
87 // If true, we transmit the target playout delay to the receiver. | 96 // If true, we transmit the target playout delay to the receiver. |
88 bool send_target_playout_delay_; | 97 bool send_target_playout_delay_; |
89 | 98 |
90 // Max encoded frames generated per second. | 99 // Max encoded frames generated per second. |
91 double max_frame_rate_; | 100 double max_frame_rate_; |
92 | 101 |
93 // Maximum number of outstanding frames before the encoding and sending of | 102 // Maximum number of outstanding frames before the encoding and sending of |
94 // new frames shall halt. | 103 // new frames shall halt. |
95 int max_unacked_frames_; | 104 int max_unacked_frames_; |
96 | 105 |
| 106 // Counts how many RTCP reports are being "aggressively" sent (i.e., one per |
| 107 // frame) at the start of the session. Once a threshold is reached, RTCP |
| 108 // reports are instead sent at the configured interval + random drift. |
| 109 int num_aggressive_rtcp_reports_sent_; |
| 110 |
| 111 // This is "null" until the first frame is sent. Thereafter, this tracks the |
| 112 // last time any frame was sent or re-sent. |
| 113 base::TimeTicks last_send_time_; |
| 114 |
| 115 // The ID of the last frame sent. Logic throughout AudioSender assumes this |
| 116 // can safely wrap-around. This member is invalid until |
| 117 // |!last_send_time_.is_null()|. |
| 118 uint32 last_sent_frame_id_; |
| 119 |
| 120 // The ID of the latest (not necessarily the last) frame that has been |
| 121 // acknowledged. Logic throughout AudioSender assumes this can safely |
| 122 // wrap-around. This member is invalid until |!last_send_time_.is_null()|. |
| 123 uint32 latest_acked_frame_id_; |
| 124 |
| 125 // Counts the number of duplicate ACK that are being received. When this |
| 126 // number reaches a threshold, the sender will take this as a sign that the |
| 127 // receiver hasn't yet received the first packet of the next frame. In this |
| 128 // case, VideoSender will trigger a re-send of the next frame. |
| 129 int duplicate_ack_counter_; |
| 130 |
| 131 // If this sender is ready for use, this is STATUS_AUDIO_INITIALIZED or |
| 132 // STATUS_VIDEO_INITIALIZED. |
| 133 CastInitializationStatus cast_initialization_status_; |
| 134 |
| 135 // This is a "good enough" mapping for finding the RTP timestamp associated |
| 136 // with a video frame. The key is the lowest 8 bits of frame id (which is |
| 137 // what is sent via RTCP). This map is used for logging purposes. |
| 138 RtpTimestamp frame_id_to_rtp_timestamp_[256]; |
| 139 |
97 private: | 140 private: |
98 // NOTE: Weak pointers must be invalidated before all other member variables. | 141 // NOTE: Weak pointers must be invalidated before all other member variables. |
99 base::WeakPtrFactory<FrameSender> weak_factory_; | 142 base::WeakPtrFactory<FrameSender> weak_factory_; |
100 | 143 |
101 DISALLOW_COPY_AND_ASSIGN(FrameSender); | 144 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
102 }; | 145 }; |
103 | 146 |
104 } // namespace cast | 147 } // namespace cast |
105 } // namespace media | 148 } // namespace media |
106 | 149 |
107 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 150 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
OLD | NEW |