| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SENDER_VIDEO_SENDER_H_ | 5 #ifndef MEDIA_CAST_SENDER_VIDEO_SENDER_H_ |
| 6 #define MEDIA_CAST_SENDER_VIDEO_SENDER_H_ | 6 #define MEDIA_CAST_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/sender/congestion_control.h" | 16 #include "media/cast/sender/congestion_control.h" |
| 17 #include "media/cast/sender/frame_sender.h" | 17 #include "media/cast/sender/frame_sender.h" |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 | 20 |
| 21 class VideoFrame; | 21 class VideoFrame; |
| 22 | 22 |
| 23 namespace cast { | 23 namespace cast { |
| 24 | 24 |
| 25 class CastTransportSender; | 25 class CastTransportSender; |
| 26 struct SenderEncodedFrame; | |
| 27 class VideoEncoder; | 26 class VideoEncoder; |
| 28 class VideoFrameFactory; | 27 class VideoFrameFactory; |
| 29 | 28 |
| 30 typedef base::Callback<void(base::TimeDelta)> PlayoutDelayChangeCB; | 29 typedef base::Callback<void(base::TimeDelta)> PlayoutDelayChangeCB; |
| 31 | 30 |
| 32 // Not thread safe. Only called from the main cast thread. | 31 // Not thread safe. Only called from the main cast thread. |
| 33 // This class owns all objects related to sending video, objects that create RTP | 32 // This class owns all objects related to sending video, objects that create RTP |
| 34 // packets, congestion control, video encoder, parsing and sending of | 33 // packets, congestion control, video encoder, parsing and sending of |
| 35 // RTCP packets. | 34 // RTCP packets. |
| 36 // Additionally it posts a bunch of delayed tasks to the main thread for various | 35 // Additionally it posts a bunch of delayed tasks to the main thread for various |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 scoped_ptr<VideoFrameFactory> CreateVideoFrameFactory(); | 60 scoped_ptr<VideoFrameFactory> CreateVideoFrameFactory(); |
| 62 | 61 |
| 63 protected: | 62 protected: |
| 64 int GetNumberOfFramesInEncoder() const final; | 63 int GetNumberOfFramesInEncoder() const final; |
| 65 base::TimeDelta GetInFlightMediaDuration() const final; | 64 base::TimeDelta GetInFlightMediaDuration() const final; |
| 66 void OnAck(uint32 frame_id) final; | 65 void OnAck(uint32 frame_id) final; |
| 67 | 66 |
| 68 private: | 67 private: |
| 69 // Called by the |video_encoder_| with the next EncodedFrame to send. | 68 // Called by the |video_encoder_| with the next EncodedFrame to send. |
| 70 void OnEncodedVideoFrame(int encoder_bitrate, | 69 void OnEncodedVideoFrame(int encoder_bitrate, |
| 71 scoped_ptr<SenderEncodedFrame> encoded_frame); | 70 scoped_ptr<EncodedFrame> encoded_frame); |
| 72 | 71 |
| 73 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, | 72 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, |
| 74 // this will point to either the internal software-based encoder or a proxy to | 73 // this will point to either the internal software-based encoder or a proxy to |
| 75 // a hardware-based encoder. | 74 // a hardware-based encoder. |
| 76 scoped_ptr<VideoEncoder> video_encoder_; | 75 scoped_ptr<VideoEncoder> video_encoder_; |
| 77 | 76 |
| 78 // The number of frames queued for encoding, but not yet sent. | 77 // The number of frames queued for encoding, but not yet sent. |
| 79 int frames_in_encoder_; | 78 int frames_in_encoder_; |
| 80 | 79 |
| 81 // The duration of video queued for encoding, but not yet sent. | 80 // The duration of video queued for encoding, but not yet sent. |
| 82 base::TimeDelta duration_in_encoder_; | 81 base::TimeDelta duration_in_encoder_; |
| 83 | 82 |
| 84 // The timestamp of the frame that was last enqueued in |video_encoder_|. | 83 // The timestamp of the frame that was last enqueued in |video_encoder_|. |
| 85 RtpTimestamp last_enqueued_frame_rtp_timestamp_; | 84 RtpTimestamp last_enqueued_frame_rtp_timestamp_; |
| 86 base::TimeTicks last_enqueued_frame_reference_time_; | 85 base::TimeTicks last_enqueued_frame_reference_time_; |
| 87 | 86 |
| 88 // Remember what we set the bitrate to before, no need to set it again if | 87 // Remember what we set the bitrate to before, no need to set it again if |
| 89 // we get the same value. | 88 // we get the same value. |
| 90 uint32 last_bitrate_; | 89 uint32 last_bitrate_; |
| 91 | 90 |
| 92 PlayoutDelayChangeCB playout_delay_change_cb_; | 91 PlayoutDelayChangeCB playout_delay_change_cb_; |
| 93 | 92 |
| 94 // The video encoder's performance metrics as of the last call to | |
| 95 // OnEncodedVideoFrame(). See header file comments for SenderEncodedFrame for | |
| 96 // an explanation of these values. | |
| 97 double last_reported_deadline_utilization_; | |
| 98 double last_reported_lossy_utilization_; | |
| 99 | |
| 100 // NOTE: Weak pointers must be invalidated before all other member variables. | 93 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 101 base::WeakPtrFactory<VideoSender> weak_factory_; | 94 base::WeakPtrFactory<VideoSender> weak_factory_; |
| 102 | 95 |
| 103 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 96 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
| 104 }; | 97 }; |
| 105 | 98 |
| 106 } // namespace cast | 99 } // namespace cast |
| 107 } // namespace media | 100 } // namespace media |
| 108 | 101 |
| 109 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ | 102 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ |
| OLD | NEW |