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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 typedef base::Callback<void(CastTransportStatus status)> | 49 typedef base::Callback<void(CastTransportStatus status)> |
50 CastTransportStatusCallback; | 50 CastTransportStatusCallback; |
51 | 51 |
52 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, | 52 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, |
53 scoped_ptr<std::vector<PacketEvent>>)> | 53 scoped_ptr<std::vector<PacketEvent>>)> |
54 BulkRawEventsCallback; | 54 BulkRawEventsCallback; |
55 | 55 |
56 // The application should only trigger this class from the transport thread. | 56 // The application should only trigger this class from the transport thread. |
57 class CastTransportSender : public base::NonThreadSafe { | 57 class CastTransportSender : public base::NonThreadSafe { |
58 public: | 58 public: |
59 static scoped_ptr<CastTransportSender> Create( | 59 // Interface to create a cast transport sender / receiver. |
60 net::NetLog* net_log, | 60 class CastTransportClient { |
61 base::TickClock* clock, | 61 public: |
62 const net::IPEndPoint& local_end_point, | 62 // Audio and Video transport status change is reported on this callback. |
63 const net::IPEndPoint& remote_end_point, | 63 virtual void OnStatusChange(CastTransportStatus status) = 0; |
64 scoped_ptr<base::DictionaryValue> options, | 64 |
65 const CastTransportStatusCallback& status_callback, | 65 // Raw events will be invoked on this callback every |
66 const BulkRawEventsCallback& raw_events_callback, | 66 // |logging_flush_interval|. If the user is not interested in raw events, |
67 base::TimeDelta raw_events_callback_interval, | 67 // |logging_flush_interval| should be set to |base::TimeDelta|. |
68 const PacketReceiverCallback& packet_callback, | 68 virtual void OnReceivedLoggingEvents( |
69 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | 69 scoped_ptr<std::vector<FrameEvent>>, |
| 70 scoped_ptr<std::vector<PacketEvent>>) = 0; |
| 71 |
| 72 // Incoming packets that do not match the channels created by |
| 73 // Initialize{Audio,Video} will report to this callback. |
| 74 virtual void OnReceivedPackets(scoped_ptr<Packet> packet) = 0; |
| 75 |
| 76 protected: |
| 77 virtual ~CastTransportClient(); |
| 78 }; |
| 79 |
| 80 // Parameters to create a cast transport sender / receiver. |
| 81 // |options| contains optional settings for the transport, possible |
| 82 // keys are: |
| 83 // "DSCP" (value ignored) |
| 84 // - Turns DSCP on (higher IP Precedence and Type of Service). |
| 85 // "disable_non_blocking_io" (value ignored) |
| 86 // - Windows only. Turns off non-blocking IO for the socket. |
| 87 // Note: Non-blocking IO is, by default, enabled on all platforms. |
| 88 // "pacer_target_burst_size": int |
| 89 // - Specifies how many packets to send per 10 ms ideally. |
| 90 // "pacer_max_burst_size": int |
| 91 // - Specifies how many pakcets to send per 10 ms, maximum. |
| 92 // "send_buffer_min_size": int |
| 93 // - Specifies the minimum socket send buffer size. |
| 94 // "disable_wifi_scan" (value ignored) |
| 95 // - Disable wifi scans while streaming. |
| 96 // "media_streaming_mode" (value ignored) |
| 97 // - Turn media streaming mode on. |
| 98 // Note, these options may be ignored on some platforms. |
| 99 struct CreateParams { |
| 100 CreateParams( |
| 101 net::NetLog* log, |
| 102 base::TickClock* input_clock, |
| 103 net::IPEndPoint local_addr, |
| 104 net::IPEndPoint remote_addr, |
| 105 CastTransportClient* transport_client, |
| 106 base::TimeDelta transport_logging_flush_interval, |
| 107 scoped_ptr<base::DictionaryValue> options, |
| 108 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 109 ~CreateParams(); |
| 110 |
| 111 net::NetLog* net_log; |
| 112 base::TickClock* clock; |
| 113 net::IPEndPoint local_end_point; |
| 114 net::IPEndPoint remote_end_point; |
| 115 CastTransportClient* client; |
| 116 base::TimeDelta logging_flush_interval; |
| 117 scoped_ptr<base::DictionaryValue> optional_config; |
| 118 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner; |
| 119 }; |
| 120 |
| 121 static scoped_ptr<CastTransportSender> Create(const CreateParams& params); |
70 | 122 |
71 virtual ~CastTransportSender() {} | 123 virtual ~CastTransportSender() {} |
72 | 124 |
73 // Audio/Video initialization. | 125 // Audio/Video initialization. |
74 // Encoded frames cannot be transmitted until the relevant initialize method | 126 // Encoded frames cannot be transmitted until the relevant initialize method |
75 // is called. | 127 // is called. |
76 virtual void InitializeAudio(const CastTransportRtpConfig& config, | 128 virtual void InitializeAudio(const CastTransportRtpConfig& config, |
77 const RtcpCastMessageCallback& cast_message_cb, | 129 const RtcpCastMessageCallback& cast_message_cb, |
78 const RtcpRttCallback& rtt_cb) = 0; | 130 const RtcpRttCallback& rtt_cb) = 0; |
79 virtual void InitializeVideo(const CastTransportRtpConfig& config, | 131 virtual void InitializeVideo(const CastTransportRtpConfig& config, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const RtcpCastMessage* cast_message, | 173 const RtcpCastMessage* cast_message, |
122 base::TimeDelta target_delay, | 174 base::TimeDelta target_delay, |
123 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, | 175 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, |
124 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; | 176 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; |
125 }; | 177 }; |
126 | 178 |
127 } // namespace cast | 179 } // namespace cast |
128 } // namespace media | 180 } // namespace media |
129 | 181 |
130 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ | 182 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ |
OLD | NEW |