Skip to content

Commit 9428cf3

Browse files
steventroughtonsmithtiagomartinho
authored andcommitted
Updated build scripts for Mac Catalyst & added satellite TV codecs
1 parent bd44fd8 commit 9428cf3

26 files changed

Lines changed: 1042 additions & 53 deletions

SGPlayer iOS copy-Info.plist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>SGPlayer</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>FMWK</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>2.0.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
23+
<key>NSHumanReadableCopyright</key>
24+
<string>Copyright © 2017年 single. All rights reserved.</string>
25+
<key>NSPrincipalClass</key>
26+
<string></string>
27+
</dict>
28+
</plist>

SGPlayer.xcodeproj/project.pbxproj

Lines changed: 636 additions & 18 deletions
Large diffs are not rendered by default.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1100"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "B0198738231AAB3900EC1C47"
18+
BuildableName = "SGPlayer.framework"
19+
BlueprintName = "SGPlayer Catalyst"
20+
ReferencedContainer = "container:SGPlayer.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "B0198738231AAB3900EC1C47"
54+
BuildableName = "SGPlayer.framework"
55+
BlueprintName = "SGPlayer Catalyst"
56+
ReferencedContainer = "container:SGPlayer.xcodeproj">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>

SGPlayer/Classes/Catalyst.h

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
//
2+
// Catalyst.h
3+
// SGPlayer
4+
//
5+
// Created by Steven Troughton-Smith on 31/08/2019.
6+
// Copyright © 2019 single. All rights reserved.
7+
//
8+
9+
#ifndef Catalyst_h
10+
#define Catalyst_h
11+
12+
#define GLK_INLINE static __inline__
13+
14+
#if defined(__STRICT_ANSI__)
15+
struct _GLKMatrix4
16+
{
17+
float m[16];
18+
} __attribute__((aligned(16)));
19+
typedef struct _GLKMatrix4 GLKMatrix4;
20+
#else
21+
union _GLKMatrix4
22+
{
23+
struct
24+
{
25+
float m00, m01, m02, m03;
26+
float m10, m11, m12, m13;
27+
float m20, m21, m22, m23;
28+
float m30, m31, m32, m33;
29+
};
30+
float m[16];
31+
} __attribute__((aligned(16)));
32+
typedef union _GLKMatrix4 GLKMatrix4;
33+
#endif
34+
35+
GLK_INLINE GLKMatrix4 GLKMatrix4Multiply(GLKMatrix4 matrixLeft, GLKMatrix4 matrixRight)
36+
{
37+
#if defined(GLK_SSE3_INTRINSICS)
38+
39+
const __m128 l0 = _mm_load_ps(&matrixLeft.m[0]);
40+
const __m128 l1 = _mm_load_ps(&matrixLeft.m[4]);
41+
const __m128 l2 = _mm_load_ps(&matrixLeft.m[8]);
42+
const __m128 l3 = _mm_load_ps(&matrixLeft.m[12]);
43+
44+
const __m128 r0 = _mm_load_ps(&matrixRight.m[0]);
45+
const __m128 r1 = _mm_load_ps(&matrixRight.m[4]);
46+
const __m128 r2 = _mm_load_ps(&matrixRight.m[8]);
47+
const __m128 r3 = _mm_load_ps(&matrixRight.m[12]);
48+
49+
const __m128 m0 = l0 * _mm_shuffle_ps(r0, r0, _MM_SHUFFLE(0, 0, 0, 0))
50+
+ l1 * _mm_shuffle_ps(r0, r0, _MM_SHUFFLE(1, 1, 1, 1))
51+
+ l2 * _mm_shuffle_ps(r0, r0, _MM_SHUFFLE(2, 2, 2, 2))
52+
+ l3 * _mm_shuffle_ps(r0, r0, _MM_SHUFFLE(3, 3, 3, 3));
53+
54+
const __m128 m1 = l0 * _mm_shuffle_ps(r1, r1, _MM_SHUFFLE(0, 0, 0, 0))
55+
+ l1 * _mm_shuffle_ps(r1, r1, _MM_SHUFFLE(1, 1, 1, 1))
56+
+ l2 * _mm_shuffle_ps(r1, r1, _MM_SHUFFLE(2, 2, 2, 2))
57+
+ l3 * _mm_shuffle_ps(r1, r1, _MM_SHUFFLE(3, 3, 3, 3));
58+
59+
const __m128 m2 = l0 * _mm_shuffle_ps(r2, r2, _MM_SHUFFLE(0, 0, 0, 0))
60+
+ l1 * _mm_shuffle_ps(r2, r2, _MM_SHUFFLE(1, 1, 1, 1))
61+
+ l2 * _mm_shuffle_ps(r2, r2, _MM_SHUFFLE(2, 2, 2, 2))
62+
+ l3 * _mm_shuffle_ps(r2, r2, _MM_SHUFFLE(3, 3, 3, 3));
63+
64+
const __m128 m3 = l0 * _mm_shuffle_ps(r3, r3, _MM_SHUFFLE(0, 0, 0, 0))
65+
+ l1 * _mm_shuffle_ps(r3, r3, _MM_SHUFFLE(1, 1, 1, 1))
66+
+ l2 * _mm_shuffle_ps(r3, r3, _MM_SHUFFLE(2, 2, 2, 2))
67+
+ l3 * _mm_shuffle_ps(r3, r3, _MM_SHUFFLE(3, 3, 3, 3));
68+
69+
GLKMatrix4 m;
70+
_mm_store_ps(&m.m[0], m0);
71+
_mm_store_ps(&m.m[4], m1);
72+
_mm_store_ps(&m.m[8], m2);
73+
_mm_store_ps(&m.m[12], m3);
74+
return m;
75+
76+
#else
77+
GLKMatrix4 m;
78+
79+
m.m[0] = matrixLeft.m[0] * matrixRight.m[0] + matrixLeft.m[4] * matrixRight.m[1] + matrixLeft.m[8] * matrixRight.m[2] + matrixLeft.m[12] * matrixRight.m[3];
80+
m.m[4] = matrixLeft.m[0] * matrixRight.m[4] + matrixLeft.m[4] * matrixRight.m[5] + matrixLeft.m[8] * matrixRight.m[6] + matrixLeft.m[12] * matrixRight.m[7];
81+
m.m[8] = matrixLeft.m[0] * matrixRight.m[8] + matrixLeft.m[4] * matrixRight.m[9] + matrixLeft.m[8] * matrixRight.m[10] + matrixLeft.m[12] * matrixRight.m[11];
82+
m.m[12] = matrixLeft.m[0] * matrixRight.m[12] + matrixLeft.m[4] * matrixRight.m[13] + matrixLeft.m[8] * matrixRight.m[14] + matrixLeft.m[12] * matrixRight.m[15];
83+
84+
m.m[1] = matrixLeft.m[1] * matrixRight.m[0] + matrixLeft.m[5] * matrixRight.m[1] + matrixLeft.m[9] * matrixRight.m[2] + matrixLeft.m[13] * matrixRight.m[3];
85+
m.m[5] = matrixLeft.m[1] * matrixRight.m[4] + matrixLeft.m[5] * matrixRight.m[5] + matrixLeft.m[9] * matrixRight.m[6] + matrixLeft.m[13] * matrixRight.m[7];
86+
m.m[9] = matrixLeft.m[1] * matrixRight.m[8] + matrixLeft.m[5] * matrixRight.m[9] + matrixLeft.m[9] * matrixRight.m[10] + matrixLeft.m[13] * matrixRight.m[11];
87+
m.m[13] = matrixLeft.m[1] * matrixRight.m[12] + matrixLeft.m[5] * matrixRight.m[13] + matrixLeft.m[9] * matrixRight.m[14] + matrixLeft.m[13] * matrixRight.m[15];
88+
89+
m.m[2] = matrixLeft.m[2] * matrixRight.m[0] + matrixLeft.m[6] * matrixRight.m[1] + matrixLeft.m[10] * matrixRight.m[2] + matrixLeft.m[14] * matrixRight.m[3];
90+
m.m[6] = matrixLeft.m[2] * matrixRight.m[4] + matrixLeft.m[6] * matrixRight.m[5] + matrixLeft.m[10] * matrixRight.m[6] + matrixLeft.m[14] * matrixRight.m[7];
91+
m.m[10] = matrixLeft.m[2] * matrixRight.m[8] + matrixLeft.m[6] * matrixRight.m[9] + matrixLeft.m[10] * matrixRight.m[10] + matrixLeft.m[14] * matrixRight.m[11];
92+
m.m[14] = matrixLeft.m[2] * matrixRight.m[12] + matrixLeft.m[6] * matrixRight.m[13] + matrixLeft.m[10] * matrixRight.m[14] + matrixLeft.m[14] * matrixRight.m[15];
93+
94+
m.m[3] = matrixLeft.m[3] * matrixRight.m[0] + matrixLeft.m[7] * matrixRight.m[1] + matrixLeft.m[11] * matrixRight.m[2] + matrixLeft.m[15] * matrixRight.m[3];
95+
m.m[7] = matrixLeft.m[3] * matrixRight.m[4] + matrixLeft.m[7] * matrixRight.m[5] + matrixLeft.m[11] * matrixRight.m[6] + matrixLeft.m[15] * matrixRight.m[7];
96+
m.m[11] = matrixLeft.m[3] * matrixRight.m[8] + matrixLeft.m[7] * matrixRight.m[9] + matrixLeft.m[11] * matrixRight.m[10] + matrixLeft.m[15] * matrixRight.m[11];
97+
m.m[15] = matrixLeft.m[3] * matrixRight.m[12] + matrixLeft.m[7] * matrixRight.m[13] + matrixLeft.m[11] * matrixRight.m[14] + matrixLeft.m[15] * matrixRight.m[15];
98+
99+
return m;
100+
#endif
101+
}
102+
103+
104+
extern const GLKMatrix4 GLKMatrix4Identity;
105+
106+
GLK_INLINE GLKMatrix4 GLKMatrix4MakeZRotation(float radians)
107+
{
108+
float cos = cosf(radians);
109+
float sin = sinf(radians);
110+
111+
GLKMatrix4 m = { cos, sin, 0.0f, 0.0f,
112+
-sin, cos, 0.0f, 0.0f,
113+
0.0f, 0.0f, 1.0f, 0.0f,
114+
0.0f, 0.0f, 0.0f, 1.0f };
115+
116+
return m;
117+
}
118+
119+
GLK_INLINE GLKMatrix4 GLKMatrix4RotateZ(GLKMatrix4 matrix, float radians);
120+
GLK_INLINE GLKMatrix4 GLKMatrix4RotateZ(GLKMatrix4 matrix, float radians)
121+
{
122+
GLKMatrix4 rm = GLKMatrix4MakeZRotation(radians);
123+
return GLKMatrix4Multiply(matrix, rm);
124+
}
125+
126+
127+
GLK_INLINE GLKMatrix4 GLKMatrix4Transpose(GLKMatrix4 matrix)
128+
{
129+
GLKMatrix4 m = { matrix.m[0], matrix.m[4], matrix.m[8], matrix.m[12],
130+
matrix.m[1], matrix.m[5], matrix.m[9], matrix.m[13],
131+
matrix.m[2], matrix.m[6], matrix.m[10], matrix.m[14],
132+
matrix.m[3], matrix.m[7], matrix.m[11], matrix.m[15] };
133+
return m;
134+
}
135+
136+
137+
GLK_INLINE GLKMatrix4 GLKMatrix4MakeYRotation(float radians)
138+
{
139+
float cos = cosf(radians);
140+
float sin = sinf(radians);
141+
142+
GLKMatrix4 m = { cos, 0.0f, -sin, 0.0f,
143+
0.0f, 1.0f, 0.0f, 0.0f,
144+
sin, 0.0f, cos, 0.0f,
145+
0.0f, 0.0f, 0.0f, 1.0f };
146+
147+
return m;
148+
}
149+
150+
GLK_INLINE GLKMatrix4 GLKMatrix4RotateY(GLKMatrix4 matrix, float radians)
151+
{
152+
GLKMatrix4 rm = GLKMatrix4MakeYRotation(radians);
153+
return GLKMatrix4Multiply(matrix, rm);
154+
}
155+
156+
GLK_INLINE float GLKMathDegreesToRadians(float degrees) { return degrees * (M_PI / 180); };
157+
158+
159+
#endif /* Catalyst_h */

