├── README.md ├── UNLICENSE ├── client ├── .gitignore ├── ScreenProjectorClient.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── ScreenProjectorClient │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ └── MainMenu.xib │ ├── Credits.html │ ├── Images.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon_128x128.png │ │ ├── icon_128x128@2x.png │ │ ├── icon_16x16.png │ │ ├── icon_16x16@2x.png │ │ ├── icon_256x256.png │ │ ├── icon_256x256@2x.png │ │ ├── icon_32x32.png │ │ ├── icon_32x32@2x.png │ │ ├── icon_512x512.png │ │ └── icon_512x512@2x.png │ ├── SPADBWrapper.h │ ├── SPADBWrapper.m │ ├── ScreenProjectorClient-Info.plist │ ├── ScreenProjectorClient-Prefix.pch │ ├── en.lproj │ └── InfoPlist.strings │ ├── main.m │ └── server.apk ├── screenshot.jpg └── server ├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── me │ │ └── grishka │ │ └── screenprojector │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── me │ │ │ └── grishka │ │ │ └── screenprojector │ │ │ ├── MainActivity.java │ │ │ └── ProjectionService.java │ └── res │ │ ├── drawable-hdpi │ │ └── ic_videocam.png │ │ ├── drawable-mdpi │ │ └── ic_videocam.png │ │ ├── drawable-xhdpi │ │ └── ic_videocam.png │ │ ├── drawable-xxhdpi │ │ └── ic_videocam.png │ │ ├── drawable-xxxhdpi │ │ └── ic_videocam.png │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── me │ └── grishka │ └── screenprojector │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /README.md: -------------------------------------------------------------------------------- 1 | # Android screen projection for OS X 2 | 3 | ![Screenshot](/screenshot.jpg) 4 | 5 | You plug in your Android device, you select it in the list, you click the button, and you see its screen live on your computer. As simple as that. On some devices you might need to manually allow the access to screen capture because the adb command to grant that permission doesn't work on them. 6 | 7 | This app requires that you have Android SDK installed as it uses `adb` for communication. -------------------------------------------------------------------------------- /UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | # 39 | # Add this line if you want to avoid checking in source code from the Xcode workspace 40 | # *.xcworkspace 41 | 42 | # Carthage 43 | # 44 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 45 | # Carthage/Checkouts 46 | 47 | Carthage/Build 48 | 49 | # fastlane 50 | # 51 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 52 | # screenshots whenever they are needed. 53 | # For more information about the recommended setup visit: 54 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 55 | 56 | fastlane/report.xml 57 | fastlane/Preview.html 58 | fastlane/screenshots/**/*.png 59 | fastlane/test_output 60 | 61 | # Code Injection 62 | # 63 | # After new code Injection tools there's a generated folder /iOSInjectionProject 64 | # https://github.com/johnno1962/injectionforxcode 65 | 66 | iOSInjectionProject/ -------------------------------------------------------------------------------- /client/ScreenProjectorClient.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6939C12420B7045B00119CC2 /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = 6939C12320B7045B00119CC2 /* Credits.html */; }; 11 | 69575B481FBB9CDE0052F16A /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69575B471FBB9CDE0052F16A /* CoreMedia.framework */; }; 12 | 69AAA2EF1DF44CC200C407B8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69AAA2EE1DF44CC200C407B8 /* Cocoa.framework */; }; 13 | 69AAA2F91DF44CC200C407B8 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 69AAA2F71DF44CC200C407B8 /* InfoPlist.strings */; }; 14 | 69AAA2FB1DF44CC200C407B8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 69AAA2FA1DF44CC200C407B8 /* main.m */; }; 15 | 69AAA3021DF44CC200C407B8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 69AAA3011DF44CC200C407B8 /* AppDelegate.m */; }; 16 | 69AAA3051DF44CC200C407B8 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 69AAA3031DF44CC200C407B8 /* MainMenu.xib */; }; 17 | 69AAA3071DF44CC200C407B8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 69AAA3061DF44CC200C407B8 /* Images.xcassets */; }; 18 | 69B69DBF1FBB87A300E6DDCD /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69B69DBE1FBB87A300E6DDCD /* AVFoundation.framework */; }; 19 | 69BEF64F1F92794C000232FB /* SPADBWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 69BEF64E1F92794C000232FB /* SPADBWrapper.m */; }; 20 | 69D307601FC4369C002F92B5 /* server.apk in Resources */ = {isa = PBXBuildFile; fileRef = 69D3075F1FC4369C002F92B5 /* server.apk */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 6939C12320B7045B00119CC2 /* Credits.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = Credits.html; sourceTree = ""; }; 25 | 69575B471FBB9CDE0052F16A /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; 26 | 69AAA2EB1DF44CC200C407B8 /* ScreenProjectorClient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScreenProjectorClient.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 69AAA2EE1DF44CC200C407B8 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 28 | 69AAA2F11DF44CC200C407B8 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 29 | 69AAA2F21DF44CC200C407B8 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 30 | 69AAA2F31DF44CC200C407B8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 31 | 69AAA2F81DF44CC200C407B8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 32 | 69AAA2FA1DF44CC200C407B8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 33 | 69AAA3001DF44CC200C407B8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 34 | 69AAA3011DF44CC200C407B8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; usesTabs = 1; }; 35 | 69AAA3041DF44CC200C407B8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 36 | 69AAA3061DF44CC200C407B8 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 37 | 69B69DBE1FBB87A300E6DDCD /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 38 | 69BEF64D1F92794C000232FB /* SPADBWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPADBWrapper.h; sourceTree = ""; }; 39 | 69BEF64E1F92794C000232FB /* SPADBWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPADBWrapper.m; sourceTree = ""; }; 40 | 69D3075F1FC4369C002F92B5 /* server.apk */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.apk; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 69AAA2E81DF44CC200C407B8 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 69575B481FBB9CDE0052F16A /* CoreMedia.framework in Frameworks */, 49 | 69B69DBF1FBB87A300E6DDCD /* AVFoundation.framework in Frameworks */, 50 | 69AAA2EF1DF44CC200C407B8 /* Cocoa.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 69AAA2E21DF44CC200C407B8 = { 58 | isa = PBXGroup; 59 | children = ( 60 | 69AAA2F41DF44CC200C407B8 /* ScreenProjectorClient */, 61 | 69AAA2ED1DF44CC200C407B8 /* Frameworks */, 62 | 69AAA2EC1DF44CC200C407B8 /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 69AAA2EC1DF44CC200C407B8 /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 69AAA2EB1DF44CC200C407B8 /* ScreenProjectorClient.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | 69AAA2ED1DF44CC200C407B8 /* Frameworks */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 69575B471FBB9CDE0052F16A /* CoreMedia.framework */, 78 | 69B69DBE1FBB87A300E6DDCD /* AVFoundation.framework */, 79 | 69AAA2EE1DF44CC200C407B8 /* Cocoa.framework */, 80 | 69AAA2F01DF44CC200C407B8 /* Other Frameworks */, 81 | ); 82 | name = Frameworks; 83 | sourceTree = ""; 84 | }; 85 | 69AAA2F01DF44CC200C407B8 /* Other Frameworks */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 69AAA2F11DF44CC200C407B8 /* AppKit.framework */, 89 | 69AAA2F21DF44CC200C407B8 /* CoreData.framework */, 90 | 69AAA2F31DF44CC200C407B8 /* Foundation.framework */, 91 | ); 92 | name = "Other Frameworks"; 93 | sourceTree = ""; 94 | }; 95 | 69AAA2F41DF44CC200C407B8 /* ScreenProjectorClient */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 69AAA3001DF44CC200C407B8 /* AppDelegate.h */, 99 | 69AAA3011DF44CC200C407B8 /* AppDelegate.m */, 100 | 69BEF64D1F92794C000232FB /* SPADBWrapper.h */, 101 | 69BEF64E1F92794C000232FB /* SPADBWrapper.m */, 102 | 69D3075F1FC4369C002F92B5 /* server.apk */, 103 | 69AAA3031DF44CC200C407B8 /* MainMenu.xib */, 104 | 6939C12320B7045B00119CC2 /* Credits.html */, 105 | 69AAA3061DF44CC200C407B8 /* Images.xcassets */, 106 | 69AAA2F51DF44CC200C407B8 /* Supporting Files */, 107 | ); 108 | path = ScreenProjectorClient; 109 | sourceTree = ""; 110 | }; 111 | 69AAA2F51DF44CC200C407B8 /* Supporting Files */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 69AAA2F71DF44CC200C407B8 /* InfoPlist.strings */, 115 | 69AAA2FA1DF44CC200C407B8 /* main.m */, 116 | ); 117 | name = "Supporting Files"; 118 | sourceTree = ""; 119 | }; 120 | /* End PBXGroup section */ 121 | 122 | /* Begin PBXNativeTarget section */ 123 | 69AAA2EA1DF44CC200C407B8 /* ScreenProjectorClient */ = { 124 | isa = PBXNativeTarget; 125 | buildConfigurationList = 69AAA31C1DF44CC200C407B8 /* Build configuration list for PBXNativeTarget "ScreenProjectorClient" */; 126 | buildPhases = ( 127 | 69AAA2E71DF44CC200C407B8 /* Sources */, 128 | 69AAA2E81DF44CC200C407B8 /* Frameworks */, 129 | 69AAA2E91DF44CC200C407B8 /* Resources */, 130 | ); 131 | buildRules = ( 132 | ); 133 | dependencies = ( 134 | ); 135 | name = ScreenProjectorClient; 136 | productName = OpenGLTest; 137 | productReference = 69AAA2EB1DF44CC200C407B8 /* ScreenProjectorClient.app */; 138 | productType = "com.apple.product-type.application"; 139 | }; 140 | /* End PBXNativeTarget section */ 141 | 142 | /* Begin PBXProject section */ 143 | 69AAA2E31DF44CC200C407B8 /* Project object */ = { 144 | isa = PBXProject; 145 | attributes = { 146 | LastUpgradeCheck = 0500; 147 | ORGANIZATIONNAME = Grishka; 148 | }; 149 | buildConfigurationList = 69AAA2E61DF44CC200C407B8 /* Build configuration list for PBXProject "ScreenProjectorClient" */; 150 | compatibilityVersion = "Xcode 3.2"; 151 | developmentRegion = English; 152 | hasScannedForEncodings = 0; 153 | knownRegions = ( 154 | en, 155 | Base, 156 | ); 157 | mainGroup = 69AAA2E21DF44CC200C407B8; 158 | productRefGroup = 69AAA2EC1DF44CC200C407B8 /* Products */; 159 | projectDirPath = ""; 160 | projectRoot = ""; 161 | targets = ( 162 | 69AAA2EA1DF44CC200C407B8 /* ScreenProjectorClient */, 163 | ); 164 | }; 165 | /* End PBXProject section */ 166 | 167 | /* Begin PBXResourcesBuildPhase section */ 168 | 69AAA2E91DF44CC200C407B8 /* Resources */ = { 169 | isa = PBXResourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | 69D307601FC4369C002F92B5 /* server.apk in Resources */, 173 | 69AAA2F91DF44CC200C407B8 /* InfoPlist.strings in Resources */, 174 | 69AAA3071DF44CC200C407B8 /* Images.xcassets in Resources */, 175 | 69AAA3051DF44CC200C407B8 /* MainMenu.xib in Resources */, 176 | 6939C12420B7045B00119CC2 /* Credits.html in Resources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXResourcesBuildPhase section */ 181 | 182 | /* Begin PBXSourcesBuildPhase section */ 183 | 69AAA2E71DF44CC200C407B8 /* Sources */ = { 184 | isa = PBXSourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | 69BEF64F1F92794C000232FB /* SPADBWrapper.m in Sources */, 188 | 69AAA3021DF44CC200C407B8 /* AppDelegate.m in Sources */, 189 | 69AAA2FB1DF44CC200C407B8 /* main.m in Sources */, 190 | ); 191 | runOnlyForDeploymentPostprocessing = 0; 192 | }; 193 | /* End PBXSourcesBuildPhase section */ 194 | 195 | /* Begin PBXVariantGroup section */ 196 | 69AAA2F71DF44CC200C407B8 /* InfoPlist.strings */ = { 197 | isa = PBXVariantGroup; 198 | children = ( 199 | 69AAA2F81DF44CC200C407B8 /* en */, 200 | ); 201 | name = InfoPlist.strings; 202 | sourceTree = ""; 203 | }; 204 | 69AAA3031DF44CC200C407B8 /* MainMenu.xib */ = { 205 | isa = PBXVariantGroup; 206 | children = ( 207 | 69AAA3041DF44CC200C407B8 /* Base */, 208 | ); 209 | name = MainMenu.xib; 210 | sourceTree = ""; 211 | }; 212 | /* End PBXVariantGroup section */ 213 | 214 | /* Begin XCBuildConfiguration section */ 215 | 69AAA31A1DF44CC200C407B8 /* Debug */ = { 216 | isa = XCBuildConfiguration; 217 | buildSettings = { 218 | ALWAYS_SEARCH_USER_PATHS = NO; 219 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 220 | CLANG_CXX_LIBRARY = "libc++"; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_BOOL_CONVERSION = YES; 223 | CLANG_WARN_CONSTANT_CONVERSION = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_EMPTY_BODY = YES; 226 | CLANG_WARN_ENUM_CONVERSION = YES; 227 | CLANG_WARN_INT_CONVERSION = YES; 228 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 229 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 230 | COPY_PHASE_STRIP = NO; 231 | GCC_C_LANGUAGE_STANDARD = gnu99; 232 | GCC_DYNAMIC_NO_PIC = NO; 233 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 234 | GCC_OPTIMIZATION_LEVEL = 0; 235 | GCC_PREPROCESSOR_DEFINITIONS = ( 236 | "DEBUG=1", 237 | "$(inherited)", 238 | ); 239 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 240 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 241 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 242 | GCC_WARN_UNDECLARED_SELECTOR = YES; 243 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 244 | GCC_WARN_UNUSED_FUNCTION = YES; 245 | GCC_WARN_UNUSED_VARIABLE = YES; 246 | MACOSX_DEPLOYMENT_TARGET = 10.9; 247 | ONLY_ACTIVE_ARCH = YES; 248 | SDKROOT = macosx; 249 | }; 250 | name = Debug; 251 | }; 252 | 69AAA31B1DF44CC200C407B8 /* Release */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | ALWAYS_SEARCH_USER_PATHS = NO; 256 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 257 | CLANG_CXX_LIBRARY = "libc++"; 258 | CLANG_ENABLE_OBJC_ARC = YES; 259 | CLANG_WARN_BOOL_CONVERSION = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_EMPTY_BODY = YES; 263 | CLANG_WARN_ENUM_CONVERSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 267 | COPY_PHASE_STRIP = YES; 268 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 269 | ENABLE_NS_ASSERTIONS = NO; 270 | GCC_C_LANGUAGE_STANDARD = gnu99; 271 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 272 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 273 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 274 | GCC_WARN_UNDECLARED_SELECTOR = YES; 275 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 276 | GCC_WARN_UNUSED_FUNCTION = YES; 277 | GCC_WARN_UNUSED_VARIABLE = YES; 278 | MACOSX_DEPLOYMENT_TARGET = 10.9; 279 | SDKROOT = macosx; 280 | }; 281 | name = Release; 282 | }; 283 | 69AAA31D1DF44CC200C407B8 /* Debug */ = { 284 | isa = XCBuildConfiguration; 285 | buildSettings = { 286 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 287 | COMBINE_HIDPI_IMAGES = YES; 288 | GCC_OPTIMIZATION_LEVEL = 0; 289 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 290 | GCC_PREFIX_HEADER = "ScreenProjectorClient/ScreenProjectorClient-Prefix.pch"; 291 | INFOPLIST_FILE = "ScreenProjectorClient/ScreenProjectorClient-Info.plist"; 292 | LIBRARY_SEARCH_PATHS = ( 293 | "$(inherited)", 294 | "$(PROJECT_DIR)/ScreenProjectorClient", 295 | ); 296 | MACOSX_DEPLOYMENT_TARGET = 10.9; 297 | PRODUCT_NAME = "$(TARGET_NAME)"; 298 | WRAPPER_EXTENSION = app; 299 | }; 300 | name = Debug; 301 | }; 302 | 69AAA31E1DF44CC200C407B8 /* Release */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 306 | COMBINE_HIDPI_IMAGES = YES; 307 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 308 | GCC_PREFIX_HEADER = "ScreenProjectorClient/ScreenProjectorClient-Prefix.pch"; 309 | INFOPLIST_FILE = "ScreenProjectorClient/ScreenProjectorClient-Info.plist"; 310 | LIBRARY_SEARCH_PATHS = ( 311 | "$(inherited)", 312 | "$(PROJECT_DIR)/ScreenProjectorClient", 313 | ); 314 | MACOSX_DEPLOYMENT_TARGET = 10.9; 315 | PRODUCT_NAME = "$(TARGET_NAME)"; 316 | WRAPPER_EXTENSION = app; 317 | }; 318 | name = Release; 319 | }; 320 | /* End XCBuildConfiguration section */ 321 | 322 | /* Begin XCConfigurationList section */ 323 | 69AAA2E61DF44CC200C407B8 /* Build configuration list for PBXProject "ScreenProjectorClient" */ = { 324 | isa = XCConfigurationList; 325 | buildConfigurations = ( 326 | 69AAA31A1DF44CC200C407B8 /* Debug */, 327 | 69AAA31B1DF44CC200C407B8 /* Release */, 328 | ); 329 | defaultConfigurationIsVisible = 0; 330 | defaultConfigurationName = Release; 331 | }; 332 | 69AAA31C1DF44CC200C407B8 /* Build configuration list for PBXNativeTarget "ScreenProjectorClient" */ = { 333 | isa = XCConfigurationList; 334 | buildConfigurations = ( 335 | 69AAA31D1DF44CC200C407B8 /* Debug */, 336 | 69AAA31E1DF44CC200C407B8 /* Release */, 337 | ); 338 | defaultConfigurationIsVisible = 0; 339 | defaultConfigurationName = Release; 340 | }; 341 | /* End XCConfigurationList section */ 342 | }; 343 | rootObject = 69AAA2E31DF44CC200C407B8 /* Project object */; 344 | } 345 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OpenGLTest 4 | // 5 | // Created by Grishka on 04.12.16. 6 | // Copyright (c) 2016 Grishka. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SPADBWrapper.h" 11 | 12 | @interface AppDelegate : NSObject 13 | 14 | @property (assign) IBOutlet NSWindow *window; 15 | @property (assign) IBOutlet NSView* deviceSelectionOverlay; 16 | @property (assign) IBOutlet NSView* progressOverlay; 17 | @property (assign) IBOutlet NSPopUpButton* deviceListBox; 18 | @property (assign) IBOutlet NSView* videoView; 19 | @property (assign) IBOutlet NSButton* connectBtn; 20 | @property (assign) IBOutlet NSProgressIndicator* progressBar; 21 | @property (assign) IBOutlet NSTextField* progressText; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OpenGLTest 4 | // 5 | // Created by Grishka on 04.12.16. 6 | // Copyright (c) 2016 Grishka. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | 12 | #include 13 | 14 | @implementation AppDelegate{ 15 | SPADBWrapper* adb; 16 | NSMenuItem* placeholderItem; 17 | NSView* titleBarView; 18 | bool updatingDevices; 19 | NSMutableArray* devices; 20 | SPDevice* currentDevice; 21 | int streamingSocket; 22 | NSSize videoSize; 23 | int retryCount; 24 | 25 | AVSampleBufferDisplayLayer* videoLayer; 26 | } 27 | @synthesize window, deviceSelectionOverlay, deviceListBox, videoView, connectBtn, progressBar, progressText, progressOverlay; 28 | 29 | 30 | 31 | - (void)applicationWillFinishLaunching:(NSNotification *)aNotification{ 32 | retryCount=0; 33 | 34 | window.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; 35 | [window setTitle: @"ScreenProjector"]; 36 | [window setMovableByWindowBackground:true]; 37 | adb=[[SPADBWrapper alloc]init]; 38 | [adb setDelegate:self]; 39 | [connectBtn setEnabled:false]; 40 | 41 | placeholderItem=[[NSMenuItem alloc] initWithTitle:@"(no Android devices are connected)" action:NULL keyEquivalent:@""]; 42 | [placeholderItem setEnabled:false]; 43 | [[deviceListBox cell] setMenuItem:placeholderItem]; 44 | devices=[[NSMutableArray alloc]init]; 45 | updatingDevices=true; 46 | [self updateConnectedDevices]; 47 | [window setAspectRatio:NSMakeSize(9.0, 16.0)]; 48 | 49 | for(NSView* view in [[[window contentView] superview] subviews]){ 50 | if([view isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")]){ 51 | titleBarView=view; 52 | break; 53 | } 54 | } 55 | 56 | videoLayer=[[AVSampleBufferDisplayLayer alloc] init]; 57 | videoLayer.videoGravity=AVLayerVideoGravityResizeAspect; 58 | [videoView setLayer:videoLayer]; 59 | [videoView setWantsLayer:true]; 60 | 61 | [progressOverlay setHidden:true]; 62 | [videoView setHidden:true]; 63 | } 64 | 65 | - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender{ 66 | return YES; 67 | } 68 | 69 | - (void)updateConnectedDevices{ 70 | /*[adb listConnectedDevicesWithCompletionBlock:^(NSArray* devices){ 71 | [deviceListBox removeAllItems]; 72 | for(unsigned int i=0;i<[devices count];i++){ 73 | [deviceListBox addItemWithTitle:devices[i].name]; 74 | } 75 | [self->devices removeAllObjects]; 76 | [self->devices addObjectsFromArray:devices]; 77 | 78 | //if(updatingDevices) 79 | // [self performSelector:@selector(updateConnectedDevices) withObject:NULL afterDelay:1]; 80 | }];*/ 81 | [adb startTrackingDevices]; 82 | } 83 | 84 | - (void)startServer{ 85 | [progressText setStringValue:@"Starting server..."]; 86 | [adb runShellCommand:@"am start -n \"me.grishka.screenprojector/me.grishka.screenprojector.MainActivity\" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER" onDeviceWithSerial:currentDevice.serial completion:^(NSString* output){ 87 | [progressText setStringValue:@"Connecting..."]; 88 | [self startStreaming]; 89 | //[self performSelector:@selector(startStreaming) withObject:NULL afterDelay:1]; 90 | }]; 91 | } 92 | 93 | - (void)installServer{ 94 | [progressText setStringValue:@"Installing server..."]; 95 | [adb pushFileFromLocalPath:[[NSBundle mainBundle] pathForResource:@"server" ofType:@"apk"] toRemotePath:@"/data/local/tmp/screen_projector_server.apk" onDeviceWithSerial:currentDevice.serial completion:^{ 96 | NSString* cmd=@"pm install /data/local/tmp/screen_projector_server.apk"; 97 | [adb runShellCommand:cmd onDeviceWithSerial:currentDevice.serial completion:^(NSString* output) { 98 | if([output containsString:@"Success"]){ 99 | [adb runShellCommand:@"appops set me.grishka.screenprojector PROJECT_MEDIA allow" onDeviceWithSerial: currentDevice.serial completion:^(NSString* output) { 100 | [self startServer]; 101 | }]; 102 | }else{ 103 | [self adbCommand:cmd onDeviceWithSerial:NULL didFailWithError:output]; 104 | deviceSelectionOverlay.animator.hidden=false; 105 | progressOverlay.animator.hidden=true; 106 | connectBtn.enabled=true; 107 | } 108 | }]; 109 | }]; 110 | } 111 | 112 | - (void)startStreaming{ 113 | NSLog(@"start streaming"); 114 | [adb forwardTcpPort:5050 onDeviceWithSerial:currentDevice.serial toHostPort:35050 completion:^(){ 115 | [adb connectToTcpPortOnLocalHost:35050 completion:^(int sck){ 116 | streamingSocket=sck; 117 | [self performSelectorInBackground:@selector(runStreamingThread) withObject:NULL]; 118 | }]; 119 | }]; 120 | } 121 | 122 | - (void)retryConnectionDelayed{ 123 | [self performSelector:@selector(startStreaming) withObject:NULL afterDelay:0.25]; 124 | } 125 | 126 | - (void)runStreamingThread{ 127 | unsigned char* buffer=malloc(1024*1024); 128 | send(streamingSocket, buffer, 1, 0); 129 | uint8_t sps[1024], pps[1024]; 130 | bool recvdSPS=false, recvdPPS=false; 131 | size_t spsLen, ppsLen; 132 | CMFormatDescriptionRef formatDesc; 133 | 134 | bool receivedFirstFrame=false; 135 | 136 | while(true){ 137 | int32_t len; 138 | unsigned char flags; 139 | ssize_t rlen=recv(streamingSocket, &len, 4, 0); 140 | if(rlen!=4){ 141 | NSLog(@"socket closed? rlen=%ld", rlen); 142 | if(!receivedFirstFrame && retryCount<10){ 143 | NSLog(@"retrying"); 144 | retryCount++; 145 | [self performSelectorOnMainThread:@selector(retryConnectionDelayed) withObject:NULL waitUntilDone:false]; 146 | close(streamingSocket); 147 | free(buffer); 148 | return; 149 | } 150 | break; 151 | } 152 | len=ntohl(len); 153 | if(len>1024*1024){ 154 | NSLog(@"packet too long"); 155 | break; 156 | } 157 | rlen=recv(streamingSocket, &flags, 1, 0); 158 | if(rlen!=1){ 159 | NSLog(@"socket closed? rlen=%ld", rlen); 160 | break; 161 | } 162 | size_t totalRecvd=0; 163 | while(totalRecvd /dev/null; echo $?" onDeviceWithSerial:currentDevice.serial completion:^(NSString* output){ 270 | if([output length]>=1 && [[output substringToIndex:1] isEqualToString:@"0"]){ 271 | NSLog(@"server installed"); 272 | [self startServer]; 273 | }else{ 274 | NSLog(@"server NOT installed"); 275 | [self installServer]; 276 | } 277 | }]; 278 | } 279 | 280 | - (void)mouseEntered:(NSEvent *)event{ 281 | titleBarView.animator.alphaValue=1; 282 | } 283 | 284 | - (void)mouseExited:(NSEvent *)event{ 285 | titleBarView.animator.alphaValue=0; 286 | } 287 | 288 | - (void)resizeWindowForNewVideoSize{ 289 | float size=MAX(window.frame.size.width, window.frame.size.height); 290 | NSSize newSize; 291 | if(videoSize.height>videoSize.width){ 292 | newSize=NSMakeSize(videoSize.width/videoSize.height*size, size); 293 | }else{ 294 | newSize=NSMakeSize(size, videoSize.height/videoSize.width*size); 295 | } 296 | window.aspectRatio=newSize; 297 | NSRect frame=window.frame; 298 | float centerX=frame.origin.x+frame.size.width/2; 299 | float centerY=frame.origin.y+frame.size.height/2; 300 | frame.origin=NSMakePoint(centerX-roundf(newSize.width/2), centerY-roundf(newSize.height/2)); 301 | frame.size=newSize; 302 | [window setFrame:frame display:true animate:true]; 303 | } 304 | 305 | - (void)adbCommand:(NSString *)cmd onDeviceWithSerial:(NSString *)serial didFailWithError:(NSString *)error { 306 | NSLog(@"command %@ failed with error %@", cmd, error); 307 | NSAlert* alert=[[NSAlert alloc] init]; 308 | [alert setAlertStyle:NSAlertStyleCritical]; 309 | [alert addButtonWithTitle:@"Quit"]; 310 | [alert setInformativeText:error]; 311 | if([cmd isEqualToString:@"connect"]){ 312 | [alert setMessageText:@"Failed to connect to the ADB daemon. Please make sure it's running. To start the daemon, either open Android Studio or run `adb start-server` in Terminal."]; 313 | [alert addButtonWithTitle:@"Try Again"]; 314 | }else{ 315 | [alert setMessageText:[NSString stringWithFormat:@"ADB command '%@' didn't complete successfully.", cmd]]; 316 | } 317 | [alert beginSheetModalForWindow:window completionHandler:^(NSModalResponse returnCode) { 318 | if(returnCode==1001){ 319 | [self updateConnectedDevices]; 320 | }else{ 321 | [[NSApplication sharedApplication] terminate:NULL]; 322 | } 323 | }]; 324 | } 325 | 326 | - (void)adbDeviceAdded:(SPDevice *)device { 327 | [devices addObject:device]; 328 | [deviceListBox addItemWithTitle:device.name]; 329 | [connectBtn setEnabled:true]; 330 | } 331 | 332 | - (void)adbDeviceRemoved:(SPDevice *)device { 333 | NSUInteger index=[devices indexOfObject:device]; 334 | if(index==NSNotFound) 335 | return; 336 | [devices removeObjectAtIndex:index]; 337 | [deviceListBox removeItemAtIndex:index]; 338 | if([devices count]==0){ 339 | [[deviceListBox cell] setMenuItem:placeholderItem]; 340 | [connectBtn setEnabled:false]; 341 | } 342 | } 343 | 344 | - (void)didReceiveFirstVideoFrame{ 345 | NSTrackingArea* area=[[NSTrackingArea alloc] initWithRect:NSMakeRect(0, 0, 100, 100) options: NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect owner:self userInfo:NULL]; 346 | [[window contentView] addTrackingArea:area]; 347 | progressOverlay.animator.hidden=true; 348 | videoView.animator.hidden=false; 349 | } 350 | 351 | - (void)resetUI{ 352 | if(streamingSocket) 353 | close(streamingSocket); 354 | streamingSocket=0; 355 | retryCount=0; 356 | videoView.animator.hidden=true; 357 | deviceSelectionOverlay.animator.hidden=false; 358 | [deviceListBox removeAllItems]; 359 | [[deviceListBox cell] setMenuItem:placeholderItem]; 360 | [devices removeAllObjects]; 361 | [adb startTrackingDevices]; 362 | } 363 | 364 | @end 365 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 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 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | Default 524 | 525 | 526 | 527 | 528 | 529 | 530 | Left to Right 531 | 532 | 533 | 534 | 535 | 536 | 537 | Right to Left 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | Default 549 | 550 | 551 | 552 | 553 | 554 | 555 | Left to Right 556 | 557 | 558 | 559 | 560 | 561 | 562 | Right to Left 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Credits.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | This project on GitHub 5 | 6 | 7 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "icon_16x16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "icon_16x16@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "icon_32x32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "icon_32x32@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "icon_128x128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "icon_128x128@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "icon_256x256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "icon_256x256@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "icon_512x512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "icon_512x512@2x.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_128x128.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_128x128@2x.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_16x16.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_16x16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_16x16@2x.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_256x256.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_256x256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_256x256@2x.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_32x32.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_512x512.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_512x512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/Images.xcassets/AppIcon.appiconset/icon_512x512@2x.png -------------------------------------------------------------------------------- /client/ScreenProjectorClient/SPADBWrapper.h: -------------------------------------------------------------------------------- 1 | // 2 | // SPADBWrapper.h 3 | // ScreenProjectorClient 4 | // 5 | // Created by Grishka on 14.10.2017. 6 | // Copyright © 2017 Grishka. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SPDevice : NSObject 12 | 13 | @property (retain) NSString* serial; 14 | @property (retain) NSString* name; 15 | @property (retain) NSString* androidVersion; 16 | @property int apiLevel; 17 | 18 | @end 19 | 20 | @protocol SPADBDelegate 21 | 22 | - (void)adbCommand: (NSString*)cmd onDeviceWithSerial: (NSString*)serial didFailWithError: (NSString*)error; 23 | - (void)adbDeviceAdded: (SPDevice*)device; 24 | - (void)adbDeviceRemoved: (SPDevice*)device; 25 | 26 | @end 27 | 28 | @interface SPADBWrapper : NSObject 29 | 30 | - (void)listConnectedDevicesWithCompletionBlock: (void (^)(NSArray*))completion; 31 | - (void)runShellCommand: (NSString*)cmd onDeviceWithSerial: (NSString*)serial completion: (void (^)(NSString*))completion; 32 | - (void)connectToTcpPort: (uint16_t)port onDeviceWithSerial: (NSString*)serial completion: (void (^)(int))completion; 33 | - (void)forwardTcpPort: (uint16_t)port onDeviceWithSerial: (NSString*)serial toHostPort: (uint16_t)hport completion: (void (^)())completion; 34 | - (void)connectToTcpPortOnLocalHost: (uint16_t)port completion: (void (^)(int))completion; 35 | - (void)setDelegate: (id)delegate; 36 | - (void)startTrackingDevices; 37 | - (void)stopTrackingDevices; 38 | - (void)pushFileFromLocalPath: (NSString*)localPath toRemotePath: (NSString*)remotePath onDeviceWithSerial: (NSString*)serial completion: (void (^)())completion; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/SPADBWrapper.m: -------------------------------------------------------------------------------- 1 | // 2 | // SPADBWrapper.m 3 | // ScreenProjectorClient 4 | // 5 | // Created by Grishka on 14.10.2017. 6 | // Copyright © 2017 Grishka. All rights reserved. 7 | // 8 | 9 | #import "SPADBWrapper.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | @implementation SPADBWrapper{ 23 | NSThread* adbThread; 24 | id delegate; 25 | int deviceTrackingSocket; 26 | } 27 | 28 | - (id)init{ 29 | adbThread=[[NSThread alloc] init]; 30 | deviceTrackingSocket=0; 31 | 32 | return self; 33 | } 34 | 35 | - (void)_runBlock: (void (^)(void))block{ 36 | block(); 37 | } 38 | 39 | - (void)_runInBackground: (void (^)(void))block{ 40 | [self performSelectorInBackground:@selector(_runBlock:) withObject:block]; 41 | } 42 | 43 | - (void)_runOnMainThread: (void (^)(void))block{ 44 | [self performSelectorOnMainThread:@selector(_runBlock:) withObject:block waitUntilDone:false]; 45 | } 46 | 47 | - (int)_makeAndConnectSocket{ 48 | int s=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); 49 | struct sockaddr_in addr; 50 | inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr); 51 | addr.sin_family=AF_INET; 52 | addr.sin_port=htons(5037); 53 | int res=connect(s, (struct sockaddr*)&addr, sizeof(addr)); 54 | if(res!=0){ 55 | [self performSelectorOnMainThread:@selector(_reportError:) withObject:@[@"connect",[NSString stringWithUTF8String:strerror(errno)]] waitUntilDone:false]; 56 | close(s); 57 | return 0; 58 | } 59 | 60 | return s; 61 | } 62 | 63 | - (bool)_sendCommand: (NSString*)cmd toSocket: (int)sck{ 64 | uint16_t len=[cmd lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; 65 | const char* ccmd=[[NSString stringWithFormat:@"%04X%@", len, cmd] cStringUsingEncoding:NSUTF8StringEncoding]; 66 | NSLog(@"Sending adb command: %@", cmd); 67 | send(sck, ccmd, len+4, 0); 68 | char buffer[4]; 69 | size_t recvd=recv(sck, buffer, 4, 0); 70 | if(recvd<=0) 71 | return false; 72 | if(strncmp(buffer, "OKAY", 4)==0){ 73 | return true; 74 | }else{ 75 | NSLog(@"Failed: %s", buffer); 76 | [self performSelectorOnMainThread:@selector(_reportError:) withObject:@[cmd,[NSString stringWithUTF8String:buffer]] waitUntilDone:false]; 77 | return false; 78 | } 79 | } 80 | 81 | - (NSString*)_receiveLengthPrefixedStringFromSocket: (int)sck{ 82 | char lbuf[5]; 83 | ssize_t rlen=recv(sck, lbuf, 4, 0); 84 | if(rlen!=4){ 85 | return NULL; 86 | } 87 | lbuf[4]=0; 88 | size_t slen; 89 | sscanf(lbuf, "%4zX", &slen); 90 | char sbuf[slen+1]; 91 | sbuf[slen]=0; 92 | size_t totalRecvd=0; 93 | while(totalRecvd*))completion{ 104 | [self _runInBackground:^{ 105 | int sck=[self _makeAndConnectSocket]; 106 | if([self _sendCommand:@"host:devices-l" toSocket:sck]){ 107 | char buffer[1024]; 108 | size_t recvd=recv(sck, buffer, 1023, 0); 109 | if(recvd<=0){ 110 | NSLog(@"Failed to list devices [2]"); 111 | }else{ 112 | NSMutableArray* result=[[NSMutableArray alloc]init]; 113 | buffer[recvd]=0; 114 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[ ]+" options:NSRegularExpressionCaseInsensitive error:NULL]; 115 | NSString* unparsedList=[NSString stringWithUTF8String:buffer+4]; 116 | unparsedList = [regex stringByReplacingMatchesInString:unparsedList options:0 range:NSMakeRange(0, [unparsedList length]) withTemplate:@"\t"]; 117 | NSArray* list=[unparsedList componentsSeparatedByString:@"\n"]; 118 | for(unsigned int i=0;i<[list count];i++){ 119 | NSArray* parts=[list[i] componentsSeparatedByString:@"\t"]; 120 | if([parts count]<2) 121 | break; 122 | NSString* serial=parts[0]; 123 | NSString* state=parts[1]; 124 | if(![state isEqualToString:@"device"]) 125 | continue; 126 | SPDevice* dev=[[SPDevice alloc]init]; 127 | dev.serial=serial; 128 | for(unsigned int j=2;j<[parts count];j++){ 129 | NSArray* kv=[[parts objectAtIndex:j] componentsSeparatedByString:@":"]; 130 | NSString* key=kv[0]; 131 | NSString* value=kv[1]; 132 | if([key isEqualToString:@"model"]){ 133 | NSLog(@"Device: serial=%@, model=%@", serial, value); 134 | dev.name=value; 135 | } 136 | } 137 | [result addObject:dev]; 138 | } 139 | [self _runOnMainThread:^{ 140 | completion(result); 141 | }]; 142 | } 143 | }else{ 144 | NSLog(@"Failed to list devices!"); 145 | } 146 | close(sck); 147 | }]; 148 | } 149 | 150 | - (void)runShellCommand: (NSString*)cmd onDeviceWithSerial: (NSString*)serial completion: (void (^)(NSString*))completion{ 151 | [self _runInBackground:^{ 152 | int sck=[self _makeAndConnectSocket]; 153 | if([self _sendCommand:[NSString stringWithFormat:@"host:transport:%@", serial] toSocket:sck]){ 154 | if([self _sendCommand:[NSString stringWithFormat:@"shell:%@", cmd] toSocket:sck]){ 155 | NSString* result=@""; 156 | size_t recvd=0; 157 | do{ 158 | char buffer[1024]; 159 | recvd=recv(sck, buffer, 1023, 0); 160 | if(recvd>0){ 161 | buffer[recvd]=0; 162 | NSLog(@"received: %s", buffer); 163 | NSString* part=[NSString stringWithUTF8String:buffer]; 164 | result=[result stringByAppendingString:part]; 165 | } 166 | }while(recvd>0); 167 | [self _runOnMainThread:^{ 168 | completion(result); 169 | }]; 170 | } 171 | } 172 | close(sck); 173 | }]; 174 | } 175 | 176 | - (void)connectToTcpPort: (uint16_t)port onDeviceWithSerial: (NSString*)serial completion: (void (^)(int))completion{ 177 | [self _runInBackground:^{ 178 | int sck=[self _makeAndConnectSocket]; 179 | if([self _sendCommand:[NSString stringWithFormat:@"host:transport:%@", serial] toSocket:sck]){ 180 | if([self _sendCommand:[NSString stringWithFormat:@"tcp:%u", port] toSocket:sck]){ 181 | [self _runOnMainThread:^{ 182 | completion(sck); 183 | }]; 184 | } 185 | } 186 | }]; 187 | } 188 | 189 | - (void)forwardTcpPort: (uint16_t)port onDeviceWithSerial: (NSString*)serial toHostPort: (uint16_t)hport completion: (void (^)())completion{ 190 | [self _runInBackground:^{ 191 | int sck=[self _makeAndConnectSocket]; 192 | //if([self _sendCommand:[NSString stringWithFormat:@"host:transport:%@", serial] toSocket:sck]){ 193 | if([self _sendCommand:[NSString stringWithFormat:@"host-serial:%@:forward:tcp:%u;tcp:%u", serial, hport, port] toSocket:sck]){ 194 | [self _runOnMainThread:^{ 195 | completion(); 196 | }]; 197 | } 198 | //} 199 | }]; 200 | } 201 | 202 | - (void)connectToTcpPortOnLocalHost: (uint16_t)port completion: (void (^)(int))completion{ 203 | [self _runInBackground:^{ 204 | int s=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); 205 | struct sockaddr_in addr; 206 | inet_pton(AF_INET, "127.0.0.1", &addr.sin_addr); 207 | addr.sin_family=AF_INET; 208 | addr.sin_port=htons(port); 209 | int result=connect(s, (struct sockaddr*)&addr, sizeof(addr)); 210 | NSLog(@"connect to port %u: result %d error %d %s", port, result, errno, strerror(errno)); 211 | [self _runOnMainThread:^{ 212 | completion(s); 213 | }]; 214 | }]; 215 | } 216 | 217 | - (void)setDelegate:(id)_delegate{ 218 | delegate=_delegate; 219 | } 220 | 221 | - (void)startTrackingDevices{ 222 | [self _runInBackground:^{ 223 | int sck=[self _makeAndConnectSocket]; 224 | if(!sck) 225 | return; 226 | deviceTrackingSocket=sck; 227 | if([self _sendCommand:@"host:track-devices" toSocket:sck]){ 228 | NSMutableArray* devices=[[NSMutableArray alloc]init]; 229 | while(deviceTrackingSocket){ 230 | NSString* resp=[self _receiveLengthPrefixedStringFromSocket:deviceTrackingSocket]; 231 | if(!resp) 232 | break; 233 | NSArray* lines=[resp componentsSeparatedByString:@"\n"]; 234 | NSMutableArray* newDevList=[[NSMutableArray alloc] init]; 235 | for(NSString* line in lines){ 236 | NSArray* parts=[line componentsSeparatedByString:@"\t"]; 237 | if([parts count]<2) 238 | continue; 239 | NSString* serial=parts[0]; 240 | NSString* state=parts[1]; 241 | if(![state isEqualToString:@"device"]) 242 | continue; 243 | [newDevList addObject:serial]; 244 | bool found=false; 245 | for(SPDevice* dev in devices){ 246 | if([dev.serial isEqualToString:serial]){ 247 | found=true; 248 | break; 249 | } 250 | } 251 | if(!found){ 252 | int tmpsck=[self _makeAndConnectSocket]; 253 | if([self _sendCommand:[NSString stringWithFormat:@"host:transport:%@", serial] toSocket:tmpsck]){ 254 | if([self _sendCommand:@"shell:echo \"$(getprop ro.product.manufacturer) $(getprop ro.product.model)|$(getprop ro.build.version.sdk)|$(getprop ro.build.version.release)|\"" toSocket:tmpsck]){ 255 | char buffer[1024]; 256 | size_t recvd=recv(tmpsck, buffer, 1023, 0); 257 | if(recvd<=0){ 258 | NSLog(@"Failed to run shell command"); 259 | }else{ 260 | buffer[recvd]=0; 261 | NSLog(@"received: %s", buffer); 262 | NSString* devinfo=[NSString stringWithUTF8String:buffer]; 263 | NSArray* infoParts=[devinfo componentsSeparatedByString:@"|"]; 264 | SPDevice* dev=[[SPDevice alloc] init]; 265 | dev.serial=serial; 266 | dev.name=infoParts[0]; 267 | dev.apiLevel=infoParts[1].intValue; 268 | dev.androidVersion=infoParts[2]; 269 | [devices addObject:dev]; 270 | [delegate performSelectorOnMainThread:@selector(adbDeviceAdded:) withObject:dev waitUntilDone:false]; 271 | } 272 | }else{ 273 | NSLog(@"Failed to get device info for %@", serial); 274 | } 275 | }else{ 276 | NSLog(@"Failed to transport to %@", serial); 277 | } 278 | close(tmpsck); 279 | } 280 | } 281 | NSMutableArray* devicesToRemove=[[NSMutableArray alloc] init]; 282 | for(SPDevice* dev in devices){ 283 | if([newDevList indexOfObject:dev.serial]==NSNotFound){ 284 | [delegate performSelectorOnMainThread:@selector(adbDeviceRemoved:) withObject:dev waitUntilDone:false]; 285 | [devicesToRemove addObject:dev]; 286 | } 287 | } 288 | if([devicesToRemove count]) 289 | [devices removeObjectsInArray:devicesToRemove]; 290 | //NSLog(@"devices: %@", resp); 291 | } 292 | }else{ 293 | NSLog(@"Failed to list devices!"); 294 | //[self performSelectorOnMainThread:@selector(_reportError:) withObject:@[@"host:track-devices",(NSString*)nil,[NSString stringWithUTF8String:strerror(errno)]] waitUntilDone:false]; 295 | } 296 | if(deviceTrackingSocket) 297 | close(deviceTrackingSocket); 298 | }]; 299 | } 300 | 301 | - (void)stopTrackingDevices{ 302 | if(deviceTrackingSocket){ 303 | int s=deviceTrackingSocket; 304 | deviceTrackingSocket=0; 305 | close(s); 306 | } 307 | } 308 | 309 | - (void)_reportError:(NSArray*)params{ 310 | [delegate adbCommand:params[0] onDeviceWithSerial:nil didFailWithError:params[1]]; 311 | } 312 | 313 | - (void)pushFileFromLocalPath: (NSString*)localPath toRemotePath: (NSString*)remotePath onDeviceWithSerial: (NSString*)serial completion: (void (^)())completion{ 314 | [self _runInBackground:^{ 315 | int sck=[self _makeAndConnectSocket]; 316 | if([self _sendCommand:[NSString stringWithFormat:@"host:transport:%@", serial] toSocket:sck]){ 317 | if([self _sendCommand:@"sync:" toSocket:sck]){ 318 | char buf[512]; 319 | memcpy(buf, "SEND", 4); 320 | NSString* rpath=[NSString stringWithFormat:@"%@,0666",remotePath]; 321 | UInt32 nameLen=(UInt32)[rpath lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; 322 | assert(nameLen+8<=sizeof(buf)); 323 | memcpy(buf+4, &nameLen, 4); 324 | memcpy(buf+8, [rpath cStringUsingEncoding:NSUTF8StringEncoding], nameLen); 325 | send(sck, buf, nameLen+8, 0); 326 | FILE* file=fopen([localPath cStringUsingEncoding:NSUTF8StringEncoding], "r"); 327 | if(!file){ 328 | close(sck); 329 | return; 330 | } 331 | unsigned char* fbuf=malloc(64*1024); 332 | while(!feof(file)){ 333 | size_t _count=fread(fbuf, 1, 64*1024, file); 334 | UInt32 count=(UInt32)_count; 335 | memcpy(buf, "DATA", 4); 336 | memcpy(buf+4, &count, 4); 337 | NSLog(@"sending file part of length %u", count); 338 | send(sck, buf, 8, 0); 339 | send(sck, fbuf, _count, 0); 340 | } 341 | free(fbuf); 342 | UInt32 lastmod=(UInt32)time(NULL); 343 | memcpy(buf, "DONE", 4); 344 | memcpy(buf+4, &lastmod, 4); 345 | send(sck, buf, 8, 0); 346 | ssize_t recvd=recv(sck, buf, 8, 0); 347 | if(recvd==8){ 348 | buf[4]=0; 349 | NSLog(@"push done: %s", buf); 350 | } 351 | close(sck); 352 | fclose(file); 353 | [self _runOnMainThread:^{ 354 | completion(); 355 | }]; 356 | } 357 | } 358 | }]; 359 | } 360 | 361 | @end 362 | 363 | 364 | @implementation SPDevice 365 | @end 366 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/ScreenProjectorClient-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | me.grishka.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Made by Grishka, released into public domain 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/ScreenProjectorClient-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #endif 10 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OpenGLTest 4 | // 5 | // Created by Grishka on 04.12.16. 6 | // Copyright (c) 2016 Grishka. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) 12 | { 13 | return NSApplicationMain(argc, argv); 14 | } 15 | -------------------------------------------------------------------------------- /client/ScreenProjectorClient/server.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/client/ScreenProjectorClient/server.apk -------------------------------------------------------------------------------- /screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/screenshot.jpg -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /server/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /server/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /server/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /server/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /server/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | -------------------------------------------------------------------------------- /server/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /server/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 23 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | -------------------------------------------------------------------------------- /server/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /server/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /server/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /server/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.1" 6 | defaultConfig { 7 | applicationId "me.grishka.screenprojector" 8 | minSdkVersion 21 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | } 25 | -------------------------------------------------------------------------------- /server/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/grishka/android-sdks/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /server/app/src/androidTest/java/me/grishka/screenprojector/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package me.grishka.screenprojector; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest{ 19 | @Test 20 | public void useAppContext() throws Exception{ 21 | // Context of the app under test. 22 | Context appContext=InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("me.grishka.screenprojector", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /server/app/src/main/java/me/grishka/screenprojector/MainActivity.java: -------------------------------------------------------------------------------- 1 | package me.grishka.screenprojector; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.media.projection.MediaProjectionManager; 6 | import android.os.Bundle; 7 | import android.view.View; 8 | import android.widget.Button; 9 | import android.widget.Toast; 10 | 11 | public class MainActivity extends Activity{ 12 | 13 | private Button startBtn; 14 | private MediaProjectionManager projectionManager; 15 | 16 | private int resultCode; 17 | private Intent resultData; 18 | 19 | private static final int PROJECTION_RESULT=101; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState){ 23 | super.onCreate(savedInstanceState); 24 | 25 | projectionManager=(MediaProjectionManager) getSystemService(MEDIA_PROJECTION_SERVICE); 26 | setupMediaProjection(); 27 | } 28 | 29 | private void setupMediaProjection(){ 30 | if(resultData==null){ 31 | startActivityForResult(projectionManager.createScreenCaptureIntent(), PROJECTION_RESULT); 32 | }else{ 33 | startProjectionService(); 34 | } 35 | } 36 | 37 | @Override 38 | protected void onActivityResult(int requestCode, int resultCode, Intent data){ 39 | if(requestCode==PROJECTION_RESULT){ 40 | if(resultCode!=RESULT_OK){ 41 | Toast.makeText(this, "Permission denied :(", Toast.LENGTH_SHORT).show(); 42 | finish(); 43 | return; 44 | } 45 | this.resultCode=resultCode; 46 | resultData=data; 47 | startProjectionService(); 48 | } 49 | } 50 | 51 | private void startProjectionService(){ 52 | Intent intent=new Intent(this, ProjectionService.class); 53 | intent.putExtra("result_data", resultData); 54 | startService(intent); 55 | finish(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /server/app/src/main/java/me/grishka/screenprojector/ProjectionService.java: -------------------------------------------------------------------------------- 1 | package me.grishka.screenprojector; 2 | 3 | import android.app.Activity; 4 | import android.app.Notification; 5 | import android.app.NotificationChannel; 6 | import android.app.NotificationManager; 7 | import android.app.Service; 8 | import android.content.Intent; 9 | import android.graphics.Point; 10 | import android.hardware.display.DisplayManager; 11 | import android.hardware.display.VirtualDisplay; 12 | import android.media.MediaCodec; 13 | import android.media.MediaCodecInfo; 14 | import android.media.MediaFormat; 15 | import android.media.projection.MediaProjection; 16 | import android.media.projection.MediaProjectionManager; 17 | import android.os.Build; 18 | import android.os.Handler; 19 | import android.os.HandlerThread; 20 | import android.os.IBinder; 21 | import android.os.Looper; 22 | import android.os.Process; 23 | import android.util.Log; 24 | import android.view.Display; 25 | import android.view.Surface; 26 | import android.view.WindowManager; 27 | 28 | import java.io.ByteArrayOutputStream; 29 | import java.io.DataOutputStream; 30 | import java.io.IOException; 31 | import java.io.InputStream; 32 | import java.net.ServerSocket; 33 | import java.net.Socket; 34 | import java.nio.ByteBuffer; 35 | import java.util.ArrayList; 36 | import java.util.concurrent.LinkedBlockingQueue; 37 | 38 | /** 39 | * Created by grishka on 08.10.2017. 40 | */ 41 | 42 | public class ProjectionService extends Service implements DisplayManager.DisplayListener{ 43 | 44 | private static final String TAG="ProjectionService"; 45 | 46 | private static final int ID_NOTIFICATION=20; 47 | private static ProjectionService instance; 48 | 49 | private MediaProjectionManager projectionManager; 50 | private MediaProjection projection; 51 | private Intent projectionData; 52 | private VirtualDisplay virtualDisplay; 53 | private MediaCodec codec; 54 | private Surface surface; 55 | private MediaFormat format; 56 | private MediaCodec.Callback codecCallback; 57 | 58 | private ServerSocket serverSocket; 59 | private Socket currentClientSocket; 60 | private DataOutputStream currentClientStream; 61 | private boolean codecReleased; 62 | private LinkedBlockingQueue buffersToSend=new LinkedBlockingQueue<>(); 63 | private final ArrayList emptyBuffers=new ArrayList<>(); 64 | private HandlerThread encoderThread=new HandlerThread("ProjectionEncoder", Process.THREAD_PRIORITY_URGENT_DISPLAY); 65 | 66 | @Override 67 | public IBinder onBind(Intent intent){ 68 | return null; 69 | } 70 | 71 | @Override 72 | public int onStartCommand(Intent intent, int flags, int startId){ 73 | 74 | Notification.Builder bldr=new Notification.Builder(this) 75 | .setContentTitle("Streaming device screen") 76 | .setSmallIcon(R.drawable.ic_videocam) 77 | .setPriority(Notification.PRIORITY_MIN) 78 | .setOngoing(true); 79 | if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){ 80 | NotificationChannel ch=new NotificationChannel("service", "Foreground service", NotificationManager.IMPORTANCE_MIN); 81 | bldr.setChannelId(ch.getId()); 82 | ((NotificationManager)getSystemService(NOTIFICATION_SERVICE)).createNotificationChannel(ch); 83 | } 84 | Notification n=bldr.build(); 85 | startForeground(ID_NOTIFICATION, n); 86 | projectionData=intent.getParcelableExtra("result_data"); 87 | projectionManager=(MediaProjectionManager) getSystemService(MEDIA_PROJECTION_SERVICE); 88 | instance=this; 89 | 90 | startServer(); 91 | return START_NOT_STICKY; 92 | } 93 | 94 | @Override 95 | public void onCreate(){ 96 | super.onCreate(); 97 | encoderThread.start(); 98 | } 99 | 100 | @Override 101 | public void onDestroy(){ 102 | super.onDestroy(); 103 | stopForeground(true); 104 | encoderThread.quit(); 105 | instance=null; 106 | codecReleased=true; 107 | if(codec!=null) 108 | codec.release(); 109 | if(surface!=null) 110 | surface.release(); 111 | if(virtualDisplay!=null) 112 | virtualDisplay.release(); 113 | if(projection!=null) 114 | projection.stop(); 115 | if(serverSocket!=null){ 116 | try{serverSocket.close();}catch(Exception checkedExceptionsAreStupid){} 117 | } 118 | } 119 | 120 | public static boolean isRunning(){ 121 | return instance!=null; 122 | } 123 | 124 | private void startProjection(){ 125 | projection=projectionManager.getMediaProjection(Activity.RESULT_OK, projectionData); 126 | if(projection==null){ 127 | Log.e(TAG, "Projection is null"); 128 | stopSelf(); 129 | return; 130 | } 131 | Display display=((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); 132 | Point size=new Point(); 133 | display.getRealSize(size); 134 | float scaling=Math.min(1f, 720f/Math.min(size.x, size.y)); 135 | format=MediaFormat.createVideoFormat("video/avc", Math.round(size.x*scaling), Math.round(size.y*scaling)); 136 | Log.i(TAG, "format: "+format); 137 | format.setInteger(MediaFormat.KEY_BIT_RATE, 12000000); 138 | format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); 139 | format.setFloat(MediaFormat.KEY_FRAME_RATE, display.getRefreshRate()); 140 | format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1); 141 | Log.i(TAG, "display refresh rate: "+display.getRefreshRate()); 142 | try{ 143 | codec=MediaCodec.createEncoderByType("video/avc"); 144 | codecCallback=new MediaCodec.Callback(){ 145 | @Override 146 | public void onInputBufferAvailable(MediaCodec codec, int index){ 147 | //Log.v(TAG, "input buffer available"); 148 | } 149 | 150 | @Override 151 | public void onOutputBufferAvailable(MediaCodec codec, int index, MediaCodec.BufferInfo info){ 152 | if(codecReleased) 153 | return; 154 | try{ 155 | ByteBuffer buffer=codec.getOutputBuffer(index); 156 | //Log.d(TAG, "output buffer length "+info.size+" flags "+info.flags); 157 | EncodedBuffer buf; 158 | synchronized(emptyBuffers){ 159 | if(emptyBuffers.size()==0){ 160 | buf=new EncodedBuffer(); 161 | buf.data=new byte[2048000]; 162 | }else{ 163 | buf=emptyBuffers.remove(emptyBuffers.size()-1); 164 | } 165 | } 166 | buf.length=info.size; 167 | buf.flags=0; 168 | buffer.position(info.offset); 169 | buffer.get(buf.data, 0, info.size); 170 | buffersToSend.add(buf); 171 | codec.releaseOutputBuffer(index, false); 172 | }catch(IllegalStateException ignore){} 173 | } 174 | 175 | @Override 176 | public void onError(MediaCodec codec, MediaCodec.CodecException e){ 177 | Log.e(TAG, "codec error: "+e+" recoverable "+e.isRecoverable()); 178 | } 179 | 180 | @Override 181 | public void onOutputFormatChanged(MediaCodec codec, MediaFormat format){ 182 | ByteBuffer[] bufs={format.getByteBuffer("csd-0"), format.getByteBuffer("csd-1")}; 183 | for(ByteBuffer buffer:bufs){ 184 | EncodedBuffer buf; 185 | synchronized(emptyBuffers){ 186 | if(emptyBuffers.size()==0){ 187 | buf=new EncodedBuffer(); 188 | buf.data=new byte[2048000]; 189 | }else{ 190 | buf=emptyBuffers.remove(emptyBuffers.size()-1); 191 | } 192 | } 193 | buf.length=buffer.limit(); 194 | buf.flags=1; 195 | buffer.position(0); 196 | buffer.get(buf.data, 0, buffer.limit()); 197 | buffersToSend.add(buf); 198 | Log.d(TAG, "Sending codec specific data"); 199 | } 200 | } 201 | }; 202 | codec.setCallback(codecCallback); 203 | codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); 204 | surface=codec.createInputSurface(); 205 | virtualDisplay=projection.createVirtualDisplay("ScreenProjection", Math.round(size.x*scaling), Math.round(size.y*scaling), Math.round(getResources().getDisplayMetrics().xdpi*scaling), DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, surface, null, new Handler(encoderThread.getLooper())); 206 | ((DisplayManager)getSystemService(DISPLAY_SERVICE)).registerDisplayListener(this, new Handler(Looper.getMainLooper())); 207 | codec.start(); 208 | }catch(Exception x){ 209 | Log.w(TAG, x); 210 | } 211 | } 212 | 213 | private void startServer(){ 214 | new Thread(new Runnable(){ 215 | @Override 216 | public void run(){ 217 | try{ 218 | serverSocket=new ServerSocket(5050); 219 | serverSocket.setSoTimeout(10000); 220 | //while(true){ 221 | currentClientSocket=serverSocket.accept(); 222 | Log.i(TAG, "accepted a connection"); 223 | currentClientSocket.setTcpNoDelay(true); 224 | ByteArrayOutputStream obuf=new ByteArrayOutputStream(); 225 | DataOutputStream out=new DataOutputStream(obuf); 226 | currentClientStream=new DataOutputStream(currentClientSocket.getOutputStream()); 227 | InputStream in=currentClientSocket.getInputStream(); 228 | startProjection(); 229 | in.read(); 230 | try{ 231 | while(true){ 232 | EncodedBuffer buf=buffersToSend.take(); 233 | obuf.reset(); 234 | out.writeInt(buf.length); 235 | out.write(buf.flags); 236 | if(buf.length>0) 237 | out.write(buf.data, 0, buf.length); 238 | obuf.writeTo(currentClientStream); 239 | synchronized(emptyBuffers){ 240 | emptyBuffers.add(buf); 241 | } 242 | } 243 | }catch(Exception x){ 244 | Log.w(TAG, x); 245 | } 246 | currentClientSocket.close(); 247 | //} 248 | }catch(Exception x){ 249 | Log.e(TAG, "error in server", x); 250 | }finally{ 251 | try{ 252 | serverSocket.close(); 253 | }catch(IOException ignore){ 254 | 255 | } 256 | stopSelf(); 257 | } 258 | } 259 | }).start(); 260 | } 261 | 262 | @Override 263 | public void onDisplayAdded(int displayId){ 264 | 265 | } 266 | 267 | @Override 268 | public void onDisplayRemoved(int displayId){ 269 | 270 | } 271 | 272 | @Override 273 | public void onDisplayChanged(int displayId){ 274 | Log.i(TAG, "onDisplayChanged "+displayId); 275 | Display display=((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); 276 | if(display.getDisplayId()!=displayId) 277 | return; 278 | codecReleased=true; 279 | for(int i=0;i<10;i++){ 280 | try{ 281 | codec.reset(); 282 | break; 283 | }catch(Exception x){ 284 | Log.w(TAG, x); 285 | } 286 | } 287 | Point size=new Point(); 288 | display.getRealSize(size); 289 | float scaling=Math.min(1f, 720f/Math.min(size.x, size.y)); 290 | format.setInteger(MediaFormat.KEY_WIDTH, Math.round(size.x*scaling)); 291 | format.setInteger(MediaFormat.KEY_HEIGHT, Math.round(size.y*scaling)); 292 | codec.setCallback(codecCallback); 293 | codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); 294 | virtualDisplay.resize(Math.round(size.x*scaling), Math.round(size.y*scaling), Math.round(getResources().getDisplayMetrics().xdpi*scaling)); 295 | virtualDisplay.setSurface(surface=codec.createInputSurface()); 296 | codecReleased=false; 297 | codec.start(); 298 | } 299 | 300 | private static class EncodedBuffer{ 301 | byte[] data; 302 | int length; 303 | int flags; 304 | } 305 | } 306 | -------------------------------------------------------------------------------- /server/app/src/main/res/drawable-hdpi/ic_videocam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/drawable-hdpi/ic_videocam.png -------------------------------------------------------------------------------- /server/app/src/main/res/drawable-mdpi/ic_videocam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/drawable-mdpi/ic_videocam.png -------------------------------------------------------------------------------- /server/app/src/main/res/drawable-xhdpi/ic_videocam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/drawable-xhdpi/ic_videocam.png -------------------------------------------------------------------------------- /server/app/src/main/res/drawable-xxhdpi/ic_videocam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/drawable-xxhdpi/ic_videocam.png -------------------------------------------------------------------------------- /server/app/src/main/res/drawable-xxxhdpi/ic_videocam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/drawable-xxxhdpi/ic_videocam.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /server/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /server/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /server/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ScreenProjector 3 | 4 | -------------------------------------------------------------------------------- /server/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /server/app/src/test/java/me/grishka/screenprojector/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package me.grishka.screenprojector; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest{ 13 | @Test 14 | public void addition_isCorrect() throws Exception{ 15 | assertEquals(4, 2+2); 16 | } 17 | } -------------------------------------------------------------------------------- /server/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /server/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /server/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grishka/AndroidScreenProjector/19c513d50cb1bf66af34f60a66e694652c77ddb2/server/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /server/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Oct 08 10:24:19 MSK 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /server/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /server/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /server/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------