| 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 <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 14 #include "base/time/tick_clock.h" | 15 #include "base/time/tick_clock.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "media/cast/cast_config.h" | 17 #include "media/cast/cast_config.h" |
| 17 #include "media/cast/cast_sender.h" | 18 #include "media/cast/cast_sender.h" |
| 18 #include "media/cast/common/rtp_time.h" | 19 #include "media/cast/common/rtp_time.h" |
| 19 #include "media/cast/sender/congestion_control.h" | 20 #include "media/cast/sender/congestion_control.h" |
| 20 #include "media/cast/sender/frame_sender.h" | 21 #include "media/cast/sender/frame_sender.h" |
| 21 | 22 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 54 |
| 54 // Note: It is not guaranteed that |video_frame| will actually be encoded and | 55 // Note: It is not guaranteed that |video_frame| will actually be encoded and |
| 55 // sent, if VideoSender detects too many frames in flight. Therefore, clients | 56 // sent, if VideoSender detects too many frames in flight. Therefore, clients |
| 56 // should be careful about the rate at which this method is called. | 57 // should be careful about the rate at which this method is called. |
| 57 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 58 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
| 58 const base::TimeTicks& reference_time); | 59 const base::TimeTicks& reference_time); |
| 59 | 60 |
| 60 // Creates a |VideoFrameFactory| object to vend |VideoFrame| object with | 61 // Creates a |VideoFrameFactory| object to vend |VideoFrame| object with |
| 61 // encoder affinity (defined as offering some sort of performance benefit). If | 62 // encoder affinity (defined as offering some sort of performance benefit). If |
| 62 // the encoder does not have any such capability, returns null. | 63 // the encoder does not have any such capability, returns null. |
| 63 scoped_ptr<VideoFrameFactory> CreateVideoFrameFactory(); | 64 std::unique_ptr<VideoFrameFactory> CreateVideoFrameFactory(); |
| 64 | 65 |
| 65 protected: | 66 protected: |
| 66 int GetNumberOfFramesInEncoder() const final; | 67 int GetNumberOfFramesInEncoder() const final; |
| 67 base::TimeDelta GetInFlightMediaDuration() const final; | 68 base::TimeDelta GetInFlightMediaDuration() const final; |
| 68 | 69 |
| 69 private: | 70 private: |
| 70 // Called by the |video_encoder_| with the next EncodedFrame to send. | 71 // Called by the |video_encoder_| with the next EncodedFrame to send. |
| 71 void OnEncodedVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 72 void OnEncodedVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
| 72 int encoder_bitrate, | 73 int encoder_bitrate, |
| 73 scoped_ptr<SenderEncodedFrame> encoded_frame); | 74 std::unique_ptr<SenderEncodedFrame> encoded_frame); |
| 74 | 75 |
| 75 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, | 76 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, |
| 76 // this will point to either the internal software-based encoder or a proxy to | 77 // this will point to either the internal software-based encoder or a proxy to |
| 77 // a hardware-based encoder. | 78 // a hardware-based encoder. |
| 78 scoped_ptr<VideoEncoder> video_encoder_; | 79 std::unique_ptr<VideoEncoder> video_encoder_; |
| 79 | 80 |
| 80 // The number of frames queued for encoding, but not yet sent. | 81 // The number of frames queued for encoding, but not yet sent. |
| 81 int frames_in_encoder_; | 82 int frames_in_encoder_; |
| 82 | 83 |
| 83 // The duration of video queued for encoding, but not yet sent. | 84 // The duration of video queued for encoding, but not yet sent. |
| 84 base::TimeDelta duration_in_encoder_; | 85 base::TimeDelta duration_in_encoder_; |
| 85 | 86 |
| 86 // The timestamp of the frame that was last enqueued in |video_encoder_|. | 87 // The timestamp of the frame that was last enqueued in |video_encoder_|. |
| 87 RtpTimeTicks last_enqueued_frame_rtp_timestamp_; | 88 RtpTimeTicks last_enqueued_frame_rtp_timestamp_; |
| 88 base::TimeTicks last_enqueued_frame_reference_time_; | 89 base::TimeTicks last_enqueued_frame_reference_time_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 112 // NOTE: Weak pointers must be invalidated before all other member variables. | 113 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 113 base::WeakPtrFactory<VideoSender> weak_factory_; | 114 base::WeakPtrFactory<VideoSender> weak_factory_; |
| 114 | 115 |
| 115 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 116 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 } // namespace cast | 119 } // namespace cast |
| 119 } // namespace media | 120 } // namespace media |
| 120 | 121 |
| 121 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ | 122 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ |
| OLD | NEW |