| 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 class VideoEncoder; | 26 class VideoEncoder; |
| 27 class VideoFrameFactory; |
| 27 | 28 |
| 28 typedef base::Callback<void(base::TimeDelta)> PlayoutDelayChangeCB; | 29 typedef base::Callback<void(base::TimeDelta)> PlayoutDelayChangeCB; |
| 29 | 30 |
| 30 // Not thread safe. Only called from the main cast thread. | 31 // Not thread safe. Only called from the main cast thread. |
| 31 // 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 |
| 32 // packets, congestion control, video encoder, parsing and sending of | 33 // packets, congestion control, video encoder, parsing and sending of |
| 33 // RTCP packets. | 34 // RTCP packets. |
| 34 // 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 |
| 35 // timeouts. | 36 // timeouts. |
| 36 class VideoSender : public FrameSender, | 37 class VideoSender : public FrameSender, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 49 | 50 |
| 50 // Note: It is not guaranteed that |video_frame| will actually be encoded and | 51 // Note: It is not guaranteed that |video_frame| will actually be encoded and |
| 51 // sent, if VideoSender detects too many frames in flight. Therefore, clients | 52 // sent, if VideoSender detects too many frames in flight. Therefore, clients |
| 52 // should be careful about the rate at which this method is called. | 53 // should be careful about the rate at which this method is called. |
| 53 // | 54 // |
| 54 // Note: It is invalid to call this method if InitializationResult() returns | 55 // Note: It is invalid to call this method if InitializationResult() returns |
| 55 // anything but STATUS_VIDEO_INITIALIZED. | 56 // anything but STATUS_VIDEO_INITIALIZED. |
| 56 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 57 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
| 57 const base::TimeTicks& reference_time); | 58 const base::TimeTicks& reference_time); |
| 58 | 59 |
| 60 // Creates a |VideoFrameFactory| object to vend |VideoFrame| object with |
| 61 // encoder affinity (defined as offering some sort of performance benefit). If |
| 62 // the encoder does not have any such capability, returns null. |
| 63 scoped_ptr<VideoFrameFactory> CreateVideoFrameFactory(); |
| 64 |
| 59 protected: | 65 protected: |
| 60 int GetNumberOfFramesInEncoder() const override; | 66 int GetNumberOfFramesInEncoder() const override; |
| 61 base::TimeDelta GetInFlightMediaDuration() const override; | 67 base::TimeDelta GetInFlightMediaDuration() const override; |
| 62 void OnAck(uint32 frame_id) override; | 68 void OnAck(uint32 frame_id) override; |
| 63 | 69 |
| 64 private: | 70 private: |
| 65 // Called when the encoder is initialized or has failed to initialize. | 71 // Called when the encoder is initialized or has failed to initialize. |
| 66 void OnEncoderInitialized( | 72 void OnEncoderInitialized( |
| 67 const CastInitializationCallback& initialization_cb, | 73 const CastInitializationCallback& initialization_cb, |
| 68 CastInitializationStatus status); | 74 CastInitializationStatus status); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 95 // NOTE: Weak pointers must be invalidated before all other member variables. | 101 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 96 base::WeakPtrFactory<VideoSender> weak_factory_; | 102 base::WeakPtrFactory<VideoSender> weak_factory_; |
| 97 | 103 |
| 98 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 104 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
| 99 }; | 105 }; |
| 100 | 106 |
| 101 } // namespace cast | 107 } // namespace cast |
| 102 } // namespace media | 108 } // namespace media |
| 103 | 109 |
| 104 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ | 110 #endif // MEDIA_CAST_SENDER_VIDEO_SENDER_H_ |
| OLD | NEW |