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 "base/basictypes.h" | |
22 #include "base/callback.h" | 21 #include "base/callback.h" |
23 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
24 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
25 #include "base/threading/non_thread_safe.h" | 24 #include "base/threading/non_thread_safe.h" |
26 #include "base/time/tick_clock.h" | 25 #include "base/time/tick_clock.h" |
27 #include "media/cast/logging/logging_defines.h" | 26 #include "media/cast/logging/logging_defines.h" |
28 #include "media/cast/net/cast_transport_config.h" | 27 #include "media/cast/net/cast_transport_config.h" |
29 #include "media/cast/net/cast_transport_defines.h" | 28 #include "media/cast/net/cast_transport_defines.h" |
30 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" | 29 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" |
31 #include "media/cast/net/rtcp/rtcp_defines.h" | 30 #include "media/cast/net/rtcp/rtcp_defines.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // is called. | 74 // is called. |
76 virtual void InitializeAudio(const CastTransportRtpConfig& config, | 75 virtual void InitializeAudio(const CastTransportRtpConfig& config, |
77 const RtcpCastMessageCallback& cast_message_cb, | 76 const RtcpCastMessageCallback& cast_message_cb, |
78 const RtcpRttCallback& rtt_cb) = 0; | 77 const RtcpRttCallback& rtt_cb) = 0; |
79 virtual void InitializeVideo(const CastTransportRtpConfig& config, | 78 virtual void InitializeVideo(const CastTransportRtpConfig& config, |
80 const RtcpCastMessageCallback& cast_message_cb, | 79 const RtcpCastMessageCallback& cast_message_cb, |
81 const RtcpRttCallback& rtt_cb) = 0; | 80 const RtcpRttCallback& rtt_cb) = 0; |
82 | 81 |
83 // Encrypt, packetize and transmit |frame|. |ssrc| must refer to a | 82 // Encrypt, packetize and transmit |frame|. |ssrc| must refer to a |
84 // a channel already established with InitializeAudio / InitializeVideo. | 83 // a channel already established with InitializeAudio / InitializeVideo. |
85 virtual void InsertFrame(uint32 ssrc, const EncodedFrame& frame) = 0; | 84 virtual void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) = 0; |
86 | 85 |
87 // Sends a RTCP sender report to the receiver. | 86 // Sends a RTCP sender report to the receiver. |
88 // |ssrc| is the SSRC for this report. | 87 // |ssrc| is the SSRC for this report. |
89 // |current_time| is the current time reported by a tick clock. | 88 // |current_time| is the current time reported by a tick clock. |
90 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. | 89 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. |
91 virtual void SendSenderReport( | 90 virtual void SendSenderReport(uint32_t ssrc, |
92 uint32 ssrc, | 91 base::TimeTicks current_time, |
93 base::TimeTicks current_time, | 92 uint32_t current_time_as_rtp_timestamp) = 0; |
94 uint32 current_time_as_rtp_timestamp) = 0; | |
95 | 93 |
96 // Cancels sending packets for the frames in the set. | 94 // Cancels sending packets for the frames in the set. |
97 // |ssrc| is the SSRC for the stream. | 95 // |ssrc| is the SSRC for the stream. |
98 // |frame_ids| contains the IDs of the frames that will be cancelled. | 96 // |frame_ids| contains the IDs of the frames that will be cancelled. |
99 virtual void CancelSendingFrames(uint32 ssrc, | 97 virtual void CancelSendingFrames(uint32_t ssrc, |
100 const std::vector<uint32>& frame_ids) = 0; | 98 const std::vector<uint32_t>& frame_ids) = 0; |
101 | 99 |
102 // Resends a frame or part of a frame to kickstart. This is used when the | 100 // Resends a frame or part of a frame to kickstart. This is used when the |
103 // stream appears to be stalled. | 101 // stream appears to be stalled. |
104 virtual void ResendFrameForKickstart(uint32 ssrc, uint32 frame_id) = 0; | 102 virtual void ResendFrameForKickstart(uint32_t ssrc, uint32_t frame_id) = 0; |
105 | 103 |
106 // Returns a callback for receiving packets for testing purposes. | 104 // Returns a callback for receiving packets for testing purposes. |
107 virtual PacketReceiverCallback PacketReceiverForTesting(); | 105 virtual PacketReceiverCallback PacketReceiverForTesting(); |
108 | 106 |
109 // The following functions are needed for receving. | 107 // The following functions are needed for receving. |
110 | 108 |
111 // Add a valid SSRC. This is used to verify that incoming packets | 109 // Add a valid SSRC. This is used to verify that incoming packets |
112 // come from the right sender. Without valid SSRCs, the return address cannot | 110 // come from the right sender. Without valid SSRCs, the return address cannot |
113 // be automatically established. | 111 // be automatically established. |
114 virtual void AddValidSsrc(uint32 ssrc) = 0; | 112 virtual void AddValidSsrc(uint32_t ssrc) = 0; |
115 | 113 |
116 // Send an RTCP message from receiver to sender. | 114 // Send an RTCP message from receiver to sender. |
117 virtual void SendRtcpFromRtpReceiver( | 115 virtual void SendRtcpFromRtpReceiver( |
118 uint32 ssrc, | 116 uint32_t ssrc, |
119 uint32 sender_ssrc, | 117 uint32_t sender_ssrc, |
120 const RtcpTimeData& time_data, | 118 const RtcpTimeData& time_data, |
121 const RtcpCastMessage* cast_message, | 119 const RtcpCastMessage* cast_message, |
122 base::TimeDelta target_delay, | 120 base::TimeDelta target_delay, |
123 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, | 121 const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, |
124 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; | 122 const RtpReceiverStatistics* rtp_receiver_statistics) = 0; |
125 }; | 123 }; |
126 | 124 |
127 } // namespace cast | 125 } // namespace cast |
128 } // namespace media | 126 } // namespace media |
129 | 127 |
130 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ | 128 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ |
OLD | NEW |