| 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 net sender. The cast sender handles | 5 // This is the main interface for the cast transport sender. The cast sender |
| 6 // the cast pipeline from encoded frames (both audio and video), to encryption, | 6 // handles the cast pipeline from encoded frames (both audio and video), to |
| 7 // packetization and transport. | 7 // encryption, 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/net/cast_transport_defines.h" | 16 #include "media/cast/transport/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 class CastNetNotification { | 27 typedef base::Callback<void(CastTransportStatus status)> |
| 28 public: | 28 CastTransportStatusCallback; |
| 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 }; | |
| 40 | 29 |
| 41 // This Class is not thread safe. | 30 // This Class is not thread safe. |
| 42 // The application should only trigger this class from one thread. | 31 // The application should only trigger this class from the transport thread. |
| 43 class CastNetSender : public base::NonThreadSafe { | 32 class CastTransportSender : public base::NonThreadSafe { |
| 44 public: | 33 public: |
| 45 static CastNetSender* CreateCastNetSender( | 34 static CastTransportSender* CreateCastNetSender( |
| 46 base::TickClock* clock, | 35 base::TickClock* clock, |
| 47 const CastNetConfig& config, | 36 const CastTransportConfig& config, |
| 48 CastNetNotification* const notifier, | 37 const CastTransportStatusCallback& status_callback, |
| 49 scoped_refptr<PacketReceiver> packet_receiver); | 38 scoped_refptr<base::TaskRunner> transport_task_runner); |
| 50 | 39 |
| 51 virtual ~CastNetSender() {} | 40 virtual ~CastTransportSender() {} |
| 52 virtual void InsertCodedAudioFrame(const AudioBus* audio_bus, | 41 |
| 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, |
| 53 const base::TimeTicks& recorded_time) = 0; | 51 const base::TimeTicks& recorded_time) = 0; |
| 54 | 52 |
| 55 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, | 53 virtual void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, |
| 56 const base::TimeTicks& capture_time) = 0; | 54 const base::TimeTicks& capture_time) = 0; |
| 57 | 55 |
| 56 // Builds an RTCP packet and sends it to the network. |
| 58 virtual void SendRtcpFromRtpSender( | 57 virtual void SendRtcpFromRtpSender( |
| 59 uint32 packet_type_flags, | 58 uint32 packet_type_flags, |
| 60 const RtcpSenderInfo& sender_info, | 59 const RtcpSenderInfo& sender_info, |
| 61 const RtcpDlrrReportBlock& dlrr, | 60 const RtcpDlrrReportBlock& dlrr, |
| 62 const RtcpSenderLogMessage& sender_log) = 0; | 61 const RtcpSenderLogMessage& sender_log) = 0; |
| 63 | 62 |
| 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; |
| 67 | 74 |
| 68 } // namespace transport | 75 } // namespace transport |
| 69 } // namespace cast | 76 } // namespace cast |
| 70 } // namespace media | 77 } // namespace media |
| 71 | 78 |
| 72 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ | 79 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_SENDER_H_ |
| OLD | NEW |