| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 class FrameSender { | 23 class FrameSender { |
| 24 public: | 24 public: |
| 25 FrameSender(scoped_refptr<CastEnvironment> cast_environment, | 25 FrameSender(scoped_refptr<CastEnvironment> cast_environment, |
| 26 bool is_audio, | 26 bool is_audio, |
| 27 CastTransportSender* const transport_sender, | 27 CastTransportSender* const transport_sender, |
| 28 base::TimeDelta rtcp_interval, | 28 base::TimeDelta rtcp_interval, |
| 29 int rtp_timebase, | 29 int rtp_timebase, |
| 30 uint32 ssrc, | 30 uint32 ssrc, |
| 31 double max_frame_rate, | 31 double max_frame_rate, |
| 32 base::TimeDelta playout_delay, | 32 base::TimeDelta min_playout_delay, |
| 33 base::TimeDelta max_playout_delay, |
| 33 CongestionControl* congestion_control); | 34 CongestionControl* congestion_control); |
| 34 virtual ~FrameSender(); | 35 virtual ~FrameSender(); |
| 35 | 36 |
| 36 // Calling this function is only valid if the receiver supports the | 37 // Calling this function is only valid if the receiver supports the |
| 37 // "extra_playout_delay", rtp extension. | 38 // "extra_playout_delay", rtp extension. |
| 38 void SetTargetPlayoutDelay(base::TimeDelta new_target_playout_delay); | 39 void SetTargetPlayoutDelay(base::TimeDelta new_target_playout_delay); |
| 39 | 40 |
| 40 base::TimeDelta GetTargetPlayoutDelay() const { | 41 base::TimeDelta GetTargetPlayoutDelay() const { |
| 41 return target_playout_delay_; | 42 return target_playout_delay_; |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Called by the encoder with the next EncodeFrame to send. | 45 // Called by the encoder with the next EncodeFrame to send. |
| 45 void SendEncodedFrame(int requested_bitrate_before_encode, | 46 void SendEncodedFrame(int requested_bitrate_before_encode, |
| 46 scoped_ptr<EncodedFrame> encoded_frame); | 47 scoped_ptr<EncodedFrame> encoded_frame); |
| 47 | 48 |
| 48 protected: | 49 protected: |
| 49 // Returns the number of frames in the encoder's backlog. | 50 // Returns the number of frames in the encoder's backlog. |
| 50 virtual int GetNumberOfFramesInEncoder() const = 0; | 51 virtual int GetNumberOfFramesInEncoder() const = 0; |
| 51 | 52 |
| 52 // Called when we get an ACK for a frame. | 53 // Called when we get an ACK for a frame. |
| 53 virtual void OnAck(uint32 frame_id) = 0; | 54 virtual void OnAck(uint32 frame_id) = 0; |
| 54 | 55 |
| 55 protected: | 56 protected: |
| 56 // Schedule and execute periodic sending of RTCP report. | 57 // Schedule and execute periodic sending of RTCP report. |
| 57 void ScheduleNextRtcpReport(); | 58 void ScheduleNextRtcpReport(); |
| 58 void SendRtcpReport(bool schedule_future_reports); | 59 void SendRtcpReport(bool schedule_future_reports); |
| 59 | 60 |
| 60 void OnMeasuredRoundTripTime(base::TimeDelta rtt); | 61 void OnMeasuredRoundTripTime(base::TimeDelta rtt); |
| 62 base::TimeDelta AverageRTT(); |
| 61 | 63 |
| 62 const scoped_refptr<CastEnvironment> cast_environment_; | 64 const scoped_refptr<CastEnvironment> cast_environment_; |
| 63 | 65 |
| 64 // Sends encoded frames over the configured transport (e.g., UDP). In | 66 // Sends encoded frames over the configured transport (e.g., UDP). In |
| 65 // Chromium, this could be a proxy that first sends the frames from a renderer | 67 // Chromium, this could be a proxy that first sends the frames from a renderer |
| 66 // process to the browser process over IPC, with the browser process being | 68 // process to the browser process over IPC, with the browser process being |
| 67 // responsible for "packetizing" the frames and pushing packets into the | 69 // responsible for "packetizing" the frames and pushing packets into the |
| 68 // network layer. | 70 // network layer. |
| 69 CastTransportSender* const transport_sender_; | 71 CastTransportSender* const transport_sender_; |
| 70 | 72 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 101 | 103 |
| 102 const base::TimeDelta rtcp_interval_; | 104 const base::TimeDelta rtcp_interval_; |
| 103 | 105 |
| 104 // The total amount of time between a frame's capture/recording on the sender | 106 // The total amount of time between a frame's capture/recording on the sender |
| 105 // and its playback on the receiver (i.e., shown to a user). This is fixed as | 107 // and its playback on the receiver (i.e., shown to a user). This is fixed as |
| 106 // a value large enough to give the system sufficient time to encode, | 108 // a value large enough to give the system sufficient time to encode, |
| 107 // transmit/retransmit, receive, decode, and render; given its run-time | 109 // transmit/retransmit, receive, decode, and render; given its run-time |
| 108 // environment (sender/receiver hardware performance, network conditions, | 110 // environment (sender/receiver hardware performance, network conditions, |
| 109 // etc.). | 111 // etc.). |
| 110 base::TimeDelta target_playout_delay_; | 112 base::TimeDelta target_playout_delay_; |
| 113 base::TimeDelta min_playout_delay_; |
| 114 base::TimeDelta max_playout_delay_; |
| 111 | 115 |
| 112 // If true, we transmit the target playout delay to the receiver. | 116 // If true, we transmit the target playout delay to the receiver. |
| 113 bool send_target_playout_delay_; | 117 bool send_target_playout_delay_; |
| 114 | 118 |
| 115 // Max encoded frames generated per second. | 119 // Max encoded frames generated per second. |
| 116 double max_frame_rate_; | 120 double max_frame_rate_; |
| 117 | 121 |
| 118 // Maximum number of outstanding frames before the encoding and sending of | 122 // Maximum number of outstanding frames before the encoding and sending of |
| 119 // new frames shall halt. | 123 // new frames shall halt. |
| 120 int max_unacked_frames_; | 124 int max_unacked_frames_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 164 |
| 161 // Ring buffers to keep track of recent frame timestamps (both in terms of | 165 // Ring buffers to keep track of recent frame timestamps (both in terms of |
| 162 // local reference time and RTP media time). These should only be accessed | 166 // local reference time and RTP media time). These should only be accessed |
| 163 // through the Record/GetXXX() methods. | 167 // through the Record/GetXXX() methods. |
| 164 base::TimeTicks frame_reference_times_[256]; | 168 base::TimeTicks frame_reference_times_[256]; |
| 165 RtpTimestamp frame_rtp_timestamps_[256]; | 169 RtpTimestamp frame_rtp_timestamps_[256]; |
| 166 | 170 |
| 167 // The most recently measured round trip time. | 171 // The most recently measured round trip time. |
| 168 base::TimeDelta current_round_trip_time_; | 172 base::TimeDelta current_round_trip_time_; |
| 169 | 173 |
| 174 // Used to keep track of historic round-trip times. |
| 175 std::deque<base::TimeDelta> recent_round_trip_times_; |
| 176 base::TimeDelta recent_round_trip_times_sum_; |
| 177 |
| 170 // NOTE: Weak pointers must be invalidated before all other member variables. | 178 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 171 base::WeakPtrFactory<FrameSender> weak_factory_; | 179 base::WeakPtrFactory<FrameSender> weak_factory_; |
| 172 | 180 |
| 173 DISALLOW_COPY_AND_ASSIGN(FrameSender); | 181 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
| 174 }; | 182 }; |
| 175 | 183 |
| 176 } // namespace cast | 184 } // namespace cast |
| 177 } // namespace media | 185 } // namespace media |
| 178 | 186 |
| 179 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 187 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
| OLD | NEW |