Chromium Code Reviews| 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 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 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. | |
|
miu
2016/02/22 22:38:48
nit: Add newline above this line.
xjz
2016/02/23 21:51:46
Done.
| |
| 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 options for the PacedSender and Wifi. | |
| 142 // Possible keys are: | |
|
miu
2016/02/22 22:38:48
nit: I'd suggest moving lines 142-153 to cast_tran
xjz
2016/02/23 21:51:46
Done.
| |
| 143 // "pacer_target_burst_size": int | |
| 144 // - Specifies how many packets to send per 10 ms ideally. | |
| 145 // "pacer_max_burst_size": int | |
| 146 // - Specifies how many pakcets to send per 10 ms, maximum. | |
| 147 // "send_buffer_min_size": int | |
| 148 // - Specifies the minimum socket send buffer size. | |
| 149 // "disable_wifi_scan" (value ignored) | |
| 150 // - Disable wifi scans while streaming. | |
| 151 // "media_streaming_mode" (value ignored) | |
| 152 // - Turn media streaming mode on. | |
| 153 // Note, these options may be ignored on some platforms. | |
| 154 virtual void SetOptions(const base::DictionaryValue& options) = 0; | |
| 125 }; | 155 }; |
| 126 | 156 |
| 127 } // namespace cast | 157 } // namespace cast |
| 128 } // namespace media | 158 } // namespace media |
| 129 | 159 |
| 130 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ | 160 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ |
| OLD | NEW |