| OLD | NEW |
| 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 // This file contains the interface to the cast RTP sender. | 5 // This file contains the interface to the cast RTP sender. |
| 6 | 6 |
| 7 #ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ | 7 #ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ |
| 8 #define MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ | 8 #define MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/time/tick_clock.h" | 14 #include "base/time/tick_clock.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "media/cast/cast_config.h" | 17 #include "media/cast/cast_config.h" |
| 18 #include "media/cast/cast_environment.h" | 18 #include "media/cast/cast_environment.h" |
| 19 #include "media/cast/transport/cast_transport_defines.h" | 19 #include "media/cast/transport/cast_transport_defines.h" |
| 20 #include "media/cast/transport/cast_transport_sender.h" | 20 #include "media/cast/transport/cast_transport_sender.h" |
| 21 #include "media/cast/transport/pacing/paced_sender.h" | 21 #include "media/cast/transport/pacing/paced_sender.h" |
| 22 #include "media/cast/transport/rtp_sender/packet_storage/packet_storage.h" | 22 #include "media/cast/transport/rtp_sender/packet_storage/packet_storage.h" |
| 23 #include "media/cast/transport/rtp_sender/rtp_packetizer/rtp_packetizer.h" | 23 #include "media/cast/transport/rtp_sender/rtp_packetizer/rtp_packetizer.h" |
| 24 | 24 |
| 25 namespace media { | 25 namespace media { |
| 26 namespace cast { | 26 namespace cast { |
| 27 | 27 |
| 28 class LoggingImpl; | |
| 29 | |
| 30 namespace transport { | 28 namespace transport { |
| 31 | 29 |
| 32 // This object is only called from the main cast thread. | 30 // This object is only called from the main cast thread. |
| 33 // This class handles splitting encoded audio and video frames into packets and | 31 // This class handles splitting encoded audio and video frames into packets and |
| 34 // add an RTP header to each packet. The sent packets are stored until they are | 32 // add an RTP header to each packet. The sent packets are stored until they are |
| 35 // acknowledged by the remote peer or timed out. | 33 // acknowledged by the remote peer or timed out. |
| 36 class RtpSender { | 34 class RtpSender { |
| 37 public: | 35 public: |
| 38 RtpSender( | 36 RtpSender( |
| 39 base::TickClock* clock, | 37 base::TickClock* clock, |
| 40 LoggingImpl* logging, | |
| 41 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner, | 38 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner, |
| 42 PacedSender* const transport); | 39 PacedSender* const transport); |
| 43 | 40 |
| 44 ~RtpSender(); | 41 ~RtpSender(); |
| 45 | 42 |
| 46 // Initialize audio stack. Audio must be initialized prior to sending encoded | 43 // Initialize audio stack. Audio must be initialized prior to sending encoded |
| 47 // audio frames. | 44 // audio frames. |
| 48 void InitializeAudio(const CastTransportAudioConfig& config); | 45 void InitializeAudio(const CastTransportAudioConfig& config); |
| 49 | 46 |
| 50 // Initialize video stack. Video must be initialized prior to sending encoded | 47 // Initialize video stack. Video must be initialized prior to sending encoded |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 // this function would start a timer that would schedule the callback in | 62 // this function would start a timer that would schedule the callback in |
| 66 // a constant interval. | 63 // a constant interval. |
| 67 void SubscribeRtpStatsCallback(const CastTransportRtpStatistics& callback); | 64 void SubscribeRtpStatsCallback(const CastTransportRtpStatistics& callback); |
| 68 | 65 |
| 69 private: | 66 private: |
| 70 void ScheduleNextStatsReport(); | 67 void ScheduleNextStatsReport(); |
| 71 void RtpStatistics(); | 68 void RtpStatistics(); |
| 72 void UpdateSequenceNumber(Packet* packet); | 69 void UpdateSequenceNumber(Packet* packet); |
| 73 | 70 |
| 74 base::TickClock* clock_; // Not owned by this class. | 71 base::TickClock* clock_; // Not owned by this class. |
| 75 LoggingImpl* logging_; // Not owned by this class. | |
| 76 RtpPacketizerConfig config_; | 72 RtpPacketizerConfig config_; |
| 77 scoped_ptr<RtpPacketizer> packetizer_; | 73 scoped_ptr<RtpPacketizer> packetizer_; |
| 78 scoped_ptr<PacketStorage> storage_; | 74 scoped_ptr<PacketStorage> storage_; |
| 79 PacedSender* const transport_; | 75 PacedSender* const transport_; |
| 80 CastTransportRtpStatistics stats_callback_; | 76 CastTransportRtpStatistics stats_callback_; |
| 81 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; | 77 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; |
| 82 | 78 |
| 83 // NOTE: Weak pointers must be invalidated before all other member variables. | 79 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 84 base::WeakPtrFactory<RtpSender> weak_factory_; | 80 base::WeakPtrFactory<RtpSender> weak_factory_; |
| 85 | 81 |
| 86 DISALLOW_COPY_AND_ASSIGN(RtpSender); | 82 DISALLOW_COPY_AND_ASSIGN(RtpSender); |
| 87 }; | 83 }; |
| 88 | 84 |
| 89 } // namespace transport | 85 } // namespace transport |
| 90 } // namespace cast | 86 } // namespace cast |
| 91 } // namespace media | 87 } // namespace media |
| 92 | 88 |
| 93 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ | 89 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ |
| OLD | NEW |