Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.10.0

* Adds `setBandwidthLimit` for adaptive bitrate streaming via `preferredPeakBitRate`.

## 2.9.4

* Ensures that the display link does not continue requesting frames after a player is disposed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,27 @@ - (void)selectAudioTrackAtIndex:(NSInteger)trackIndex
}
}

- (void)setBandwidthLimit:(NSInteger)maxBandwidthBps
error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
AVPlayerItem *currentItem = _player.currentItem;
if (!currentItem) {
*error = [FlutterError errorWithCode:@"no_player_item"
message:@"The player has no current item."
details:nil];
return;
}

if (maxBandwidthBps <= 0) {
// A value of 0 tells AVFoundation to use its default limit, effectively
// removing any cap and letting the player choose quality freely.
currentItem.preferredPeakBitRate = 0;
} else {
// AVPlayer will attempt to select HLS variant streams at or below this
// bitrate. The actual bitrate depends on available variants.
currentItem.preferredPeakBitRate = (double)maxBandwidthBps;
}
}

#pragma mark - Private

- (int64_t)duration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,42 @@ NS_ASSUME_NONNULL_BEGIN
@interface FVPPlatformVideoViewCreationParams : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithPlayerId:(NSInteger)playerId;
@property(nonatomic, assign) NSInteger playerId;
+ (instancetype)makeWithPlayerId:(NSInteger )playerId;
@property(nonatomic, assign) NSInteger playerId;
@end

@interface FVPCreationOptions : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithUri:(NSString *)uri
httpHeaders:(NSDictionary<NSString *, NSString *> *)httpHeaders;
@property(nonatomic, copy) NSString *uri;
@property(nonatomic, copy) NSDictionary<NSString *, NSString *> *httpHeaders;
httpHeaders:(NSDictionary<NSString *, NSString *> *)httpHeaders;
@property(nonatomic, copy) NSString * uri;
@property(nonatomic, copy) NSDictionary<NSString *, NSString *> * httpHeaders;
@end

@interface FVPTexturePlayerIds : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithPlayerId:(NSInteger)playerId textureId:(NSInteger)textureId;
@property(nonatomic, assign) NSInteger playerId;
@property(nonatomic, assign) NSInteger textureId;
+ (instancetype)makeWithPlayerId:(NSInteger )playerId
textureId:(NSInteger )textureId;
@property(nonatomic, assign) NSInteger playerId;
@property(nonatomic, assign) NSInteger textureId;
@end

/// Raw audio track data from AVMediaSelectionOption (for HLS streams).
@interface FVPMediaSelectionAudioTrackData : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithIndex:(NSInteger)index
displayName:(nullable NSString *)displayName
languageCode:(nullable NSString *)languageCode
isSelected:(BOOL)isSelected
commonMetadataTitle:(nullable NSString *)commonMetadataTitle;
@property(nonatomic, assign) NSInteger index;
@property(nonatomic, copy, nullable) NSString *displayName;
@property(nonatomic, copy, nullable) NSString *languageCode;
@property(nonatomic, assign) BOOL isSelected;
@property(nonatomic, copy, nullable) NSString *commonMetadataTitle;
+ (instancetype)makeWithIndex:(NSInteger )index
displayName:(nullable NSString *)displayName
languageCode:(nullable NSString *)languageCode
isSelected:(BOOL )isSelected
commonMetadataTitle:(nullable NSString *)commonMetadataTitle;
@property(nonatomic, assign) NSInteger index;
@property(nonatomic, copy, nullable) NSString * displayName;
@property(nonatomic, copy, nullable) NSString * languageCode;
@property(nonatomic, assign) BOOL isSelected;
@property(nonatomic, copy, nullable) NSString * commonMetadataTitle;
@end

