pub struct AVCaptureScreenInput { /* private fields */ }AVCaptureInput only.Expand description
AVCaptureScreenInput is a concrete subclass of AVCaptureInput that provides an interface for capturing media from a screen or portion thereof.
Instances of AVCaptureScreenInput are input sources for AVCaptureSession that provide media data from one of the screens connected to the system, represented by CGDirectDisplayIDs.
See also Apple’s documentation
Implementations§
Source§impl AVCaptureScreenInput
impl AVCaptureScreenInput
Sourcepub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
Creates an AVCaptureScreenInput instance that provides media data from the main display.
This method creates an instance of AVCaptureScreenInput using the main display whose id is returned from CGMainDisplayID().
pub unsafe fn new() -> Retained<Self>
Sourcepub unsafe fn initWithDisplayID(
this: Allocated<Self>,
display_id: CGDirectDisplayID,
) -> Option<Retained<Self>>
Available on crate feature objc2-core-graphics only.
pub unsafe fn initWithDisplayID( this: Allocated<Self>, display_id: CGDirectDisplayID, ) -> Option<Retained<Self>>
objc2-core-graphics only.Creates an AVCaptureScreenInput instance that provides media data from the given display.
Parameter displayID: The id of the display from which to capture video. CGDirectDisplayID is defined in
<CoreGraphics
/CGDirectDisplay.h>
Returns: An AVCaptureScreenInput instance that provides data from the given screen, or nil, if the screen could not be used for capture.
This method creates an instance of AVCaptureScreenInput that can be used to capture data from a display in an AVCaptureSession. This method validates the displayID. If the display cannot be used because it is not available on the system, for example, this method returns nil.
Sourcepub unsafe fn minFrameDuration(&self) -> CMTime
Available on crate feature objc2-core-media only.
pub unsafe fn minFrameDuration(&self) -> CMTime
objc2-core-media only.A property indicating the screen input’s minimum frame duration.
An AVCaptureScreenInput’s minFrameDuration is the reciprocal of its maximum frame rate. This property may be used to request a maximum frame rate at which the input produces video frames. The requested rate may not be achievable due to overall bandwidth, so actual frame rates may be lower.
Sourcepub unsafe fn setMinFrameDuration(&self, min_frame_duration: CMTime)
Available on crate feature objc2-core-media only.
pub unsafe fn setMinFrameDuration(&self, min_frame_duration: CMTime)
objc2-core-media only.Setter for minFrameDuration.
Sourcepub unsafe fn cropRect(&self) -> CGRect
Available on crate feature objc2-core-foundation only.
pub unsafe fn cropRect(&self) -> CGRect
objc2-core-foundation only.A property indicating the bounding rectangle of the screen area to be captured in points.
By default, AVCaptureScreenInput captures the entire area of the displayID with which it is associated. To limit the capture rectangle to a subsection of the screen, set the cropRect property, which defines a smaller section of the screen in the screen’s coordinate system. The origin (0,0) is the bottom-left corner of the screen.
Sourcepub unsafe fn setCropRect(&self, crop_rect: CGRect)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setCropRect(&self, crop_rect: CGRect)
objc2-core-foundation only.Setter for cropRect.
Sourcepub unsafe fn scaleFactor(&self) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn scaleFactor(&self) -> CGFloat
objc2-core-foundation only.A property indicating the factor by which video buffers captured from the screen are to be scaled.
By default, AVCaptureScreenInput captures the video buffers from the display at a scale factor of 1.0 (no scaling). Set this property to scale the buffers by a given factor. For instance, a 320x240 capture area with a scaleFactor of 2.0f produces video buffers at 640x480.
Sourcepub unsafe fn setScaleFactor(&self, scale_factor: CGFloat)
Available on crate feature objc2-core-foundation only.
pub unsafe fn setScaleFactor(&self, scale_factor: CGFloat)
objc2-core-foundation only.Setter for scaleFactor.
Sourcepub unsafe fn capturesMouseClicks(&self) -> bool
pub unsafe fn capturesMouseClicks(&self) -> bool
A property indicating whether mouse clicks should be highlighted in the captured output.
By default, AVCaptureScreenInput does not highlight mouse clicks in its captured output. If this property is set to YES, mouse clicks are highlighted (a circle is drawn around the mouse for the duration of the click) in the captured output.
Sourcepub unsafe fn setCapturesMouseClicks(&self, captures_mouse_clicks: bool)
pub unsafe fn setCapturesMouseClicks(&self, captures_mouse_clicks: bool)
Setter for capturesMouseClicks.
Sourcepub unsafe fn capturesCursor(&self) -> bool
pub unsafe fn capturesCursor(&self) -> bool
A property indicating whether the cursor should be rendered to the captured output.
By default, AVCaptureScreenInput draws the cursor in its captured output. If this property is set to NO, the captured output contains only the windows on the screen. Cursor is omitted. Note that cursor position and mouse button state at the time of capture is preserved in CMSampleBuffers emitted from AVCaptureScreenInput. See the inline documentation for kCMIOSampleBufferAttachmentKey_MouseAndKeyboardModifiers in <CoreMediaIO /CMIOSampleBuffer.h>
Sourcepub unsafe fn setCapturesCursor(&self, captures_cursor: bool)
pub unsafe fn setCapturesCursor(&self, captures_cursor: bool)
Setter for capturesCursor.
Sourcepub unsafe fn removesDuplicateFrames(&self) -> bool
👎Deprecated: No longer supported.
pub unsafe fn removesDuplicateFrames(&self) -> bool
A property indicating whether duplicate frames should be removed by the input.
If this property is set to YES, AVCaptureScreenInput performs frame differencing and when it detects duplicate frames, it drops them. If set to NO, the captured output receives all frames from the input. Prior to 10.9 this value defaulted to YES. In 10.9 and later, it defaults to NO, as modern platforms support frame differencing in hardware-based encoders.
As of 10.10, this property has been deprecated and is ignored. Clients wishing to re-create this functionality can use an AVCaptureVideoDataOutput and compare frame contents in their own code. If they wish to write a movie file, they can then pass the unique frames to an AVAssetWriterInput.
Sourcepub unsafe fn setRemovesDuplicateFrames(&self, removes_duplicate_frames: bool)
👎Deprecated: No longer supported.
pub unsafe fn setRemovesDuplicateFrames(&self, removes_duplicate_frames: bool)
Setter for removesDuplicateFrames.
Methods from Deref<Target = AVCaptureInput>§
Sourcepub unsafe fn ports(&self) -> Retained<NSArray<AVCaptureInputPort>>
pub unsafe fn ports(&self) -> Retained<NSArray<AVCaptureInputPort>>
The ports owned by the receiver.
The value of this property is an array of AVCaptureInputPort objects, each exposing an interface to a single stream of media data provided by an input.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AVCaptureInput> for AVCaptureScreenInput
impl AsRef<AVCaptureInput> for AVCaptureScreenInput
Source§fn as_ref(&self) -> &AVCaptureInput
fn as_ref(&self) -> &AVCaptureInput
Source§impl AsRef<AnyObject> for AVCaptureScreenInput
impl AsRef<AnyObject> for AVCaptureScreenInput
Source§impl AsRef<NSObject> for AVCaptureScreenInput
impl AsRef<NSObject> for AVCaptureScreenInput
Source§impl Borrow<AVCaptureInput> for AVCaptureScreenInput
impl Borrow<AVCaptureInput> for AVCaptureScreenInput
Source§fn borrow(&self) -> &AVCaptureInput
fn borrow(&self) -> &AVCaptureInput
Source§impl Borrow<AnyObject> for AVCaptureScreenInput
impl Borrow<AnyObject> for AVCaptureScreenInput
Source§impl Borrow<NSObject> for AVCaptureScreenInput
impl Borrow<NSObject> for AVCaptureScreenInput
Source§impl ClassType for AVCaptureScreenInput
impl ClassType for AVCaptureScreenInput
Source§const NAME: &'static str = "AVCaptureScreenInput"
const NAME: &'static str = "AVCaptureScreenInput"
Source§type Super = AVCaptureInput
type Super = AVCaptureInput
Source§type ThreadKind = <<AVCaptureScreenInput as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<AVCaptureScreenInput as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for AVCaptureScreenInput
impl Debug for AVCaptureScreenInput
Source§impl Deref for AVCaptureScreenInput
impl Deref for AVCaptureScreenInput
Source§impl Hash for AVCaptureScreenInput
impl Hash for AVCaptureScreenInput
Source§impl Message for AVCaptureScreenInput
impl Message for AVCaptureScreenInput
Source§impl NSObjectProtocol for AVCaptureScreenInput
impl NSObjectProtocol for AVCaptureScreenInput
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref