Skip to content

DVR #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 33 commits into
base: dev
Choose a base branch
from
Open

DVR #68

Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
518a325
WIP refacto
jlucidar May 22, 2021
ab9d3ca
Merge branch 'dev' into feature/refacto
jlucidar May 23, 2021
258e9a2
bug fixes + Proper event handling for player (Observable Java pattern)
jlucidar May 24, 2021
8aed123
No more warnings + update dependencies
jlucidar May 24, 2021
7e3a4f8
add dvr feature
markussta May 16, 2021
98457fe
stuff
markussta May 16, 2021
e519abd
rollback
markussta May 16, 2021
806e25a
update dvr
markussta May 19, 2021
556beb6
add missing files
markussta May 19, 2021
2f703fe
dvr version first
markussta May 20, 2021
879ddb1
moved init
markussta May 20, 2021
2fb45ad
updated dvr branch
markussta May 21, 2021
5b29b5e
rebased to new dev branch
markussta May 21, 2021
42d04b9
first version of dvr implementation. work in progress
markussta May 22, 2021
f2bc27e
updated style and minor changes
markussta May 24, 2021
e31693c
rebased to dev
markussta May 24, 2021
252f91d
Merge remote-tracking branch 'origin/feature/refacto' into feature/22
markussta May 24, 2021
45a38cc
merged refactor branch
markussta May 24, 2021
4efb67c
added feature for gallery button and fixed toolbar display bug
markussta May 24, 2021
e0b6c7f
removed isRecording check from MainActivity
markussta May 24, 2021
60cb09b
added thumb update to different locations
markussta May 24, 2021
c99dd7c
minor updates
markussta May 25, 2021
b04bc43
fixed some perfomance issues and recording lags on the dvr
markussta May 25, 2021
f44645b
changed to a different access to InputStream
markussta May 25, 2021
6f17c81
changed from handler to Listener
markussta May 25, 2021
6710312
added dvr repair function
markussta May 26, 2021
46280c6
fixed crash on dvr repair
markussta May 26, 2021
ff5dc68
removed toast causes crashes ...
markussta May 26, 2021
4f6d55c
on overlay visible show toolbar as well
markussta May 26, 2021
b481180
Merge branch 'dev' into feature/22
markussta Jun 7, 2021
c5ef237
reorganize mainActivity to facilitate merge
jlucidar Nov 22, 2021
70d41c9
Merge branch 'dev' into feature/22
jlucidar Nov 23, 2021
e4af1f5
minor tweaking of the DVR toolbar look / fix typo
jlucidar Dec 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
keyAlias digiviewKeyAlias
}
catch (ex) {
println("You should define mStoreFile, mStorePassword, mKeyPassword and mKeyAlias in ~/.gradle/gradle.properties.")
println("You should define mStoreFile, mStorePassword, mKeyPassword and mKeyAlias in ~/.gradle/gradle.properties : "+ ex.message)
}
}
}
Expand Down Expand Up @@ -65,14 +65,18 @@ android {

dependencies {

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.exoplayer:exoplayer:2.13.3'
implementation 'com.google.android.exoplayer:exoplayer:2.14.0'
implementation 'org.mp4parser:isoparser:1.9.39'
implementation 'org.mp4parser:muxer:1.9.39'
compile 'org.slf4j:slf4j-nop:1.7.25'
implementation 'org.jcodec:jcodec:0.2.5'
implementation 'io.sentry:sentry-android:4.3.0'
implementation 'androidx.preference:preference:1.1.1'

testImplementation 'junit:junit:4.+'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
package="com.fpvout.digiview">

<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:largeHeap="true"
android:requestLegacyExternalStorage="true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be best to use scoped storage and shared directories :
https://developer.android.com/training/data-storage/shared/media

Copy link
Collaborator Author

@shambler123 shambler123 May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhh i know bad habit to use the old implementation ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for backwards compatibility I leave it as it is. we can change it later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better change it before a release/merge: WRITE_EXTERNAL_STORAGE no longer provides write access when targeting Android 11 - even with 'android:requestLegacyExternalStorage'. Sdk level 11+ is required for updates starting November 2021. This could delay feature/bugfix rollouts until the dvr is reworked.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok good to know! i will update that

android:supportsRtl="true"
android:theme="@style/Theme.Digiview"
>
Expand Down
23 changes: 7 additions & 16 deletions app/src/main/java/com/fpvout/digiview/H264Extractor.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.fpvout.digiview;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.ExtractorOutput;
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
import com.google.android.exoplayer2.extractor.PositionHolder;
import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.extractor.ts.H264Reader;
import com.google.android.exoplayer2.extractor.ts.SeiReader;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader;
import com.google.android.exoplayer2.util.NonNullApi;
import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.extractor.ts.SeiReader;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -21,9 +20,6 @@
* Extracts data from H264 bitstreams.
*/
public final class H264Extractor implements Extractor {
/** Factory for {@link H264Extractor} instances. */
public static final ExtractorsFactory FACTORY = () -> new Extractor[] {new H264Extractor()};

private static int MAX_SYNC_FRAME_SIZE = 131072;

private long firstSampleTimestampUs;
Expand All @@ -33,33 +29,27 @@ public final class H264Extractor implements Extractor {

private boolean startedPacket;

public H264Extractor() {
this(0);
}

public H264Extractor(int mMaxSyncFrameSize, int mSampleTime) {
this(0, mMaxSyncFrameSize, mSampleTime);
}

public H264Extractor(long firstSampleTimestampUs) {
this(firstSampleTimestampUs, MAX_SYNC_FRAME_SIZE, (int) sampleTime);
}

public H264Extractor(long firstSampleTimestampUs, int mMaxSyncFrameSize, int mSampleTime) {
MAX_SYNC_FRAME_SIZE = mMaxSyncFrameSize;
sampleTime = mSampleTime;
this.firstSampleTimestampUs = firstSampleTimestampUs;
reader = new H264Reader(new SeiReader(new ArrayList<Format>()),false,true);
reader = new H264Reader(new SeiReader(new ArrayList<>()), false, true);
sampleData = new ParsableByteArray(MAX_SYNC_FRAME_SIZE);
}

// Extractor implementation.
@Override
public boolean sniff(ExtractorInput input) throws IOException {
@NonNullApi
public boolean sniff(ExtractorInput input) {
return true;
}

@Override
@NonNullApi
public void init(ExtractorOutput output) {
reader.createTracks(output, new TsPayloadReader.TrackIdGenerator(0, 1));
output.endTracks();
Expand All @@ -78,6 +68,7 @@ public void release() {
}

@Override
@NonNullApi
public int read(ExtractorInput input, PositionHolder seekPosition) throws IOException {
int bytesRead = input.read(sampleData.getData(), 0, MAX_SYNC_FRAME_SIZE);
if (bytesRead == C.RESULT_END_OF_INPUT) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.fpvout.digiview;

import android.content.Context;
import android.net.Uri;

import androidx.annotation.NonNull;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
Expand All @@ -19,31 +20,29 @@ public class InputStreamBufferedDataSource implements DataSource {
private static final String ERROR_THREAD_NOT_INITIALIZED = "Read thread not initialized, call first 'startReadThread()'";
private static final long READ_TIMEOUT = 200;

private Context context;
private DataSpec dataSpec;
private final DataSpec dataSpec;
private InputStream inputStream;
private long bytesRemaining;
private boolean opened;

private CircularByteBuffer readBuffer;
private Thread receiveThread;
private boolean working;


public InputStreamBufferedDataSource(Context context, DataSpec dataSpec, InputStream inputStream) {
this.context = context;
public InputStreamBufferedDataSource(DataSpec dataSpec, InputStream inputStream) {
this.dataSpec = dataSpec;
this.inputStream = inputStream;
startReadThread();
}

@Override
public void addTransferListener(TransferListener transferListener) {
public void addTransferListener(@NonNull TransferListener transferListener) {

}

@Override
public long open(DataSpec dataSpec) throws IOException {
long bytesRemaining;
try {
long skipped = inputStream.skip(dataSpec.position);
if (skipped < dataSpec.position)
Expand All @@ -63,16 +62,14 @@ public long open(DataSpec dataSpec) throws IOException {
}

@Override
public int read(byte[] buffer, int offset, int readLength) throws IOException {
public int read(@NonNull byte[] buffer, int offset, int readLength) throws IOException {
if (readBuffer == null)
throw new IOException(ERROR_THREAD_NOT_INITIALIZED);

long deadLine = System.currentTimeMillis() + READ_TIMEOUT;
int readBytes = 0;
while (System.currentTimeMillis() < deadLine && readBytes <= 0)
readBytes = readBuffer.read(buffer, offset, readLength);
if (readBytes <= 0)
return readBytes;
return readBytes;
}

Expand Down
14 changes: 6 additions & 8 deletions app/src/main/java/com/fpvout/digiview/InputStreamDataSource.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.fpvout.digiview;

import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.upstream.DataSource;
Expand All @@ -13,25 +13,23 @@
import java.io.InputStream;

public class InputStreamDataSource implements DataSource {
private Context context;
private DataSpec dataSpec;
private final DataSpec dataSpec;
private InputStream inputStream;
private long bytesRemaining;
private boolean opened;

public InputStreamDataSource(Context context, DataSpec dataSpec, InputStream inputStream) {
this.context = context;
public InputStreamDataSource(DataSpec dataSpec, InputStream inputStream) {
this.dataSpec = dataSpec;
this.inputStream = inputStream;
}

@Override
public void addTransferListener(TransferListener transferListener) {
public void addTransferListener(@NonNull TransferListener transferListener) {

}

@Override
public long open(DataSpec dataSpec) throws IOException {
long bytesRemaining;
try {
long skipped = inputStream.skip(dataSpec.position);
if (skipped < dataSpec.position)
Expand All @@ -51,7 +49,7 @@ public long open(DataSpec dataSpec) throws IOException {
}

@Override
public int read(byte[] buffer, int offset, int readLength) throws IOException {
public int read(@NonNull byte[] buffer, int offset, int readLength) throws IOException {
return inputStream.read(buffer, offset, readLength);
}

Expand Down
Loading