Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / cast / net / rtp / cast_message_builder.h
blob58d8e9a2bc61dc6af5b87c6e0fabf59574255f0d
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
3 // found in the LICENSE file.
5 // Handles NACK list and manages ACK.
7 #ifndef MEDIA_CAST_FRAMER_CAST_MESSAGE_BUILDER_H_
8 #define MEDIA_CAST_FRAMER_CAST_MESSAGE_BUILDER_H_
10 #include <deque>
11 #include <map>
13 #include "media/cast/net/rtcp/rtcp.h"
14 #include "media/cast/net/rtp/rtp_receiver_defines.h"
16 namespace media {
17 namespace cast {
19 class Framer;
20 class RtpPayloadFeedback;
22 typedef std::map<uint32, base::TimeTicks> TimeLastNackMap;
24 class CastMessageBuilder {
25 public:
26 CastMessageBuilder(base::TickClock* clock,
27 RtpPayloadFeedback* incoming_payload_feedback,
28 const Framer* framer,
29 uint32 media_ssrc,
30 bool decoder_faster_than_max_frame_rate,
31 int max_unacked_frames);
32 ~CastMessageBuilder();
34 void CompleteFrameReceived(uint32 frame_id);
35 bool TimeToSendNextCastMessage(base::TimeTicks* time_to_send);
36 void UpdateCastMessage();
37 void Reset();
39 private:
40 bool UpdateAckMessage(uint32 frame_id);
41 void BuildPacketList();
42 bool UpdateCastMessageInternal(RtcpCastMessage* message);
44 base::TickClock* const clock_; // Not owned by this class.
45 RtpPayloadFeedback* const cast_feedback_;
47 // CastMessageBuilder has only const access to the framer.
48 const Framer* const framer_;
49 const uint32 media_ssrc_;
50 const bool decoder_faster_than_max_frame_rate_;
51 const int max_unacked_frames_;
53 RtcpCastMessage cast_msg_;
54 base::TimeTicks last_update_time_;
56 TimeLastNackMap time_last_nacked_map_;
58 bool slowing_down_ack_;
59 bool acked_last_frame_;
60 uint32 last_acked_frame_id_;
61 std::deque<uint32> ack_queue_;
63 DISALLOW_COPY_AND_ASSIGN(CastMessageBuilder);
66 } // namespace cast
67 } // namespace media
69 #endif // MEDIA_CAST_FRAMER_CAST_MESSAGE_BUILDER_H_