| 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_ENCODER_H_ | 5 #ifndef MEDIA_CAST_SENDER_VIDEO_ENCODER_H_ |
| 6 #define MEDIA_CAST_SENDER_VIDEO_ENCODER_H_ | 6 #define MEDIA_CAST_SENDER_VIDEO_ENCODER_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" | |
| 12 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 13 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 14 #include "media/cast/cast_config.h" | 13 #include "media/cast/cast_config.h" |
| 15 #include "media/cast/cast_environment.h" | 14 #include "media/cast/cast_environment.h" |
| 15 #include "media/cast/sender/video_frame_factory.h" |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 namespace cast { | 18 namespace cast { |
| 19 | 19 |
| 20 class VideoFrameFactory; | |
| 21 | |
| 22 // All these functions are called from the main cast thread. | 20 // All these functions are called from the main cast thread. |
| 23 class VideoEncoder { | 21 class VideoEncoder { |
| 24 public: | 22 public: |
| 25 typedef base::Callback<void(scoped_ptr<EncodedFrame>)> FrameEncodedCallback; | 23 typedef base::Callback<void(scoped_ptr<EncodedFrame>)> FrameEncodedCallback; |
| 26 | 24 |
| 25 // Creates a VideoEncoder instance from the given |video_config| and based on |
| 26 // the current platform's hardware/library support; or null if no |
| 27 // implementation will suffice. The instance will run |status_change_cb| at |
| 28 // some point in the future to indicate initialization success/failure. |
| 29 // |
| 30 // All VideoEncoder instances returned by this function support encoding |
| 31 // sequences of differently-size VideoFrames. |
| 32 // |
| 33 // TODO(miu): Remove the CreateVEA callbacks. http://crbug.com/454029 |
| 34 static scoped_ptr<VideoEncoder> Create( |
| 35 const scoped_refptr<CastEnvironment>& cast_environment, |
| 36 const VideoSenderConfig& video_config, |
| 37 const StatusChangeCallback& status_change_cb, |
| 38 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
| 39 const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb); |
| 40 |
| 27 virtual ~VideoEncoder() {} | 41 virtual ~VideoEncoder() {} |
| 28 | 42 |
| 29 // Returns true if the size of video frames passed in successive calls to | |
| 30 // EncodedVideoFrame() can vary. | |
| 31 virtual bool CanEncodeVariedFrameSizes() const = 0; | |
| 32 | |
| 33 // If true is returned, the Encoder has accepted the request and will process | 43 // If true is returned, the Encoder has accepted the request and will process |
| 34 // it asynchronously, running |frame_encoded_callback| on the MAIN | 44 // it asynchronously, running |frame_encoded_callback| on the MAIN |
| 35 // CastEnvironment thread with the result. If false is returned, nothing | 45 // CastEnvironment thread with the result. If false is returned, nothing |
| 36 // happens and the callback will not be run. | 46 // happens and the callback will not be run. |
| 37 virtual bool EncodeVideoFrame( | 47 virtual bool EncodeVideoFrame( |
| 38 const scoped_refptr<media::VideoFrame>& video_frame, | 48 const scoped_refptr<media::VideoFrame>& video_frame, |
| 39 const base::TimeTicks& reference_time, | 49 const base::TimeTicks& reference_time, |
| 40 const FrameEncodedCallback& frame_encoded_callback) = 0; | 50 const FrameEncodedCallback& frame_encoded_callback) = 0; |
| 41 | 51 |
| 42 // Inform the encoder about the new target bit rate. | 52 // Inform the encoder about the new target bit rate. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 59 // network congestion, it is necessary to flush out of the encoder all | 69 // network congestion, it is necessary to flush out of the encoder all |
| 60 // submitted frames so that eventually new frames may be encoded. Like | 70 // submitted frames so that eventually new frames may be encoded. Like |
| 61 // EncodeVideoFrame(), the encoder will process this request asynchronously. | 71 // EncodeVideoFrame(), the encoder will process this request asynchronously. |
| 62 virtual void EmitFrames(); | 72 virtual void EmitFrames(); |
| 63 }; | 73 }; |
| 64 | 74 |
| 65 } // namespace cast | 75 } // namespace cast |
| 66 } // namespace media | 76 } // namespace media |
| 67 | 77 |
| 68 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_H_ | 78 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_H_ |
| OLD | NEW |