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: |
(...skipping 10 matching lines...) Expand all Loading... |
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 "media/cast/logging/logging_defines.h" | 28 #include "media/cast/logging/logging_defines.h" |
29 #include "media/cast/net/cast_transport_config.h" | 29 #include "media/cast/net/cast_transport_config.h" |
30 #include "media/cast/net/cast_transport_defines.h" | 30 #include "media/cast/net/cast_transport_defines.h" |
| 31 #include "media/cast/net/pacing/paced_sender.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 { |
45 struct RtpReceiverStatistics; | 46 struct RtpReceiverStatistics; |
46 struct RtcpTimeData; | 47 struct RtcpTimeData; |
47 | 48 |
48 // Following the initialization of either audio or video an initialization | 49 // Following the initialization of either audio or video an initialization |
49 // status will be sent via this callback. | 50 // status will be sent via this callback. |
50 typedef base::Callback<void(CastTransportStatus status)> | 51 typedef base::Callback<void(CastTransportStatus status)> |
51 CastTransportStatusCallback; | 52 CastTransportStatusCallback; |
52 | 53 |
53 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, | 54 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, |
54 scoped_ptr<std::vector<PacketEvent>>)> | 55 scoped_ptr<std::vector<PacketEvent>>)> |
55 BulkRawEventsCallback; | 56 BulkRawEventsCallback; |
56 | 57 |
57 // The application should only trigger this class from the transport thread. | 58 // The application should only trigger this class from the transport thread. |
58 class CastTransportSender : public base::NonThreadSafe { | 59 class CastTransportSender : public base::NonThreadSafe { |
59 public: | 60 public: |
| 61 // Interface used for receiving status updates, raw events, and RTP packets |
| 62 // from CastTransportSender. |
| 63 class Client { |
| 64 public: |
| 65 virtual ~Client(){}; |
| 66 // Audio and Video transport status change is reported on this callback. |
| 67 virtual void OnStatusChanged(CastTransportStatus status) = 0; |
| 68 |
| 69 // Raw events will be invoked on this callback periodically, according to |
| 70 // the configured logging flush interval passed to |
| 71 // CastTransportSender::Create(). |
| 72 virtual void OnLoggingEventsReceived( |
| 73 scoped_ptr<std::vector<FrameEvent>> frame_events, |
| 74 scoped_ptr<std::vector<PacketEvent>> packet_events) = 0; |
| 75 |
| 76 // Called to pass RTP packets to the Client. |
| 77 virtual void ProcessRtpPacket(scoped_ptr<Packet> packet) = 0; |
| 78 }; |
| 79 |
60 static scoped_ptr<CastTransportSender> Create( | 80 static scoped_ptr<CastTransportSender> Create( |
61 net::NetLog* net_log, | 81 base::TickClock* clock, // Owned by the caller. |
62 base::TickClock* clock, | 82 base::TimeDelta logging_flush_interval, |
63 const net::IPEndPoint& local_end_point, | 83 scoped_ptr<Client> client, |
64 const net::IPEndPoint& remote_end_point, | 84 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); | 85 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); |
71 | 86 |
72 virtual ~CastTransportSender() {} | 87 virtual ~CastTransportSender() {} |
73 | 88 |
74 // Audio/Video initialization. | 89 // Audio/Video initialization. |
75 // Encoded frames cannot be transmitted until the relevant initialize method | 90 // Encoded frames cannot be transmitted until the relevant initialize method |
76 // is called. | 91 // is called. |
77 virtual void InitializeAudio(const CastTransportRtpConfig& config, | 92 virtual void InitializeAudio(const CastTransportRtpConfig& config, |
78 const RtcpCastMessageCallback& cast_message_cb, | 93 const RtcpCastMessageCallback& cast_message_cb, |
79 const RtcpRttCallback& rtt_cb) = 0; | 94 const RtcpRttCallback& rtt_cb) = 0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 130 |
116 // Send an RTCP message from receiver to sender. | 131 // Send an RTCP message from receiver to sender. |
117 virtual void SendRtcpFromRtpReceiver( | 132 virtual void SendRtcpFromRtpReceiver( |
118 uint32_t ssrc, | 133 uint32_t ssrc, |
119 uint32_t sender_ssrc, | 134 uint32_t sender_ssrc, |
120 const RtcpTimeData& time_data, | 135 const RtcpTimeData& time_data, |
121 const RtcpCastMessage* cast_message, | 136 const RtcpCastMessage* cast_message, |
122 base::TimeDelta target_delay, | 137 base::TimeDelta target_delay, |
123 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, | 138 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, |
124 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; | 139 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; |
| 140 |
| 141 // Set |target_burst_size| and |max_target_burst_size| for PacedSender. |
| 142 virtual PacedSender* GetPacedSender() = 0; |
| 143 |
| 144 virtual void SetWifiOptions(int wifi_options) = 0; |
125 }; | 145 }; |
126 | 146 |
127 } // namespace cast | 147 } // namespace cast |
128 } // namespace media | 148 } // namespace media |
129 | 149 |
130 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ | 150 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ |
OLD | NEW |