OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Accumulates frames for the next packet until more frames no longer fit or | 5 // Accumulates frames for the next packet until more frames no longer fit or |
6 // it's time to create a packet from them. Also provides packet creation of | 6 // it's time to create a packet from them. Also provides packet creation of |
7 // FEC packets based on previously created packets. | 7 // FEC packets based on previously created packets. |
8 | 8 |
9 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_ | 9 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_ |
10 #define NET_QUIC_QUIC_PACKET_CREATOR_H_ | 10 #define NET_QUIC_QUIC_PACKET_CREATOR_H_ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 QuicFramer* framer, | 50 QuicFramer* framer, |
51 QuicRandom* random_generator, | 51 QuicRandom* random_generator, |
52 bool is_server); | 52 bool is_server); |
53 | 53 |
54 virtual ~QuicPacketCreator(); | 54 virtual ~QuicPacketCreator(); |
55 | 55 |
56 // QuicFecBuilderInterface | 56 // QuicFecBuilderInterface |
57 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header, | 57 virtual void OnBuiltFecProtectedPayload(const QuicPacketHeader& header, |
58 base::StringPiece payload) OVERRIDE; | 58 base::StringPiece payload) OVERRIDE; |
59 | 59 |
60 // Turn on FEC protection for subsequently created packets. FEC should | 60 // Turn on FEC protection for subsequently created packets. FEC should be |
61 // be enabled first (set_max_packets_per_fec_group should be non-zero) for | 61 // enabled first (max_packets_per_fec_group should be non-zero) for FEC |
62 // FEC protection to start. | 62 // protection to start. |
63 void StartFecProtectingPackets(); | 63 void StartFecProtectingPackets(); |
64 | 64 |
65 // Turn off FEC protection for subsequently created packets. If the creator | 65 // Turn off FEC protection for subsequently created packets. If the creator |
66 // has any open fec group, call will fail. It is the caller's responsibility | 66 // has any open fec group, call will fail. It is the caller's responsibility |
67 // to flush out FEC packets in generation, and to verify with ShouldSendFec() | 67 // to flush out FEC packets in generation, and to verify with ShouldSendFec() |
68 // that there is no open FEC group. | 68 // that there is no open FEC group. |
69 void StopFecProtectingPackets(); | 69 void StopFecProtectingPackets(); |
70 | 70 |
71 // Checks if it's time to send an FEC packet. |force_close| forces this to | 71 // Checks if it's time to send an FEC packet. |force_close| forces this to |
72 // return true if an fec group is open. | 72 // return true if an fec group is open. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 QuicFrame* frame); | 119 QuicFrame* frame); |
120 | 120 |
121 // Serializes all frames into a single packet. All frames must fit into a | 121 // Serializes all frames into a single packet. All frames must fit into a |
122 // single packet. Also, sets the entropy hash of the serialized packet to a | 122 // single packet. Also, sets the entropy hash of the serialized packet to a |
123 // random bool and returns that value as a member of SerializedPacket. | 123 // random bool and returns that value as a member of SerializedPacket. |
124 // Never returns a RetransmittableFrames in SerializedPacket. | 124 // Never returns a RetransmittableFrames in SerializedPacket. |
125 SerializedPacket SerializeAllFrames(const QuicFrames& frames); | 125 SerializedPacket SerializeAllFrames(const QuicFrames& frames); |
126 | 126 |
127 // Re-serializes frames with the original packet's sequence number length. | 127 // Re-serializes frames with the original packet's sequence number length. |
128 // Used for retransmitting packets to ensure they aren't too long. | 128 // Used for retransmitting packets to ensure they aren't too long. |
129 // Caller must ensure that any open FEC group are closed before calling this | 129 // Caller must ensure that any open FEC group is closed before calling this |
130 // method. | 130 // method. |
131 SerializedPacket ReserializeAllFrames( | 131 SerializedPacket ReserializeAllFrames( |
132 const QuicFrames& frames, QuicSequenceNumberLength original_length); | 132 const QuicFrames& frames, QuicSequenceNumberLength original_length); |
133 | 133 |
134 // Returns true if there are frames pending to be serialized. | 134 // Returns true if there are frames pending to be serialized. |
135 bool HasPendingFrames(); | 135 bool HasPendingFrames(); |
136 | 136 |
137 // Returns whether FEC protection is currently enabled. Note: Enabled does not | 137 // Returns whether FEC protection is currently enabled. Note: Enabled does not |
138 // mean that an FEC group is currently active; i.e., IsFecProtected() may | 138 // mean that an FEC group is currently active; i.e., IsFecProtected() may |
139 // still return NOT_IN_FEC_GROUP, and fec_group_.get() may still be NULL. | 139 // still return false. |
140 bool IsFecEnabled() const; | 140 bool IsFecEnabled() const; |
141 | 141 |
142 // Returns true if subsequent packets will be FEC protected. Note: True does | 142 // Returns true if subsequent packets will be FEC protected. Note: True does |
143 // not mean that an FEC packet is currently under construction; i.e., | 143 // not mean that an FEC packet is currently under construction; i.e., |
144 // fec_group_.get() may still be NULL, until MaybeStartFec() is called. | 144 // fec_group_.get() may still be NULL, until MaybeStartFec() is called. |
145 bool IsFecProtected() const; | 145 bool IsFecProtected() const; |
146 | 146 |
147 // Returns the number of bytes which are available to be used by additional | 147 // Returns the number of bytes which are available to be used by additional |
148 // frames in the packet. Since stream frames are slightly smaller when they | 148 // frames in the packet. Since stream frames are slightly smaller when they |
149 // are the last frame in a packet, this method will return a different | 149 // are the last frame in a packet, this method will return a different |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 mutable size_t packet_size_; | 262 mutable size_t packet_size_; |
263 QuicFrames queued_frames_; | 263 QuicFrames queued_frames_; |
264 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; | 264 scoped_ptr<RetransmittableFrames> queued_retransmittable_frames_; |
265 | 265 |
266 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); | 266 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); |
267 }; | 267 }; |
268 | 268 |
269 } // namespace net | 269 } // namespace net |
270 | 270 |
271 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ | 271 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ |
OLD | NEW |