Chromium Code Reviews| 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 handle a nullptr return value. | |
|
hubbe
2015/02/11 00:47:53
And do what?
Should the caller create an un-optimi
miu
2015/02/11 02:14:23
Done.
| |
| 53 virtual scoped_refptr<VideoFrame> MaybeCreateOptimizedFrame( | |
|
hubbe
2015/02/11 00:47:54
I think the "Maybe" is redundant.
miu
2015/02/11 02:14:23
I put it in there for two reasons: 1) The naming s
| |
| 54 const gfx::Size& frame_size, base::TimeDelta timestamp) = 0; | |
| 48 | 55 |
| 49 // Returns true if the encoder supports creating optimized frames. | 56 // Returns true if the encoder supports creating optimized frames. |
| 50 virtual bool SupportsCreateOptimizedFrame() const = 0; | 57 virtual bool CanCreateOptimizedFrames() const = 0; |
| 51 | 58 |
| 52 protected: | 59 protected: |
| 53 virtual ~VideoFrameInput() {} | 60 virtual ~VideoFrameInput() {} |
| 54 | 61 |
| 55 private: | 62 private: |
| 56 friend class base::RefCountedThreadSafe<VideoFrameInput>; | 63 friend class base::RefCountedThreadSafe<VideoFrameInput>; |
| 57 }; | 64 }; |
| 58 | 65 |
| 59 class AudioFrameInput : public base::RefCountedThreadSafe<AudioFrameInput> { | 66 class AudioFrameInput : public base::RefCountedThreadSafe<AudioFrameInput> { |
| 60 public: | 67 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 | 112 // Change the target delay. This is only valid if the receiver |
| 106 // supports the "adaptive_target_delay" rtp extension. | 113 // supports the "adaptive_target_delay" rtp extension. |
| 107 virtual void SetTargetPlayoutDelay( | 114 virtual void SetTargetPlayoutDelay( |
| 108 base::TimeDelta new_target_playout_delay) = 0; | 115 base::TimeDelta new_target_playout_delay) = 0; |
| 109 }; | 116 }; |
| 110 | 117 |
| 111 } // namespace cast | 118 } // namespace cast |
| 112 } // namespace media | 119 } // namespace media |
| 113 | 120 |
| 114 #endif // MEDIA_CAST_CAST_SENDER_H_ | 121 #endif // MEDIA_CAST_CAST_SENDER_H_ |
| OLD | NEW |