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