├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ ├── ffmpeg.jar
│ ├── javacpp.jar
│ └── javacv.jar
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── bajicdusko
│ │ └── javacvwowzastarterkit
│ │ ├── CameraManager.java
│ │ ├── LiveBroadcastActivity.java
│ │ └── exceptions
│ │ └── NoCameraDeviceFoundException.java
│ ├── jniLibs
│ ├── armeabi-v7a
│ │ ├── libavcodec.so
│ │ ├── libavdevice.so
│ │ ├── libavfilter.so
│ │ ├── libavformat.so
│ │ ├── libavutil.so
│ │ ├── libjniARToolKitPlus.so
│ │ ├── libjniavcodec.so
│ │ ├── libjniavdevice.so
│ │ ├── libjniavfilter.so
│ │ ├── libjniavformat.so
│ │ ├── libjniavutil.so
│ │ ├── libjnipostproc.so
│ │ ├── libjniswresample.so
│ │ ├── libjniswscale.so
│ │ ├── libpostproc.so
│ │ ├── libswresample.so
│ │ └── libswscale.so
│ ├── armeabi
│ │ ├── libavcodec.so
│ │ ├── libavdevice.so
│ │ ├── libavfilter.so
│ │ ├── libavformat.so
│ │ ├── libavutil.so
│ │ ├── libjniARToolKitPlus.so
│ │ ├── libjniavcodec.so
│ │ ├── libjniavdevice.so
│ │ ├── libjniavfilter.so
│ │ ├── libjniavformat.so
│ │ ├── libjniavutil.so
│ │ ├── libjnipostproc.so
│ │ ├── libjniswresample.so
│ │ ├── libjniswscale.so
│ │ ├── libpostproc.so
│ │ ├── libswresample.so
│ │ └── libswscale.so
│ └── x86
│ │ ├── libavcodec.so
│ │ ├── libavdevice.so
│ │ ├── libavfilter.so
│ │ ├── libavformat.so
│ │ ├── libavutil.so
│ │ ├── libjniARToolKitPlus.so
│ │ ├── libjniavcodec.so
│ │ ├── libjniavdevice.so
│ │ ├── libjniavfilter.so
│ │ ├── libjniavformat.so
│ │ ├── libjniavutil.so
│ │ ├── libjnipostproc.so
│ │ ├── libjniswresample.so
│ │ ├── libjniswscale.so
│ │ ├── libpostproc.so
│ │ ├── libswresample.so
│ │ └── libswscale.so
│ └── res
│ ├── drawable
│ ├── ic_broadcast.png
│ ├── ic_broadcast_stop.png
│ ├── ic_camera_toggle.png
│ ├── ic_flash_off.png
│ └── ic_flash_on.png
│ ├── layout
│ └── activity_live_broadcast.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JavaCV to Wowza - Android Boilerplate
2 |
3 | Few short notes for the beginning.
4 |
5 | - This application is boilerplate for live streaming from android to Wowza via RTMP protocol. It is based on [JavaCV library](https://github.com/bytedeco/javacv). Many thanks to [Samuel Audet](https://github.com/saudet)
6 | - It is built on AndroidStudio 2.1.2
7 | - Compatible with Marshmallow (using Marshmallow permission model)
8 |
9 | # Getting started
10 |
11 | ## JavaCV in short
12 |
13 | This boilerplate is actually a simple wrapper around JavaCV library. More about JavaCV you can find at [Samuel Audet repository](https://github.com/bytedeco/javacv). In short, it is using precompiled C libraries placed in jniLibs folder for each architecture, then, as dependencies javaccv.jar, javacpp.jar and ofcourse ffmpeg.jar. And thats mostly all about needed libraries. Then we need to build android app by using those libraries.
14 |
15 | You can reference libraries above through gradle/maven or by downloading and copy-pasting files in libs folder. I've did this way, since i could not make it work via gradle/maven. It does not mean that its not possible, its probably lack of my knowledge.. :(.
16 |
17 | ### Possible issues
18 |
19 | Issues with copy-paste libraries can occur if you mix different versions of .so files and .jar libraries. So, this would be some steps you'd have to do:
20 | - Download latest javacv-bin
21 | - Extract library on file system
22 | - copy ffmpeg.jar, javacv.jar and javacpp.jar in libs folder of your android project
23 | - extract ffmpeg-android-x86.jar, ffmpeg-android-arm.jar, artoolkitplus-android-x86.jar and artoolkitplus-android-arm.jar and copy all .so files to related folders (arm to jniLibs/armeabi and to jniLibs/armeabi-v7a, x86 to jniLibs/x86). And that should be it.
24 |
25 | ##How it works
26 |
27 | AS any library it is good to know how it works but it is nor necessary. So, i'll describe this boilerplate in few steps only. I assume that you've checked [source code](https://github.com/bajicdusko/JavaCVWowzaStarterKit/blob/master/app/src/main/java/com/bajicdusko/javacvwowzastarterkit/LiveBroadcastActivity.java) and [layout](https://github.com/bajicdusko/JavaCVWowzaStarterKit/blob/master/app/src/main/res/layout/activity_live_broadcast.xml) already.
28 |
29 | 1. On activity initialization, we take care of camera choice and camera initialization. This boilerplate is still using old Camera API.
30 | 2. When SurfaceHolder gets ready, we connect camera with holder and preview starts.
31 | 3. On SurfaceChanged, we are inspecting possible video formats and framerates that camera can support and we are choosing nearest profile to those settings you've required.
32 | 4. On broadcast button click, FFMpegRecorder is started and AudioRecord thread is started also. AudioRecord thread is initializing microphone and taking data from it.
33 | 5. Video and audio needs to be synced and it is done in onPreviewFrame method. Currently, there is some audio lag on recording start.
34 | 6. When broadcast is stopped, we are releasing and stopping recorder, audiothread also. Camera preview still remains.
35 |
36 | ##Features
37 |
38 | There are few default features that this boilerplate should support:
39 |
40 | 1. Torch on/off
41 | 2. Camera switching
42 | 3. Auto-Focus
43 | 4. Screen rotation.
44 |
45 | All of those features are currently in #TODO, or #INPROGRESS and none of them is working currently (they will)
46 |
47 | ##Wowza settings
48 |
49 | AS you may have seen already in source, there are few variables that you should set for your own environment. wowzaUsername and wowzaPassword are optional.
50 |
51 | ```
52 | //broadcast credentials (if stream source requires authentication)
53 | private String wowzaUsername;
54 | private String wowzaPassword;
55 | private String wowzaIp = "xxx.xxx.xxx.xxx";
56 | private int wowzaLivePort = 1935; //by default Wowza settings
57 | private String wowzaApplicationName = "";
58 | private String wowzaStreamName = "";
59 | ```
60 |
61 | Also there are few properties that are hardcoded for wowza:
62 |
63 | ```
64 | private final String PROTOCOL = "rtmp://";
65 | .
66 | .
67 | recorder.setFormat("flv");
68 | recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
69 | recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
70 | ```
71 |
72 | I have tried RTSP and it is not working, but since Wowza accept RTP and RTMP its not a huge issue.
73 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'com.neenbedankt.android-apt'
3 |
4 | android {
5 | compileSdkVersion 23
6 | buildToolsVersion "23.0.3"
7 |
8 | defaultConfig {
9 | applicationId "com.bajicdusko.javacvwowzastarterkit"
10 | minSdkVersion 19
11 | targetSdkVersion 23
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | configurations {
22 | all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
23 | }
24 |
25 | packagingOptions {
26 | exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
27 | exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
28 | }
29 | }
30 |
31 | dependencies {
32 | compile fileTree(dir: 'libs', include: ['*.jar'])
33 | apt 'com.jakewharton:butterknife-compiler:8.0.1'
34 | provided 'javax.annotation:jsr250-api:1.0'
35 | apt 'com.github.hotchemi:permissionsdispatcher-processor:2.0.7'
36 | compile 'com.jakewharton:butterknife:8.0.1'
37 | compile 'com.android.support:support-v4:23.3.0'
38 | compile 'com.android.support:design:23.4.0'
39 | compile 'com.android.support:cardview-v7:23.3.0'
40 | compile 'com.github.hotchemi:permissionsdispatcher:2.0.7'
41 | compile files('libs/ffmpeg.jar')
42 | compile files('libs/javacpp.jar')
43 | compile files('libs/javacv.jar')
44 | }
45 |
--------------------------------------------------------------------------------
/app/libs/ffmpeg.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/libs/ffmpeg.jar
--------------------------------------------------------------------------------
/app/libs/javacpp.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/libs/javacpp.jar
--------------------------------------------------------------------------------
/app/libs/javacv.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/libs/javacv.jar
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bajicdusko/javacvwowzastarterkit/CameraManager.java:
--------------------------------------------------------------------------------
1 | package com.bajicdusko.javacvwowzastarterkit;
2 |
3 | import android.hardware.Camera;
4 | import android.view.SurfaceHolder;
5 |
6 | import com.bajicdusko.javacvwowzastarterkit.exceptions.NoCameraDeviceFoundException;
7 |
8 | import java.io.IOException;
9 |
10 | /**
11 | * Created by Bajic Dusko (www.bajicdusko.com) on 30-Oct-16.
12 | */
13 |
14 | public class CameraManager {
15 |
16 | public static final int NO_ACTIVE_CAMERA = -1;
17 |
18 | private int activeCameraId = NO_ACTIVE_CAMERA;
19 | private Camera camera;
20 | private boolean isInPreview;
21 |
22 | public Camera getBackCamera() throws NoCameraDeviceFoundException {
23 | return getCamera(Camera.CameraInfo.CAMERA_FACING_BACK);
24 | }
25 |
26 | public Camera getFrontCamera() throws NoCameraDeviceFoundException {
27 | return getCamera(Camera.CameraInfo.CAMERA_FACING_FRONT);
28 | }
29 |
30 | private Camera getCamera(int cameraId) throws NoCameraDeviceFoundException {
31 | if (Camera.getNumberOfCameras() == 0) {
32 | throw new NoCameraDeviceFoundException();
33 | }
34 |
35 | Camera camera = Camera.open(cameraId);
36 | if (camera == null) {
37 | throw new NoCameraDeviceFoundException();
38 | }
39 |
40 | return camera;
41 | }
42 |
43 | public Camera getCamera() {
44 | return camera;
45 | }
46 |
47 | public void initCamera() throws NoCameraDeviceFoundException {
48 | if (camera == null) {
49 | try {
50 | camera = getBackCamera();
51 | } catch (NoCameraDeviceFoundException noCameraDeviceFound) {
52 | noCameraDeviceFound.printStackTrace();
53 | }
54 | }
55 |
56 | if (camera == null) {
57 | try {
58 | camera = getFrontCamera();
59 | } catch (NoCameraDeviceFoundException e) {
60 |
61 | }
62 | }
63 |
64 | if (camera == null) {
65 | throw new NoCameraDeviceFoundException();
66 | }
67 | }
68 |
69 | public void releaseCamera() {
70 | if (camera != null) {
71 | camera.stopPreview();
72 | camera.setPreviewCallback(null);
73 | camera.release();
74 | camera = null;
75 | }
76 | }
77 |
78 | public void initPreview(SurfaceHolder holder, Camera.PreviewCallback previewCallback) throws IOException {
79 | camera.setPreviewDisplay(holder);
80 | camera.setPreviewCallback(previewCallback);
81 | }
82 |
83 | public void startPreview() {
84 | if (!isInPreview) {
85 | camera.startPreview();
86 | }
87 | }
88 |
89 | public void stopPreview() {
90 | if (isInPreview) {
91 | camera.stopPreview();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/bajicdusko/javacvwowzastarterkit/LiveBroadcastActivity.java:
--------------------------------------------------------------------------------
1 | package com.bajicdusko.javacvwowzastarterkit;
2 |
3 | import android.Manifest;
4 | import android.content.DialogInterface;
5 | import android.hardware.Camera;
6 | import android.media.AudioFormat;
7 | import android.media.AudioRecord;
8 | import android.media.MediaRecorder;
9 | import android.os.Bundle;
10 | import android.support.annotation.NonNull;
11 | import android.support.v7.app.AlertDialog;
12 | import android.support.v7.app.AppCompatActivity;
13 | import android.text.TextUtils;
14 | import android.util.Log;
15 | import android.view.SurfaceHolder;
16 | import android.view.SurfaceView;
17 | import android.view.View;
18 | import android.widget.ImageView;
19 | import android.widget.Toast;
20 |
21 | import com.bajicdusko.javacvwowzastarterkit.exceptions.NoCameraDeviceFoundException;
22 |
23 | import org.bytedeco.javacpp.avcodec;
24 | import org.bytedeco.javacv.FFmpegFrameRecorder;
25 | import org.bytedeco.javacv.Frame;
26 |
27 | import java.io.IOException;
28 | import java.nio.ByteBuffer;
29 | import java.nio.ShortBuffer;
30 | import java.util.Collections;
31 | import java.util.Comparator;
32 | import java.util.List;
33 |
34 | import butterknife.BindView;
35 | import butterknife.ButterKnife;
36 | import butterknife.OnClick;
37 | import permissions.dispatcher.NeedsPermission;
38 | import permissions.dispatcher.OnNeverAskAgain;
39 | import permissions.dispatcher.OnPermissionDenied;
40 | import permissions.dispatcher.OnShowRationale;
41 | import permissions.dispatcher.PermissionRequest;
42 | import permissions.dispatcher.RuntimePermissions;
43 |
44 | @RuntimePermissions
45 | public class LiveBroadcastActivity extends AppCompatActivity implements Camera.PreviewCallback, SurfaceHolder.Callback {
46 |
47 | private final static String CLASS_LABEL = "LiveBroadcastActivity";
48 | private final static String LOG_TAG = CLASS_LABEL;
49 | private final String EMPTY_STRING = "";
50 |
51 | private final String PROTOCOL = "rtmp://";
52 |
53 | @BindView(R.id.activity_live_broadcast_sv_video)
54 | SurfaceView svVideo;
55 | @BindView(R.id.activity_live_broadcast_bt_toggle)
56 | ImageView btToggle;
57 | @BindView(R.id.activity_live_broadcast_bt_broadcast)
58 | ImageView btBroadcast;
59 | @BindView(R.id.activity_live_broadcast_bt_flash)
60 | ImageView btFlash;
61 |
62 | //broadcast credentials (if stream source requires authentication)
63 | private String wowzaUsername;
64 | private String wowzaPassword;
65 | private String wowzaIp = "xxx.xxx.xxx.xxx";
66 | private int wowzaLivePort = 1935; //by default Wowza settings
67 | private String wowzaApplicationName = "live";
68 | private String wowzaStreamName = "android";
69 |
70 | private int sampleAudioRateInHz = 44100;
71 | private int imageWidth;
72 | private int imageHeight;
73 | private int frameRate = 30;
74 | private int VIDEO_BITRATE = 700 * 1000;
75 | private int AUDIO_BITRATE = 8 * 1000;
76 |
77 | /* audio data getting thread */
78 | private AudioRecord audioRecord;
79 | private AudioRecordRunnable audioRecordRunnable;
80 | private Thread audioThread;
81 | volatile boolean runAudioThread = true;
82 |
83 | /* video data getting thread */
84 | private FFmpegFrameRecorder recorder;
85 |
86 | private Frame yuvImage = null;
87 |
88 | long startTime = 0;
89 | boolean recording = false;
90 | private boolean isPreviewOn = false;
91 | private int screenHeight;
92 | private int screenWidth;
93 | private final int videoWidth = 854;
94 | private final int videoHeight = 480;
95 |
96 | private boolean isFlashOn = false;
97 | private boolean cameraToggleEnabled = true;
98 | private boolean continueRecordingOnSwitch = false;
99 | private CameraManager cameraManager;
100 | private SurfaceHolder.Callback surfaceCallback;
101 |
102 | @Override
103 | public void onCreate(Bundle savedInstanceState) {
104 | super.onCreate(savedInstanceState);
105 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
106 | setContentView(R.layout.activity_live_broadcast);
107 | ButterKnife.bind(this);
108 | cameraManager = new CameraManager();
109 |
110 | screenWidth = getResources().getDisplayMetrics().widthPixels;
111 | screenHeight = getResources().getDisplayMetrics().heightPixels;
112 | setSurfaceSize(videoWidth, videoHeight);
113 | }
114 |
115 | @Override
116 | protected void onResume() {
117 | super.onResume();
118 | surfaceCallback = LiveBroadcastActivity.this;
119 | LiveBroadcastActivityPermissionsDispatcher.startInitializationSequenceWithCheck(LiveBroadcastActivity.this);
120 | }
121 |
122 | private void setSurfaceSize(int videoWidth, int videoHeight) {
123 | svVideo.getLayoutParams().width = (int) (screenWidth * ((float) videoWidth / (float) videoHeight));
124 | }
125 |
126 | @NeedsPermission({Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO})
127 | public void startInitializationSequence() {
128 | cameraManager.releaseCamera();
129 | try {
130 | cameraManager.initCamera();
131 | initSurfaceCallback();
132 | } catch (NoCameraDeviceFoundException e) {
133 | Toast.makeText(this, "Camera not found on device.", Toast.LENGTH_SHORT).show();
134 | }
135 | }
136 |
137 | private void initSurfaceCallback() {
138 | SurfaceHolder mHolder = svVideo.getHolder();
139 | mHolder.addCallback(surfaceCallback);
140 | mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
141 | }
142 |
143 | private void releaseSurfaceCallback(SurfaceHolder holder) {
144 | holder.addCallback(null);
145 | }
146 |
147 | @OnClick(R.id.activity_live_broadcast_sv_video)
148 | public void onSurfaceClick() {
149 | if (cameraManager.getCamera() != null) {
150 | cameraManager.getCamera().autoFocus(new Camera.AutoFocusCallback() {
151 | @Override
152 | public void onAutoFocus(boolean b, Camera camera) {
153 |
154 | }
155 | });
156 | }
157 | }
158 |
159 | @OnClick(R.id.activity_live_broadcast_bt_broadcast)
160 | public void onRecordClick() {
161 | if (!recording) {
162 | startRecording();
163 | } else {
164 | stopRecording();
165 | }
166 | }
167 |
168 | @Override
169 | protected void onDestroy() {
170 | super.onDestroy();
171 | recording = false;
172 | cameraManager.stopPreview();
173 | cameraManager.releaseCamera();
174 | }
175 |
176 | @Override
177 | public void onPreviewFrame(byte[] bytes, Camera camera) {
178 | if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
179 | startTime = System.currentTimeMillis();
180 | return;
181 | }
182 |
183 | if (yuvImage != null && recording) {
184 | ((ByteBuffer) yuvImage.image[0].position(0)).put(bytes);
185 |
186 | try {
187 | Log.v(LOG_TAG, "Writing Frame");
188 | long t = 1000 * (System.currentTimeMillis() - startTime);
189 | if (t > recorder.getTimestamp()) {
190 | recorder.setTimestamp(t);
191 | }
192 | recorder.record(yuvImage);
193 | } catch (FFmpegFrameRecorder.Exception e) {
194 | Log.v(LOG_TAG, e.getMessage());
195 | e.printStackTrace();
196 | }
197 | }
198 | }
199 |
200 | @Override
201 | public void surfaceCreated(SurfaceHolder holder) {
202 | try {
203 | cameraManager.stopPreview();
204 | cameraManager.initPreview(holder, null);
205 | } catch (IOException exception) {
206 | cameraManager.releaseCamera();
207 | }
208 | }
209 |
210 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
211 | cameraManager.stopPreview();
212 |
213 | Camera.Parameters camParams = cameraManager.getCamera().getParameters();
214 | List sizes = camParams.getSupportedPreviewSizes();
215 | Collections.sort(sizes, new Comparator() {
216 |
217 | public int compare(final Camera.Size a, final Camera.Size b) {
218 | return a.width * a.height - b.width * b.height;
219 | }
220 | });
221 |
222 | // Pick the first preview size that is equal or bigger, or pick the last (biggest) option if we cannot
223 | // reach the initial settings of imageWidth/imageHeight.
224 | for (int i = 0; i < sizes.size(); i++) {
225 | if ((sizes.get(i).width >= videoWidth && sizes.get(i).height >= videoHeight) || i == sizes.size() - 1) {
226 | imageWidth = sizes.get(i).width;
227 | imageHeight = sizes.get(i).height;
228 | Log.v(LOG_TAG, "Changed to supported resolution: " + imageWidth + "x" + imageHeight);
229 | break;
230 | }
231 | }
232 | camParams.setPreviewSize(imageWidth, imageHeight);
233 | setSurfaceSize(imageWidth, imageHeight);
234 |
235 | Log.v(LOG_TAG, "Setting imageWidth: " + imageWidth + " imageHeight: " + imageHeight + " frameRate: " + frameRate);
236 |
237 | camParams.setPreviewFrameRate(frameRate);
238 | Log.v(LOG_TAG, "Preview Framerate: " + camParams.getPreviewFrameRate());
239 |
240 | cameraManager.getCamera().setParameters(camParams);
241 |
242 | try {
243 | cameraManager.initPreview(holder, LiveBroadcastActivity.this);
244 | cameraManager.startPreview();
245 | } catch (Exception e) {
246 | Log.e(LOG_TAG, "Could not set preview display in surfaceChanged");
247 | }
248 | }
249 |
250 | @Override
251 | public void surfaceDestroyed(SurfaceHolder holder) {
252 | try {
253 | releaseSurfaceCallback(holder);
254 | cameraManager.releaseCamera();
255 | } catch (RuntimeException e) {
256 | }
257 | }
258 |
259 | private void initRecorder() {
260 |
261 | Log.w(LOG_TAG, "init recorder");
262 | if (yuvImage == null) {
263 | yuvImage = new Frame(imageWidth, imageHeight, Frame.DEPTH_UBYTE, 2);
264 | Log.i(LOG_TAG, "create yuvImage");
265 | }
266 |
267 | String streamUrl = buildWowzaStreamEndpoint();
268 | if (!TextUtils.isEmpty(streamUrl)) {
269 | Log.i(LOG_TAG, "Stream url: " + streamUrl);
270 | recorder = new FFmpegFrameRecorder(streamUrl, imageWidth, imageHeight, 1);
271 | recorder.setFormat("flv");
272 | recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
273 | recorder.setVideoBitrate(VIDEO_BITRATE);
274 | recorder.setAudioBitrate(AUDIO_BITRATE);
275 | recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
276 | recorder.setSampleRate(sampleAudioRateInHz);
277 | recorder.setFrameRate(frameRate);
278 |
279 | Log.i(LOG_TAG, "recorder initialize success");
280 |
281 | audioRecordRunnable = new AudioRecordRunnable();
282 | audioThread = new Thread(audioRecordRunnable);
283 | runAudioThread = true;
284 | }
285 | }
286 |
287 | private String buildWowzaStreamEndpoint() {
288 |
289 | StringBuilder builder = new StringBuilder();
290 | builder.append(PROTOCOL);
291 | if (!TextUtils.isEmpty(wowzaUsername) && !TextUtils.isEmpty(wowzaPassword)) {
292 | builder.append(wowzaUsername).append(":").append(wowzaPassword).append("@");
293 | }
294 |
295 | if (wowzaIp.contains("x")) {
296 | Toast.makeText(this, "Wowza IP address not set. Check \"wowzaIp\" property.", Toast.LENGTH_SHORT).show();
297 | } else if (TextUtils.isEmpty(wowzaApplicationName)) {
298 | Toast.makeText(this, "Wowza application name not set. Check \"wowzaApplicationName\" property.", Toast.LENGTH_SHORT).show();
299 | } else if (TextUtils.isEmpty(wowzaStreamName)) {
300 | Toast.makeText(this, "Wowza stream name not set. Check \"wowzaStreamName\" property.", Toast.LENGTH_SHORT).show();
301 | } else {
302 | builder.append(wowzaIp).append(":").append(wowzaLivePort).append("/");
303 | builder.append(wowzaApplicationName).append("/");
304 | builder.append(wowzaStreamName);
305 | return builder.toString();
306 | }
307 |
308 | return EMPTY_STRING;
309 | }
310 |
311 | public void startRecording() {
312 | btBroadcast.setImageResource(R.drawable.ic_broadcast_stop);
313 | initRecorder();
314 |
315 | try {
316 | recorder.start();
317 | startTime = System.currentTimeMillis();
318 | recording = true;
319 | audioThread.start();
320 |
321 | } catch (FFmpegFrameRecorder.Exception e) {
322 | e.printStackTrace();
323 | btBroadcast.setImageResource(R.drawable.ic_broadcast);
324 | } catch (Exception e) {
325 | Log.e(LOG_TAG, e.getMessage());
326 | }
327 | }
328 |
329 | public void stopRecording() {
330 |
331 | if (!continueRecordingOnSwitch) {
332 | btBroadcast.setImageResource(R.drawable.ic_broadcast);
333 | }
334 | runAudioThread = false;
335 | try {
336 | if (audioThread != null) {
337 | audioThread.join();
338 | }
339 | } catch (InterruptedException e) {
340 | // reset interrupt to be nice
341 | Thread.currentThread().interrupt();
342 | return;
343 | }
344 | audioRecordRunnable = null;
345 | audioThread = null;
346 |
347 | if (recorder != null && recording) {
348 |
349 | recording = false;
350 | Log.v(LOG_TAG, "Finishing recording, calling stop and release on recorder");
351 | try {
352 | recorder.stop();
353 | recorder.release();
354 | } catch (FFmpegFrameRecorder.Exception e) {
355 | e.printStackTrace();
356 | }
357 | recorder = null;
358 |
359 | }
360 | }
361 |
362 | @Override
363 | public void onBackPressed() {
364 | if (recording) {
365 | stopRecording();
366 | }
367 | super.onBackPressed();
368 | }
369 |
370 | class AudioRecordRunnable implements Runnable {
371 |
372 | @Override
373 | public void run() {
374 | android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
375 |
376 | // Audio
377 | int bufferSize;
378 | ShortBuffer audioData;
379 | int bufferReadResult;
380 |
381 | bufferSize = AudioRecord.getMinBufferSize(sampleAudioRateInHz,
382 | AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
383 | audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleAudioRateInHz,
384 | AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
385 |
386 | audioData = ShortBuffer.allocate(bufferSize);
387 |
388 | Log.d(LOG_TAG, "audioRecord.startRecording()");
389 | audioRecord.startRecording();
390 |
391 | /* ffmpeg_audio encoding loop */
392 | while (runAudioThread) {
393 |
394 | bufferReadResult = audioRecord.read(audioData.array(), 0, audioData.capacity());
395 | audioData.limit(bufferReadResult);
396 | if (bufferReadResult > 0) {
397 | Log.v(LOG_TAG, "bufferReadResult: " + bufferReadResult);
398 | if (recording) {
399 | try {
400 | recorder.recordSamples(audioData);
401 | } catch (FFmpegFrameRecorder.Exception e) {
402 | Log.v(LOG_TAG, e.getMessage());
403 | e.printStackTrace();
404 | }
405 | }
406 | }
407 | }
408 | Log.v(LOG_TAG, "AudioThread Finished, release audioRecord");
409 |
410 | if (audioRecord != null) {
411 | audioRecord.stop();
412 | audioRecord.release();
413 | audioRecord = null;
414 | Log.v(LOG_TAG, "audioRecord released");
415 | }
416 | }
417 | }
418 |
419 | @Override
420 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
421 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
422 | LiveBroadcastActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
423 | }
424 |
425 | @OnShowRationale({Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO})
426 | public void showRationaleDialog(final PermissionRequest permissionRequest) {
427 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
428 | builder.setTitle("Why do we need these permissions?");
429 | builder.setMessage("In order to stream video and audio from this device, we need to be able to access Camera and Microphone.");
430 | builder.setPositiveButton("Ok, continue", new DialogInterface.OnClickListener() {
431 | @Override
432 | public void onClick(DialogInterface dialogInterface, int i) {
433 | permissionRequest.proceed();
434 | }
435 | });
436 | builder.setNegativeButton("Deny for now", new DialogInterface.OnClickListener() {
437 | @Override
438 | public void onClick(DialogInterface dialogInterface, int i) {
439 | permissionRequest.cancel();
440 | }
441 | });
442 | builder.create().show();
443 | }
444 |
445 | @OnPermissionDenied({Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO})
446 | public void onPermissionDenied() {
447 | Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show();
448 | }
449 |
450 | @OnNeverAskAgain({Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO})
451 | public void onNeverAskAgain() {
452 |
453 | }
454 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/bajicdusko/javacvwowzastarterkit/exceptions/NoCameraDeviceFoundException.java:
--------------------------------------------------------------------------------
1 | package com.bajicdusko.javacvwowzastarterkit.exceptions;
2 |
3 | /**
4 | * Created by Bajic Dusko (www.bajicdusko.com) on 30-Oct-16.
5 | */
6 |
7 | public class NoCameraDeviceFoundException extends Exception {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libavcodec.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libavcodec.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libavdevice.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libavdevice.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libavfilter.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libavfilter.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libavformat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libavformat.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libavutil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libavutil.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniARToolKitPlus.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniARToolKitPlus.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniavcodec.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniavcodec.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniavdevice.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniavdevice.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniavfilter.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniavfilter.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniavformat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniavformat.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniavutil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniavutil.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjnipostproc.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjnipostproc.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniswresample.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniswresample.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libjniswscale.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libjniswscale.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libpostproc.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libpostproc.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libswresample.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libswresample.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi-v7a/libswscale.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi-v7a/libswscale.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libavcodec.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libavcodec.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libavdevice.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libavdevice.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libavfilter.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libavfilter.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libavformat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libavformat.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libavutil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libavutil.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniARToolKitPlus.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniARToolKitPlus.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniavcodec.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniavcodec.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniavdevice.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniavdevice.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniavfilter.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniavfilter.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniavformat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniavformat.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniavutil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniavutil.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjnipostproc.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjnipostproc.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniswresample.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniswresample.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libjniswscale.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libjniswscale.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libpostproc.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libpostproc.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libswresample.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libswresample.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libswscale.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/armeabi/libswscale.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libavcodec.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libavcodec.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libavdevice.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libavdevice.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libavfilter.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libavfilter.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libavformat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libavformat.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libavutil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libavutil.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniARToolKitPlus.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniARToolKitPlus.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniavcodec.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniavcodec.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniavdevice.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniavdevice.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniavfilter.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniavfilter.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniavformat.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniavformat.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniavutil.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniavutil.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjnipostproc.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjnipostproc.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniswresample.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniswresample.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libjniswscale.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libjniswscale.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libpostproc.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libpostproc.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libswresample.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libswresample.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/x86/libswscale.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/jniLibs/x86/libswscale.so
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_broadcast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/drawable/ic_broadcast.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_broadcast_stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/drawable/ic_broadcast_stop.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_camera_toggle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/drawable/ic_camera_toggle.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_flash_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/drawable/ic_flash_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_flash_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/drawable/ic_flash_on.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_live_broadcast.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
12 |
13 |
23 |
24 |
33 |
34 |
35 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 65dp
6 | 30dp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | JavaCVWowzaStarterKit
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | maven { url "https://jitpack.io" }
19 | }
20 | }
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
25 | dependencies {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bajicdusko/JavaCVWowzaStarterKit/83220928574c096ae2a56cd61fefa7239edbc18b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Oct 30 10:43:34 CET 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------