OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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. The cast sender | 5 // This is the main interface for the cast transport sender. The cast sender |
6 // handles the cast pipeline from encoded frames (both audio and video), to | 6 // handles the cast pipeline from encoded frames (both audio and video), to |
7 // encryption, packetization and transport. | 7 // encryption, packetization and transport. |
8 // All configurations are done at creation. | |
9 | 8 |
10 // 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 |
11 // in the following order: | 10 // in the following order: |
12 // 1. Create CastTransportSender. | 11 // 1. Create CastTransportSender. |
13 // 2. Create CastSender (accepts CastTransportSender as an input). | 12 // 2. Create CastSender (accepts CastTransportSender as an input). |
14 // 3. Call CastTransportSender::SetPacketReceiver to ensure that the packets | 13 // 3. Call CastTransportSender::SetPacketReceiver to ensure that the packets |
15 // received by the CastTransportSender will be sent to the CastSender. | 14 // received by the CastTransportSender will be sent to the CastSender. |
| 15 // 4. Initialize audio and/or video. |
| 16 // Steps 3 & 4 can be done interchangeably. |
16 | 17 |
17 // Destruction: The CastTransportSender is assumed to be valid as long as the | 18 // Destruction: The CastTransportSender is assumed to be valid as long as the |
18 // CastSender is alive. Therefore the CastSender should be destructed before the | 19 // CastSender is alive. Therefore the CastSender should be destructed before the |
19 // CastTransportSender. | 20 // CastTransportSender. |
20 // This also works when the CastSender acts as a receiver for the RTCP packets | 21 // This also works when the CastSender acts as a receiver for the RTCP packets |
21 // due to the weak pointers in the ReceivedPacket method in cast_sender_impl.cc. | 22 // due to the weak pointers in the ReceivedPacket method in cast_sender_impl.cc. |
22 | 23 |
23 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | 24 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ |
24 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | 25 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ |
25 | 26 |
26 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
27 #include "base/callback.h" | 28 #include "base/callback.h" |
28 #include "base/single_thread_task_runner.h" | 29 #include "base/single_thread_task_runner.h" |
29 #include "base/threading/non_thread_safe.h" | 30 #include "base/threading/non_thread_safe.h" |
30 #include "base/time/tick_clock.h" | 31 #include "base/time/tick_clock.h" |
31 #include "media/cast/transport/cast_transport_config.h" | 32 #include "media/cast/transport/cast_transport_config.h" |
32 #include "media/cast/transport/cast_transport_defines.h" | 33 #include "media/cast/transport/cast_transport_defines.h" |
33 | 34 |
34 namespace net { | 35 namespace net { |
35 class NetLog; | 36 class NetLog; |
36 } // namespace net | 37 } // namespace net |
37 | 38 |
38 namespace media { | 39 namespace media { |
39 namespace cast { | 40 namespace cast { |
40 namespace transport { | 41 namespace transport { |
41 | 42 |
| 43 // Following the initialization of either audio or video an initialization |
| 44 // status will be sent via this callback. |
42 typedef base::Callback<void(CastTransportStatus status)> | 45 typedef base::Callback<void(CastTransportStatus status)> |
43 CastTransportStatusCallback; | 46 CastTransportStatusCallback; |
44 | 47 |
45 typedef base::Callback<void(const RtcpSenderInfo& sender_info, | 48 typedef base::Callback<void(const RtcpSenderInfo& sender_info, |
46 base::TimeTicks time_sent, | 49 base::TimeTicks time_sent, |
47 uint32 rtp_timestamp)> CastTransportRtpStatistics; | 50 uint32 rtp_timestamp)> CastTransportRtpStatistics; |
48 | 51 |
49 // The application should only trigger this class from the transport thread. | 52 // The application should only trigger this class from the transport thread. |
50 class CastTransportSender : public base::NonThreadSafe { | 53 class CastTransportSender : public base::NonThreadSafe { |
51 public: | 54 public: |
52 static CastTransportSender* CreateCastTransportSender( | 55 static scoped_ptr<CastTransportSender> Create( |
53 net::NetLog* net_log, | 56 net::NetLog* net_log, |
54 base::TickClock* clock, | 57 base::TickClock* clock, |
55 const CastTransportConfig& config, | 58 const net::IPEndPoint& local_end_point, |
| 59 const net::IPEndPoint& remote_end_point, |
56 const CastTransportStatusCallback& status_callback, | 60 const CastTransportStatusCallback& status_callback, |
57 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); | 61 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); |
58 | 62 |
59 virtual ~CastTransportSender() {} | 63 virtual ~CastTransportSender() {} |
60 | 64 |
| 65 // Audio/Video initialization. |
| 66 // Encoded frames cannot be transmitted until the relevant initialize method |
| 67 // is called. |
| 68 virtual void InitializeAudio(const CastTransportAudioConfig& config) = 0; |
| 69 |
| 70 virtual void InitializeVideo(const CastTransportVideoConfig& config) = 0; |
| 71 |
61 // Sets the Cast packet receiver. Should be called after creation on the | 72 // Sets the Cast packet receiver. Should be called after creation on the |
62 // Cast sender. Packets won't be received until this function is called. | 73 // Cast sender. Packets won't be received until this function is called. |
63 virtual void SetPacketReceiver( | 74 virtual void SetPacketReceiver( |
64 const PacketReceiverCallback& packet_receiver) = 0; | 75 const PacketReceiverCallback& packet_receiver) = 0; |
65 | 76 |
66 // The following two functions handle the encoded media frames (audio and | 77 // The following two functions handle the encoded media frames (audio and |
67 // video) to be processed. | 78 // video) to be processed. |
68 // Frames will be encrypted, packetized and transmitted to the network. | 79 // Frames will be encrypted, packetized and transmitted to the network. |
69 virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, | 80 virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, |
70 const base::TimeTicks& recorded_time) = 0; | 81 const base::TimeTicks& recorded_time) = 0; |
71 | 82 |
72 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, | 83 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, |
73 const base::TimeTicks& capture_time) = 0; | 84 const base::TimeTicks& capture_time) = 0; |
74 | 85 |
75 // Builds an RTCP packet and sends it to the network. | 86 // Builds an RTCP packet and sends it to the network. |
76 virtual void SendRtcpFromRtpSender(uint32 packet_type_flags, | 87 virtual void SendRtcpFromRtpSender(uint32 packet_type_flags, |
77 const RtcpSenderInfo& sender_info, | 88 const RtcpSenderInfo& sender_info, |
78 const RtcpDlrrReportBlock& dlrr, | 89 const RtcpDlrrReportBlock& dlrr, |
79 const RtcpSenderLogMessage& sender_log, | 90 const RtcpSenderLogMessage& sender_log, |
80 uint32 sending_ssrc, | 91 uint32 sending_ssrc, |
81 const std::string& c_name) = 0; | 92 const std::string& c_name) = 0; |
82 | 93 |
83 // Retransmission request. | 94 // Retransmission request. |
84 virtual void ResendPackets( | 95 virtual void ResendPackets( |
85 bool is_audio, | 96 bool is_audio, |
86 const MissingFramesAndPacketsMap& missing_packets) = 0; | 97 const MissingFramesAndPacketsMap& missing_packets) = 0; |
87 | 98 |
88 // Audio/Video RTP statistics. | |
89 // RTP statistics will be returned on a regular interval on the designated | 99 // RTP statistics will be returned on a regular interval on the designated |
90 // callback. | 100 // callback. |
| 101 // Must be called after initialization of the corresponding A/V pipeline. |
91 virtual void SubscribeAudioRtpStatsCallback( | 102 virtual void SubscribeAudioRtpStatsCallback( |
92 const CastTransportRtpStatistics& callback) = 0; | 103 const CastTransportRtpStatistics& callback) = 0; |
93 | 104 |
94 virtual void SubscribeVideoRtpStatsCallback( | 105 virtual void SubscribeVideoRtpStatsCallback( |
95 const CastTransportRtpStatistics& callback) = 0; | 106 const CastTransportRtpStatistics& callback) = 0; |
96 }; | 107 }; |
97 | 108 |
98 } // namespace transport | 109 } // namespace transport |
99 } // namespace cast | 110 } // namespace cast |
100 } // namespace media | 111 } // namespace media |
101 | 112 |
102 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | 113 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ |
OLD | NEW |