SGPlayer/Classes/Core/SGAudio/SGAudioPlayer.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ + (AudioComponentDescription)mixerACD
2929
{
3030
AudioComponentDescription acd;
3131
acd.componentType = kAudioUnitType_Mixer;
32-
#if SGPLATFORM_TARGET_OS_MAC
33-
acd.componentSubType = kAudioUnitSubType_StereoMixer;
32+
#if SGPLATFORM_TARGET_OS_MAC || TARGET_OS_MACCATALYST
33+
acd.componentSubType = kAudioUnitSubType_SpatialMixer;
3434
#elif SGPLATFORM_TARGET_OS_IPHONE_OR_TV
3535
acd.componentSubType = kAudioUnitSubType_MultiChannelMixer;
3636
#endif

SGPlayer/Classes/Core/SGFFmpeg/SGFFmpeg.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
static void SGFFmpegLogCallback(void * context, int level, const char * format, va_list args)
1212
{
13-
// NSString * message = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args];
14-
// NSLog(@"SGFFLog : %@", message);
13+
NSString * message = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:args];
14+
NSLog(@"> SGFFLog : %@", message);
1515
}
1616

1717
void SGFFmpegSetupIfNeeded(void)

SGPlayer/Classes/Core/SGMetal/SGMetalProjection.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
//
88

