From abfc026fe2cd063cd8a57fa0ffe395d6f94f2c01 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Fri, 20 Oct 2023 15:14:24 +0200 Subject: [PATCH 1/6] chore: fix typos in the changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 210b8f83..fdce0a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,11 @@ - API Reference now can be found [here](https://cdn.bitmovin.com/player/reactnative/0/docs/index.html) - `PlayerViewConfig` with a `UiConfig` to the `PlayerView` to enable configuration of the visual presentation and behaviour - `PictureInPictureConfig` to `PlayerViewConfig` to allow configuring the Picture in Picture behavior -- `PictureInPictureConfig.isEnabled` to enable configing if Picture in Picture is enabled +- `PictureInPictureConfig.isEnabled` to enable configuring if Picture in Picture is enabled - `PictureInPictureConfig.shouldEnterOnBackground` to start Picture in Picture automatically when the app transitions to background - `onPictureInPictureAvailabilityChanged` event is now emitted on iOS and tvOS in addition to Android - `BufferConfig` to configure player buffer depth -- `PlayerView.isPictureInPictureRequested` to programatically create a Picture in Picture request +- `PlayerView.isPictureInPictureRequested` to programmatically create a Picture in Picture request - `PlayerView.scalingMode` to allow changing the video scaling mode ### Changed From ceee4302d978b1872e8224cadea23ff18a026376 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Fri, 20 Oct 2023 15:14:24 +0200 Subject: [PATCH 2/6] chore: fix typos in the changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 210b8f83..fdce0a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,11 @@ - API Reference now can be found [here](https://cdn.bitmovin.com/player/reactnative/0/docs/index.html) - `PlayerViewConfig` with a `UiConfig` to the `PlayerView` to enable configuration of the visual presentation and behaviour - `PictureInPictureConfig` to `PlayerViewConfig` to allow configuring the Picture in Picture behavior -- `PictureInPictureConfig.isEnabled` to enable configing if Picture in Picture is enabled +- `PictureInPictureConfig.isEnabled` to enable configuring if Picture in Picture is enabled - `PictureInPictureConfig.shouldEnterOnBackground` to start Picture in Picture automatically when the app transitions to background - `onPictureInPictureAvailabilityChanged` event is now emitted on iOS and tvOS in addition to Android - `BufferConfig` to configure player buffer depth -- `PlayerView.isPictureInPictureRequested` to programatically create a Picture in Picture request +- `PlayerView.isPictureInPictureRequested` to programmatically create a Picture in Picture request - `PlayerView.scalingMode` to allow changing the video scaling mode ### Changed From b008469446cc44affc0b8c7023fb21db3fcdf82a Mon Sep 17 00:00:00 2001 From: Michele Pozzi <123.mpozzi@gmail.com> Date: Mon, 23 Oct 2023 15:28:19 +0200 Subject: [PATCH 3/6] feat(minTimeshiftBufferDepth): add `LiveConfig` and `minTimeshiftBufferDepth` on ts --- src/index.ts | 1 + src/liveConfig.ts | 12 ++++++++++++ src/playerConfig.ts | 5 +++++ 3 files changed, 18 insertions(+) create mode 100644 src/liveConfig.ts diff --git a/src/index.ts b/src/index.ts index b70fcb90..b0573e48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,3 +21,4 @@ export * from './tweaksConfig'; export * from './bufferConfig'; export * from './playbackConfig'; export * from './playerConfig'; +export * from './liveConfig'; diff --git a/src/liveConfig.ts b/src/liveConfig.ts new file mode 100644 index 00000000..8092dc98 --- /dev/null +++ b/src/liveConfig.ts @@ -0,0 +1,12 @@ +/** + * Contains config values regarding the behaviour when playing live streams. + */ +export interface LiveConfig { + /** + * The minimum buffer depth of a stream needed to enable time shifting. + * When the internal value for the maximal possible timeshift is lower than this value, + * timeshifting should be disabled. That means `Player.maxTimeShift` returns `0` in that case. + * This value should always be non-positive value, default value is `-40`. + */ + minTimeshiftBufferDepth?: number; +} diff --git a/src/playerConfig.ts b/src/playerConfig.ts index 21ad9bbb..87835889 100644 --- a/src/playerConfig.ts +++ b/src/playerConfig.ts @@ -7,6 +7,7 @@ import { RemoteControlConfig } from './remoteControlConfig'; import { BufferConfig } from './bufferConfig'; import { NativeInstanceConfig } from './nativeInstance'; import { PlaybackConfig } from './playbackConfig'; +import { LiveConfig } from './liveConfig'; /** * Object used to configure a new `Player` instance. @@ -63,4 +64,8 @@ export interface PlayerConfig extends NativeInstanceConfig { * Configures buffer settings. A default {@link BufferConfig} is set initially. */ bufferConfig?: BufferConfig; + /** + * Configures behaviour when playing live content. A default {@link LiveConfig} is set initially. + */ + liveConfig?: LiveConfig; } From e5af624ae0d48edc75a2adfe0d5e216fb6578bfc Mon Sep 17 00:00:00 2001 From: Michele Pozzi <123.mpozzi@gmail.com> Date: Mon, 23 Oct 2023 16:09:40 +0200 Subject: [PATCH 4/6] feat(minTimeshiftBufferDepth): add `LiveConfig` serializers on Android --- .../reactnative/converter/JsonConverter.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt b/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt index f3b9b110..54071c35 100644 --- a/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt +++ b/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt @@ -26,6 +26,7 @@ import com.bitmovin.player.api.event.PlayerEvent import com.bitmovin.player.api.event.SourceEvent import com.bitmovin.player.api.event.data.CastPayload import com.bitmovin.player.api.event.data.SeekPosition +import com.bitmovin.player.api.live.LiveConfig import com.bitmovin.player.api.media.AdaptationConfig import com.bitmovin.player.api.media.audio.AudioTrack import com.bitmovin.player.api.media.subtitle.SubtitleTrack @@ -116,6 +117,11 @@ class JsonConverter { playerConfig.bufferConfig = it } } + if (json.hasKey("liveConfig")) { + toLiveConfig(json.getMap("liveConfig"))?.let { + playerConfig.liveConfig = it + } + } return playerConfig } @@ -1169,6 +1175,23 @@ class JsonConverter { playerViewConfig = toPlayerViewConfig(json), pictureInPictureConfig = toPictureInPictureConfig(json.getMap("pictureInPictureConfig")), ) + + /** + * Converts any JS object into a [LiveConfig] object. + * @param json JS object representing the [LiveConfig]. + * @return The generated [LiveConfig] if successful, `null` otherwise. + */ + @JvmStatic + fun toLiveConfig(json: ReadableMap?): LiveConfig? { + if (json == null) { + return null + } + val liveConfig = LiveConfig() + if (json.hasKey("minTimeshiftBufferDepth")) { + liveConfig.minTimeShiftBufferDepth = json.getDouble("minTimeshiftBufferDepth") + } + return liveConfig + } } } From 2356bdce67cb79575f11c1194da407d05a797168 Mon Sep 17 00:00:00 2001 From: Michele Pozzi <123.mpozzi@gmail.com> Date: Mon, 23 Oct 2023 16:14:08 +0200 Subject: [PATCH 5/6] feat(minTimeshiftBufferDepth): add `LiveConfig` serializers on iOS --- ios/RCTConvert+BitmovinPlayer.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ios/RCTConvert+BitmovinPlayer.swift b/ios/RCTConvert+BitmovinPlayer.swift index 9de12cc0..25b07ba7 100644 --- a/ios/RCTConvert+BitmovinPlayer.swift +++ b/ios/RCTConvert+BitmovinPlayer.swift @@ -36,6 +36,9 @@ extension RCTConvert { if let bufferConfig = RCTConvert.bufferConfig(json["bufferConfig"]) { playerConfig.bufferConfig = bufferConfig } + if let liveConfig = RCTConvert.liveConfig(json["liveConfig"]) { + playerConfig.liveConfig = liveConfig + } #if os(iOS) if let remoteControlConfig = RCTConvert.remoteControlConfig(json["remoteControlConfig"]) { playerConfig.remoteControlConfig = remoteControlConfig @@ -191,6 +194,22 @@ extension RCTConvert { return bufferConfig } + /** + Utility method to instantiate a `LiveConfig` from a JS object. + - Parameter json: JS object. + - Returns: The produced `LiveConfig` object, or `nil` if `json` is not valid. + */ + static func liveConfig(_ json: Any?) -> LiveConfig? { + guard let json = json as? [String: Any?] else { + return nil + } + let liveConfig = LiveConfig() + if let minTimeshiftBufferDepth = json["minTimeshiftBufferDepth"] as? NSNumber { + liveConfig.minTimeshiftBufferDepth = minTimeshiftBufferDepth.doubleValue + } + return liveConfig + } + /** Utility method to instantiate an `AdvertisingConfig` from a JS object. - Parameter json: JS object. From 613cc6a4fd0d193507b95c79c8d36b1cfc2ab189 Mon Sep 17 00:00:00 2001 From: Michele Pozzi <123.mpozzi@gmail.com> Date: Mon, 23 Oct 2023 16:43:11 +0200 Subject: [PATCH 6/6] feat(minTimeshiftBufferDepth): add CHANGELOG entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdce0a6d..2ccaa4cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Added + +- `LiveConfig.minTimeshiftBufferDepth` to control the minimum buffer depth of a stream needed to enable time shifting. + ## [0.13.0] (2023-10-20) ### Added