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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 protected: | 56 protected: |
57 // Returns the number of frames in the encoder's backlog. | 57 // Returns the number of frames in the encoder's backlog. |
58 virtual int GetNumberOfFramesInEncoder() const = 0; | 58 virtual int GetNumberOfFramesInEncoder() const = 0; |
59 | 59 |
60 // Returns the duration of the data in the encoder's backlog plus the duration | 60 // Returns the duration of the data in the encoder's backlog plus the duration |
61 // of sent, unacknowledged frames. | 61 // of sent, unacknowledged frames. |
62 virtual base::TimeDelta GetInFlightMediaDuration() const = 0; | 62 virtual base::TimeDelta GetInFlightMediaDuration() const = 0; |
63 | 63 |
64 protected: | 64 protected: |
| 65 class RtcpObserver : public SenderRtcpObserver { |
| 66 public: |
| 67 explicit RtcpObserver(base::WeakPtr<FrameSender> frame_sender); |
| 68 ~RtcpObserver() override; |
| 69 |
| 70 void OnCastMessageReceived(const RtcpCastMessage& cast_message) override; |
| 71 void OnRttReceived(base::TimeDelta round_trip_time) override; |
| 72 void OnPliReceived() override; |
| 73 |
| 74 private: |
| 75 const base::WeakPtr<FrameSender> frame_sender_; |
| 76 }; |
65 // Schedule and execute periodic sending of RTCP report. | 77 // Schedule and execute periodic sending of RTCP report. |
66 void ScheduleNextRtcpReport(); | 78 void ScheduleNextRtcpReport(); |
67 void SendRtcpReport(bool schedule_future_reports); | 79 void SendRtcpReport(bool schedule_future_reports); |
68 | 80 |
| 81 // Protected for testability. |
| 82 void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback); |
| 83 |
| 84 // Called when a Pli message is received. |
| 85 void OnReceivedPli(); |
| 86 |
69 void OnMeasuredRoundTripTime(base::TimeDelta rtt); | 87 void OnMeasuredRoundTripTime(base::TimeDelta rtt); |
70 | 88 |
71 const scoped_refptr<CastEnvironment> cast_environment_; | 89 const scoped_refptr<CastEnvironment> cast_environment_; |
72 | 90 |
73 // Sends encoded frames over the configured transport (e.g., UDP). In | 91 // 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 | 92 // 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 | 93 // process to the browser process over IPC, with the browser process being |
76 // responsible for "packetizing" the frames and pushing packets into the | 94 // responsible for "packetizing" the frames and pushing packets into the |
77 // network layer. | 95 // network layer. |
78 CastTransport* const transport_sender_; | 96 CastTransport* const transport_sender_; |
79 | 97 |
80 const uint32_t ssrc_; | 98 const uint32_t ssrc_; |
81 | 99 |
82 protected: | 100 protected: |
83 // Schedule and execute periodic checks for re-sending packets. If no | 101 // Schedule and execute periodic checks for re-sending packets. If no |
84 // acknowledgements have been received for "too long," AudioSender will | 102 // acknowledgements have been received for "too long," AudioSender will |
85 // speculatively re-send certain packets of an unacked frame to kick-start | 103 // 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 | 104 // re-transmission. This is a last resort tactic to prevent the session from |
87 // getting stuck after a long outage. | 105 // getting stuck after a long outage. |
88 void ScheduleNextResendCheck(); | 106 void ScheduleNextResendCheck(); |
89 void ResendCheck(); | 107 void ResendCheck(); |
90 void ResendForKickstart(); | 108 void ResendForKickstart(); |
91 | 109 |
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 | 110 // Returns true if too many frames would be in-flight by encoding and sending |
99 // the next frame having the given |frame_duration|. | 111 // the next frame having the given |frame_duration|. |
100 bool ShouldDropNextFrame(base::TimeDelta frame_duration) const; | 112 bool ShouldDropNextFrame(base::TimeDelta frame_duration) const; |
101 | 113 |
102 // Record or retrieve a recent history of each frame's timestamps. | 114 // 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 | 115 // 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 | 116 // silently succeed but return incorrect values. Be sure to respect |
105 // media::cast::kMaxUnackedFrames. | 117 // media::cast::kMaxUnackedFrames. |
106 void RecordLatestFrameTimestamps(uint32_t frame_id, | 118 void RecordLatestFrameTimestamps(uint32_t frame_id, |
107 base::TimeTicks reference_time, | 119 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. | 204 // NOTE: Weak pointers must be invalidated before all other member variables. |
193 base::WeakPtrFactory<FrameSender> weak_factory_; | 205 base::WeakPtrFactory<FrameSender> weak_factory_; |
194 | 206 |
195 DISALLOW_COPY_AND_ASSIGN(FrameSender); | 207 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
196 }; | 208 }; |
197 | 209 |
198 } // namespace cast | 210 } // namespace cast |
199 } // namespace media | 211 } // namespace media |
200 | 212 |
201 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 213 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
OLD | NEW |