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