| 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> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 namespace transport { | 27 namespace transport { |
| 28 | 28 |
| 29 // This object is only called from the main cast thread. | 29 // This object is only called from the main cast thread. |
| 30 // This class handles splitting encoded audio and video frames into packets and | 30 // This class handles splitting encoded audio and video frames into packets and |
| 31 // add an RTP header to each packet. The sent packets are stored until they are | 31 // add an RTP header to each packet. The sent packets are stored until they are |
| 32 // acknowledged by the remote peer or timed out. | 32 // acknowledged by the remote peer or timed out. |
| 33 class RtpSender : public base::SupportsWeakPtr<RtpSender>{ | 33 class RtpSender { |
| 34 public: | 34 public: |
| 35 RtpSender(base::TickClock* clock, | 35 RtpSender( |
| 36 const CastTransportConfig& config, | 36 base::TickClock* clock, |
| 37 bool is_audio, | 37 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner, |
| 38 const scoped_refptr<base::TaskRunner>& transport_task_runner, | 38 PacedSender* const transport); |
| 39 PacedSender* const transport); | |
| 40 | 39 |
| 41 ~RtpSender(); | 40 ~RtpSender(); |
| 42 | 41 |
| 42 // Initialize audio stack. Audio must be initialized prior to sending encoded |
| 43 // audio frames. |
| 44 void InitializeAudio(const CastTransportAudioConfig& config); |
| 45 |
| 46 // Initialize video stack. Video must be initialized prior to sending encoded |
| 47 // video frames. |
| 48 void InitializeVideo(const CastTransportVideoConfig& config); |
| 49 |
| 43 // The video_frame objects ownership is handled by the main cast thread. | 50 // The video_frame objects ownership is handled by the main cast thread. |
| 44 void IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame, | 51 void IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame, |
| 45 const base::TimeTicks& capture_time); | 52 const base::TimeTicks& capture_time); |
| 46 | 53 |
| 47 // The audio_frame objects ownership is handled by the main cast thread. | 54 // The audio_frame objects ownership is handled by the main cast thread. |
| 48 void IncomingEncodedAudioFrame(const EncodedAudioFrame* audio_frame, | 55 void IncomingEncodedAudioFrame(const EncodedAudioFrame* audio_frame, |
| 49 const base::TimeTicks& recorded_time); | 56 const base::TimeTicks& recorded_time); |
| 50 | 57 |
| 51 void ResendPackets(const MissingFramesAndPacketsMap& missing_packets); | 58 void ResendPackets(const MissingFramesAndPacketsMap& missing_packets); |
| 52 | 59 |
| 53 // Set the callback on which RTP statistics data will be returned. Calling | 60 // Set the callback on which RTP statistics data will be returned. Calling |
| 54 // this function would start a timer that would schedule the callback in | 61 // this function would start a timer that would schedule the callback in |
| 55 // a constant interval. | 62 // a constant interval. |
| 56 void SubscribeRtpStatsCallback(const CastTransportRtpStatistics& callback); | 63 void SubscribeRtpStatsCallback(const CastTransportRtpStatistics& callback); |
| 57 | 64 |
| 58 private: | 65 private: |
| 59 void ScheduleNextStatsReport(); | 66 void ScheduleNextStatsReport(); |
| 60 void RtpStatistics(); | 67 void RtpStatistics(); |
| 61 void UpdateSequenceNumber(Packet* packet); | 68 void UpdateSequenceNumber(Packet* packet); |
| 62 | 69 |
| 70 base::TickClock* clock_; // Not owned by this class. |
| 63 RtpPacketizerConfig config_; | 71 RtpPacketizerConfig config_; |
| 64 scoped_ptr<RtpPacketizer> packetizer_; | 72 scoped_ptr<RtpPacketizer> packetizer_; |
| 65 scoped_ptr<PacketStorage> storage_; | 73 scoped_ptr<PacketStorage> storage_; |
| 66 PacedSender* const transport_; | 74 PacedSender* const transport_; |
| 67 CastTransportRtpStatistics stats_callback_; | 75 CastTransportRtpStatistics stats_callback_; |
| 68 scoped_refptr<base::TaskRunner> transport_task_runner_; | 76 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; |
| 77 |
| 78 base::WeakPtrFactory<RtpSender> weak_factory_; |
| 69 | 79 |
| 70 DISALLOW_COPY_AND_ASSIGN(RtpSender); | 80 DISALLOW_COPY_AND_ASSIGN(RtpSender); |
| 71 }; | 81 }; |
| 72 | 82 |
| 73 } // namespace transport | 83 } // namespace transport |
| 74 } // namespace cast | 84 } // namespace cast |
| 75 } // namespace media | 85 } // namespace media |
| 76 | 86 |
| 77 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ | 87 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_SENDER_H_ |
| OLD | NEW |