Chromium Code Reviews| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/power_monitor/power_observer.h" | 12 #include "base/power_monitor/power_observer.h" |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "media/base/mac/videotoolbox_glue.h" | 14 #include "media/base/mac/videotoolbox_glue.h" |
| 15 #include "media/base/mac/videotoolbox_helpers.h" | |
| 15 #include "media/cast/sender/size_adaptable_video_encoder_base.h" | 16 #include "media/cast/sender/size_adaptable_video_encoder_base.h" |
| 16 #include "media/cast/sender/video_encoder.h" | 17 #include "media/cast/sender/video_encoder.h" |
| 17 | 18 |
| 18 namespace media { | 19 namespace media { |
| 19 namespace cast { | 20 namespace cast { |
| 20 | 21 |
| 21 // VideoToolbox implementation of the media::cast::VideoEncoder interface. | 22 // VideoToolbox implementation of the media::cast::VideoEncoder interface. |
| 22 // VideoToolbox makes no guarantees that it is thread safe, so this object is | 23 // VideoToolbox makes no guarantees that it is thread safe, so this object is |
| 23 // pinned to the thread on which it is constructed. Supports changing frame | 24 // pinned to the thread on which it is constructed. Supports changing frame |
| 24 // sizes directly. Implements the base::PowerObserver interface to reset the | 25 // sizes directly. Implements the base::PowerObserver interface to reset the |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 69 |
| 69 // Destroy the current compression session if any. Blocks until all pending | 70 // Destroy the current compression session if any. Blocks until all pending |
| 70 // frames have been flushed out (similar to EmitFrames without doing any | 71 // frames have been flushed out (similar to EmitFrames without doing any |
| 71 // encoding work). | 72 // encoding work). |
| 72 void DestroyCompressionSession(); | 73 void DestroyCompressionSession(); |
| 73 | 74 |
| 74 // Update the encoder's target frame size by resetting the compression | 75 // Update the encoder's target frame size by resetting the compression |
| 75 // session. This will also update the video frame factory. | 76 // session. This will also update the video frame factory. |
| 76 void UpdateFrameSize(const gfx::Size& size_needed); | 77 void UpdateFrameSize(const gfx::Size& size_needed); |
| 77 | 78 |
| 78 // Set a compression session property. | |
| 79 bool SetSessionProperty(CFStringRef key, int32_t value); | |
| 80 bool SetSessionProperty(CFStringRef key, bool value); | |
| 81 bool SetSessionProperty(CFStringRef key, CFStringRef value); | |
| 82 | |
| 83 // Compression session callback function to handle compressed frames. | 79 // Compression session callback function to handle compressed frames. |
| 84 static void CompressionCallback(void* encoder_opaque, | 80 static void CompressionCallback(void* encoder_opaque, |
| 85 void* request_opaque, | 81 void* request_opaque, |
| 86 OSStatus status, | 82 OSStatus status, |
| 87 VTEncodeInfoFlags info, | 83 VTEncodeInfoFlags info, |
| 88 CMSampleBufferRef sbuf); | 84 CMSampleBufferRef sbuf); |
| 89 | 85 |
| 90 // The cast environment (contains worker threads & more). | 86 // The cast environment (contains worker threads & more). |
| 91 const scoped_refptr<CastEnvironment> cast_environment_; | 87 const scoped_refptr<CastEnvironment> cast_environment_; |
| 92 | 88 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 116 | 112 |
| 117 // The ID of the last frame that was emitted. | 113 // The ID of the last frame that was emitted. |
| 118 uint32_t last_frame_id_; | 114 uint32_t last_frame_id_; |
| 119 | 115 |
| 120 // Force next frame to be a keyframe. | 116 // Force next frame to be a keyframe. |
| 121 bool encode_next_frame_as_keyframe_; | 117 bool encode_next_frame_as_keyframe_; |
| 122 | 118 |
| 123 // Power suspension state. | 119 // Power suspension state. |
| 124 bool power_suspended_; | 120 bool power_suspended_; |
| 125 | 121 |
| 122 // Set parameters for VTCompressionSession. | |
| 123 scoped_ptr<video_toolbox::SessionPropertySetter> session_property_setter_; | |
|
miu
2016/02/09 23:29:22
Please remove (see comment in .cc file).
emircan
2016/02/10 05:21:53
Done.
| |
| 124 | |
| 126 // NOTE: Weak pointers must be invalidated before all other member variables. | 125 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 127 base::WeakPtrFactory<H264VideoToolboxEncoder> weak_factory_; | 126 base::WeakPtrFactory<H264VideoToolboxEncoder> weak_factory_; |
| 128 | 127 |
| 129 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoder); | 128 DISALLOW_COPY_AND_ASSIGN(H264VideoToolboxEncoder); |
| 130 }; | 129 }; |
| 131 | 130 |
| 132 } // namespace cast | 131 } // namespace cast |
| 133 } // namespace media | 132 } // namespace media |
| 134 | 133 |
| 135 #endif // MEDIA_CAST_SENDER_H264_VT_ENCODER_H_ | 134 #endif // MEDIA_CAST_SENDER_H264_VT_ENCODER_H_ |
| OLD | NEW |