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/rtcp/rtcp.h" | 18 #include "media/cast/rtcp/rtcp.h" |
19 #include "media/cast/transport/rtp_sender/rtp_sender.h" | 19 #include "media/cast/transport/rtp_sender/rtp_sender.h" |
| 20 #include "media/filters/gpu_video_accelerator_factories.h" |
| 21 #include "media/video/video_encode_accelerator.h" |
20 | 22 |
21 namespace crypto { | 23 namespace crypto { |
22 class Encryptor; | 24 class Encryptor; |
23 class SymmetricKey; | 25 class SymmetricKey; |
24 } | 26 } |
25 | 27 |
26 namespace media { | 28 namespace media { |
27 class VideoFrame; | 29 class VideoFrame; |
28 } | 30 } |
29 | 31 |
30 namespace media { | 32 namespace media { |
31 namespace cast { | 33 namespace cast { |
32 | 34 |
33 class VideoEncoder; | 35 class VideoEncoder; |
34 class LocalRtcpVideoSenderFeedback; | 36 class LocalRtcpVideoSenderFeedback; |
35 class LocalRtpVideoSenderStatistics; | 37 class LocalRtpVideoSenderStatistics; |
36 class LocalVideoEncoderCallback; | 38 class LocalVideoEncoderCallback; |
37 | 39 |
38 // Not thread safe. Only called from the main cast thread. | 40 // Not thread safe. Only called from the main cast thread. |
39 // This class owns all objects related to sending video, objects that create RTP | 41 // This class owns all objects related to sending video, objects that create RTP |
40 // packets, congestion control, video encoder, parsing and sending of | 42 // packets, congestion control, video encoder, parsing and sending of |
41 // RTCP packets. | 43 // RTCP packets. |
42 // Additionally it posts a bunch of delayed tasks to the main thread for various | 44 // Additionally it posts a bunch of delayed tasks to the main thread for various |
43 // timeouts. | 45 // timeouts. |
44 class VideoSender : public base::NonThreadSafe, | 46 class VideoSender : public base::NonThreadSafe, |
45 public base::SupportsWeakPtr<VideoSender> { | 47 public base::SupportsWeakPtr<VideoSender> { |
46 public: | 48 public: |
47 VideoSender(scoped_refptr<CastEnvironment> cast_environment, | 49 VideoSender(scoped_refptr<CastEnvironment> cast_environment, |
48 const VideoSenderConfig& video_config, | 50 const VideoSenderConfig& video_config, |
49 VideoEncoderController* const video_encoder_controller, | 51 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories, |
50 transport::PacedPacketSender* const paced_packet_sender); | 52 transport::PacedPacketSender* const paced_packet_sender); |
51 | 53 |
52 virtual ~VideoSender(); | 54 virtual ~VideoSender(); |
53 | 55 |
54 // The video_frame must be valid until the closure callback is called. | 56 // The video_frame must be valid until the closure callback is called. |
55 // The closure callback is called from the video encoder thread as soon as | 57 // The closure callback is called from the video encoder thread as soon as |
56 // the encoder is done with the frame; it does not mean that the encoded frame | 58 // the encoder is done with the frame; it does not mean that the encoded frame |
57 // has been sent out. | 59 // has been sent out. |
58 void InsertRawVideoFrame( | 60 void InsertRawVideoFrame( |
59 const scoped_refptr<media::VideoFrame>& video_frame, | 61 const scoped_refptr<media::VideoFrame>& video_frame, |
60 const base::TimeTicks& capture_time); | 62 const base::TimeTicks& capture_time); |
61 | 63 |
62 // The video_frame must be valid until the closure callback is called. | |
63 // The closure callback is called from the main thread as soon as | |
64 // the cast sender is done with the frame; it does not mean that the encoded | |
65 // frame has been sent out. | |
66 void InsertCodedVideoFrame(const EncodedVideoFrame* video_frame, | |
67 const base::TimeTicks& capture_time, | |
68 const base::Closure callback); | |
69 | |
70 // Only called from the main cast thread. | 64 // Only called from the main cast thread. |
71 void IncomingRtcpPacket(const uint8* packet, size_t length, | 65 void IncomingRtcpPacket(const uint8* packet, size_t length, |
72 const base::Closure callback); | 66 const base::Closure callback); |
73 | 67 |
74 protected: | 68 protected: |
75 // Protected for testability. | 69 // Protected for testability. |
76 void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback); | 70 void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback); |
77 | 71 |
78 private: | 72 private: |
79 friend class LocalRtcpVideoSenderFeedback; | 73 friend class LocalRtcpVideoSenderFeedback; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 110 |
117 const base::TimeDelta rtp_max_delay_; | 111 const base::TimeDelta rtp_max_delay_; |
118 const int max_frame_rate_; | 112 const int max_frame_rate_; |
119 | 113 |
120 scoped_refptr<CastEnvironment> cast_environment_; | 114 scoped_refptr<CastEnvironment> cast_environment_; |
121 scoped_ptr<LocalRtcpVideoSenderFeedback> rtcp_feedback_; | 115 scoped_ptr<LocalRtcpVideoSenderFeedback> rtcp_feedback_; |
122 scoped_ptr<LocalRtpVideoSenderStatistics> rtp_video_sender_statistics_; | 116 scoped_ptr<LocalRtpVideoSenderStatistics> rtp_video_sender_statistics_; |
123 scoped_ptr<VideoEncoder> video_encoder_; | 117 scoped_ptr<VideoEncoder> video_encoder_; |
124 scoped_ptr<Rtcp> rtcp_; | 118 scoped_ptr<Rtcp> rtcp_; |
125 scoped_ptr<transport::RtpSender> rtp_sender_; | 119 scoped_ptr<transport::RtpSender> rtp_sender_; |
126 VideoEncoderController* video_encoder_controller_; | |
127 uint8 max_unacked_frames_; | 120 uint8 max_unacked_frames_; |
128 scoped_ptr<crypto::Encryptor> encryptor_; | 121 scoped_ptr<crypto::Encryptor> encryptor_; |
129 scoped_ptr<crypto::SymmetricKey> encryption_key_; | 122 scoped_ptr<crypto::SymmetricKey> encryption_key_; |
130 std::string iv_mask_; | 123 std::string iv_mask_; |
131 int last_acked_frame_id_; | 124 int last_acked_frame_id_; |
132 int last_sent_frame_id_; | 125 int last_sent_frame_id_; |
133 int duplicate_ack_; | 126 int duplicate_ack_; |
134 base::TimeTicks last_send_time_; | 127 base::TimeTicks last_send_time_; |
135 base::TimeTicks last_checked_skip_count_time_; | 128 base::TimeTicks last_checked_skip_count_time_; |
136 int last_skip_count_; | 129 int last_skip_count_; |
137 CongestionControl congestion_control_; | 130 CongestionControl congestion_control_; |
138 | 131 |
139 bool initialized_; | 132 bool initialized_; |
140 base::WeakPtrFactory<VideoSender> weak_factory_; | 133 base::WeakPtrFactory<VideoSender> weak_factory_; |
141 | 134 |
142 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 135 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
143 }; | 136 }; |
144 | 137 |
145 } // namespace cast | 138 } // namespace cast |
146 } // namespace media | 139 } // namespace media |
147 | 140 |
148 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 141 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
OLD | NEW |