99
#import <Metal/Metal.h>
10+
#if TARGET_OS_MACCATALYST
11+
#import "Catalyst.h"
12+
#else
1013
#import <GLKit/GLKit.h>
14+
#endif
1115

1216
@interface SGMetalProjection : NSObject
1317

SGPlayer/Classes/Core/SGMetal/SGMetalRenderPipelinePool.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
#import "SGMetalBGRARenderPipeline.h"
1313

1414
#import "SGPLFTargets.h"
15+
#if TARGET_OS_MACCATALYST
16+
#import "SGMetalShader_macOS.h"
17+
#else
1518
#if SGPLATFORM_TARGET_OS_IPHONE
1619
#import "SGMetalShader_iOS.h"
1720
#elif SGPLATFORM_TARGET_OS_TV
1821
#import "SGMetalShader_tvOS.h"
1922
#elif SGPLATFORM_TARGET_OS_MAC
2023
#import "SGMetalShader_macOS.h"
2124
#endif
25+
#endif
2226

2327
@interface SGMetalRenderPipelinePool ()
2428

@@ -36,8 +40,8 @@ - (instancetype)initWithDevice:(id<MTLDevice>)device
3640
{
3741
if (self = [super init]) {
3842
self.device = device;
39-
self.library = [device newLibraryWithData:dispatch_data_create(metallib, sizeof(metallib), dispatch_get_global_queue(0, 0), ^{}) error:NULL];
40-
}
43+
self.library = [device newLibraryWithData:dispatch_data_create(metallib, sizeof(metallib), dispatch_get_global_queue(0, 0), ^{}) error:NULL];
44+
}
4145
return self;
4246
}
4347

