pub struct SCStream { /* private fields */ }SCStream only.Expand description
Implementations§
Source§impl SCStream
impl SCStream
Sourcepub unsafe fn synchronizationClock(&self) -> Option<Retained<CMClock>>
Available on crate feature objc2-core-media only.
pub unsafe fn synchronizationClock(&self) -> Option<Retained<CMClock>>
objc2-core-media only.Synchronization clock used for media capture.
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn new() -> Retained<Self>
Sourcepub unsafe fn initWithFilter_configuration_delegate(
this: Allocated<Self>,
content_filter: &SCContentFilter,
stream_config: &SCStreamConfiguration,
delegate: Option<&ProtocolObject<dyn SCStreamDelegate>>,
) -> Retained<Self>
pub unsafe fn initWithFilter_configuration_delegate( this: Allocated<Self>, content_filter: &SCContentFilter, stream_config: &SCStreamConfiguration, delegate: Option<&ProtocolObject<dyn SCStreamDelegate>>, ) -> Retained<Self>
initWithFilter:configuration:delegate:
Parameter contentFilter: the requested content filter to be captured
Parameter streamConfig: the requested stream configuration to be applied to the SCStream
Parameter delegate: the SCStream delegate object
this method create a SCStream object that has the particular output settings for the content stream
Sourcepub unsafe fn addStreamOutput_type_sampleHandlerQueue_error(
&self,
output: &ProtocolObject<dyn SCStreamOutput>,
type: SCStreamOutputType,
sample_handler_queue: Option<&DispatchQueue>,
) -> Result<(), Retained<NSError>>
Available on crate feature dispatch2 only.
pub unsafe fn addStreamOutput_type_sampleHandlerQueue_error( &self, output: &ProtocolObject<dyn SCStreamOutput>, type: SCStreamOutputType, sample_handler_queue: Option<&DispatchQueue>, ) -> Result<(), Retained<NSError>>
dispatch2 only.addStreamOutput:type:sampleHandlerQueue:error:
Parameter output: an object that adheres to the SCStreamOutput protocol that will receive the frames and call its delegate frame call back on its sample handler queue
Parameter type: the SCStreamOutput type
Parameter sampleHandlerQueue: the return queue for the sample handler
Parameter error: the error pertaining to the add stream output
An SCStreamOutput protocol object instance can only be added to a session using -addStreamOutput: Returns a BOOL denoting if the add was successful
§Safety
sample_handler_queue possibly has additional threading requirements.
Sourcepub unsafe fn removeStreamOutput_type_error(
&self,
output: &ProtocolObject<dyn SCStreamOutput>,
type: SCStreamOutputType,
) -> Result<(), Retained<NSError>>
pub unsafe fn removeStreamOutput_type_error( &self, output: &ProtocolObject<dyn SCStreamOutput>, type: SCStreamOutputType, ) -> Result<(), Retained<NSError>>
removeStreamOutput:type:error:
Parameter output: an object that adheres to the SCStreamOutput protocol that will received the frames and call its delegate frame call back on its sample handler queue
Parameter type: the SCStreamOutput type
Parameter error: the error pertaining to the removing stream output
An SCStreamOutput protocol object instance can only be removed to a session using -addStreamOutput: Returns a BOOL denoting if the remove was successful
Sourcepub unsafe fn updateContentFilter_completionHandler(
&self,
content_filter: &SCContentFilter,
completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>,
)
Available on crate feature block2 only.
pub unsafe fn updateContentFilter_completionHandler( &self, content_filter: &SCContentFilter, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.updateContentFilter:completionHandler:
Parameter contentFilter: the requested content filter to be updated
Parameter completionHandler: the handler to be called when the function completes
this method will update the content filter for a content stream. A completion handler will be called when the update is complete with an error denoting if the update has failed.
Sourcepub unsafe fn updateConfiguration_completionHandler(
&self,
stream_config: &SCStreamConfiguration,
completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>,
)
Available on crate feature block2 only.
pub unsafe fn updateConfiguration_completionHandler( &self, stream_config: &SCStreamConfiguration, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.updateConfiguration:completionHandler:
Parameter streamConfig: the requested content filter to be updated
Parameter completionHandler: the handler to be called when the function completes
this method will update the stream configuration for a content stream. A completion handler will be called when the update is complete with an error denoting if the update has failed.
Sourcepub unsafe fn startCaptureWithCompletionHandler(
&self,
completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>,
)
Available on crate feature block2 only.
pub unsafe fn startCaptureWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.startCaptureWithCompletionHandler:
Parameter completionHandler: the handler to be called when the function completes
this method starts the content stream. The handler will be called when the content stream start has completed with an error denoting if the start has failed.
Sourcepub unsafe fn stopCaptureWithCompletionHandler(
&self,
completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>,
)
Available on crate feature block2 only.
pub unsafe fn stopCaptureWithCompletionHandler( &self, completion_handler: Option<&DynBlock<dyn Fn(*mut NSError)>>, )
block2 only.stopCaptureWithCompletionHandler:
Parameter completionHandler: the handler to be called when the function completes
this method stops the content stream. The handler will be called when the content stream stop has completed with an error denoting if the stop has failed.
Sourcepub unsafe fn addRecordingOutput_error(
&self,
recording_output: &SCRecordingOutput,
) -> Result<(), Retained<NSError>>
Available on crate feature SCRecordingOutput only.
pub unsafe fn addRecordingOutput_error( &self, recording_output: &SCRecordingOutput, ) -> Result<(), Retained<NSError>>
SCRecordingOutput only.Add a SCRecordingOutput to the SCStream. Starts Recording if stream is already capturing, otherwise recording will be started after capture starts. Recording will be written into a file url specified in SCRecordingOutput. Media(Screen/Audio/Microphone) to be recorded will be based on the SCStream configuration.
Parameter recordingOutput: an SCRecordingOutput that including configuration of recording, and delegate for recording event.
Parameter error: the error pertaining to the add recording output
Returns a BOOL denoting if the add was successful. Currently only support one recordingOutput on a stream. To guarantee the first sample captured in the stream to be written into the recording file, client need to add recordingOutput before startCapture. Delegate for recordingDidStart will be notified in SCRecordingOutput or recordingDidFinishWithError will be notified with an error associated if recording failed to start.
Sourcepub unsafe fn removeRecordingOutput_error(
&self,
recording_output: &SCRecordingOutput,
) -> Result<(), Retained<NSError>>
Available on crate feature SCRecordingOutput only.
pub unsafe fn removeRecordingOutput_error( &self, recording_output: &SCRecordingOutput, ) -> Result<(), Retained<NSError>>
SCRecordingOutput only.Remove SCRecordingOutput from the SCStream. Stops Recording if the stream is currently recording.
Parameter recordingOutput: an SCRecordingOutput that including configuration of recording, and delegate for recording event.
Parameter error: the error pertaining to the remove recording output
Returns a BOOL denoting if the remove was successful. Delegate for recordingDidFinishWithError will be notified in SCRecordingOutput, associate with an error code if recording failed to finish written to the file. If stopCapture is called without removing recordingOutput, recording will be stopped and finish writting into the file. In case client update the stream configuration during recording, recording will be stopped as well.
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 ClassType for SCStream
impl ClassType for SCStream
Source§const NAME: &'static str = "SCStream"
const NAME: &'static str = "SCStream"
Source§type ThreadKind = <<SCStream as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<SCStream as ClassType>::Super as ClassType>::ThreadKind
Source§impl NSObjectProtocol for SCStream
impl NSObjectProtocol for SCStream
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