Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: media/cast/sender/frame_sender.h

Issue 1878883003: Refactor: simplify interface of SenderRtcpSession and CastTransport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/sender/audio_sender.cc ('k') | media/cast/sender/frame_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 RtcpClient : public RtcpObserver {
66 public:
67 explicit RtcpClient(base::WeakPtr<FrameSender> frame_sender);
68 ~RtcpClient() override;
69
70 void OnReceivedCastMessage(const RtcpCastMessage& cast_message) override;
71 void OnReceivedRtt(base::TimeDelta round_trip_time) override;
72 void OnReceivedPli() 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(FrameId frame_id, 118 void RecordLatestFrameTimestamps(FrameId frame_id,
107 base::TimeTicks reference_time, 119 base::TimeTicks reference_time,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // NOTE: Weak pointers must be invalidated before all other member variables. 203 // NOTE: Weak pointers must be invalidated before all other member variables.
192 base::WeakPtrFactory<FrameSender> weak_factory_; 204 base::WeakPtrFactory<FrameSender> weak_factory_;
193 205
194 DISALLOW_COPY_AND_ASSIGN(FrameSender); 206 DISALLOW_COPY_AND_ASSIGN(FrameSender);
195 }; 207 };
196 208
197 } // namespace cast 209 } // namespace cast
198 } // namespace media 210 } // namespace media
199 211
200 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ 212 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_
OLDNEW
« no previous file with comments | « media/cast/sender/audio_sender.cc ('k') | media/cast/sender/frame_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698