| 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_H264_VT_ENCODER_H_ | 5 #ifndef MEDIA_CAST_SENDER_H264_VT_ENCODER_H_ |
| 6 #define MEDIA_CAST_SENDER_H264_VT_ENCODER_H_ | 6 #define MEDIA_CAST_SENDER_H264_VT_ENCODER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // compression session when the host process is suspended. | 26 // compression session when the host process is suspended. |
| 27 class H264VideoToolboxEncoder : public VideoEncoder, | 27 class H264VideoToolboxEncoder : public VideoEncoder, |
| 28 public base::PowerObserver { | 28 public base::PowerObserver { |
| 29 typedef CoreMediaGlue::CMSampleBufferRef CMSampleBufferRef; | 29 typedef CoreMediaGlue::CMSampleBufferRef CMSampleBufferRef; |
| 30 typedef VideoToolboxGlue::VTCompressionSessionRef VTCompressionSessionRef; | 30 typedef VideoToolboxGlue::VTCompressionSessionRef VTCompressionSessionRef; |
| 31 typedef VideoToolboxGlue::VTEncodeInfoFlags VTEncodeInfoFlags; | 31 typedef VideoToolboxGlue::VTEncodeInfoFlags VTEncodeInfoFlags; |
| 32 | 32 |
| 33 public: | 33 public: |
| 34 // Returns true if the current platform and system configuration supports | 34 // Returns true if the current platform and system configuration supports |
| 35 // using H264VideoToolboxEncoder with the given |video_config|. | 35 // using H264VideoToolboxEncoder with the given |video_config|. |
| 36 static bool IsSupported(const VideoSenderConfig& video_config); | 36 static bool IsSupported(const FrameSenderConfig& video_config); |
| 37 | 37 |
| 38 H264VideoToolboxEncoder( | 38 H264VideoToolboxEncoder( |
| 39 const scoped_refptr<CastEnvironment>& cast_environment, | 39 const scoped_refptr<CastEnvironment>& cast_environment, |
| 40 const VideoSenderConfig& video_config, | 40 const FrameSenderConfig& video_config, |
| 41 const StatusChangeCallback& status_change_cb); | 41 const StatusChangeCallback& status_change_cb); |
| 42 ~H264VideoToolboxEncoder() final; | 42 ~H264VideoToolboxEncoder() final; |
| 43 | 43 |
| 44 // media::cast::VideoEncoder implementation | 44 // media::cast::VideoEncoder implementation |
| 45 bool EncodeVideoFrame( | 45 bool EncodeVideoFrame( |
| 46 const scoped_refptr<media::VideoFrame>& video_frame, | 46 const scoped_refptr<media::VideoFrame>& video_frame, |
| 47 const base::TimeTicks& reference_time, | 47 const base::TimeTicks& reference_time, |
| 48 const FrameEncodedCallback& frame_encoded_callback) final; | 48 const FrameEncodedCallback& frame_encoded_callback) final; |
| 49 void SetBitRate(int new_bit_rate) final; | 49 void SetBitRate(int new_bit_rate) final; |
| 50 void GenerateKeyFrame() final; | 50 void GenerateKeyFrame() final; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 // The cast environment (contains worker threads & more). | 86 // The cast environment (contains worker threads & more). |
| 87 const scoped_refptr<CastEnvironment> cast_environment_; | 87 const scoped_refptr<CastEnvironment> cast_environment_; |
| 88 | 88 |
| 89 // VideoToolboxGlue provides access to VideoToolbox at runtime. | 89 // VideoToolboxGlue provides access to VideoToolbox at runtime. |
| 90 const VideoToolboxGlue* const videotoolbox_glue_; | 90 const VideoToolboxGlue* const videotoolbox_glue_; |
| 91 | 91 |
| 92 // VideoSenderConfig copy so we can create compression sessions on demand. | 92 // VideoSenderConfig copy so we can create compression sessions on demand. |
| 93 // This is needed to recover from backgrounding and other events that can | 93 // This is needed to recover from backgrounding and other events that can |
| 94 // invalidate compression sessions. | 94 // invalidate compression sessions. |
| 95 const VideoSenderConfig video_config_; | 95 const FrameSenderConfig video_config_; |
| 96 | 96 |
| 97 // Frame size of the current compression session. Can be changed by submitting | 97 // Frame size of the current compression session. Can be changed by submitting |
| 98 // a frame of a different size, which will cause a compression session reset. | 98 // a frame of a different size, which will cause a compression session reset. |
| 99 gfx::Size frame_size_; | 99 gfx::Size frame_size_; |
| 100 | 100 |
| 101 // Callback used to report initialization status and runtime errors. | 101 // Callback used to report initialization status and runtime errors. |
| 102 const StatusChangeCallback status_change_cb_; | 102 const StatusChangeCallback status_change_cb_; |
| 103 | 103 |
| 104 // Thread checker to enforce that this object is used on a specific thread. | 104 // Thread checker to enforce that this object is used on a specific thread. |
| 105 base::ThreadChecker thread_checker_; | 105 base::ThreadChecker thread_checker_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 122 // NOTE: Weak pointers must be invalidated before all other member variables. | 122 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 123 base::WeakPtrFactory<H264VideoToolboxEncoder> weak_factory_; | 123 base::WeakPtrFactory<H264VideoToolboxEncoder> weak_factory_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoder); | 125 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoder); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace cast | 128 } // namespace cast |
| 129 } // namespace media | 129 } // namespace media |
| 130 | 130 |
| 131 #endif // MEDIA_CAST_SENDER_H264_VT_ENCODER_H_ | 131 #endif // MEDIA_CAST_SENDER_H264_VT_ENCODER_H_ |
| OLD | NEW |