SGPlayer/Classes/Core/SGMetal/SGMetalYUVRenderPipeline.m

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,26 @@ @implementation SGMetalYUVRenderPipeline
1313
- (instancetype)initWithDevice:(id<MTLDevice>)device library:(id<MTLLibrary>)library
1414
{
1515
if (self = [super initWithDevice:device library:library]) {
16+
17+
NSError *error = nil;
18+
1619
self.descriptor = [[MTLRenderPipelineDescriptor alloc] init];
17-
self.descriptor.vertexFunction = [self.library newFunctionWithName:@"vertexShader"];
18-
self.descriptor.fragmentFunction = [self.library newFunctionWithName:@"fragmentShaderYUV"];
19-
self.descriptor.colorAttachments[0].pixelFormat = MTLPixelFormatBGRA8Unorm;
20-
self.state = [self.device newRenderPipelineStateWithDescriptor:self.descriptor error:nil];
20+
self.descriptor.vertexFunction = [self.library newFunctionWithName:@"vertexShader" constantValues:[MTLFunctionConstantValues new] error:&error];
21+
22+
if (error)
23+
NSLog(@"ERROR: %@", error.localizedDescription);
24+
25+
self.descriptor.fragmentFunction = [self.library newFunctionWithName:@"fragmentShaderYUV" constantValues:[MTLFunctionConstantValues new] error:&error];
26+
27+
if (error)
28+
NSLog(@"ERROR: %@", error.localizedDescription);
29+
30+
self.descriptor.colorAttachments[0].pixelFormat = MTLPixelFormatBGRA8Unorm;
31+
self.state = [self.device newRenderPipelineStateWithDescriptor:self.descriptor error:&error];
32+
33+
if (error)
34+
NSLog(@"ERROR: %@", error.localizedDescription);
35+
2136
}
2237
return self;
2338
}

SGPlayer/Classes/Core/SGOption/SGDecoderOptions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ - (id)copyWithZone:(NSZone *)zone
2626
- (instancetype)init
2727
{
2828
if (self = [super init]) {
29-
self->_options = nil;
29+
self->_options = @{@"sn":[NSNull null]};
3030
self->_threadsAuto = YES;
3131
self->_refcountedFrames = YES;
3232
self->_hardwareDecodeH264 = YES;

0 commit comments

Comments
 (0)