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

Side by Side Diff: media/cast/transport/pacing/paced_sender.h

Issue 131233007: Cast: Clean up injection of transport into PacedPacketSender (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merged Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ 5 #ifndef MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_
6 #define MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ 6 #define MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 33
34 virtual bool SendRtcpPacket(const Packet& packet) = 0; 34 virtual bool SendRtcpPacket(const Packet& packet) = 0;
35 35
36 virtual ~PacedPacketSender() {} 36 virtual ~PacedPacketSender() {}
37 }; 37 };
38 38
39 class PacedSender : public PacedPacketSender, 39 class PacedSender : public PacedPacketSender,
40 public base::NonThreadSafe, 40 public base::NonThreadSafe,
41 public base::SupportsWeakPtr<PacedSender> { 41 public base::SupportsWeakPtr<PacedSender> {
42 public: 42 public:
43 // The |external_transport| should only be used by the Cast receiver and for
44 // testing.
45 PacedSender(base::TickClock* clock, 43 PacedSender(base::TickClock* clock,
46 const CastTransportConfig* const config, 44 PacketSender* transport,
47 PacketSender* external_transport, 45 const scoped_refptr<base::TaskRunner>& transport_task_runner);
48 const scoped_refptr<base::TaskRunner>& transport_task_runner,
49 const CastTransportStatusCallback& status_callback);
50 46
51 virtual ~PacedSender(); 47 virtual ~PacedSender();
52 48
53 // PacedPacketSender implementation. 49 // PacedPacketSender implementation.
54 virtual void SetPacketReceiver(const PacketReceiverCallback& packet_receiver);
55
56 virtual bool SendPackets(const PacketList& packets) OVERRIDE; 50 virtual bool SendPackets(const PacketList& packets) OVERRIDE;
57 51
58 virtual bool ResendPackets(const PacketList& packets) OVERRIDE; 52 virtual bool ResendPackets(const PacketList& packets) OVERRIDE;
59 53
60 virtual bool SendRtcpPacket(const Packet& packet) OVERRIDE; 54 virtual bool SendRtcpPacket(const Packet& packet) OVERRIDE;
61 55
62 void InsertFakeTransportForTesting(PacketSender* fake_transport);
63
64 protected: 56 protected:
65 // Schedule a delayed task on the main cast thread when it's time to send the 57 // Schedule a delayed task on the main cast thread when it's time to send the
66 // next packet burst. 58 // next packet burst.
67 void ScheduleNextSend(); 59 void ScheduleNextSend();
68 60
69 // Process any pending packets in the queue(s). 61 // Process any pending packets in the queue(s).
70 void SendNextPacketBurst(); 62 void SendNextPacketBurst();
71 63
72 private: 64 private:
73 bool SendPacketsToTransport(const PacketList& packets, 65 bool SendPacketsToTransport(const PacketList& packets,
74 PacketList* packets_not_sent); 66 PacketList* packets_not_sent);
75 67
76 // Actually sends the packets to the transport. When set, packets will be sent 68 // Actually sends the packets to the transport.
77 // to the external transport.
78 bool TransmitPackets(const PacketList& packets); 69 bool TransmitPackets(const PacketList& packets);
79 void SendStoredPackets(); 70 void SendStoredPackets();
80 void UpdateBurstSize(size_t num_of_packets); 71 void UpdateBurstSize(size_t num_of_packets);
81 72
82 // Not owned by this class. 73 // Not owned by this class.
83 base::TickClock* const clock_; 74 base::TickClock* const clock_;
84 scoped_ptr<UdpTransport> transport_; 75 PacketSender* transport_; // Not owned by this class.
85 PacketSender* external_transport_; // Not owned by this class.
86 const CastTransportConfig* const config_; // Not owned by this class.
87 scoped_refptr<base::TaskRunner> transport_task_runner_; 76 scoped_refptr<base::TaskRunner> transport_task_runner_;
88 77
89 size_t burst_size_; 78 size_t burst_size_;
90 size_t packets_sent_in_burst_; 79 size_t packets_sent_in_burst_;
91 base::TimeTicks time_last_process_; 80 base::TimeTicks time_last_process_;
92 // Note: We can't combine the |packet_list_| and the |resend_packet_list_| 81 // Note: We can't combine the |packet_list_| and the |resend_packet_list_|
93 // since then we might get reordering of the retransmitted packets. 82 // since then we might get reordering of the retransmitted packets.
94 PacketList packet_list_; 83 PacketList packet_list_;
95 PacketList resend_packet_list_; 84 PacketList resend_packet_list_;
96 85
97 base::WeakPtrFactory<PacedSender> weak_factory_; 86 base::WeakPtrFactory<PacedSender> weak_factory_;
98 87
99 DISALLOW_COPY_AND_ASSIGN(PacedSender); 88 DISALLOW_COPY_AND_ASSIGN(PacedSender);
100 }; 89 };
101 90
102 } // namespace transport 91 } // namespace transport
103 } // namespace cast 92 } // namespace cast
104 } // namespace media 93 } // namespace media
105 94
106 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ 95 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_
OLDNEW
« no previous file with comments | « media/cast/transport/cast_transport_sender_impl.cc ('k') | media/cast/transport/pacing/paced_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698