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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 void SetTargetPlayoutDelay(base::TimeDelta new_target_playout_delay); | 46 void SetTargetPlayoutDelay(base::TimeDelta new_target_playout_delay); |
47 | 47 |
48 base::TimeDelta GetTargetPlayoutDelay() const { | 48 base::TimeDelta GetTargetPlayoutDelay() const { |
49 return target_playout_delay_; | 49 return target_playout_delay_; |
50 } | 50 } |
51 | 51 |
52 // Called by the encoder with the next EncodeFrame to send. | 52 // Called by the encoder with the next EncodeFrame to send. |
53 void SendEncodedFrame(int requested_bitrate_before_encode, | 53 void SendEncodedFrame(int requested_bitrate_before_encode, |
54 scoped_ptr<SenderEncodedFrame> encoded_frame); | 54 scoped_ptr<SenderEncodedFrame> encoded_frame); |
55 | 55 |
56 // Protected for testability. | |
57 void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback); | |
miu
2016/04/15 23:14:39
Instead of making these methods public, consider o
xjz
2016/04/20 01:09:03
Done. Choose #2 for convenience.
| |
58 | |
59 // Called when a Pli message is received. | |
60 void OnReceivedPli(); | |
61 | |
62 void OnMeasuredRoundTripTime(base::TimeDelta rtt); | |
63 | |
56 protected: | 64 protected: |
57 // Returns the number of frames in the encoder's backlog. | 65 // Returns the number of frames in the encoder's backlog. |
58 virtual int GetNumberOfFramesInEncoder() const = 0; | 66 virtual int GetNumberOfFramesInEncoder() const = 0; |
59 | 67 |
60 // Returns the duration of the data in the encoder's backlog plus the duration | 68 // Returns the duration of the data in the encoder's backlog plus the duration |
61 // of sent, unacknowledged frames. | 69 // of sent, unacknowledged frames. |
62 virtual base::TimeDelta GetInFlightMediaDuration() const = 0; | 70 virtual base::TimeDelta GetInFlightMediaDuration() const = 0; |
63 | 71 |
64 protected: | 72 protected: |
65 // Schedule and execute periodic sending of RTCP report. | 73 // Schedule and execute periodic sending of RTCP report. |
66 void ScheduleNextRtcpReport(); | 74 void ScheduleNextRtcpReport(); |
67 void SendRtcpReport(bool schedule_future_reports); | 75 void SendRtcpReport(bool schedule_future_reports); |
68 | 76 |
69 void OnMeasuredRoundTripTime(base::TimeDelta rtt); | |
70 | |
71 const scoped_refptr<CastEnvironment> cast_environment_; | 77 const scoped_refptr<CastEnvironment> cast_environment_; |
72 | 78 |
73 // Sends encoded frames over the configured transport (e.g., UDP). In | 79 // Sends encoded frames over the configured transport (e.g., UDP). In |
74 // Chromium, this could be a proxy that first sends the frames from a renderer | 80 // Chromium, this could be a proxy that first sends the frames from a renderer |
75 // process to the browser process over IPC, with the browser process being | 81 // process to the browser process over IPC, with the browser process being |
76 // responsible for "packetizing" the frames and pushing packets into the | 82 // responsible for "packetizing" the frames and pushing packets into the |
77 // network layer. | 83 // network layer. |
78 CastTransport* const transport_sender_; | 84 CastTransport* const transport_sender_; |
79 | 85 |
80 const uint32_t ssrc_; | 86 const uint32_t ssrc_; |
81 | 87 |
82 protected: | 88 protected: |
83 // Schedule and execute periodic checks for re-sending packets. If no | 89 // Schedule and execute periodic checks for re-sending packets. If no |
84 // acknowledgements have been received for "too long," AudioSender will | 90 // acknowledgements have been received for "too long," AudioSender will |
85 // speculatively re-send certain packets of an unacked frame to kick-start | 91 // speculatively re-send certain packets of an unacked frame to kick-start |
86 // re-transmission. This is a last resort tactic to prevent the session from | 92 // re-transmission. This is a last resort tactic to prevent the session from |
87 // getting stuck after a long outage. | 93 // getting stuck after a long outage. |
88 void ScheduleNextResendCheck(); | 94 void ScheduleNextResendCheck(); |
89 void ResendCheck(); | 95 void ResendCheck(); |
90 void ResendForKickstart(); | 96 void ResendForKickstart(); |
91 | 97 |
92 // Protected for testability. | |
93 void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback); | |
94 | |
95 // Called when a Pli message is received. | |
96 void OnReceivedPli(); | |
97 | |
98 // Returns true if too many frames would be in-flight by encoding and sending | 98 // Returns true if too many frames would be in-flight by encoding and sending |
99 // the next frame having the given |frame_duration|. | 99 // the next frame having the given |frame_duration|. |
100 bool ShouldDropNextFrame(base::TimeDelta frame_duration) const; | 100 bool ShouldDropNextFrame(base::TimeDelta frame_duration) const; |
101 | 101 |
102 // Record or retrieve a recent history of each frame's timestamps. | 102 // Record or retrieve a recent history of each frame's timestamps. |
103 // Warning: If a frame ID too far in the past is requested, the getters will | 103 // Warning: If a frame ID too far in the past is requested, the getters will |
104 // silently succeed but return incorrect values. Be sure to respect | 104 // silently succeed but return incorrect values. Be sure to respect |
105 // media::cast::kMaxUnackedFrames. | 105 // media::cast::kMaxUnackedFrames. |
106 void RecordLatestFrameTimestamps(uint32_t frame_id, | 106 void RecordLatestFrameTimestamps(uint32_t frame_id, |
107 base::TimeTicks reference_time, | 107 base::TimeTicks reference_time, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 // NOTE: Weak pointers must be invalidated before all other member variables. | 192 // NOTE: Weak pointers must be invalidated before all other member variables. |
193 base::WeakPtrFactory<FrameSender> weak_factory_; | 193 base::WeakPtrFactory<FrameSender> weak_factory_; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(FrameSender); | 195 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
196 }; | 196 }; |
197 | 197 |
198 } // namespace cast | 198 } // namespace cast |
199 } // namespace media | 199 } // namespace media |
200 | 200 |
201 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 201 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
OLD | NEW |