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 should be done | 9 // Construction of the Cast Sender and the Cast Transport should be done |
10 // in the following order: | 10 // in the following order: |
11 // 1. Create CastTransport. | 11 // 1. Create CastTransport. |
12 // 2. Create CastSender (accepts CastTransport as an input). | 12 // 2. Create CastSender (accepts CastTransport as an input). |
13 | 13 |
14 // Destruction: The CastTransport is assumed to be valid as long as the | 14 // Destruction: The CastTransport 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 // CastTransport. | 16 // CastTransport. |
17 | 17 |
18 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_H_ | 18 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_H_ |
19 #define MEDIA_CAST_NET_CAST_TRANSPORT_H_ | 19 #define MEDIA_CAST_NET_CAST_TRANSPORT_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" | |
25 #include "base/single_thread_task_runner.h" | 24 #include "base/single_thread_task_runner.h" |
26 #include "base/threading/non_thread_safe.h" | 25 #include "base/threading/non_thread_safe.h" |
27 #include "base/time/tick_clock.h" | 26 #include "base/time/tick_clock.h" |
28 #include "base/values.h" | 27 #include "base/values.h" |
29 #include "media/cast/logging/logging_defines.h" | 28 #include "media/cast/logging/logging_defines.h" |
30 #include "media/cast/net/cast_transport_config.h" | 29 #include "media/cast/net/cast_transport_config.h" |
31 #include "media/cast/net/cast_transport_defines.h" | 30 #include "media/cast/net/cast_transport_defines.h" |
32 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" | 31 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" |
33 #include "media/cast/net/rtcp/rtcp_defines.h" | 32 #include "media/cast/net/rtcp/rtcp_defines.h" |
34 #include "net/base/ip_endpoint.h" | 33 #include "net/base/ip_endpoint.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
45 namespace cast { | 44 namespace cast { |
46 | 45 |
47 struct RtpReceiverStatistics; | 46 struct RtpReceiverStatistics; |
48 struct RtcpTimeData; | 47 struct RtcpTimeData; |
49 | 48 |
50 // Following the initialization of either audio or video an initialization | 49 // Following the initialization of either audio or video an initialization |
51 // status will be sent via this callback. | 50 // status will be sent via this callback. |
52 typedef base::Callback<void(CastTransportStatus status)> | 51 typedef base::Callback<void(CastTransportStatus status)> |
53 CastTransportStatusCallback; | 52 CastTransportStatusCallback; |
54 | 53 |
55 typedef base::Callback<void(scoped_ptr<std::vector<FrameEvent>>, | 54 typedef base::Callback<void(std::unique_ptr<std::vector<FrameEvent>>, |
miu
2016/04/15 23:14:39
nit: ditto on "using" instead of "typedef" syntax
xjz
2016/04/20 01:09:02
Done.
| |
56 scoped_ptr<std::vector<PacketEvent>>)> | 55 std::unique_ptr<std::vector<PacketEvent>>)> |
57 BulkRawEventsCallback; | 56 BulkRawEventsCallback; |
58 | 57 |
58 // Interface to handle received RTCP messages on RTP sender. | |
59 class RtpSenderRtcpClient { | |
60 public: | |
61 virtual ~RtpSenderRtcpClient() {} | |
62 | |
63 virtual void OnCastMessageReceived(const RtcpCastMessage& cast_message) = 0; | |
64 virtual void OnRttReceived(base::TimeDelta round_trip_time) = 0; | |
65 virtual void OnPliReceived() = 0; | |
66 }; | |
67 | |
59 // The application should only trigger this class from the transport thread. | 68 // The application should only trigger this class from the transport thread. |
60 class CastTransport : public base::NonThreadSafe { | 69 class CastTransport : public base::NonThreadSafe { |
61 public: | 70 public: |
62 // Interface used for receiving status updates, raw events, and RTP packets | 71 // Interface used for receiving status updates, raw events, and RTP packets |
63 // from CastTransport. | 72 // from CastTransport. |
64 class Client { | 73 class Client { |
65 public: | 74 public: |
66 virtual ~Client(){}; | 75 virtual ~Client(){}; |
67 | 76 |
68 // Audio and Video transport status change is reported on this callback. | 77 // Audio and Video transport status change is reported on this callback. |
69 virtual void OnStatusChanged(CastTransportStatus status) = 0; | 78 virtual void OnStatusChanged(CastTransportStatus status) = 0; |
70 | 79 |
71 // Raw events will be invoked on this callback periodically, according to | 80 // Raw events will be invoked on this callback periodically, according to |
72 // the configured logging flush interval passed to | 81 // the configured logging flush interval passed to |
73 // CastTransport::Create(). | 82 // CastTransport::Create(). |
74 virtual void OnLoggingEventsReceived( | 83 virtual void OnLoggingEventsReceived( |
75 scoped_ptr<std::vector<FrameEvent>> frame_events, | 84 std::unique_ptr<std::vector<FrameEvent>> frame_events, |
76 scoped_ptr<std::vector<PacketEvent>> packet_events) = 0; | 85 std::unique_ptr<std::vector<PacketEvent>> packet_events) = 0; |
77 | 86 |
78 // Called to pass RTP packets to the Client. | 87 // Called to pass RTP packets to the Client. |
79 virtual void ProcessRtpPacket(scoped_ptr<Packet> packet) = 0; | 88 virtual void ProcessRtpPacket(std::unique_ptr<Packet> packet) = 0; |
80 }; | 89 }; |
81 | 90 |
82 static scoped_ptr<CastTransport> Create( | 91 static std::unique_ptr<CastTransport> Create( |
83 base::TickClock* clock, // Owned by the caller. | 92 base::TickClock* clock, // Owned by the caller. |
84 base::TimeDelta logging_flush_interval, | 93 base::TimeDelta logging_flush_interval, |
85 scoped_ptr<Client> client, | 94 std::unique_ptr<Client> client, |
86 scoped_ptr<PacketTransport> transport, | 95 std::unique_ptr<PacketTransport> transport, |
87 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | 96 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); |
88 | 97 |
89 virtual ~CastTransport() {} | 98 virtual ~CastTransport() {} |
90 | 99 |
91 // Audio/Video initialization. | 100 // Audio/Video initialization. |
92 // Encoded frames cannot be transmitted until the relevant initialize method | 101 // Encoded frames cannot be transmitted until the relevant initialize method |
93 // is called. | 102 // is called. |
94 virtual void InitializeAudio(const CastTransportRtpConfig& config, | 103 virtual void InitializeAudio( |
95 const RtcpCastMessageCallback& cast_message_cb, | 104 const CastTransportRtpConfig& config, |
96 const RtcpRttCallback& rtt_cb, | 105 std::unique_ptr<RtpSenderRtcpClient> rtcp_client) {} |
97 const RtcpPliCallback& pli_cb) = 0; | 106 virtual void InitializeVideo( |
98 virtual void InitializeVideo(const CastTransportRtpConfig& config, | 107 const CastTransportRtpConfig& config, |
99 const RtcpCastMessageCallback& cast_message_cb, | 108 std::unique_ptr<RtpSenderRtcpClient> rtcp_client) {} |
100 const RtcpRttCallback& rtt_cb, | |
101 const RtcpPliCallback& pli_cb) = 0; | |
102 | 109 |
103 // Encrypt, packetize and transmit |frame|. |ssrc| must refer to a | 110 // Encrypt, packetize and transmit |frame|. |ssrc| must refer to a |
104 // a channel already established with InitializeAudio / InitializeVideo. | 111 // a channel already established with InitializeAudio / InitializeVideo. |
105 virtual void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) = 0; | 112 virtual void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) = 0; |
106 | 113 |
107 // Sends a RTCP sender report to the receiver. | 114 // Sends a RTCP sender report to the receiver. |
108 // |ssrc| is the SSRC for this report. | 115 // |ssrc| is the SSRC for this report. |
109 // |current_time| is the current time reported by a tick clock. | 116 // |current_time| is the current time reported by a tick clock. |
110 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. | 117 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. |
111 virtual void SendSenderReport(uint32_t ssrc, | 118 virtual void SendSenderReport(uint32_t ssrc, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 virtual void SendRtcpFromRtpReceiver() = 0; | 162 virtual void SendRtcpFromRtpReceiver() = 0; |
156 | 163 |
157 // Set options for the PacedSender and Wifi. | 164 // Set options for the PacedSender and Wifi. |
158 virtual void SetOptions(const base::DictionaryValue& options) = 0; | 165 virtual void SetOptions(const base::DictionaryValue& options) = 0; |
159 }; | 166 }; |
160 | 167 |
161 } // namespace cast | 168 } // namespace cast |
162 } // namespace media | 169 } // namespace media |
163 | 170 |
164 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_H_ | 171 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_H_ |
OLD | NEW |