• Skip to Search
  • Skip to Content
  • Skip to Side Navigation
Getting StartedSDK ReferenceGlossary
  • Home
  • Getting Started
  • SDK Reference
  • Portal
  • How-To
  • Troubleshooting
  • FAQs
  • Reference
  • Glossary
REST API
Web SDK
Android SDK
iOS SDK
Unity SDK
React Native SDK
EdgeAuth SDK
  • Overview
  • Express API
    • Channel
    • Room
    • PCast™
  • Low-Level API
    • Room
    • Chat
    • PCast™
  • Examples
  • Release Notes

iOS Examples

GitHub Examples

You can find our iOS examples on GitHub:

  • Channel Viewer
  • Channel Publisher
  • Groups
  • MultiAngle
  • MultiAngle VoD

Override Playout Delay

Example Code for overriding the playout delay via a PhenixMediaStream object

Swift
1import PhenixSdk
2
3class SomeClass {
4 private var currentRendererPlayoutDelayOverride: PhenixDisposable?
5 private var currentRenderer: PhenixRenderer?
6
7 private func setPlayoutDelayOverrideFor10Seconds() {
8 // Previously obtained
9 let mediaStream: PhenixMediaStream = ...
10
11 self.currentRenderer = mediaStream.createRenderer()
12
13 // Override playout delay to 900ms for 10 seconds
14 let playoutDelay: TimeInterval = 0.9
15
16 self.currentRendererPlayoutDelayOverride = self.currentRenderer?.overridePlayoutDelay(playoutDelay)
17
18 DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
19 // Dropping the disposable will undo the playout delay override
20 self.currentRendererPlayoutDelayOverride = nil
21 }
22 }
23}

Example Code for limiting video bandwidth with a PhenixExpressSubscriber object

Swift
1import PhenixSdk
2
3class SomeClass {
4 private var currentRendererPlayoutDelayOverride: PhenixDisposable?
5 private var currentRenderer: PhenixRenderer?
6
7 private func setPlayoutDelayOverrideFor10Seconds() {
8 // Previously obtained
9 let subscriber: PhenixExpressSubscriber = ...
10
11 self.currentRenderer = subscriber.createRenderer()
12
13 // Override playout delay to 900ms for 10 seconds
14 let playoutDelay: TimeInterval = 0.9
15
16 self.currentRendererPlayoutDelayOverride = self.currentRenderer?.overridePlayoutDelay(playoutDelay)
17
18 DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
19 // Dropping the disposable will undo the playout delay override
20 self.currentRendererPlayoutDelayOverride = nil
21 }
22 }
23}

The playout delay represents the amount of time by which audio and video are delayed when content is rendered by a subscriber; i.e. it works as a buffer. The delay adds to the overall end-to-end latency experienced by the user (on top of capture, encoding, and network latencies). It is necessary to handle network-related fluctuations (such as jitter or data loss). By default, the playout delay for real-time streams is set to 230ms. The following API allows app developers to override this default value.

In order to access the API, a reference to a PhenixRenderer is needed. It can be obtained either by creating it from PhenixMediaStream or PhenixExpressSubscriber, or via several of the Express APIs, which can return renderers (joinChannel, subscribeToMemberStream, subscribe).

The returned disposable allows control over how long the override should stay in effect; it therefore needs to be held onto via a strong reference. If overridePlayoutDelay is called multiple times before any of the previous disposables are released, then only the most recent override will remain in effect until its disposable is released. Releasing any of the disposables from earlier overridePlayoutDelay calls will have no effect.

Notes:

  • The override represents an absolute value, not a delta.
  • If an override increases the playout delay, it will result in content being paused. Example: changing a delay of 1 second to 5 seconds will cause the content to be paused for roughly 4 seconds.
  • If an override decreases the playout delay, it will cause a jump where some of the content will be skipped.
  • Very large override values will increase the amount of memory consumed. It is generally recommended to stay below 10 seconds.

Parameters

NameTypeDescription
desiredPlayoutDelay (required)TimeIntervalDesired playout delay

Returns

TypeDescription
PhenixDisposableEnsures override is kept in effect for as long as a strong reference is held
Page Content
    Copyright 2023 © Phenix RTS
    Privacy Policy | Terms of Service
    v2023-01-31T21:25:10