Port for macOS (#311)

* merged moonlight-mac with moonlight-ios

* reverted to the original project.pbxproj

* cleaned up the code, fixed lots of unnecessary code duplications

* multicontroller support (not tested)

* new class that can be used for further modularization of the MainFrameViewController
This commit is contained in:
Felix Kratz
2018-03-27 08:50:40 +02:00
committed by Cameron Gutman
parent 1c86c4485d
commit 6cc165b589
73 changed files with 5116 additions and 239 deletions

View File

@@ -11,7 +11,11 @@
#include "Limelight.h"
@implementation VideoDecoderRenderer {
#if TARGET_OS_IPHONE
UIView *_view;
#else
NSView *_view;
#endif
AVSampleBufferDisplayLayer* displayLayer;
Boolean waitingForSps, waitingForPps, waitingForVps;
@@ -27,7 +31,12 @@
displayLayer = [[AVSampleBufferDisplayLayer alloc] init];
displayLayer.bounds = _view.bounds;
#if TARGET_OS_IPHONE
displayLayer.backgroundColor = [UIColor blackColor].CGColor;
#else
displayLayer.backgroundColor = [NSColor blackColor].CGColor;
#endif
displayLayer.position = CGPointMake(CGRectGetMidX(_view.bounds), CGRectGetMidY(_view.bounds));
displayLayer.videoGravity = AVLayerVideoGravityResizeAspect;
@@ -52,7 +61,7 @@
formatDesc = nil;
}
}
#if TARGET_OS_IPHONE
- (id)initWithView:(UIView*)view
{
self = [super init];
@@ -63,6 +72,20 @@
return self;
}
#else
- (id)initWithView:(NSView*)view
{
self = [super init];
_view = view;
[self reinitializeDisplayLayer];
return self;
}
#endif
- (void)setupWithVideoFormat:(int)videoFormat
{
@@ -222,6 +245,8 @@
const size_t parameterSetSizes[] = { [vpsData length], [spsData length], [ppsData length] };
Log(LOG_I, @"Constructing new HEVC format description");
#if TARGET_OS_IPHONE
if (@available(iOS 11.0, *)) {
status = CMVideoFormatDescriptionCreateFromHEVCParameterSets(kCFAllocatorDefault,
3, /* count of parameter sets */
@@ -235,6 +260,21 @@
// even though we said we couldn't support it. All we can do is abort().
abort();
}
#else
if (@available(macOS 10.13, *)) {
status = CMVideoFormatDescriptionCreateFromHEVCParameterSets(kCFAllocatorDefault,
3, /* count of parameter sets */
parameterSetPointers,
parameterSetSizes,
NAL_LENGTH_PREFIX_SIZE,
nil,
&formatDesc);
} else {
// This means Moonlight-common-c decided to give us an HEVC stream
// even though we said we couldn't support it. All we can do is abort().
abort();
}
#endif
if (status != noErr) {
Log(LOG_E, @"Failed to create HEVC format description: %d", (int)status);