| 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 | 27 |
| 28 typedef base::Callback<void(base::TimeDelta)> PlayoutDelayChangeCB; |
| 29 |
| 28 // Not thread safe. Only called from the main cast thread. | 30 // Not thread safe. Only called from the main cast thread. |
| 29 // This class owns all objects related to sending video, objects that create RTP | 31 // This class owns all objects related to sending video, objects that create RTP |
| 30 // packets, congestion control, video encoder, parsing and sending of | 32 // packets, congestion control, video encoder, parsing and sending of |
| 31 // RTCP packets. | 33 // RTCP packets. |
| 32 // Additionally it posts a bunch of delayed tasks to the main thread for various | 34 // Additionally it posts a bunch of delayed tasks to the main thread for various |
| 33 // timeouts. | 35 // timeouts. |
| 34 class VideoSender : public FrameSender, | 36 class VideoSender : public FrameSender, |
| 35 public base::NonThreadSafe, | 37 public base::NonThreadSafe, |
| 36 public base::SupportsWeakPtr<VideoSender> { | 38 public base::SupportsWeakPtr<VideoSender> { |
| 37 public: | 39 public: |
| 38 VideoSender(scoped_refptr<CastEnvironment> cast_environment, | 40 VideoSender(scoped_refptr<CastEnvironment> cast_environment, |
| 39 const VideoSenderConfig& video_config, | 41 const VideoSenderConfig& video_config, |
| 40 const CastInitializationCallback& initialization_cb, | 42 const CastInitializationCallback& initialization_cb, |
| 41 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, | 43 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
| 42 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, | 44 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, |
| 43 CastTransportSender* const transport_sender); | 45 CastTransportSender* const transport_sender, |
| 46 const PlayoutDelayChangeCB& playout_delay_change_cb); |
| 44 | 47 |
| 45 virtual ~VideoSender(); | 48 virtual ~VideoSender(); |
| 46 | 49 |
| 47 // Note: It is not guaranteed that |video_frame| will actually be encoded and | 50 // 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 | 51 // sent, if VideoSender detects too many frames in flight. Therefore, clients |
| 49 // should be careful about the rate at which this method is called. | 52 // should be careful about the rate at which this method is called. |
| 50 // | 53 // |
| 51 // Note: It is invalid to call this method if InitializationResult() returns | 54 // Note: It is invalid to call this method if InitializationResult() returns |
| 52 // anything but STATUS_VIDEO_INITIALIZED. | 55 // anything but STATUS_VIDEO_INITIALIZED. |
| 53 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 56 void InsertRawVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 72 // a hardware-based encoder. | 75 // a hardware-based encoder. |
| 73 scoped_ptr<VideoEncoder> video_encoder_; | 76 scoped_ptr<VideoEncoder> video_encoder_; |
| 74 | 77 |
| 75 // The number of frames queued for encoding, but not yet sent. | 78 // The number of frames queued for encoding, but not yet sent. |
| 76 int frames_in_encoder_; | 79 int frames_in_encoder_; |
| 77 | 80 |
| 78 // Remember what we set the bitrate to before, no need to set it again if | 81 // Remember what we set the bitrate to before, no need to set it again if |
| 79 // we get the same value. | 82 // we get the same value. |
| 80 uint32 last_bitrate_; | 83 uint32 last_bitrate_; |
| 81 | 84 |
| 85 PlayoutDelayChangeCB playout_delay_change_cb_; |
| 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 |