IVSReplayKitBroadcastSession
Objective-C
@interface IVSReplayKitBroadcastSession : NSObject
Swift
class IVSReplayKitBroadcastSession : NSObject
This is a streamlined version of an IVSBroadcastSession
to be used in a Broadcast Upload Extension.
The extensions are under strict memory constraints, and this class removes some of the SDK features in exchange
for a reduction in memory footprint.
For example, there are no attach or detach APIs. There are 3 devices created for you, corresponding to the screen,
app audio, and the microphone. Pass CMSampleBuffers to these devices from your RPBroadcastSampleHandler
implementation. In addition, there is no mixer configuration and no access to an IVSMixer
. This class
does not support multiple image layers, and the primary layer (the device screen) is always sized to the full output
stream scaled to fit. Transparency is also disabled regardless of what is provided in the video configuration.
Finally, you can not create a preview for the systemImageSource
or the session as a whole, they will not render anything.
Note
this will automatically setIVSBroadcastSession.applicationAudioSessionStrategy
to noAction
.
-
Unavailable
Do not create instances of this class directly
Declaration
Objective-C
IVS_INIT_UNAVAILABLE
-
Unavailable
Do not create instances of this class directly
Declaration
Objective-C
IVS_INIT_UNAVAILABLE
-
A device that is meant to be associated with the
video
samples in yourRPBroadcastSampleHandler
implementation.Declaration
Objective-C
@property (nonatomic, readonly) id<IVSCustomImageSource> _Nonnull systemImageSource;
Swift
var systemImageSource: IVSCustomImageSource { get }
-
A device that is meant to be associated with the
audioApp
samples in yourRPBroadcastSampleHandler
implementation.Declaration
Objective-C
@property (nonatomic, readonly) id<IVSCustomAudioSource> _Nonnull systemAudioSource;
Swift
var systemAudioSource: IVSCustomAudioSource { get }
-
A device that is meant to be associated with the
audioMic
samples in yourRPBroadcastSampleHandler
implementation.Declaration
Objective-C
@property (nonatomic, readonly) id<IVSCustomAudioSource> _Nonnull microphoneSource;
Swift
var microphoneSource: IVSCustomAudioSource { get }
-
Creates an instance of
IVSReplayKitBroadcastSession
.Declaration
Objective-C
- (nullable instancetype) initVideoConfiguration:(nonnull IVSVideoConfiguration *)videoConfig audioConfig:(nonnull IVSAudioConfiguration *)audioConfig delegate:(nullable id<IVSBroadcastSessionDelegate>)delegate error:(NSError *_Nullable *_Nullable)outError;
Swift
init(videoConfiguration videoConfig: IVSVideoConfiguration, audioConfig: IVSAudioConfiguration, delegate: IVSBroadcastSessionDelegate?) throws
Parameters
videoConfig
the video configuration for the output stream.
audioConfig
the audio configuration for the output stream.
delegate
an
IVSBroadcastSessionDelegate
to receive callbacks from the broadcast session.outError
On input, a pointer to an error object. If an error occurs, the pointer is an NSError object that describes the error. If you don’t want error information, pass in nil.
-
Creates an instance of
IVSReplayKitBroadcastSession
.Note
On ReplayKit streams when using auto-reconnect the system will still show as broadcasting when attempting to reconnect because the screen is still being captured and the ReplayKit process is still alive. It is recommended that host applications find a way to communicate this to their users.
Declaration
Objective-C
- (nullable instancetype) initVideoConfiguration:(nonnull IVSVideoConfiguration *)videoConfig audioConfig:(nonnull IVSAudioConfiguration *)audioConfig reconnectConfig:(nullable IVSBroadcastAutoReconnectConfiguration *) reconnectConfig delegate:(nullable id<IVSBroadcastSessionDelegate>)delegate error:(NSError *_Nullable *_Nullable)outError;
Swift
init(videoConfiguration videoConfig: IVSVideoConfiguration, audioConfig: IVSAudioConfiguration, reconnectConfig: IVSBroadcastAutoReconnectConfiguration?, delegate: IVSBroadcastSessionDelegate?) throws
Parameters
videoConfig
the video configuration for the output stream.
audioConfig
the audio configuration for the output stream.
reconnectConfig
the auto-reconnect configuration.
delegate
an
IVSBroadcastSessionDelegate
to receive callbacks from the broadcast session.outError
On input, a pointer to an error object. If an error occurs, the pointer is an NSError object that describes the error. If you don’t want error information, pass in nil.
-
Start the configured broadcast session.
Declaration
Objective-C
- (BOOL)startWithURL:(nonnull NSURL *)url streamKey:(nonnull NSString *)streamKey error:(NSError *_Nullable *_Nullable)outError;
Swift
func start(with url: URL, streamKey: String) throws
Parameters
url
the RTMPS endpoint provided by IVS.
streamKey
the broadcaster’s stream key that has been provided by IVS.
outError
A reference to an NSError that would be set if an error occurs.
Return Value
if the operation is successful. If it returns NO check
isReady
. -
Stop the broadcast session, but do not deallocate resources. If this is being called as a result of the ReplayKit broadcast finishing (not just pausing), call
broadcastFinished
as well to block until the stream properly shuts down. Otherwise iOS may kill the process before the stop call completes, leaving the channel live until it times out.Declaration
Objective-C
- (void)stop;
Swift
func stop()
-
Teardown the underlying session, freeing up resources and synchronously forcing a call to
stop
to complete. Due to the way RPBroadcastSampleHandler handles deallocation, it is strongly recommended you invoke this in thebroadcastFinished
callback. Once invoked, this all methods on this instance will either no-op, or return an error.Declaration
Objective-C
- (void)broadcastFinished;
Swift
func broadcastFinished()
-
Send timed metadata that will be automatically synchronized with the ongoing stream.
Declaration
Objective-C
- (BOOL)sendTimedMetadata:(nonnull NSString *)contents error:(NSError *_Nullable *_Nullable)outError;
Swift
func sendTimedMetadata(_ contents: String) throws
Parameters
contents
text-based metadata that will be interpreted by your receiver.
Return Value
YES if the operation is successful. If it returns NO then an error has occurred.