├── .github └── workflows │ └── deploy-frontend-sources-zip.yaml ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.MD ├── geek-tube-angular-frontend ├── .browserslistrc ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── assembly.xml ├── e2e │ ├── protractor.conf.js │ ├── src │ │ ├── app.e2e-spec.ts │ │ └── app.po.ts │ └── tsconfig.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── pom.xml ├── proxy.conf.json ├── src │ ├── app │ │ ├── app-routing.module.ts │ │ ├── app.component.html │ │ ├── app.component.scss │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── data.service.spec.ts │ │ ├── data.service.ts │ │ ├── footer │ │ │ ├── footer.component.html │ │ │ ├── footer.component.scss │ │ │ ├── footer.component.spec.ts │ │ │ └── footer.component.ts │ │ ├── header │ │ │ ├── header.component.html │ │ │ ├── header.component.scss │ │ │ ├── header.component.spec.ts │ │ │ └── header.component.ts │ │ ├── video-gallery │ │ │ ├── video-gallery.component.html │ │ │ ├── video-gallery.component.scss │ │ │ ├── video-gallery.component.spec.ts │ │ │ └── video-gallery.component.ts │ │ ├── video-metadata.ts │ │ ├── video-player │ │ │ ├── video-player.component.html │ │ │ ├── video-player.component.scss │ │ │ ├── video-player.component.spec.ts │ │ │ └── video-player.component.ts │ │ └── video-upload │ │ │ ├── video-upload.component.html │ │ │ ├── video-upload.component.scss │ │ │ ├── video-upload.component.spec.ts │ │ │ └── video-upload.component.ts │ ├── assets │ │ └── .gitkeep │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.scss │ └── test.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json ├── geek-tube ├── pom.xml └── src │ ├── main │ ├── java │ │ └── ru │ │ │ └── geektube │ │ │ ├── GeekTubeApplication.java │ │ │ ├── Utils.java │ │ │ ├── controller │ │ │ ├── NotFoundException.java │ │ │ ├── VideoController.java │ │ │ ├── VideoTimeController.java │ │ │ └── repr │ │ │ │ ├── NewVideoRepr.java │ │ │ │ └── VideoMetadataRepr.java │ │ │ ├── persist │ │ │ ├── VideoMetadata.java │ │ │ └── VideoMetadataRepository.java │ │ │ └── service │ │ │ ├── FrameGrabberService.java │ │ │ ├── StreamBytesInfo.java │ │ │ └── VideoService.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── ru │ └── geektube │ └── DemoApplicationTests.java ├── mvnw ├── mvnw.cmd └── pom.xml /.github/workflows/deploy-frontend-sources-zip.yaml: -------------------------------------------------------------------------------- 1 | name: Publish package to GitHub Packages 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | publish: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions/setup-java@v1 12 | with: 13 | java-version: 11 14 | - name: Publish package 15 | run: cd geek-tube-angular-frontend && mvn --batch-mode deploy 16 | env: 17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | geek-tube/target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | 35 | data/ -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # Very simple video hosting application 2 | 3 | You can find a very basic video hosting application in this repository. 4 | It was made to show basics of video streaming in web. 5 | 6 | To build and run the app you need to have on your PC: 7 | * [JDK 11 or later](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) 8 | * [NodeJS](https://nodejs.org/) 9 | * [Angular CLI](https://angular.io/guide/setup-local) 10 | * [MySQL](https://dev.mysql.com/downloads/) 11 | 12 | To install Angular CLI run the command 13 | ```bash 14 | npm install -g @angular/cli 15 | ``` 16 | 17 | Next we should install all NodeJS packages required to build application. Got the `geek-tube-angular-frontend directory` and run the command 18 | ```bash 19 | npm i 20 | ``` 21 | 22 | Next that we are ready to run frontend with testing server by command 23 | ```bash 24 | ng serve 25 | ``` 26 | 27 | Frontend going to be available here http://localhost:4200/ 28 | 29 | Notice the backend proxying configuration is [here](/geek-tube-angular-frontend/proxy.conf.json) in the sources 30 | 31 | After that go to the project root in another console and run backend with 32 | ```bash 33 | ./mvnw spring-boot:run 34 | ``` 35 | 36 | Some recommended links about video streaming 37 | * https://tutorial-academy.com/rest-jersey2-resume-video-streaming/ 38 | * https://saravanastar.medium.com/video-streaming-over-http-using-spring-boot-51e9830a3b8 39 | * https://technicalsand.com/streaming-data-spring-boot-restful-web-service/#2-2-streamingresponsebody-as-return-type 40 | * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range 41 | 42 | For the experiments with deployment to real servers I recommend to use 43 | 44 | [](https://www.reg.ru/?rlink=reflink-6434017) 45 | 46 | If you like that, you can support me here 47 | 48 | [](https://ko-fi.com/X8X8NI26) 49 | [](https://www.paypal.me/usharik) 50 | 51 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/README.md: -------------------------------------------------------------------------------- 1 | # GeekTubeAngularFrontend 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.0.2. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "geek-tube-angular-frontend": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss" 11 | }, 12 | "@schematics/angular:application": { 13 | "strict": true 14 | } 15 | }, 16 | "root": "", 17 | "sourceRoot": "src", 18 | "prefix": "app", 19 | "architect": { 20 | "build": { 21 | "builder": "@angular-devkit/build-angular:browser", 22 | "options": { 23 | "outputPath": "dist/geek-tube-angular-frontend", 24 | "index": "src/index.html", 25 | "main": "src/main.ts", 26 | "polyfills": "src/polyfills.ts", 27 | "tsConfig": "tsconfig.app.json", 28 | "aot": true, 29 | "assets": [ 30 | "src/favicon.ico", 31 | "src/assets" 32 | ], 33 | "styles": [ 34 | "src/styles.scss", 35 | "node_modules/bootstrap/scss/bootstrap.scss" 36 | ], 37 | "scripts": [] 38 | }, 39 | "configurations": { 40 | "production": { 41 | "fileReplacements": [ 42 | { 43 | "replace": "src/environments/environment.ts", 44 | "with": "src/environments/environment.prod.ts" 45 | } 46 | ], 47 | "optimization": true, 48 | "outputHashing": "all", 49 | "sourceMap": false, 50 | "namedChunks": false, 51 | "extractLicenses": true, 52 | "vendorChunk": false, 53 | "buildOptimizer": true, 54 | "budgets": [ 55 | { 56 | "type": "initial", 57 | "maximumWarning": "500kb", 58 | "maximumError": "1mb" 59 | }, 60 | { 61 | "type": "anyComponentStyle", 62 | "maximumWarning": "2kb", 63 | "maximumError": "4kb" 64 | } 65 | ] 66 | } 67 | } 68 | }, 69 | "serve": { 70 | "builder": "@angular-devkit/build-angular:dev-server", 71 | "options": { 72 | "browserTarget": "geek-tube-angular-frontend:build", 73 | "proxyConfig": "proxy.conf.json" 74 | }, 75 | "configurations": { 76 | "production": { 77 | "browserTarget": "geek-tube-angular-frontend:build:production" 78 | } 79 | } 80 | }, 81 | "extract-i18n": { 82 | "builder": "@angular-devkit/build-angular:extract-i18n", 83 | "options": { 84 | "browserTarget": "geek-tube-angular-frontend:build" 85 | } 86 | }, 87 | "test": { 88 | "builder": "@angular-devkit/build-angular:karma", 89 | "options": { 90 | "main": "src/test.ts", 91 | "polyfills": "src/polyfills.ts", 92 | "tsConfig": "tsconfig.spec.json", 93 | "karmaConfig": "karma.conf.js", 94 | "assets": [ 95 | "src/favicon.ico", 96 | "src/assets" 97 | ], 98 | "styles": [ 99 | "src/styles.scss" 100 | ], 101 | "scripts": [] 102 | } 103 | }, 104 | "lint": { 105 | "builder": "@angular-devkit/build-angular:tslint", 106 | "options": { 107 | "tsConfig": [ 108 | "tsconfig.app.json", 109 | "tsconfig.spec.json", 110 | "e2e/tsconfig.json" 111 | ], 112 | "exclude": [ 113 | "**/node_modules/**" 114 | ] 115 | } 116 | }, 117 | "e2e": { 118 | "builder": "@angular-devkit/build-angular:protractor", 119 | "options": { 120 | "protractorConfig": "e2e/protractor.conf.js", 121 | "devServerTarget": "geek-tube-angular-frontend:serve" 122 | }, 123 | "configurations": { 124 | "production": { 125 | "devServerTarget": "geek-tube-angular-frontend:serve:production" 126 | } 127 | } 128 | } 129 | } 130 | } 131 | }, 132 | "defaultProject": "geek-tube-angular-frontend" 133 | } 134 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/assembly.xml: -------------------------------------------------------------------------------- 1 | 6 | sources 7 | 8 | zip 9 | 10 | 11 | 12 | 13 | 14 | 15 | /dist/** 16 | /target/** 17 | /node_modules/** 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | browserName: 'chrome' 17 | }, 18 | directConnect: true, 19 | SELENIUM_PROMISE_MANAGER: false, 20 | baseUrl: 'http://localhost:4200/', 21 | framework: 'jasmine', 22 | jasmineNodeOpts: { 23 | showColors: true, 24 | defaultTimeoutInterval: 30000, 25 | print: function() {} 26 | }, 27 | onPrepare() { 28 | require('ts-node').register({ 29 | project: require('path').join(__dirname, './tsconfig.json') 30 | }); 31 | jasmine.getEnv().addReporter(new SpecReporter({ 32 | spec: { 33 | displayStacktrace: StacktraceOption.PRETTY 34 | } 35 | })); 36 | } 37 | }; -------------------------------------------------------------------------------- /geek-tube-angular-frontend/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', async () => { 12 | await page.navigateTo(); 13 | expect(await page.getTitleText()).toEqual('geek-tube-angular-frontend app is running!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | async navigateTo(): Promise { 5 | return browser.get(browser.baseUrl); 6 | } 7 | 8 | async getTitleText(): Promise { 9 | return element(by.css('app-root .content span')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "../tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "../out-tsc/e2e", 6 | "module": "commonjs", 7 | "target": "es2018", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | jasmineHtmlReporter: { 19 | suppressAll: true // removes the duplicated traces 20 | }, 21 | coverageReporter: { 22 | dir: require('path').join(__dirname, './coverage/geek-tube-angular-frontend'), 23 | subdir: '.', 24 | reporters: [ 25 | { type: 'html' }, 26 | { type: 'text-summary' } 27 | ] 28 | }, 29 | reporters: ['progress', 'kjhtml'], 30 | port: 9876, 31 | colors: true, 32 | logLevel: config.LOG_INFO, 33 | autoWatch: true, 34 | browsers: ['Chrome'], 35 | singleRun: false, 36 | restartOnFileChange: true 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "geek-tube-angular-frontend", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~11.0.1", 15 | "@angular/common": "~11.0.1", 16 | "@angular/compiler": "~11.0.1", 17 | "@angular/core": "~11.0.1", 18 | "@angular/forms": "~11.0.1", 19 | "@angular/platform-browser": "~11.0.1", 20 | "@angular/platform-browser-dynamic": "~11.0.1", 21 | "@angular/router": "~11.0.1", 22 | "bootstrap": "^5.0.0-beta2", 23 | "rxjs": "~6.6.0", 24 | "tslib": "^2.0.0", 25 | "zone.js": "~0.10.2" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~0.1100.2", 29 | "@angular/cli": "~11.0.2", 30 | "@angular/compiler-cli": "~11.0.1", 31 | "@types/jasmine": "~3.6.0", 32 | "@types/node": "^12.11.1", 33 | "codelyzer": "^6.0.0", 34 | "jasmine-core": "~3.6.0", 35 | "jasmine-spec-reporter": "~5.0.0", 36 | "karma": "~5.1.0", 37 | "karma-chrome-launcher": "~3.1.0", 38 | "karma-coverage": "~2.0.3", 39 | "karma-jasmine": "~4.0.0", 40 | "karma-jasmine-html-reporter": "^1.5.0", 41 | "protractor": "~7.0.0", 42 | "ts-node": "~8.3.0", 43 | "tslint": "~6.1.0", 44 | "typescript": "~4.0.2" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | ru.geekbrains 8 | geek-tube-angular-frontend 9 | 1.0-SNAPSHOT 10 | pom 11 | 12 | 13 | 14 | 15 | maven-assembly-plugin 16 | 2.5.5 17 | 18 | 19 | assembly.xml 20 | 21 | 22 | 23 | 24 | assembly-dist 25 | package 26 | 27 | single 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | github 38 | GitHub Packages 39 | https://maven.pkg.github.com/usharik/geek-video-stream 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/proxy.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "/api/*": { 3 | "target": "http://localhost:8080", 4 | "secure": false, 5 | "logLevel": "debug" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import {VideoGalleryComponent} from "./video-gallery/video-gallery.component"; 4 | import {VideoPlayerComponent} from "./video-player/video-player.component"; 5 | import {VideoUploadComponent} from "./video-upload/video-upload.component"; 6 | 7 | const routes: Routes = [ 8 | {path: "", pathMatch: "full", redirectTo: "gallery"}, 9 | {path: "gallery", component: VideoGalleryComponent}, 10 | {path: "player/:id", component: VideoPlayerComponent}, 11 | {path: "upload", component: VideoUploadComponent} 12 | ]; 13 | 14 | @NgModule({ 15 | imports: [RouterModule.forRoot(routes)], 16 | exports: [RouterModule] 17 | }) 18 | export class AppRoutingModule { } 19 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/app/app.component.scss -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'geek-tube-angular-frontend'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('geek-tube-angular-frontend'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement; 33 | expect(compiled.querySelector('.content span').textContent).toContain('geek-tube-angular-frontend app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'geek-tube-angular-frontend'; 10 | } 11 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { HttpClientModule } from '@angular/common/http'; 3 | import { NgModule } from '@angular/core'; 4 | 5 | import { AppRoutingModule } from './app-routing.module'; 6 | import { AppComponent } from './app.component'; 7 | import { HeaderComponent } from './header/header.component'; 8 | import { FooterComponent } from './footer/footer.component'; 9 | import { VideoGalleryComponent } from './video-gallery/video-gallery.component'; 10 | import { VideoPlayerComponent } from './video-player/video-player.component'; 11 | import { VideoUploadComponent } from './video-upload/video-upload.component'; 12 | 13 | @NgModule({ 14 | declarations: [ 15 | AppComponent, 16 | HeaderComponent, 17 | FooterComponent, 18 | VideoGalleryComponent, 19 | VideoPlayerComponent, 20 | VideoUploadComponent 21 | ], 22 | imports: [ 23 | BrowserModule, 24 | AppRoutingModule, 25 | HttpClientModule 26 | ], 27 | providers: [], 28 | bootstrap: [AppComponent] 29 | }) 30 | export class AppModule { } 31 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/data.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { DataService } from './data.service'; 4 | 5 | describe('DataService', () => { 6 | let service: DataService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(DataService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/data.service.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from '@angular/core'; 2 | import {HttpClient} from "@angular/common/http"; 3 | import {VideoMetadata} from "./video-metadata"; 4 | 5 | @Injectable({ 6 | providedIn: 'root' 7 | }) 8 | export class DataService { 9 | 10 | constructor(private http: HttpClient) { 11 | } 12 | 13 | // public findAllPreviews() { 14 | // return new Promise((resolve, reject) => 15 | // { 16 | // resolve([ 17 | // new VideoMetadata(1, 'First video', 'video/mp4', 'https://loremflickr.com/213/106', ''), 18 | // new VideoMetadata(2, 'Second video', 'video/mp4', 'https://loremflickr.com/213/106', ''), 19 | // new VideoMetadata(3, 'Third video', 'video/mp4', 'https://loremflickr.com/213/106', ''), 20 | // new VideoMetadata(4, 'Fourth video', 'video/mp4', 'https://loremflickr.com/213/106', ''), 21 | // new VideoMetadata(5, 'Fifth video', 'video/mp4', 'https://loremflickr.com/213/106', ''), 22 | // ]) 23 | // }) 24 | // } 25 | 26 | public findById(id: number) { 27 | return this.http.get('/api/v1/video/' + id).toPromise() 28 | } 29 | 30 | public findAllPreviews() { 31 | return this.http.get('/api/v1/video/all').toPromise() 32 | } 33 | 34 | public uploadNewVideo(formData: FormData) { 35 | return this.http.post('/api/v1/video/upload', formData).toPromise() 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/footer/footer.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/footer/footer.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/app/footer/footer.component.scss -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/footer/footer.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { FooterComponent } from './footer.component'; 4 | 5 | describe('FooterComponent', () => { 6 | let component: FooterComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ FooterComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(FooterComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/footer/footer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-footer', 5 | templateUrl: './footer.component.html', 6 | styleUrls: ['./footer.component.scss'] 7 | }) 8 | export class FooterComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/header/header.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Navbar 4 | 6 | 7 | 8 | 9 | 10 | 11 | Home 12 | 13 | 14 | 15 | 16 | Search 17 | 18 | Upload 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/header/header.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/app/header/header.component.scss -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/header/header.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HeaderComponent } from './header.component'; 4 | 5 | describe('HeaderComponent', () => { 6 | let component: HeaderComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ HeaderComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(HeaderComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/header/header.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-header', 5 | templateUrl: './header.component.html', 6 | styleUrls: ['./header.component.scss'] 7 | }) 8 | export class HeaderComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-gallery/video-gallery.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Can't load the video gallery 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {{preview.description}} 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-gallery/video-gallery.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/app/video-gallery/video-gallery.component.scss -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-gallery/video-gallery.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VideoGalleryComponent } from './video-gallery.component'; 4 | 5 | describe('VideoGalleryComponent', () => { 6 | let component: VideoGalleryComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VideoGalleryComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VideoGalleryComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-gallery/video-gallery.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { DataService } from "../data.service"; 3 | import {VideoMetadata} from "../video-metadata"; 4 | 5 | @Component({ 6 | selector: 'app-video-gallery', 7 | templateUrl: './video-gallery.component.html', 8 | styleUrls: ['./video-gallery.component.scss'] 9 | }) 10 | export class VideoGalleryComponent implements OnInit { 11 | 12 | previews: VideoMetadata[] = []; 13 | isError: boolean = false; 14 | 15 | constructor(public dataService: DataService) {} 16 | 17 | ngOnInit(): void { 18 | this.dataService.findAllPreviews() 19 | .then(res => { 20 | this.isError = false; 21 | this.previews = res; 22 | }) 23 | .catch(err => { 24 | this.isError = true; 25 | }); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-metadata.ts: -------------------------------------------------------------------------------- 1 | export class VideoMetadata { 2 | 3 | constructor(public id: number, 4 | public description: string, 5 | public contentType: string, 6 | public previewUrl: string, 7 | public streamUrl: string) { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-player/video-player.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Your browser does not support the video tag. 5 | 6 | 7 | {{videoMetadata.description}} 8 | 9 | 10 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-player/video-player.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/app/video-player/video-player.component.scss -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-player/video-player.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VideoPlayerComponent } from './video-player.component'; 4 | 5 | describe('VideoPlayerComponent', () => { 6 | let component: VideoPlayerComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VideoPlayerComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VideoPlayerComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-player/video-player.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; 2 | import {DataService} from "../data.service"; 3 | import {ActivatedRoute} from "@angular/router"; 4 | import {VideoMetadata} from "../video-metadata"; 5 | 6 | @Component({ 7 | selector: 'app-video-player', 8 | templateUrl: './video-player.component.html', 9 | styleUrls: ['./video-player.component.scss'] 10 | }) 11 | export class VideoPlayerComponent implements OnInit { 12 | 13 | public videoMetadata: VideoMetadata = new VideoMetadata(0, '', '', '', ''); 14 | 15 | @ViewChild("videoPlayer") videoPlayerRef!: ElementRef; 16 | 17 | constructor(public dataService: DataService, private route: ActivatedRoute) { } 18 | 19 | ngOnInit(): void { 20 | this.route.params.subscribe(param => { 21 | console.log(param) 22 | this.dataService.findById(param.id) 23 | .then((vmd) => { 24 | this.videoMetadata = vmd; 25 | 26 | let videoPlayer = this.videoPlayerRef.nativeElement; 27 | videoPlayer.load(); 28 | 29 | let currentTime = sessionStorage.getItem("currentTime"); 30 | if (currentTime) { 31 | videoPlayer.currentTime = currentTime; 32 | } 33 | 34 | videoPlayer.ontimeupdate = () => { 35 | sessionStorage.setItem("currentTime", videoPlayer.currentTime); 36 | } 37 | }) 38 | }) 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-upload/video-upload.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Error uploading file to server 5 | 6 | 7 | 8 | Video description 9 | 11 | 12 | 13 | 14 | Example file input 15 | 16 | 17 | Submit 18 | 19 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-upload/video-upload.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/app/video-upload/video-upload.component.scss -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-upload/video-upload.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { VideoUploadComponent } from './video-upload.component'; 4 | 5 | describe('VideoUploadComponent', () => { 6 | let component: VideoUploadComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ VideoUploadComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(VideoUploadComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/app/video-upload/video-upload.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { DataService } from "../data.service"; 3 | import {Router} from "@angular/router"; 4 | 5 | @Component({ 6 | selector: 'app-video-upload', 7 | templateUrl: './video-upload.component.html', 8 | styleUrls: ['./video-upload.component.scss'] 9 | }) 10 | export class VideoUploadComponent implements OnInit { 11 | 12 | isError: boolean = false; 13 | 14 | constructor(private dataService: DataService, private router: Router) { } 15 | 16 | ngOnInit(): void { 17 | } 18 | 19 | submit() { 20 | console.log("Submit button") 21 | let form:HTMLFormElement | null = document.forms.namedItem('uploadForm'); 22 | if (form) { 23 | let fd = new FormData(form); 24 | this.dataService.uploadNewVideo(fd) 25 | .then(() => { 26 | this.isError = false; 27 | this.router.navigate(['player/1']); 28 | }) 29 | .catch((err) => { 30 | this.isError = true; 31 | console.error(err); 32 | }); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/assets/.gitkeep -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usharik/geek-video-stream/e46c996f6a85fd85e1a4c6e6e628abf55ac94532/geek-tube-angular-frontend/src/favicon.ico -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | GeekTubeAngularFrontend 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "sourceMap": true, 12 | "declaration": false, 13 | "downlevelIteration": true, 14 | "experimentalDecorators": true, 15 | "moduleResolution": "node", 16 | "importHelpers": true, 17 | "target": "es2015", 18 | "module": "es2020", 19 | "lib": [ 20 | "es2018", 21 | "dom" 22 | ] 23 | }, 24 | "angularCompilerOptions": { 25 | "strictInjectionParameters": true, 26 | "strictInputAccessModifiers": true, 27 | "strictTemplates": true 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /geek-tube-angular-frontend/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "align": { 8 | "options": [ 9 | "parameters", 10 | "statements" 11 | ] 12 | }, 13 | "array-type": false, 14 | "arrow-return-shorthand": true, 15 | "curly": true, 16 | "deprecation": { 17 | "severity": "warning" 18 | }, 19 | "eofline": true, 20 | "import-blacklist": [ 21 | true, 22 | "rxjs/Rx" 23 | ], 24 | "import-spacing": true, 25 | "indent": { 26 | "options": [ 27 | "spaces" 28 | ] 29 | }, 30 | "max-classes-per-file": false, 31 | "max-line-length": [ 32 | true, 33 | 140 34 | ], 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-console": [ 47 | true, 48 | "debug", 49 | "info", 50 | "time", 51 | "timeEnd", 52 | "trace" 53 | ], 54 | "no-empty": false, 55 | "no-inferrable-types": [ 56 | true, 57 | "ignore-params" 58 | ], 59 | "no-non-null-assertion": true, 60 | "no-redundant-jsdoc": true, 61 | "no-switch-case-fall-through": true, 62 | "no-var-requires": false, 63 | "object-literal-key-quotes": [ 64 | true, 65 | "as-needed" 66 | ], 67 | "quotemark": [ 68 | true, 69 | "single" 70 | ], 71 | "semicolon": { 72 | "options": [ 73 | "always" 74 | ] 75 | }, 76 | "space-before-function-paren": { 77 | "options": { 78 | "anonymous": "never", 79 | "asyncArrow": "always", 80 | "constructor": "never", 81 | "method": "never", 82 | "named": "never" 83 | } 84 | }, 85 | "typedef": [ 86 | true, 87 | "call-signature" 88 | ], 89 | "typedef-whitespace": { 90 | "options": [ 91 | { 92 | "call-signature": "nospace", 93 | "index-signature": "nospace", 94 | "parameter": "nospace", 95 | "property-declaration": "nospace", 96 | "variable-declaration": "nospace" 97 | }, 98 | { 99 | "call-signature": "onespace", 100 | "index-signature": "onespace", 101 | "parameter": "onespace", 102 | "property-declaration": "onespace", 103 | "variable-declaration": "onespace" 104 | } 105 | ] 106 | }, 107 | "variable-name": { 108 | "options": [ 109 | "ban-keywords", 110 | "check-format", 111 | "allow-pascal-case" 112 | ] 113 | }, 114 | "whitespace": { 115 | "options": [ 116 | "check-branch", 117 | "check-decl", 118 | "check-operator", 119 | "check-separator", 120 | "check-type", 121 | "check-typecast" 122 | ] 123 | }, 124 | "component-class-suffix": true, 125 | "contextual-lifecycle": true, 126 | "directive-class-suffix": true, 127 | "no-conflicting-lifecycle": true, 128 | "no-host-metadata-property": true, 129 | "no-input-rename": true, 130 | "no-inputs-metadata-property": true, 131 | "no-output-native": true, 132 | "no-output-on-prefix": true, 133 | "no-output-rename": true, 134 | "no-outputs-metadata-property": true, 135 | "template-banana-in-box": true, 136 | "template-no-negated-async": true, 137 | "use-lifecycle-interface": true, 138 | "use-pipe-transform-interface": true, 139 | "directive-selector": [ 140 | true, 141 | "attribute", 142 | "app", 143 | "camelCase" 144 | ], 145 | "component-selector": [ 146 | true, 147 | "element", 148 | "app", 149 | "kebab-case" 150 | ] 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /geek-tube/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.4.3 9 | 10 | 11 | ru.geektube 12 | geek-tube 13 | 0.0.1-SNAPSHOT 14 | geek-tube 15 | Backend for simple video hosting 16 | 17 | 11 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-actuator 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-data-jpa 31 | 32 | 33 | 34 | org.bytedeco 35 | javacv-platform 36 | 1.5.5 37 | 38 | 39 | mysql 40 | mysql-connector-java 41 | runtime 42 | 43 | 44 | 45 | org.springframework.boot 46 | spring-boot-starter-test 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-maven-plugin 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/GeekTubeApplication.java: -------------------------------------------------------------------------------- 1 | package ru.geektube; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class GeekTubeApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(GeekTubeApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/Utils.java: -------------------------------------------------------------------------------- 1 | package ru.geektube; 2 | 3 | public final class Utils { 4 | 5 | public static String removeFileExt(String fileName) { 6 | int extIndex = fileName.lastIndexOf("."); 7 | return fileName.substring(0, extIndex); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/controller/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.controller; 2 | 3 | public class NotFoundException extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/controller/VideoController.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpRange; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.MediaType; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.bind.annotation.*; 11 | import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; 12 | import ru.geektube.service.StreamBytesInfo; 13 | import ru.geektube.controller.repr.VideoMetadataRepr; 14 | import ru.geektube.service.VideoService; 15 | import ru.geektube.controller.repr.NewVideoRepr; 16 | 17 | import java.io.InputStream; 18 | import java.text.DecimalFormat; 19 | import java.util.List; 20 | 21 | @RequestMapping("/api/v1/video") 22 | @RestController 23 | public class VideoController { 24 | 25 | private final Logger logger = LoggerFactory.getLogger(VideoController.class); 26 | 27 | private final VideoService videoService; 28 | 29 | @Autowired 30 | public VideoController(VideoService videoService) { 31 | this.videoService = videoService; 32 | } 33 | 34 | @GetMapping("/all") 35 | public List findAllVideoMetadata() { 36 | return videoService.findAllVideoMetadata(); 37 | } 38 | 39 | @GetMapping("/{id}") 40 | public VideoMetadataRepr findVideoMetadataById(@PathVariable("id") Long id) { 41 | return videoService.findById(id).orElseThrow(NotFoundException::new); 42 | } 43 | 44 | @GetMapping(value = "/preview/{id}", produces = MediaType.IMAGE_JPEG_VALUE) 45 | public ResponseEntity getPreviewPicture(@PathVariable("id") Long id) { 46 | InputStream inputStream = videoService.getPreviewInputStream(id) 47 | .orElseThrow(NotFoundException::new); 48 | return ResponseEntity.ok(inputStream::transferTo); 49 | } 50 | 51 | @GetMapping("/stream/{id}") 52 | public ResponseEntity streamVideo(@RequestHeader(value = "Range", required = false) String httpRangeHeader, 53 | @PathVariable("id") Long id) { 54 | logger.info("Requested range [{}] for file `{}`", httpRangeHeader, id); 55 | 56 | List httpRangeList = HttpRange.parseRanges(httpRangeHeader); 57 | StreamBytesInfo streamBytesInfo = videoService.getStreamBytes(id, httpRangeList.size() > 0 ? httpRangeList.get(0) : null) 58 | .orElseThrow(NotFoundException::new); 59 | 60 | long byteLength = streamBytesInfo.getRangeEnd() - streamBytesInfo.getRangeStart() + 1; 61 | ResponseEntity.BodyBuilder builder = ResponseEntity.status(httpRangeList.size() > 0 ? HttpStatus.PARTIAL_CONTENT : HttpStatus.OK) 62 | .header("Content-Type", streamBytesInfo.getContentType()) 63 | .header("Accept-Ranges", "bytes") 64 | .header("Content-Length", Long.toString(byteLength)); 65 | 66 | if (httpRangeList.size() > 0) { 67 | builder.header("Content-Range", 68 | "bytes " + streamBytesInfo.getRangeStart() + 69 | "-" + streamBytesInfo.getRangeEnd() + 70 | "/" + streamBytesInfo.getFileSize()); 71 | } 72 | logger.info("Providing bytes from {} to {}. We are at {}% of overall video.", 73 | streamBytesInfo.getRangeStart(), streamBytesInfo.getRangeEnd(), 74 | new DecimalFormat("###.##").format(100.0 * streamBytesInfo.getRangeStart() / streamBytesInfo.getFileSize())); 75 | return builder.body(streamBytesInfo.getResponseBody()); 76 | } 77 | 78 | @PostMapping(path = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) 79 | public ResponseEntity uploadVideo(NewVideoRepr newVideoRepr) { 80 | logger.info(newVideoRepr.getDescription()); 81 | 82 | try { 83 | videoService.saveNewVideo(newVideoRepr); 84 | } catch (Exception ex) { 85 | return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); 86 | } 87 | return ResponseEntity.status(HttpStatus.OK).build(); 88 | } 89 | 90 | @ExceptionHandler 91 | public ResponseEntity notFoundExceptionHandler(NotFoundException ex) { 92 | return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/controller/VideoTimeController.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.controller; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | import javax.servlet.http.HttpSession; 11 | 12 | @RestController 13 | public class VideoTimeController { 14 | 15 | private final Logger logger = LoggerFactory.getLogger(VideoTimeController.class); 16 | 17 | @PostMapping("/savetime") 18 | public void saveCurrentTime(@RequestParam("currentTime") String currentTime, HttpSession session) { 19 | session.setAttribute("currentTime", currentTime); 20 | } 21 | 22 | @GetMapping("/currenttime") 23 | public String getCurrentTime(HttpSession session) { 24 | return (String) session.getAttribute("currentTime"); 25 | } 26 | 27 | @PostMapping("/savestate") 28 | public void sendEvent(@RequestParam("state") String state, HttpSession session) { 29 | session.setAttribute("state", state); 30 | } 31 | 32 | @GetMapping("/currentstate") 33 | public String getCurrentState(HttpSession session) { 34 | return (String) session.getAttribute("state"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/controller/repr/NewVideoRepr.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.controller.repr; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | public class NewVideoRepr { 6 | 7 | private String description; 8 | 9 | private MultipartFile file; 10 | 11 | public NewVideoRepr() { 12 | } 13 | 14 | public String getDescription() { 15 | return description; 16 | } 17 | 18 | public void setDescription(String description) { 19 | this.description = description; 20 | } 21 | 22 | public MultipartFile getFile() { 23 | return file; 24 | } 25 | 26 | public void setFile(MultipartFile file) { 27 | this.file = file; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/controller/repr/VideoMetadataRepr.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.controller.repr; 2 | 3 | public class VideoMetadataRepr { 4 | 5 | private Long id; 6 | 7 | private String description; 8 | 9 | private String contentType; 10 | 11 | private String previewUrl; 12 | 13 | private String streamUrl; 14 | 15 | public VideoMetadataRepr() { 16 | } 17 | 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Long id) { 23 | this.id = id; 24 | } 25 | 26 | public String getDescription() { 27 | return description; 28 | } 29 | 30 | public void setDescription(String description) { 31 | this.description = description; 32 | } 33 | 34 | public String getPreviewUrl() { 35 | return previewUrl; 36 | } 37 | 38 | public void setPreviewUrl(String previewUrl) { 39 | this.previewUrl = previewUrl; 40 | } 41 | 42 | public String getContentType() { 43 | return contentType; 44 | } 45 | 46 | public void setContentType(String contentType) { 47 | this.contentType = contentType; 48 | } 49 | 50 | public String getStreamUrl() { 51 | return streamUrl; 52 | } 53 | 54 | public void setStreamUrl(String streamUrl) { 55 | this.streamUrl = streamUrl; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/persist/VideoMetadata.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.persist; 2 | 3 | import javax.persistence.*; 4 | 5 | @Entity 6 | @Table(name = "video_metadata") 7 | public class VideoMetadata { 8 | 9 | @Id 10 | @GeneratedValue(strategy = GenerationType.IDENTITY) 11 | private Long id; 12 | 13 | @Column 14 | private String fileName; 15 | 16 | @Column 17 | private String contentType; 18 | 19 | @Column 20 | private String description; 21 | 22 | @Column 23 | private Long fileSize; 24 | 25 | @Column 26 | private Long videoLength; 27 | 28 | public VideoMetadata() { 29 | } 30 | 31 | public Long getId() { 32 | return id; 33 | } 34 | 35 | public void setId(Long id) { 36 | this.id = id; 37 | } 38 | 39 | public String getFileName() { 40 | return fileName; 41 | } 42 | 43 | public void setFileName(String fileName) { 44 | this.fileName = fileName; 45 | } 46 | 47 | public String getContentType() { 48 | return contentType; 49 | } 50 | 51 | public void setContentType(String contentType) { 52 | this.contentType = contentType; 53 | } 54 | 55 | public Long getFileSize() { 56 | return fileSize; 57 | } 58 | 59 | public void setFileSize(Long fileSize) { 60 | this.fileSize = fileSize; 61 | } 62 | 63 | public Long getVideoLength() { 64 | return videoLength; 65 | } 66 | 67 | public void setVideoLength(Long videoLength) { 68 | this.videoLength = videoLength; 69 | } 70 | 71 | public String getDescription() { 72 | return description; 73 | } 74 | 75 | public void setDescription(String description) { 76 | this.description = description; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/persist/VideoMetadataRepository.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.persist; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface VideoMetadataRepository extends JpaRepository { 8 | } 9 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/service/FrameGrabberService.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.service; 2 | 3 | import org.bytedeco.javacv.FFmpegFrameGrabber; 4 | import org.bytedeco.javacv.Java2DFrameConverter; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.imageio.ImageIO; 8 | import java.awt.image.BufferedImage; 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.nio.file.Path; 12 | 13 | import static ru.geektube.Utils.removeFileExt; 14 | 15 | @Service 16 | public class FrameGrabberService { 17 | 18 | public long generatePreviewPictures(Path filePath) throws IOException { 19 | try (FFmpegFrameGrabber g = new FFmpegFrameGrabber(filePath.toString())) { 20 | Java2DFrameConverter converter = new Java2DFrameConverter(); 21 | 22 | g.start(); 23 | BufferedImage image; 24 | for (int i = 0; i < 50; i++) { 25 | image = converter.convert(g.grabKeyFrame()); 26 | if (image != null) { 27 | File file = Path.of( removeFileExt(filePath.toString()) + ".jpeg").toFile(); 28 | ImageIO.write(image, "jpeg", file); 29 | break; 30 | } 31 | } 32 | long lengthInTime = g.getLengthInTime(); 33 | g.stop(); 34 | return lengthInTime; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/service/StreamBytesInfo.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.service; 2 | 3 | import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; 4 | 5 | public class StreamBytesInfo { 6 | 7 | private final StreamingResponseBody responseBody; 8 | 9 | private final long fileSize; 10 | 11 | private final long rangeStart; 12 | 13 | private final long rangeEnd; 14 | 15 | private final String contentType; 16 | 17 | public StreamBytesInfo(StreamingResponseBody responseBody, 18 | long fileSize, long rangeStart, long rangeStop, 19 | String contentType) { 20 | this.responseBody = responseBody; 21 | this.fileSize = fileSize; 22 | this.rangeStart = rangeStart; 23 | this.rangeEnd = rangeStop; 24 | this.contentType = contentType; 25 | } 26 | 27 | public StreamingResponseBody getResponseBody() { 28 | return responseBody; 29 | } 30 | 31 | public long getFileSize() { 32 | return fileSize; 33 | } 34 | 35 | public long getRangeStart() { 36 | return rangeStart; 37 | } 38 | 39 | public long getRangeEnd() { 40 | return rangeEnd; 41 | } 42 | 43 | public String getContentType() { 44 | return contentType; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /geek-tube/src/main/java/ru/geektube/service/VideoService.java: -------------------------------------------------------------------------------- 1 | package ru.geektube.service; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.http.HttpRange; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | import ru.geektube.persist.VideoMetadata; 11 | import ru.geektube.persist.VideoMetadataRepository; 12 | 13 | import ru.geektube.controller.repr.VideoMetadataRepr; 14 | import ru.geektube.controller.repr.NewVideoRepr; 15 | 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | import java.io.OutputStream; 19 | import java.nio.file.Files; 20 | import java.nio.file.Path; 21 | import java.util.List; 22 | import java.util.Optional; 23 | import java.util.stream.Collectors; 24 | 25 | import static java.nio.file.StandardOpenOption.CREATE; 26 | import static java.nio.file.StandardOpenOption.WRITE; 27 | import static ru.geektube.Utils.removeFileExt; 28 | 29 | @Service 30 | public class VideoService { 31 | 32 | private final Logger logger = LoggerFactory.getLogger(VideoService.class); 33 | 34 | @Value("${data.folder}") 35 | private String dataFolder; 36 | 37 | private final VideoMetadataRepository repository; 38 | 39 | private final FrameGrabberService frameGrabberService; 40 | 41 | @Autowired 42 | public VideoService(VideoMetadataRepository repository, FrameGrabberService frameGrabberService) { 43 | this.repository = repository; 44 | this.frameGrabberService = frameGrabberService; 45 | } 46 | 47 | public List findAllVideoMetadata() { 48 | return repository.findAll().stream() 49 | .map(VideoService::convert) 50 | .collect(Collectors.toList()); 51 | } 52 | 53 | public Optional findById(Long id) { 54 | return repository.findById(id) 55 | .map(VideoService::convert); 56 | } 57 | 58 | private static VideoMetadataRepr convert(VideoMetadata vmd) { 59 | VideoMetadataRepr repr = new VideoMetadataRepr(); 60 | repr.setId(vmd.getId()); 61 | repr.setPreviewUrl("/api/v1/video/preview/" + vmd.getId()); 62 | repr.setStreamUrl("/api/v1/video/stream/" + vmd.getId()); 63 | repr.setDescription(vmd.getDescription()); 64 | repr.setContentType(vmd.getContentType()); 65 | return repr; 66 | } 67 | 68 | public Optional getPreviewInputStream(Long id) { 69 | return repository.findById(id) 70 | .flatMap(vmd -> { 71 | Path previewPicturePath = Path.of(dataFolder, 72 | vmd.getId().toString(), 73 | removeFileExt(vmd.getFileName()) + ".jpeg"); 74 | if (!Files.exists(previewPicturePath)) { 75 | return Optional.empty(); 76 | } 77 | try { 78 | return Optional.of(Files.newInputStream(previewPicturePath)); 79 | } catch (IOException ex) { 80 | logger.error("", ex); 81 | return Optional.empty(); 82 | } 83 | }); 84 | } 85 | 86 | @Transactional 87 | public void saveNewVideo(NewVideoRepr newVideoRepr) { 88 | VideoMetadata metadata = new VideoMetadata(); 89 | metadata.setFileName(newVideoRepr.getFile().getOriginalFilename()); 90 | metadata.setContentType(newVideoRepr.getFile().getContentType()); 91 | metadata.setFileSize(newVideoRepr.getFile().getSize()); 92 | metadata.setDescription(newVideoRepr.getDescription()); 93 | repository.save(metadata); 94 | 95 | Path directory = Path.of(dataFolder, metadata.getId().toString()); 96 | try { 97 | Files.createDirectory(directory); 98 | Path file = Path.of(directory.toString(), newVideoRepr.getFile().getOriginalFilename()); 99 | try (OutputStream output = Files.newOutputStream(file, CREATE, WRITE)) { 100 | newVideoRepr.getFile().getInputStream().transferTo(output); 101 | } 102 | long videoLength = frameGrabberService.generatePreviewPictures(file); 103 | metadata.setVideoLength(videoLength); 104 | repository.save(metadata); 105 | } catch (IOException ex) { 106 | logger.error("", ex); 107 | throw new IllegalStateException(ex); 108 | } 109 | } 110 | 111 | public Optional getStreamBytes(Long id, HttpRange range) { 112 | Optional byId = repository.findById(id); 113 | if (byId.isEmpty()) { 114 | return Optional.empty(); 115 | } 116 | Path filePath = Path.of(dataFolder, Long.toString(id), byId.get().getFileName()); 117 | if (!Files.exists(filePath)) { 118 | logger.error("File {} not found", filePath); 119 | return Optional.empty(); 120 | } 121 | try { 122 | long fileSize = Files.size(filePath); 123 | long chunkSize = fileSize / 100; 124 | if (range == null) { 125 | return Optional.of(new StreamBytesInfo( 126 | out -> Files.newInputStream(filePath).transferTo(out), 127 | fileSize, 0, fileSize, byId.get().getContentType())); 128 | } 129 | 130 | long rangeStart = range.getRangeStart(0); 131 | long rangeEnd = rangeStart + chunkSize; // range.getRangeEnd(fileSize); 132 | if (rangeEnd >= fileSize) { 133 | rangeEnd = fileSize - 1; 134 | } 135 | long finalRangeEnd = rangeEnd; 136 | return Optional.of(new StreamBytesInfo( 137 | out -> { 138 | try (InputStream inputStream = Files.newInputStream(filePath)) { 139 | inputStream.skip(rangeStart); 140 | byte[] bytes = inputStream.readNBytes((int) ((finalRangeEnd - rangeStart) + 1)); 141 | out.write(bytes); 142 | } 143 | }, 144 | fileSize, rangeStart, rangeEnd, byId.get().getContentType())); 145 | } catch (IOException ex) { 146 | logger.error("", ex); 147 | return Optional.empty(); 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /geek-tube/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | data.folder=/Users/macbook/IdeaProjects/geek-video-stream/data 2 | spring.servlet.multipart.max-file-size=200MB 3 | spring.servlet.multipart.max-request-size=250MB 4 | 5 | spring.datasource.url=jdbc:mysql://localhost:3306/hibernate_lesson_3_113?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 6 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 7 | spring.datasource.username=root 8 | spring.datasource.password=root 9 | 10 | spring.jpa.show-sql=true 11 | spring.jpa.properties.hibernate.format_sql=true 12 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect 13 | spring.jpa.hibernate.ddl-auto=update 14 | 15 | 16 | -------------------------------------------------------------------------------- /geek-tube/src/test/java/ru/geektube/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package ru.geektube; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DemoApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | geek-video-stream 9 | 1.0-SNAPSHOT 10 | pom 11 | 12 | 13 | 11 14 | 11 15 | 16 | 17 | 18 | geek-tube 19 | geek-tube-angular-frontend 20 | 21 | 22 | --------------------------------------------------------------------------------
{{preview.description}}
{{videoMetadata.description}}