Commit 332b82d8 authored by Carola Nitz's avatar Carola Nitz

UIDevice: Remove the Speedcategory entirely. We're okay with VLCKit dropping...

UIDevice: Remove the Speedcategory entirely. We're okay with VLCKit dropping frames if the device is too slow and for the UI the devices with iOS 9 are fast enough to be without tweaking
parent d540e6de
Pipeline #210 failed with stage
in 0 seconds
......@@ -42,8 +42,6 @@
"AR_CHANGED" = "Aspect Ratio: %@";
"DEFAULT" = "Default";
"FILL_TO_SCREEN" = "Crop to fill screen";
"DEVICE_TOOSLOW_TITLE" = "Device too slow";
"DEVICE_TOOSLOW" = "Your %@ is likely too slow to play \"%@\". Open anyway?";
"PLAYBACK_SPEED" = "Playback speed";
"SPU_DELAY" = "Subtitles delay";
"AUDIO_DELAY" = "Audio delay";
......@@ -56,7 +54,6 @@
"BUTTON_BACK" = "Back";
"BUTTON_EDIT" = "Edit";
"BUTTON_DONE" = "Done";
"BUTTON_OPEN" = "Open";
"BUTTON_CANCEL" = "Cancel";
"BUTTON_SAVE" = "Save";
"BUTTON_DOWNLOAD" = "Download";
......
......@@ -12,17 +12,8 @@
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, VLCSpeedCategory) {
VLCSpeedCategoryNotSet = 0,
VLCSpeedCategoryOneDevices, // < iOS 9 and not supported anymore
VLCSpeedCategoryTwoDevices, // iPhone 4S, iPad 2 and 3, iPod 4 and 5
VLCSpeedCategoryThreeDevices, // iPhone 5 + 5S, iPad 4, iPad Air, iPad mini 2G
VLCSpeedCategoryFourDevices, // iPhone 6 + 6S, 2014+2015 iPads and newer
};
@interface UIDevice (VLC)
@property (readonly) VLCSpeedCategory vlcSpeedCategory;
@property (readonly) NSNumber *VLCFreeDiskSpace;
@property (readonly) BOOL VLCHasExternalDisplay;
......
......@@ -16,34 +16,6 @@
@implementation UIDevice (VLC)
VLCSpeedCategory _currentSpeedCategory;
- (VLCSpeedCategory)vlcSpeedCategory
{
if (_currentSpeedCategory == VLCSpeedCategoryNotSet) {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *answer = malloc(size);
sysctlbyname("hw.machine", answer, &size, NULL, 0);
NSString *currentMachine = @(answer);
free(answer);
if ([currentMachine hasPrefix:@"iPhone4"] || [currentMachine hasPrefix:@"iPad3,1"] || [currentMachine hasPrefix:@"iPad3,2"] || [currentMachine hasPrefix:@"iPad3,3"] || [currentMachine hasPrefix:@"iPod4"] || [currentMachine hasPrefix:@"iPad2"] || [currentMachine hasPrefix:@"iPod5"]) {
APLog(@"this is a cat two device");
_currentSpeedCategory = VLCSpeedCategoryTwoDevices;
} else if ([currentMachine hasPrefix:@"iPhone5"] || [currentMachine hasPrefix:@"iPhone6"] || [currentMachine hasPrefix:@"iPad4"]) {
APLog(@"this is a cat three device");
_currentSpeedCategory = VLCSpeedCategoryThreeDevices;
} else {
APLog(@"this is a cat four device");
_currentSpeedCategory = VLCSpeedCategoryFourDevices;
}
}
return _currentSpeedCategory;
}
- (NSNumber *)VLCFreeDiskSpace
{
NSNumber *totalSpace;
......
......@@ -56,17 +56,11 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSNumber *skipLoopFilterDefaultValue;
if ([[UIDevice currentDevice] vlcSpeedCategory] < VLCSpeedCategoryThreeDevices)
skipLoopFilterDefaultValue = kVLCSettingSkipLoopFilterNonKey;
else
skipLoopFilterDefaultValue = kVLCSettingSkipLoopFilterNonRef;
NSDictionary *appDefaults = @{kVLCSettingPasscodeAllowTouchID : @(1),
kVLCSettingContinueAudioInBackgroundKey : @(YES),
kVLCSettingStretchAudio : @(NO),
kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue,
kVLCSettingSkipLoopFilter : skipLoopFilterDefaultValue,
kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef,
kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue,
kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue,
kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue,
......
......@@ -26,7 +26,6 @@
#define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter"
#define kVLCSettingSkipLoopFilterNone @(0)
#define kVLCSettingSkipLoopFilterNonRef @(1)
#define kVLCSettingSkipLoopFilterNonKey @(3)
#define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn"
#define kVLCSettingSubtitlesFont @"quartztext-font"
#define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue"
......
......@@ -14,7 +14,6 @@
#import "VLCEqualizerView.h"
#import "VLCTrackSelectorTableViewCell.h"
#import "VLCTrackSelectorHeaderView.h"
#import "UIDevice+VLC.h"
#import "VLCSlider.h"
#define PROFILE_SELECTOR_TABLEVIEW_SECTIONHEADER @"profile selector table section header"
......@@ -260,11 +259,8 @@
_tableView.sectionHeaderHeight = 28.;
[_tableView registerClass:[VLCTrackSelectorHeaderView class] forHeaderFooterViewReuseIdentifier:PROFILE_SELECTOR_TABLEVIEW_SECTIONHEADER];
[_tableView registerClass:[VLCTrackSelectorTableViewCell class] forCellReuseIdentifier:PROFILE_SELECTOR_TABLEVIEW_CELL];
if ([[UIDevice currentDevice] vlcSpeedCategory] >= VLCSpeedCategoryThreeDevices) {
_tableView.opaque = NO;
_tableView.backgroundColor = [UIColor clearColor];
} else
_tableView.backgroundColor = [UIColor blackColor];
_tableView.opaque = NO;
_tableView.backgroundColor = [UIColor clearColor];
[self addSubview:_tableView];
return self;
}
......
......@@ -154,18 +154,8 @@
return [[HTTPErrorResponse alloc] initWithErrorCode:404];
}
NSData *theData;
NSString *contentType;
/* devices category 3 and faster include HW accelerated JPEG encoding
* so we can make our transfers faster by using waaay smaller images */
if ([[UIDevice currentDevice] vlcSpeedCategory] < VLCSpeedCategoryThreeDevices) {
theData = UIImagePNGRepresentation([VLCThumbnailsCache thumbnailForManagedObject:mo]);
contentType = @"image/png";
} else {
theData = UIImageJPEGRepresentation([VLCThumbnailsCache thumbnailForManagedObject:mo], .9);
contentType = @"image/jpg";
}
NSData *theData = UIImageJPEGRepresentation([VLCThumbnailsCache thumbnailForManagedObject:mo], .9);
NSString *contentType = @"image/jpg";
if (theData) {
HTTPDataResponse *dataResponse = [[HTTPDataResponse alloc] initWithData:theData];
......
......@@ -543,11 +543,8 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
verticalSeparator.backgroundColor = [UIColor VLCLightTextColor].CGColor;
_sleepTimeDatePicker = [[UIDatePicker alloc] init];
if ([[UIDevice currentDevice] vlcSpeedCategory] >= VLCSpeedCategoryThreeDevices) {
_sleepTimeDatePicker.opaque = NO;
_sleepTimeDatePicker.backgroundColor = [UIColor clearColor];
} else
_sleepTimeDatePicker.backgroundColor = [UIColor blackColor];
_sleepTimeDatePicker.opaque = NO;
_sleepTimeDatePicker.backgroundColor = [UIColor clearColor];
_sleepTimeDatePicker.tintColor = [UIColor VLCLightTextColor];
_sleepTimeDatePicker.frame = CGRectMake(0., 0., 300., 162.);
_sleepTimeDatePicker.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
......
......@@ -136,35 +136,6 @@ VLCMediaDelegate>
#pragma mark - playback management
- (BOOL)_isMediaSuitableForDevice:(VLCMedia *)media
{
NSArray *tracksInfo = media.tracksInformation;
double width = 0.0, height = 0.0;
NSDictionary *track;
for (NSUInteger x = 0; x < tracksInfo.count; x++) {
track = tracksInfo[x];
if ([track[VLCMediaTracksInformationType] isEqualToString:VLCMediaTracksInformationTypeVideo]) {
width = [track[VLCMediaTracksInformationVideoWidth] doubleValue];
height = [track[VLCMediaTracksInformationVideoHeight] doubleValue];
}
}
NSUInteger totalNumberOfPixels = width * height;
VLCSpeedCategory speedCategory = [[UIDevice currentDevice] vlcSpeedCategory];
if (speedCategory == VLCSpeedCategoryTwoDevices) {
return (totalNumberOfPixels < 922000); // 720p
} else if (speedCategory == VLCSpeedCategoryThreeDevices) {
return (totalNumberOfPixels < 2074000); // 1080p
} else if (speedCategory == VLCSpeedCategoryFourDevices) {
return (totalNumberOfPixels < 8850000); // 4K
}
return YES;
}
- (void)playMediaList:(VLCMediaList *)mediaList firstIndex:(NSInteger)index
{
self.mediaList = mediaList;
......@@ -288,36 +259,7 @@ VLCMediaDelegate>
[_playbackSessionManagementLock unlock];
if (![self _isMediaSuitableForDevice:media]) {
#if TARGET_OS_IOS
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DEVICE_TOOSLOW_TITLE", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"DEVICE_TOOSLOW", nil), [[UIDevice currentDevice] model], media.url.lastPathComponent]
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
otherButtonTitles:NSLocalizedString(@"BUTTON_OPEN", nil), nil];
[alert show];
#else
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DEVICE_TOOSLOW_TITLE", nil)
message:[NSString stringWithFormat:NSLocalizedString(@"DEVICE_TOOSLOW", nil), [[UIDevice currentDevice] model], media.url.lastPathComponent]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OPEN", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self _playNewMedia];
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action) {
[self stopPlayback];
}];
[alert addAction:defaultAction];
[alert addAction:cancelAction];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert animated:YES completion:nil];
#endif
} else
[self _playNewMedia];
[self _playNewMedia];
}
- (void)_playNewMedia
......@@ -358,16 +300,6 @@ VLCMediaDelegate>
[_playbackSessionManagementLock unlock];
}
#if TARGET_OS_IOS
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
[self _playNewMedia];
else
[self stopPlayback];
}
#endif
- (void)stopPlayback
{
BOOL ret = [_playbackSessionManagementLock tryLock];
......
......@@ -60,13 +60,6 @@
_sideMenuViewController.delegate = self;
if ([[UIDevice currentDevice] vlcSpeedCategory] <= VLCSpeedCategoryTwoDevices) {
_sideMenuViewController.animationDuration = 0.1f;
_sideMenuViewController.parallaxEnabled = NO;
_sideMenuViewController.contentViewShadowEnabled = NO;
_sideMenuViewController.bouncesHorizontally = NO;
}
return self;
}
......
......@@ -24,11 +24,8 @@
self.contentView.backgroundColor = [UIColor VLCDarkBackgroundColor];
self.textLabel.textColor = [UIColor whiteColor];
if ([[UIDevice currentDevice] vlcSpeedCategory] >= VLCSpeedCategoryThreeDevices) {
self.opaque = NO;
self.alpha = .8;
}
self.opaque = NO;
self.alpha = .8;
return self;
}
......
......@@ -53,12 +53,8 @@
}
- (void)configureForDeviceCategory {
if ([[UIDevice currentDevice] vlcSpeedCategory] >= VLCSpeedCategoryThreeDevices) {
_trackSelectorTableView.opaque = NO;
_trackSelectorTableView.backgroundColor = [UIColor clearColor];
} else {
_trackSelectorTableView.backgroundColor = [UIColor blackColor];
}
_trackSelectorTableView.opaque = NO;
_trackSelectorTableView.backgroundColor = [UIColor clearColor];
_trackSelectorTableView.allowsMultipleSelection = YES;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment