| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 is the main interface for the cast transport sender. It accepts encoded | 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 | 6 // frames (both audio and video), encrypts their encoded data, packetizes them |
| 7 // and feeds them into a transport (e.g., UDP). | 7 // and feeds them into a transport (e.g., UDP). |
| 8 | 8 |
| 9 // Construction of the Cast Sender and the Cast Transport Sender should be done | 9 // Construction of the Cast Sender and the Cast Transport Sender should be done |
| 10 // in the following order: | 10 // in the following order: |
| 11 // 1. Create CastTransportSender. | 11 // 1. Create CastTransportSender. |
| 12 // 2. Create CastSender (accepts CastTransportSender as an input). | 12 // 2. Create CastSender (accepts CastTransportSender as an input). |
| 13 | 13 |
| 14 // Destruction: The CastTransportSender is assumed to be valid as long as the | 14 // Destruction: The CastTransportSender is assumed to be valid as long as the |
| 15 // CastSender is alive. Therefore the CastSender should be destructed before the | 15 // CastSender is alive. Therefore the CastSender should be destructed before the |
| 16 // CastTransportSender. | 16 // CastTransportSender. |
| 17 | 17 |
| 18 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ | 18 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ |
| 19 #define MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ | 19 #define MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ |
| 20 | 20 |
| 21 #include <stdint.h> | 21 #include <stdint.h> |
| 22 | 22 |
| 23 #include "base/callback.h" | 23 #include "base/callback.h" |
| 24 #include "base/memory/scoped_ptr.h" | 24 #include "base/memory/scoped_ptr.h" |
| 25 #include "base/single_thread_task_runner.h" | 25 #include "base/single_thread_task_runner.h" |
| 26 #include "base/threading/non_thread_safe.h" | 26 #include "base/threading/non_thread_safe.h" |
| 27 #include "base/time/tick_clock.h" | 27 #include "base/time/tick_clock.h" |
| 28 #include "base/values.h" |
| 28 #include "media/cast/logging/logging_defines.h" | 29 #include "media/cast/logging/logging_defines.h" |
| 29 #include "media/cast/net/cast_transport_config.h" | 30 #include "media/cast/net/cast_transport_config.h" |
| 30 #include "media/cast/net/cast_transport_defines.h" | 31 #include "media/cast/net/cast_transport_defines.h" |
| 31 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" | 32 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" |
| 32 #include "media/cast/net/rtcp/rtcp_defines.h" | 33 #include "media/cast/net/rtcp/rtcp_defines.h" |
| 33 #include "net/base/ip_endpoint.h" | 34 #include "net/base/ip_endpoint.h" |
| 34 | 35 |
| 35 namespace base { | 36 namespace base { |
| 36 class DictionaryValue; | 37 class DictionaryValue; |
| 37 } // namespace base | 38 } // namespace base |
| 38 | 39 |
| 39 namespace net { | 40 namespace net { |
| 40 class NetLog; | 41 class NetLog; |
| 41 } // namespace net | 42 } // namespace net |
| 42 | 43 |
| 43 namespace media { | 44 namespace media { |
| 44 namespace cast { | 45 namespace cast { |
| 46 |
| 45 struct RtpReceiverStatistics; | 47 struct RtpReceiverStatistics; |
| 46 struct RtcpTimeData; | 48 struct RtcpTimeData; |
| 47 | 49 |
| 48 // Following the initialization of either audio or video an initialization | 50 // Following the initialization of either audio or video an initialization |
| 49 // status will be sent via this callback. | 51 // status will be sent via this callback. |
| 50 typedef base::Callback<void(CastTransportStatus status)> | 52 typedef base::Callback<void(CastTransportStatus status)> |
| 51 CastTransportStatusCallback; | 53 CastTransportStatusCallback; |
| 52 | 54 |
| 53 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, | 55 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, |
| 54 scoped_ptr<std::vector<PacketEvent>>)> | 56 scoped_ptr<std::vector<PacketEvent>>)> |
| 55 BulkRawEventsCallback; | 57 BulkRawEventsCallback; |
| 56 | 58 |
| 59 // TODO(xjz): Rename CastTransportSender as it also deals with receiving |
| 60 // packets. http://crbug.com/589157. |
| 57 // The application should only trigger this class from the transport thread. | 61 // The application should only trigger this class from the transport thread. |
| 58 class CastTransportSender : public base::NonThreadSafe { | 62 class CastTransportSender : public base::NonThreadSafe { |
| 59 public: | 63 public: |
| 64 // Interface used for receiving status updates, raw events, and RTP packets |
| 65 // from CastTransportSender. |
| 66 class Client { |
| 67 public: |
| 68 virtual ~Client(){}; |
| 69 |
| 70 // Audio and Video transport status change is reported on this callback. |
| 71 virtual void OnStatusChanged(CastTransportStatus status) = 0; |
| 72 |
| 73 // Raw events will be invoked on this callback periodically, according to |
| 74 // the configured logging flush interval passed to |
| 75 // CastTransportSender::Create(). |
| 76 virtual void OnLoggingEventsReceived( |
| 77 scoped_ptr<std::vector<FrameEvent>> frame_events, |
| 78 scoped_ptr<std::vector<PacketEvent>> packet_events) = 0; |
| 79 |
| 80 // Called to pass RTP packets to the Client. |
| 81 virtual void ProcessRtpPacket(scoped_ptr<Packet> packet) = 0; |
| 82 }; |
| 83 |
| 60 static scoped_ptr<CastTransportSender> Create( | 84 static scoped_ptr<CastTransportSender> Create( |
| 61 net::NetLog* net_log, | 85 base::TickClock* clock, // Owned by the caller. |
| 62 base::TickClock* clock, | 86 base::TimeDelta logging_flush_interval, |
| 63 const net::IPEndPoint& local_end_point, | 87 scoped_ptr<Client> client, |
| 64 const net::IPEndPoint& remote_end_point, | 88 scoped_ptr<PacketSender> transport, |
| 65 scoped_ptr<base::DictionaryValue> options, | |
| 66 const CastTransportStatusCallback& status_callback, | |
| 67 const BulkRawEventsCallback& raw_events_callback, | |
| 68 base::TimeDelta raw_events_callback_interval, | |
| 69 const PacketReceiverCallback& packet_callback, | |
| 70 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | 89 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); |
| 71 | 90 |
| 72 virtual ~CastTransportSender() {} | 91 virtual ~CastTransportSender() {} |
| 73 | 92 |
| 74 // Audio/Video initialization. | 93 // Audio/Video initialization. |
| 75 // Encoded frames cannot be transmitted until the relevant initialize method | 94 // Encoded frames cannot be transmitted until the relevant initialize method |
| 76 // is called. | 95 // is called. |
| 77 virtual void InitializeAudio(const CastTransportRtpConfig& config, | 96 virtual void InitializeAudio(const CastTransportRtpConfig& config, |
| 78 const RtcpCastMessageCallback& cast_message_cb, | 97 const RtcpCastMessageCallback& cast_message_cb, |
| 79 const RtcpRttCallback& rtt_cb) = 0; | 98 const RtcpRttCallback& rtt_cb) = 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 134 |
| 116 // Send an RTCP message from receiver to sender. | 135 // Send an RTCP message from receiver to sender. |
| 117 virtual void SendRtcpFromRtpReceiver( | 136 virtual void SendRtcpFromRtpReceiver( |
| 118 uint32_t ssrc, | 137 uint32_t ssrc, |
| 119 uint32_t sender_ssrc, | 138 uint32_t sender_ssrc, |
| 120 const RtcpTimeData& time_data, | 139 const RtcpTimeData& time_data, |
| 121 const RtcpCastMessage* cast_message, | 140 const RtcpCastMessage* cast_message, |
| 122 base::TimeDelta target_delay, | 141 base::TimeDelta target_delay, |
| 123 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, | 142 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, |
| 124 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; | 143 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; |
| 144 |
| 145 // Set options for the PacedSender and Wifi. |
| 146 virtual void SetOptions(const base::DictionaryValue& options) = 0; |
| 125 }; | 147 }; |
| 126 | 148 |
| 127 } // namespace cast | 149 } // namespace cast |
| 128 } // namespace media | 150 } // namespace media |
| 129 | 151 |
| 130 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ | 152 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ |
| OLD | NEW |