| 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 net sender. The cast sender handles |
| 6 // handles the cast pipeline from encoded frames (both audio and video), to | 6 // the cast pipeline from encoded frames (both audio and video), to encryption, |
| 7 // encryption, packetization and transport. | 7 // packetization and transport. |
| 8 // All configurations are done at creation. | 8 // All configurations are done at creation. |
| 9 | 9 |
| 10 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | 10 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ |
| 11 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | 11 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "base/time/tick_clock.h" | 15 #include "base/time/tick_clock.h" |
| 16 #include "media/cast/transport/cast_transport_defines.h" | 16 #include "media/cast/net/cast_transport_defines.h" |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 class AudioBus; | 19 class AudioBus; |
| 20 class VideoFrame; | 20 class VideoFrame; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace media { | 23 namespace media { |
| 24 namespace cast { | 24 namespace cast { |
| 25 namespace transport { | 25 namespace transport { |
| 26 | 26 |
| 27 typedef base::Callback<void(CastTransportStatus status)> | 27 class CastNetNotification { |
| 28 CastTransportStatusCallback; | 28 public: |
| 29 enum CastNetStatus { |
| 30 UNINITIALIZED, |
| 31 INITIALIZED, |
| 32 INVALID_CRYPTO_CONFIG, |
| 33 SOCKET_ERROR, |
| 34 // TODO(mikhal): Add. |
| 35 }; |
| 36 |
| 37 virtual void NotifyStatusChange(CastNetStatus result) = 0; |
| 38 virtual ~CastNetNotification() {} |
| 39 }; |
| 29 | 40 |
| 30 // This Class is not thread safe. | 41 // This Class is not thread safe. |
| 31 // The application should only trigger this class from the transport thread. | 42 // The application should only trigger this class from one thread. |
| 32 class CastTransportSender : public base::NonThreadSafe { | 43 class CastNetSender : public base::NonThreadSafe { |
| 33 public: | 44 public: |
| 34 static CastTransportSender* CreateCastNetSender( | 45 static CastNetSender* CreateCastNetSender( |
| 35 base::TickClock* clock, | 46 base::TickClock* clock, |
| 36 const CastTransportConfig& config, | 47 const CastNetConfig& config, |
| 37 const CastTransportStatusCallback& status_callback, | 48 CastNetNotification* const notifier, |
| 38 scoped_refptr<base::TaskRunner> transport_task_runner); | 49 scoped_refptr<PacketReceiver> packet_receiver); |
| 39 | 50 |
| 40 virtual ~CastTransportSender() {} | 51 virtual ~CastNetSender() {} |
| 41 | 52 virtual void InsertCodedAudioFrame(const AudioBus* audio_bus, |
| 42 // Sets the Cast packet receiver. Should be called after creation on the | |
| 43 // Cast sender. | |
| 44 virtual void SetPacketReceiver( | |
| 45 scoped_refptr<PacketReceiver> packet_receiver) = 0; | |
| 46 | |
| 47 // The following two functions handle the encoded media frames (audio and | |
| 48 // video) to be processed. | |
| 49 // Frames will be encrypted, packetized and transmitted to the network. | |
| 50 virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, | |
| 51 const base::TimeTicks& recorded_time) = 0; | 53 const base::TimeTicks& recorded_time) = 0; |
| 52 | 54 |
| 53 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, | 55 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, |
| 54 const base::TimeTicks& capture_time) = 0; | 56 const base::TimeTicks& capture_time) = 0; |
| 55 | 57 |
| 56 // Builds an RTCP packet and sends it to the network. | |
| 57 virtual void SendRtcpFromRtpSender( | 58 virtual void SendRtcpFromRtpSender( |
| 58 uint32 packet_type_flags, | 59 uint32 packet_type_flags, |
| 59 const RtcpSenderInfo& sender_info, | 60 const RtcpSenderInfo& sender_info, |
| 60 const RtcpDlrrReportBlock& dlrr, | 61 const RtcpDlrrReportBlock& dlrr, |
| 61 const RtcpSenderLogMessage& sender_log) = 0; | 62 const RtcpSenderLogMessage& sender_log) = 0; |
| 62 | 63 |
| 63 // Retransmision request. | |
| 64 virtual void ResendPackets( | 64 virtual void ResendPackets( |
| 65 const MissingFramesAndPacketsMap& missing_packets) = 0; | 65 const MissingFramesAndPacketsMap& missing_packets) = 0; |
| 66 | 66 }; |
| 67 // Retrieves audio RTP statistics. | |
| 68 virtual void RtpAudioStatistics(const base::TimeTicks& now, | |
| 69 RtcpSenderInfo* sender_info) = 0; | |
| 70 | |
| 71 // Retrieves audio RTP statistics. | |
| 72 virtual void RtpVideoStatistics(const base::TimeTicks& now, | |
| 73 RtcpSenderInfo* sender_info) = 0; | |
| 74 | 67 |
| 75 } // namespace transport | 68 } // namespace transport |
| 76 } // namespace cast | 69 } // namespace cast |
| 77 } // namespace media | 70 } // namespace media |
| 78 | 71 |
| 79 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | 72 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ |
| OLD | NEW |