| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This is the main interface for the cast transport sender. It accepts encoded | |
| 6 // frames (both audio and video), encrypts their encoded data, packetizes them | |
| 7 // and feeds them into a transport (e.g., UDP). | |
| 8 | |
| 9 // Construction of the Cast Sender and the Cast Transport Sender should be done | |
| 10 // in the following order: | |
| 11 // 1. Create CastTransportSender. | |
| 12 // 2. Create CastSender (accepts CastTransportSender as an input). | |
| 13 // 3. Call CastTransportSender::SetPacketReceiver to ensure that the packets | |
| 14 // received by the CastTransportSender will be sent to the CastSender. | |
| 15 // Steps 3 can be done interchangeably. | |
| 16 | |
| 17 // Destruction: The CastTransportSender is assumed to be valid as long as the | |
| 18 // CastSender is alive. Therefore the CastSender should be destructed before the | |
| 19 // CastTransportSender. | |
| 20 // This also works when the CastSender acts as a receiver for the RTCP packets | |
| 21 // due to the weak pointers in the ReceivedPacket method in cast_sender_impl.cc. | |
| 22 | |
| 23 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | |
| 24 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | |
| 25 | |
| 26 #include "base/basictypes.h" | |
| 27 #include "base/callback.h" | |
| 28 #include "base/single_thread_task_runner.h" | |
| 29 #include "base/threading/non_thread_safe.h" | |
| 30 #include "base/time/tick_clock.h" | |
| 31 #include "media/cast/logging/logging_defines.h" | |
| 32 #include "media/cast/transport/cast_transport_config.h" | |
| 33 #include "media/cast/transport/cast_transport_defines.h" | |
| 34 | |
| 35 namespace net { | |
| 36 class NetLog; | |
| 37 } // namespace net | |
| 38 | |
| 39 namespace media { | |
| 40 namespace cast { | |
| 41 namespace transport { | |
| 42 | |
| 43 // Following the initialization of either audio or video an initialization | |
| 44 // status will be sent via this callback. | |
| 45 typedef base::Callback<void(CastTransportStatus status)> | |
| 46 CastTransportStatusCallback; | |
| 47 | |
| 48 typedef base::Callback<void(const std::vector<PacketEvent>&)> | |
| 49 BulkRawEventsCallback; | |
| 50 | |
| 51 // The application should only trigger this class from the transport thread. | |
| 52 class CastTransportSender : public base::NonThreadSafe { | |
| 53 public: | |
| 54 static scoped_ptr<CastTransportSender> Create( | |
| 55 net::NetLog* net_log, | |
| 56 base::TickClock* clock, | |
| 57 const net::IPEndPoint& remote_end_point, | |
| 58 const CastTransportStatusCallback& status_callback, | |
| 59 const BulkRawEventsCallback& raw_events_callback, | |
| 60 base::TimeDelta raw_events_callback_interval, | |
| 61 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | |
| 62 | |
| 63 virtual ~CastTransportSender() {} | |
| 64 | |
| 65 // Audio/Video initialization. | |
| 66 // Encoded frames cannot be transmitted until the relevant initialize method | |
| 67 // is called. Usually called by CastSender. | |
| 68 virtual void InitializeAudio(const CastTransportRtpConfig& config) = 0; | |
| 69 virtual void InitializeVideo(const CastTransportRtpConfig& config) = 0; | |
| 70 | |
| 71 // Sets the Cast packet receiver. Should be called after creation on the | |
| 72 // Cast sender. Packets won't be received until this function is called. | |
| 73 virtual void SetPacketReceiver( | |
| 74 const PacketReceiverCallback& packet_receiver) = 0; | |
| 75 | |
| 76 // The following two functions handle the encoded media frames (audio and | |
| 77 // video) to be processed. | |
| 78 // Frames will be encrypted, packetized and transmitted to the network. | |
| 79 virtual void InsertCodedAudioFrame(const EncodedFrame& audio_frame) = 0; | |
| 80 virtual void InsertCodedVideoFrame(const EncodedFrame& video_frame) = 0; | |
| 81 | |
| 82 // Builds an RTCP packet and sends it to the network. | |
| 83 // |ntp_seconds|, |ntp_fraction| and |rtp_timestamp| are used in the | |
| 84 // RTCP Sender Report. | |
| 85 virtual void SendRtcpFromRtpSender(uint32 packet_type_flags, | |
| 86 uint32 ntp_seconds, | |
| 87 uint32 ntp_fraction, | |
| 88 uint32 rtp_timestamp, | |
| 89 const RtcpDlrrReportBlock& dlrr, | |
| 90 uint32 sending_ssrc, | |
| 91 const std::string& c_name) = 0; | |
| 92 | |
| 93 // Retransmission request. | |
| 94 // |missing_packets| includes the list of frames and packets in each | |
| 95 // frame to be re-transmitted. | |
| 96 // If |cancel_rtx_if_not_in_list| is used as an optimization to cancel | |
| 97 // pending re-transmission requests of packets not listed in | |
| 98 // |missing_packets|. If the requested packet(s) were sent recently | |
| 99 // (how long is specified by |dedupe_window|) then this re-transmit | |
| 100 // will be ignored. | |
| 101 virtual void ResendPackets( | |
| 102 bool is_audio, | |
| 103 const MissingFramesAndPacketsMap& missing_packets, | |
| 104 bool cancel_rtx_if_not_in_list, | |
| 105 base::TimeDelta dedupe_window) = 0; | |
| 106 }; | |
| 107 | |
| 108 } // namespace transport | |
| 109 } // namespace cast | |
| 110 } // namespace media | |
| 111 | |
| 112 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | |
| OLD | NEW |