| 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 #ifndef MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 5 #ifndef MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
| 6 #define MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 6 #define MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "base/time/tick_clock.h" | 13 #include "base/time/tick_clock.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "media/cast/cast_config.h" | 15 #include "media/cast/cast_config.h" |
| 16 #include "media/cast/cast_environment.h" | 16 #include "media/cast/cast_environment.h" |
| 17 #include "media/cast/congestion_control/congestion_control.h" | 17 #include "media/cast/congestion_control/congestion_control.h" |
| 18 #include "media/cast/net/rtp_sender/rtp_sender.h" | |
| 19 #include "media/cast/rtcp/rtcp.h" | 18 #include "media/cast/rtcp/rtcp.h" |
| 19 #include "media/cast/transport/rtp_sender/rtp_sender.h" |
| 20 | 20 |
| 21 namespace crypto { | 21 namespace crypto { |
| 22 class Encryptor; | 22 class Encryptor; |
| 23 class SymmetricKey; | 23 class SymmetricKey; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace media { | 26 namespace media { |
| 27 class VideoFrame; | 27 class VideoFrame; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace media { | 30 namespace media { |
| 31 namespace cast { | 31 namespace cast { |
| 32 | 32 |
| 33 class VideoEncoder; | 33 class VideoEncoder; |
| 34 class LocalRtcpVideoSenderFeedback; | 34 class LocalRtcpVideoSenderFeedback; |
| 35 class LocalRtpVideoSenderStatistics; | 35 class LocalRtpVideoSenderStatistics; |
| 36 class LocalVideoEncoderCallback; | 36 class LocalVideoEncoderCallback; |
| 37 class PacedPacketSender; | |
| 38 | 37 |
| 39 // Not thread safe. Only called from the main cast thread. | 38 // Not thread safe. Only called from the main cast thread. |
| 40 // This class owns all objects related to sending video, objects that create RTP | 39 // This class owns all objects related to sending video, objects that create RTP |
| 41 // packets, congestion control, video encoder, parsing and sending of | 40 // packets, congestion control, video encoder, parsing and sending of |
| 42 // RTCP packets. | 41 // RTCP packets. |
| 43 // Additionally it posts a bunch of delayed tasks to the main thread for various | 42 // Additionally it posts a bunch of delayed tasks to the main thread for various |
| 44 // timeouts. | 43 // timeouts. |
| 45 class VideoSender : public base::NonThreadSafe, | 44 class VideoSender : public base::NonThreadSafe, |
| 46 public base::SupportsWeakPtr<VideoSender> { | 45 public base::SupportsWeakPtr<VideoSender> { |
| 47 public: | 46 public: |
| 48 VideoSender(scoped_refptr<CastEnvironment> cast_environment, | 47 VideoSender(scoped_refptr<CastEnvironment> cast_environment, |
| 49 const VideoSenderConfig& video_config, | 48 const VideoSenderConfig& video_config, |
| 50 VideoEncoderController* const video_encoder_controller, | 49 VideoEncoderController* const video_encoder_controller, |
| 51 PacedPacketSender* const paced_packet_sender); | 50 transport::PacedPacketSender* const paced_packet_sender); |
| 52 | 51 |
| 53 virtual ~VideoSender(); | 52 virtual ~VideoSender(); |
| 54 | 53 |
| 55 // The video_frame must be valid until the closure callback is called. | 54 // The video_frame must be valid until the closure callback is called. |
| 56 // The closure callback is called from the video encoder thread as soon as | 55 // The closure callback is called from the video encoder thread as soon as |
| 57 // the encoder is done with the frame; it does not mean that the encoded frame | 56 // the encoder is done with the frame; it does not mean that the encoded frame |
| 58 // has been sent out. | 57 // has been sent out. |
| 59 void InsertRawVideoFrame( | 58 void InsertRawVideoFrame( |
| 60 const scoped_refptr<media::VideoFrame>& video_frame, | 59 const scoped_refptr<media::VideoFrame>& video_frame, |
| 61 const base::TimeTicks& capture_time); | 60 const base::TimeTicks& capture_time); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 EncodedVideoFrame* encrypted_video_frame); | 115 EncodedVideoFrame* encrypted_video_frame); |
| 117 | 116 |
| 118 const base::TimeDelta rtp_max_delay_; | 117 const base::TimeDelta rtp_max_delay_; |
| 119 const int max_frame_rate_; | 118 const int max_frame_rate_; |
| 120 | 119 |
| 121 scoped_refptr<CastEnvironment> cast_environment_; | 120 scoped_refptr<CastEnvironment> cast_environment_; |
| 122 scoped_ptr<LocalRtcpVideoSenderFeedback> rtcp_feedback_; | 121 scoped_ptr<LocalRtcpVideoSenderFeedback> rtcp_feedback_; |
| 123 scoped_ptr<LocalRtpVideoSenderStatistics> rtp_video_sender_statistics_; | 122 scoped_ptr<LocalRtpVideoSenderStatistics> rtp_video_sender_statistics_; |
| 124 scoped_ptr<VideoEncoder> video_encoder_; | 123 scoped_ptr<VideoEncoder> video_encoder_; |
| 125 scoped_ptr<Rtcp> rtcp_; | 124 scoped_ptr<Rtcp> rtcp_; |
| 126 scoped_ptr<RtpSender> rtp_sender_; | 125 scoped_ptr<transport::RtpSender> rtp_sender_; |
| 127 VideoEncoderController* video_encoder_controller_; | 126 VideoEncoderController* video_encoder_controller_; |
| 128 uint8 max_unacked_frames_; | 127 uint8 max_unacked_frames_; |
| 129 scoped_ptr<crypto::Encryptor> encryptor_; | 128 scoped_ptr<crypto::Encryptor> encryptor_; |
| 130 scoped_ptr<crypto::SymmetricKey> encryption_key_; | 129 scoped_ptr<crypto::SymmetricKey> encryption_key_; |
| 131 std::string iv_mask_; | 130 std::string iv_mask_; |
| 132 int last_acked_frame_id_; | 131 int last_acked_frame_id_; |
| 133 int last_sent_frame_id_; | 132 int last_sent_frame_id_; |
| 134 int duplicate_ack_; | 133 int duplicate_ack_; |
| 135 base::TimeTicks last_send_time_; | 134 base::TimeTicks last_send_time_; |
| 136 base::TimeTicks last_checked_skip_count_time_; | 135 base::TimeTicks last_checked_skip_count_time_; |
| 137 int last_skip_count_; | 136 int last_skip_count_; |
| 138 CongestionControl congestion_control_; | 137 CongestionControl congestion_control_; |
| 139 | 138 |
| 140 bool initialized_; | 139 bool initialized_; |
| 141 base::WeakPtrFactory<VideoSender> weak_factory_; | 140 base::WeakPtrFactory<VideoSender> weak_factory_; |
| 142 | 141 |
| 143 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 142 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
| 144 }; | 143 }; |
| 145 | 144 |
| 146 } // namespace cast | 145 } // namespace cast |
| 147 } // namespace media | 146 } // namespace media |
| 148 | 147 |
| 149 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 148 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
| OLD | NEW |