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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 base::TimeDelta GetTargetPlayoutDelay() const { | 40 base::TimeDelta GetTargetPlayoutDelay() const { |
41 return target_playout_delay_; | 41 return target_playout_delay_; |
42 } | 42 } |
43 | 43 |
44 // Called by the encoder with the next EncodeFrame to send. | 44 // Called by the encoder with the next EncodeFrame to send. |
45 void SendEncodedFrame(int requested_bitrate_before_encode, | 45 void SendEncodedFrame(int requested_bitrate_before_encode, |
46 scoped_ptr<EncodedFrame> encoded_frame); | 46 scoped_ptr<EncodedFrame> encoded_frame); |
47 | 47 |
48 protected: | 48 protected: |
| 49 // Returns the number of frames in the encoder's backlog. |
| 50 virtual int GetNumberOfFramesInEncoder() const = 0; |
| 51 |
| 52 // Called when we get an ACK for a frame. |
| 53 virtual void OnAck(uint32 frame_id) = 0; |
| 54 |
| 55 protected: |
49 // Schedule and execute periodic sending of RTCP report. | 56 // Schedule and execute periodic sending of RTCP report. |
50 void ScheduleNextRtcpReport(); | 57 void ScheduleNextRtcpReport(); |
51 void SendRtcpReport(bool schedule_future_reports); | 58 void SendRtcpReport(bool schedule_future_reports); |
52 | 59 |
53 void OnMeasuredRoundTripTime(base::TimeDelta rtt); | 60 void OnMeasuredRoundTripTime(base::TimeDelta rtt); |
54 | 61 |
55 const scoped_refptr<CastEnvironment> cast_environment_; | 62 const scoped_refptr<CastEnvironment> cast_environment_; |
56 | 63 |
57 // Sends encoded frames over the configured transport (e.g., UDP). In | 64 // Sends encoded frames over the configured transport (e.g., UDP). In |
58 // Chromium, this could be a proxy that first sends the frames from a renderer | 65 // Chromium, this could be a proxy that first sends the frames from a renderer |
(...skipping 26 matching lines...) Expand all Loading... |
85 // Record or retrieve a recent history of each frame's timestamps. | 92 // Record or retrieve a recent history of each frame's timestamps. |
86 // Warning: If a frame ID too far in the past is requested, the getters will | 93 // Warning: If a frame ID too far in the past is requested, the getters will |
87 // silently succeed but return incorrect values. Be sure to respect | 94 // silently succeed but return incorrect values. Be sure to respect |
88 // media::cast::kMaxUnackedFrames. | 95 // media::cast::kMaxUnackedFrames. |
89 void RecordLatestFrameTimestamps(uint32 frame_id, | 96 void RecordLatestFrameTimestamps(uint32 frame_id, |
90 base::TimeTicks reference_time, | 97 base::TimeTicks reference_time, |
91 RtpTimestamp rtp_timestamp); | 98 RtpTimestamp rtp_timestamp); |
92 base::TimeTicks GetRecordedReferenceTime(uint32 frame_id) const; | 99 base::TimeTicks GetRecordedReferenceTime(uint32 frame_id) const; |
93 RtpTimestamp GetRecordedRtpTimestamp(uint32 frame_id) const; | 100 RtpTimestamp GetRecordedRtpTimestamp(uint32 frame_id) const; |
94 | 101 |
95 // Called when we get an ACK for a frame. | |
96 virtual void OnAck(uint32 frame_id) = 0; | |
97 | |
98 const base::TimeDelta rtcp_interval_; | 102 const base::TimeDelta rtcp_interval_; |
99 | 103 |
100 // The total amount of time between a frame's capture/recording on the sender | 104 // The total amount of time between a frame's capture/recording on the sender |
101 // and its playback on the receiver (i.e., shown to a user). This is fixed as | 105 // and its playback on the receiver (i.e., shown to a user). This is fixed as |
102 // a value large enough to give the system sufficient time to encode, | 106 // a value large enough to give the system sufficient time to encode, |
103 // transmit/retransmit, receive, decode, and render; given its run-time | 107 // transmit/retransmit, receive, decode, and render; given its run-time |
104 // environment (sender/receiver hardware performance, network conditions, | 108 // environment (sender/receiver hardware performance, network conditions, |
105 // etc.). | 109 // etc.). |
106 base::TimeDelta target_playout_delay_; | 110 base::TimeDelta target_playout_delay_; |
107 | 111 |
108 // If true, we transmit the target playout delay to the receiver. | 112 // If true, we transmit the target playout delay to the receiver. |
109 bool send_target_playout_delay_; | 113 bool send_target_playout_delay_; |
110 | 114 |
111 // Max encoded frames generated per second. | 115 // Max encoded frames generated per second. |
112 double max_frame_rate_; | 116 double max_frame_rate_; |
113 | 117 |
114 // Maximum number of outstanding frames before the encoding and sending of | 118 // Maximum number of outstanding frames before the encoding and sending of |
115 // new frames shall halt. | 119 // new frames shall halt. |
116 int max_unacked_frames_; | 120 int max_unacked_frames_; |
117 | 121 |
118 // The number of frames currently being processed in |video_encoder_|. | |
119 int frames_in_encoder_; | |
120 | |
121 // Counts how many RTCP reports are being "aggressively" sent (i.e., one per | 122 // Counts how many RTCP reports are being "aggressively" sent (i.e., one per |
122 // frame) at the start of the session. Once a threshold is reached, RTCP | 123 // frame) at the start of the session. Once a threshold is reached, RTCP |
123 // reports are instead sent at the configured interval + random drift. | 124 // reports are instead sent at the configured interval + random drift. |
124 int num_aggressive_rtcp_reports_sent_; | 125 int num_aggressive_rtcp_reports_sent_; |
125 | 126 |
126 // This is "null" until the first frame is sent. Thereafter, this tracks the | 127 // This is "null" until the first frame is sent. Thereafter, this tracks the |
127 // last time any frame was sent or re-sent. | 128 // last time any frame was sent or re-sent. |
128 base::TimeTicks last_send_time_; | 129 base::TimeTicks last_send_time_; |
129 | 130 |
130 // The ID of the last frame sent. Logic throughout FrameSender assumes this | 131 // The ID of the last frame sent. Logic throughout FrameSender assumes this |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // NOTE: Weak pointers must be invalidated before all other member variables. | 170 // NOTE: Weak pointers must be invalidated before all other member variables. |
170 base::WeakPtrFactory<FrameSender> weak_factory_; | 171 base::WeakPtrFactory<FrameSender> weak_factory_; |
171 | 172 |
172 DISALLOW_COPY_AND_ASSIGN(FrameSender); | 173 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
173 }; | 174 }; |
174 | 175 |
175 } // namespace cast | 176 } // namespace cast |
176 } // namespace media | 177 } // namespace media |
177 | 178 |
178 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 179 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
OLD | NEW |