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

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

Issue 109413004: Cast:Adding cast_transport_config and cleaning up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updating chrome/renderer Created 6 years, 11 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 | Annotate | Revision Log
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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "base/time/default_tick_clock.h" 15 #include "base/time/default_tick_clock.h"
16 #include "base/time/tick_clock.h" 16 #include "base/time/tick_clock.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "media/cast/cast_config.h" 18 #include "media/cast/cast_config.h" // PacketSender
19 #include "media/cast/cast_environment.h" 19 #include "media/cast/transport/cast_transport_config.h"
20 20
21 namespace media { 21 namespace media {
22 namespace cast { 22 namespace cast {
23 namespace transport { 23 namespace transport {
24 24
25 // We have this pure virtual class to enable mocking. 25 // We have this pure virtual class to enable mocking.
26 class PacedPacketSender { 26 class PacedPacketSender {
27 public: 27 public:
28 // Inform the pacer / sender of the total number of packets. 28 // Inform the pacer / sender of the total number of packets.
29 virtual bool SendPackets(const PacketList& packets) = 0; 29 virtual bool SendPackets(const PacketList& packets) = 0;
30 30
31 virtual bool ResendPackets(const PacketList& packets) = 0; 31 virtual bool ResendPackets(const PacketList& packets) = 0;
32 32
33 virtual bool SendRtcpPacket(const Packet& packet) = 0; 33 virtual bool SendRtcpPacket(const Packet& packet) = 0;
34 34
35 virtual ~PacedPacketSender() {} 35 virtual ~PacedPacketSender() {}
36 }; 36 };
37 37
38 class PacedSender : public PacedPacketSender, 38 class PacedSender : public PacedPacketSender,
39 public base::NonThreadSafe, 39 public base::NonThreadSafe,
40 public base::SupportsWeakPtr<PacedSender> { 40 public base::SupportsWeakPtr<PacedSender> {
41 public: 41 public:
42 PacedSender(scoped_refptr<CastEnvironment> cast_environment, 42 PacedSender(base::TickClock* clock,
43 PacketSender* transport); 43 PacketSender* transport,
44 scoped_refptr<base::TaskRunner> transport_thread);
44 virtual ~PacedSender(); 45 virtual ~PacedSender();
45 46
46 virtual bool SendPackets(const PacketList& packets) OVERRIDE; 47 virtual bool SendPackets(const PacketList& packets) OVERRIDE;
47 48
48 virtual bool ResendPackets(const PacketList& packets) OVERRIDE; 49 virtual bool ResendPackets(const PacketList& packets) OVERRIDE;
49 50
50 virtual bool SendRtcpPacket(const Packet& packet) OVERRIDE; 51 virtual bool SendRtcpPacket(const Packet& packet) OVERRIDE;
51 52
52 protected: 53 protected:
53 // Schedule a delayed task on the main cast thread when it's time to send the 54 // Schedule a delayed task on the main cast thread when it's time to send the
54 // next packet burst. 55 // next packet burst.
55 void ScheduleNextSend(); 56 void ScheduleNextSend();
56 57
57 // Process any pending packets in the queue(s). 58 // Process any pending packets in the queue(s).
58 void SendNextPacketBurst(); 59 void SendNextPacketBurst();
59 60
60 private: 61 private:
61 bool SendPacketsToTransport(const PacketList& packets, 62 bool SendPacketsToTransport(const PacketList& packets,
62 PacketList* packets_not_sent); 63 PacketList* packets_not_sent);
63 void SendStoredPackets(); 64 void SendStoredPackets();
64 void UpdateBurstSize(size_t num_of_packets); 65 void UpdateBurstSize(size_t num_of_packets);
65 66
66 scoped_refptr<CastEnvironment> cast_environment_; 67 // Not owned by this class.
68 base::TickClock* const clock_;
67 PacketSender* transport_; 69 PacketSender* transport_;
70 scoped_refptr<base::TaskRunner> transport_thread_;
scherkus (not reviewing) 2014/01/07 01:54:13 nit: this should be transport_task_runner_ (or sim
mikhal1 2014/01/07 16:20:20 Changed here and elsewhere. On 2014/01/07 01:54:13
68 71
69 size_t burst_size_; 72 size_t burst_size_;
70 size_t packets_sent_in_burst_; 73 size_t packets_sent_in_burst_;
71 base::TimeTicks time_last_process_; 74 base::TimeTicks time_last_process_;
72 // Note: We can't combine the |packet_list_| and the |resend_packet_list_| 75 // Note: We can't combine the |packet_list_| and the |resend_packet_list_|
73 // since then we might get reordering of the retransmitted packets. 76 // since then we might get reordering of the retransmitted packets.
74 PacketList packet_list_; 77 PacketList packet_list_;
75 PacketList resend_packet_list_; 78 PacketList resend_packet_list_;
76 79
77 base::WeakPtrFactory<PacedSender> weak_factory_; 80 base::WeakPtrFactory<PacedSender> weak_factory_;
78 81
79 DISALLOW_COPY_AND_ASSIGN(PacedSender); 82 DISALLOW_COPY_AND_ASSIGN(PacedSender);
80 }; 83 };
81 84
82 } // namespace transport 85 } // namespace transport
83 } // namespace cast 86 } // namespace cast
84 } // namespace media 87 } // namespace media
85 88
86 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_ 89 #endif // MEDIA_CAST_TRANSPORT_PACING_PACED_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698