| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This is the main interface for the cast sender. | 5 // This is the main interface for the cast sender. |
| 6 // | 6 // |
| 7 // The AudioFrameInput, VideoFrameInput and PacketReciever interfaces should | 7 // The AudioFrameInput, VideoFrameInput and PacketReciever interfaces should |
| 8 // be accessed from the main thread. | 8 // be accessed from the main thread. |
| 9 | 9 |
| 10 #ifndef MEDIA_CAST_CAST_SENDER_H_ | 10 #ifndef MEDIA_CAST_CAST_SENDER_H_ |
| 11 #define MEDIA_CAST_CAST_SENDER_H_ | 11 #define MEDIA_CAST_CAST_SENDER_H_ |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/time/tick_clock.h" | 17 #include "base/time/tick_clock.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "media/base/audio_bus.h" | 19 #include "media/base/audio_bus.h" |
| 20 #include "media/cast/cast_config.h" | 20 #include "media/cast/cast_config.h" |
| 21 #include "media/cast/cast_environment.h" | 21 #include "media/cast/cast_environment.h" |
| 22 #include "media/cast/net/cast_transport_sender.h" | 22 #include "media/cast/net/cast_transport_sender.h" |
| 23 | 23 |
| 24 namespace gfx { |
| 25 class Size; |
| 26 } |
| 27 |
| 24 namespace media { | 28 namespace media { |
| 25 class VideoFrame; | 29 class VideoFrame; |
| 26 | 30 |
| 27 namespace cast { | 31 namespace cast { |
| 28 class AudioSender; | 32 class AudioSender; |
| 29 class VideoSender; | 33 class VideoSender; |
| 30 | 34 |
| 31 class VideoFrameInput : public base::RefCountedThreadSafe<VideoFrameInput> { | 35 class VideoFrameInput : public base::RefCountedThreadSafe<VideoFrameInput> { |
| 32 public: | 36 public: |
| 33 // Insert video frames into Cast sender. Frames will be encoded, packetized | 37 // Insert video frames into Cast sender. Frames will be encoded, packetized |
| 34 // and sent to the network. | 38 // and sent to the network. |
| 35 virtual void InsertRawVideoFrame( | 39 virtual void InsertRawVideoFrame( |
| 36 const scoped_refptr<media::VideoFrame>& video_frame, | 40 const scoped_refptr<media::VideoFrame>& video_frame, |
| 37 const base::TimeTicks& capture_time) = 0; | 41 const base::TimeTicks& capture_time) = 0; |
| 38 | 42 |
| 39 // Creates a |VideoFrame| optimized for the encoder. When available, these | 43 // Creates a |VideoFrame| optimized for the encoder. When available, these |
| 40 // frames offer performance benefits, such as memory copy elimination. The | 44 // frames offer performance benefits, such as memory copy elimination. The |
| 41 // format is guaranteed to be I420 or NV12. | 45 // format is guaranteed to be I420 or NV12. |
| 42 // | 46 // |
| 43 // Not every encoder supports this method. Use |ShouldCreateOptimizedFrame| | 47 // Not every encoder supports this method. Use |CanCreateOptimizedFrames| to |
| 44 // to determine if you can and should use this method. Calling | 48 // determine if you can and should use this method. |
| 45 // this method when |ShouldCreateOptimizedFrame| is false will CHECK. | 49 // |
| 46 virtual scoped_refptr<VideoFrame> CreateOptimizedFrame( | 50 // Even if |CanCreateOptimizedFrames| indicates support, there are transient |
| 47 base::TimeDelta timestamp) = 0; | 51 // conditions during a session where optimized frames cannot be provided. In |
| 52 // this case, the caller must be able to account for a nullptr return value |
| 53 // and instantiate its own media::VideoFrames. |
| 54 virtual scoped_refptr<VideoFrame> MaybeCreateOptimizedFrame( |
| 55 const gfx::Size& frame_size, base::TimeDelta timestamp) = 0; |
| 48 | 56 |
| 49 // Returns true if the encoder supports creating optimized frames. | 57 // Returns true if the encoder supports creating optimized frames. |
| 50 virtual bool SupportsCreateOptimizedFrame() const = 0; | 58 virtual bool CanCreateOptimizedFrames() const = 0; |
| 51 | 59 |
| 52 protected: | 60 protected: |
| 53 virtual ~VideoFrameInput() {} | 61 virtual ~VideoFrameInput() {} |
| 54 | 62 |
| 55 private: | 63 private: |
| 56 friend class base::RefCountedThreadSafe<VideoFrameInput>; | 64 friend class base::RefCountedThreadSafe<VideoFrameInput>; |
| 57 }; | 65 }; |
| 58 | 66 |
| 59 class AudioFrameInput : public base::RefCountedThreadSafe<AudioFrameInput> { | 67 class AudioFrameInput : public base::RefCountedThreadSafe<AudioFrameInput> { |
| 60 public: | 68 public: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // Change the target delay. This is only valid if the receiver | 113 // Change the target delay. This is only valid if the receiver |
| 106 // supports the "adaptive_target_delay" rtp extension. | 114 // supports the "adaptive_target_delay" rtp extension. |
| 107 virtual void SetTargetPlayoutDelay( | 115 virtual void SetTargetPlayoutDelay( |
| 108 base::TimeDelta new_target_playout_delay) = 0; | 116 base::TimeDelta new_target_playout_delay) = 0; |
| 109 }; | 117 }; |
| 110 | 118 |
| 111 } // namespace cast | 119 } // namespace cast |
| 112 } // namespace media | 120 } // namespace media |
| 113 | 121 |
| 114 #endif // MEDIA_CAST_CAST_SENDER_H_ | 122 #endif // MEDIA_CAST_CAST_SENDER_H_ |
| OLD | NEW |