Skip to content

Commit 46078c4

Browse files
committed
Initial commit
0 parents  commit 46078c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1725
-0
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release package to Maven Central Repository
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Deploy to maven
11+
run: |
12+
echo $GPG_KEYRING_FILE_CONTENT | base64 --decode > videouploader-module/secring.gpg
13+
sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties
14+
sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties
15+
sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=secring.gpg,g" gradle.properties
16+
cat gradle.properties
17+
./gradlew build uploadArchive -PNEXUS_USERNAME=${{ secrets.OSSRH_USERNAME }} -PNEXUS_PASSWORD="${{ secrets.OSSRH_PASSWORD }}"
18+
env:
19+
GPG_KEYRING_FILE_CONTENT: "${{ secrets.GPG_KEYRING_FILE_CONTENT }}"
20+
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
21+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Run unit tests
2+
on: [push]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- name: Run the tests
9+
run: ./gradlew test

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
.DS_Store
5+
app/build
6+
/captures
7+
.externalNativeBuild
8+
.cxx
9+
.idea
10+
/.gradle/
11+
/library/
12+
/sdk/out.map
13+
14+
# [Maven] ========================
15+
target/
16+
pom.xml.tag
17+
pom.xml.releaseBackup
18+
pom.xml.versionsBackup
19+
pom.xml.next
20+
release.properties
21+
22+
# Package Files #
23+
*.jar
24+
*.war
25+
*.ear

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
![](https://github.com/apivideo/API_OAS_file/blob/master/apivideo_banner.png)
2+
# Api.Video Android Kotlin video upload Module
3+
4+
This module is an easy way to upload video file to the api.video platform
5+
6+
## Installation
7+
### With maven
8+
On build.gradle add the following code in dependencies:
9+
```xml
10+
dependencies {
11+
...
12+
implementation 'video.api:android-video-uploader:0.0.3' // add this line
13+
}
14+
```
15+
### Or import with a local aar
16+
17+
1. Download the [latest release](https://github.com/apivideo/android-video-uploader/releases) of the aar file.
18+
2. Go to “File” > “Project Structure...”
19+
3. On "Modules" select the "+" button and select "Import .JAR/.AAR Package" then click "next"
20+
4. Select the AAR file you have just downloaded, and click "Finish"
21+
5. Then go to "Dependencies" select the the app module and add a new dependencies by clicking on the "+" button, then select "Module Dependency"
22+
(if there is no "Module Dependency", close the window and re-open it, it should be fine)
23+
6. select Api.Video module, click "ok"
24+
7. click on "Apply" and then "ok"
25+
26+
27+
### Quick Start
28+
29+
30+
### FAQ
31+
If you have any questions, ask us here: https://community.api.video .
32+
Or use [Issues].
33+
34+
License
35+
----
36+
37+
MIT License
38+
Copyright (c) 2021 api.video
39+
40+
[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)
41+
42+
[rtmp-rtsp-stream-client-java]: <https://github.com/pedroSG94/rtmp-rtsp-stream-client-java>
43+
[Issues]: <https://github.com/apivideo/android-video-uploader/issues>

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
}
5+
6+
android {
7+
compileSdkVersion 30
8+
buildToolsVersion "30.0.3"
9+
10+
defaultConfig {
11+
applicationId "video.api.app"
12+
minSdkVersion 21
13+
targetSdkVersion 30
14+
versionCode 1
15+
versionName "1.0"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
}
19+
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
compileOptions {
27+
sourceCompatibility JavaVersion.VERSION_1_8
28+
targetCompatibility JavaVersion.VERSION_1_8
29+
}
30+
kotlinOptions {
31+
jvmTarget = '1.8'
32+
}
33+
}
34+
35+
dependencies {
36+
37+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
38+
implementation 'androidx.core:core-ktx:1.3.2'
39+
implementation 'androidx.appcompat:appcompat:1.2.0'
40+
implementation 'com.google.android.material:material:1.3.0'
41+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
42+
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
43+
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
44+
testImplementation 'junit:junit:4.+'
45+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
46+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
47+
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
48+
implementation project(":videouploader-module")
49+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package video.api.app
2+
3+
import androidx.core.content.ContextCompat
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
import androidx.test.platform.app.InstrumentationRegistry
6+
import okhttp3.OkHttpClient
7+
import org.json.JSONObject
8+
import org.junit.Assert.*
9+
import org.junit.Test
10+
import org.junit.runner.RunWith
11+
import video.api.videouploader_module.UploaderRequestExecutorImpl
12+
import video.api.videouploader_module.ApiError
13+
import video.api.videouploader_module.CallBack
14+
import video.api.videouploader_module.VideoUploader
15+
import java.io.File
16+
import java.io.FileOutputStream
17+
import java.io.IOException
18+
import java.io.InputStream
19+
import java.net.URI
20+
import java.util.concurrent.CountDownLatch
21+
22+
/**
23+
* Instrumented test, which will execute on an Android device.
24+
*
25+
* See [testing documentation](http://d.android.com/tools/testing).
26+
*/
27+
@RunWith(AndroidJUnit4::class)
28+
class UploaderTests {
29+
30+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
31+
val client = OkHttpClient();
32+
val uploader = VideoUploader("https://ws.api.video", UploaderRequestExecutorImpl(client), client);
33+
34+
class TestSuccessCallBack(private val signal: CountDownLatch) : CallBack {
35+
override fun onError(apiError: ApiError) {
36+
assertNull(apiError);
37+
signal.countDown();
38+
}
39+
40+
override fun onFatal(e: IOException) {
41+
assertNull(e);
42+
signal.countDown();
43+
}
44+
45+
override fun onSuccess(result: JSONObject) {
46+
assertNotNull(result.getString("videoId"));
47+
signal.countDown();
48+
}
49+
}
50+
51+
@Test
52+
fun uploadSmallFile() {
53+
val signal = CountDownLatch(1)
54+
uploader.uploadWithDelegatedToken("to4UcvhqOJLLE3NBRBl7TtGJ", File(assetToFIle("574k.mp4")), TestSuccessCallBack(signal))
55+
signal.await();
56+
}
57+
58+
@Test
59+
fun uploadBigFile() {
60+
val signal = CountDownLatch(1)
61+
uploader.uploadWithDelegatedToken("to4UcvhqOJLLE3NBRBl7TtGJ", File(assetToFIle("10m.mp4")), TestSuccessCallBack(signal))
62+
signal.await();
63+
}
64+
65+
private fun assetToFIle(assetName: String): URI? {
66+
val f = File(ContextCompat.getDataDir(appContext).toString() + "/" + assetName)
67+
try {
68+
val inputStream: InputStream = appContext.getAssets().open(assetName)
69+
val buffer = ByteArray(1024)
70+
val fos = FileOutputStream(f)
71+
do {
72+
var read = inputStream.read(buffer)
73+
fos.write(buffer)
74+
} while (read != -1)
75+
inputStream.close()
76+
fos.close()
77+
return f.toURI();
78+
} catch (e: Exception) {
79+
throw RuntimeException(e)
80+
}
81+
return null;
82+
}
83+
}

app/src/main/AndroidManifest.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="video.api.app">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.App">
14+
<activity
15+
android:name=".MainActivity"
16+
android:label="@string/app_name"
17+
android:theme="@style/Theme.App.NoActionBar">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
26+
</manifest>

app/src/main/assets/10m.mp4

10.1 MB
Binary file not shown.

0 commit comments

Comments
 (0)