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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // Note: It is not guaranteed that |video_frame| will actually be encoded and | 47 // Note: It is not guaranteed that |video_frame| will actually be encoded and |
48 // sent, if VideoSender detects too many frames in flight. Therefore, clients | 48 // sent, if VideoSender detects too many frames in flight. Therefore, clients |
49 // should be careful about the rate at which this method is called. | 49 // should be careful about the rate at which this method is called. |
50 // | 50 // |
51 // Note: It is invalid to call this method if InitializationResult() returns | 51 // Note: It is invalid to call this method if InitializationResult() returns |
52 // anything but STATUS_VIDEO_INITIALIZED. | 52 // anything but STATUS_VIDEO_INITIALIZED. |
53 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 53 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
54 const base::TimeTicks& capture_time); | 54 const base::TimeTicks& capture_time); |
55 | 55 |
56 protected: | 56 protected: |
57 virtual int GetNumberOfFramesInEncoder() const OVERRIDE; | |
58 virtual void OnAck(uint32 frame_id) OVERRIDE; | 57 virtual void OnAck(uint32 frame_id) OVERRIDE; |
59 | 58 |
60 private: | 59 private: |
61 // Called when the encoder is initialized or has failed to initialize. | 60 // Called when the encoder is initialized or has failed to initialize. |
62 void OnEncoderInitialized( | 61 void OnEncoderInitialized( |
63 const CastInitializationCallback& initialization_cb, | 62 const CastInitializationCallback& initialization_cb, |
64 CastInitializationStatus status); | 63 CastInitializationStatus status); |
65 | 64 |
66 // Called by the |video_encoder_| with the next EncodedFrame to send. | 65 // Called by the |video_encoder_| with the next EncodedFrame to send. |
67 void OnEncodedVideoFrame(int encoder_bitrate, | 66 void OnEncodedVideoFrame(int encoder_bitrate, |
68 scoped_ptr<EncodedFrame> encoded_frame); | 67 scoped_ptr<EncodedFrame> encoded_frame); |
69 | 68 |
70 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, | 69 // Encodes media::VideoFrame images into EncodedFrames. Per configuration, |
71 // this will point to either the internal software-based encoder or a proxy to | 70 // this will point to either the internal software-based encoder or a proxy to |
72 // a hardware-based encoder. | 71 // a hardware-based encoder. |
73 scoped_ptr<VideoEncoder> video_encoder_; | 72 scoped_ptr<VideoEncoder> video_encoder_; |
74 | 73 |
75 // The number of frames queued for encoding, but not yet sent. | 74 // The number of frames queued for encoding, but not yet sent. |
76 int frames_in_encoder_; | 75 int frames_in_encoder_; |
77 | 76 |
| 77 // The duration of video queued for encoding, but not yet sent. |
| 78 base::TimeDelta duration_in_encoder_; |
| 79 |
| 80 // The timestamp of the frame that was last enqueued in |video_encoder_|. |
| 81 base::TimeTicks last_enqueued_frame_reference_time_; |
| 82 |
78 // Remember what we set the bitrate to before, no need to set it again if | 83 // Remember what we set the bitrate to before, no need to set it again if |
79 // we get the same value. | 84 // we get the same value. |
80 uint32 last_bitrate_; | 85 uint32 last_bitrate_; |
81 | 86 |
82 // NOTE: Weak pointers must be invalidated before all other member variables. | 87 // NOTE: Weak pointers must be invalidated before all other member variables. |
83 base::WeakPtrFactory<VideoSender> weak_factory_; | 88 base::WeakPtrFactory<VideoSender> weak_factory_; |
84 | 89 |
85 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 90 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
86 }; | 91 }; |
87 | 92 |
88 } // namespace cast | 93 } // namespace cast |
89 } // namespace media | 94 } // namespace media |
90 | 95 |
91 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ | 96 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ |
OLD | NEW |