-
Notifications
You must be signed in to change notification settings - Fork 19
/
platform.go
145 lines (137 loc) · 3.58 KB
/
platform.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package go_librespot
import (
"runtime"
spotifypb "github.com/devgianlu/go-librespot/proto/spotify"
clienttokenpb "github.com/devgianlu/go-librespot/proto/spotify/clienttoken/data/v0"
)
func GetOS() spotifypb.Os {
switch runtime.GOOS {
case "android":
return spotifypb.Os_OS_ANDROID
case "darwin":
return spotifypb.Os_OS_OSX
case "freebsd":
return spotifypb.Os_OS_FREEBSD
case "ios":
return spotifypb.Os_OS_IPHONE
case "linux":
return spotifypb.Os_OS_LINUX
case "windows":
return spotifypb.Os_OS_WINDOWS
default:
return spotifypb.Os_OS_UNKNOWN
}
}
func GetCpuFamily() spotifypb.CpuFamily {
switch runtime.GOARCH {
case "386":
return spotifypb.CpuFamily_CPU_X86
case "amd64":
return spotifypb.CpuFamily_CPU_X86_64
case "arm":
return spotifypb.CpuFamily_CPU_ARM
case "arm64":
return spotifypb.CpuFamily_CPU_ARM
case "mips":
return spotifypb.CpuFamily_CPU_MIPS
case "mips64":
return spotifypb.CpuFamily_CPU_MIPS
case "ppc64":
return spotifypb.CpuFamily_CPU_PPC_64
default:
return spotifypb.CpuFamily_CPU_UNKNOWN
}
}
func GetPlatform() spotifypb.Platform {
switch runtime.GOOS {
case "android":
return spotifypb.Platform_PLATFORM_ANDROID_ARM
case "darwin":
switch runtime.GOARCH {
case "386":
return spotifypb.Platform_PLATFORM_OSX_X86
case "amd64":
return spotifypb.Platform_PLATFORM_OSX_X86_64
case "ppc64":
return spotifypb.Platform_PLATFORM_OSX_PPC
}
case "freebsd":
switch runtime.GOARCH {
case "386":
return spotifypb.Platform_PLATFORM_FREEBSD_X86
case "amd64":
return spotifypb.Platform_PLATFORM_FREEBSD_X86_64
}
case "ios":
switch runtime.GOARCH {
case "arm":
return spotifypb.Platform_PLATFORM_IPHONE_ARM
case "arm64":
return spotifypb.Platform_PLATFORM_IPHONE_ARM64
}
case "linux":
switch runtime.GOARCH {
case "386":
return spotifypb.Platform_PLATFORM_LINUX_X86
case "amd64":
return spotifypb.Platform_PLATFORM_LINUX_X86_64
case "mips":
return spotifypb.Platform_PLATFORM_LINUX_MIPS
case "mips64":
return spotifypb.Platform_PLATFORM_LINUX_MIPS
case "arm":
return spotifypb.Platform_PLATFORM_LINUX_ARM
case "arm64":
return spotifypb.Platform_PLATFORM_LINUX_ARM
}
case "windows":
switch runtime.GOARCH {
case "386":
return spotifypb.Platform_PLATFORM_WIN32_X86
case "amd64":
return spotifypb.Platform_PLATFORM_WIN32_X86_64
case "arm":
return spotifypb.Platform_PLATFORM_WINDOWS_CE_ARM
case "arm64":
return spotifypb.Platform_PLATFORM_WINDOWS_CE_ARM
}
case "js":
return spotifypb.Platform_PLATFORM_WEBPLAYER
}
return spotifypb.Platform_PLATFORM_GENERIC_PARTNER
}
func GetPlatformSpecificData() *clienttokenpb.PlatformSpecificData {
switch runtime.GOOS {
case "android":
return &clienttokenpb.PlatformSpecificData{
Data: &clienttokenpb.PlatformSpecificData_Android{
Android: &clienttokenpb.NativeAndroidData{},
},
}
case "darwin":
return &clienttokenpb.PlatformSpecificData{
Data: &clienttokenpb.PlatformSpecificData_DesktopMacos{
DesktopMacos: &clienttokenpb.NativeDesktopMacOSData{},
},
}
case "ios":
return &clienttokenpb.PlatformSpecificData{
Data: &clienttokenpb.PlatformSpecificData_Ios{
Ios: &clienttokenpb.NativeIOSData{},
},
}
case "linux":
return &clienttokenpb.PlatformSpecificData{
Data: &clienttokenpb.PlatformSpecificData_DesktopLinux{
DesktopLinux: &clienttokenpb.NativeDesktopLinuxData{},
},
}
case "windows":
return &clienttokenpb.PlatformSpecificData{
Data: &clienttokenpb.PlatformSpecificData_DesktopWindows{
DesktopWindows: &clienttokenpb.NativeDesktopWindowsData{},
},
}
}
return nil
}