/// The codec used by all APIs.
Expand All @@ -65,25 +66,17 @@ NSObject<FlutterMessageCodec> *FVPGetMessagesCodec(void);
@protocol FVPAVFoundationVideoPlayerApi
- (void)initialize:(FlutterError *_Nullable *_Nonnull)error;
/// @return `nil` only when `error != nil`.
- (nullable NSNumber *)createPlatformViewPlayerWithOptions:(FVPCreationOptions *)params
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSNumber *)createPlatformViewPlayerWithOptions:(FVPCreationOptions *)params error:(FlutterError *_Nullable *_Nonnull)error;
/// @return `nil` only when `error != nil`.
- (nullable FVPTexturePlayerIds *)
createTexturePlayerWithOptions:(FVPCreationOptions *)creationOptions
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable FVPTexturePlayerIds *)createTexturePlayerWithOptions:(FVPCreationOptions *)creationOptions error:(FlutterError *_Nullable *_Nonnull)error;
- (void)setMixWithOthers:(BOOL)mixWithOthers error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSString *)fileURLForAssetWithName:(NSString *)asset
package:(nullable NSString *)package
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSString *)fileURLForAssetWithName:(NSString *)asset package:(nullable NSString *)package error:(FlutterError *_Nullable *_Nonnull)error;
@end

extern void SetUpFVPAVFoundationVideoPlayerApi(
id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api);
extern void SetUpFVPAVFoundationVideoPlayerApi(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api);

extern void SetUpFVPAVFoundationVideoPlayerApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api, NSString *messageChannelSuffix);

extern void SetUpFVPAVFoundationVideoPlayerApiWithSuffix(
id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api, NSString *messageChannelSuffix);

@protocol FVPVideoPlayerInstanceApi
- (void)setLooping:(BOOL)looping error:(FlutterError *_Nullable *_Nonnull)error;
Expand All @@ -96,17 +89,23 @@ extern void SetUpFVPAVFoundationVideoPlayerApiWithSuffix(
- (void)pauseWithError:(FlutterError *_Nullable *_Nonnull)error;
- (void)disposeWithError:(FlutterError *_Nullable *_Nonnull)error;
/// @return `nil` only when `error != nil`.
- (nullable NSArray<FVPMediaSelectionAudioTrackData *> *)getAudioTracks:
(FlutterError *_Nullable *_Nonnull)error;
- (void)selectAudioTrackAtIndex:(NSInteger)trackIndex
error:(FlutterError *_Nullable *_Nonnull)error;
- (nullable NSArray<FVPMediaSelectionAudioTrackData *> *)getAudioTracks:(FlutterError *_Nullable *_Nonnull)error;
- (void)selectAudioTrackAtIndex:(NSInteger)trackIndex error:(FlutterError *_Nullable *_Nonnull)error;
/// Sets the maximum bandwidth limit in bits per second for HLS adaptive bitrate streaming.
/// Pass 0 to remove any bandwidth limit and allow the player to select quality freely.
/// Common values:
/// - 360p: 500000 bps (500 kbps)
/// - 480p: 800000 bps (800 kbps)
/// - 720p: 1200000 bps (1.2 Mbps)
/// - 1080p: 2500000 bps (2.5 Mbps)
///
/// Note: On iOS/macOS, this sets the preferredPeakBitRate on AVPlayerItem,
/// which influences AVPlayer's HLS variant selection.
- (void)setBandwidthLimit:(NSInteger)maxBandwidthBps error:(FlutterError *_Nullable *_Nonnull)error;
@end

extern void SetUpFVPVideoPlayerInstanceApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPVideoPlayerInstanceApi> *_Nullable api);
extern void SetUpFVPVideoPlayerInstanceApi(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPVideoPlayerInstanceApi> *_Nullable api);

extern void SetUpFVPVideoPlayerInstanceApiWithSuffix(
id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPVideoPlayerInstanceApi> *_Nullable api,
NSString *messageChannelSuffix);
extern void SetUpFVPVideoPlayerInstanceApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FVPVideoPlayerInstanceApi> *_Nullable api, NSString *messageChannelSuffix);

NS_ASSUME_NONNULL_END
Loading