Skip to content

Commit

Permalink
Preparing 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyvasilyev committed Apr 27, 2020
1 parent 143e05f commit 5bf40a2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ allprojects {
}
}
dependencies {
implementation 'com.github.alexeyvasilyev:rtsp-client-android:1.0.0'
implementation 'com.github.alexeyvasilyev:rtsp-client-android:1.0.1'
}
```

Expand Down
4 changes: 2 additions & 2 deletions constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ project.ext {
buildToolsVersion = '29.0.3'
minSdkVersion = 21 // 5.0
targetSdkVersion = 29 // 10.0
releaseVersion = "1.0.0"
releaseVersionCode = 100
releaseVersion = "1.0.1"
releaseVersionCode = 101

androidXAnnotationVersion = '1.1.0'
}
77 changes: 39 additions & 38 deletions library-rtsp/src/main/java/com/alexvas/utils/VideoCodecUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,13 @@ private NalUnit(int type, int offset, int length) {
this.length = length;
}
}
// public static int getH264NalUnitsNumber(
// @NonNull byte[] data,
// int dataOffset,
// int length) {
// return getH264NalUnits(data, dataOffset, length, new ArrayList<>());
// }

public static int getH264NalUnitsNumber(
@NonNull byte[] data,
int dataOffset,
int length) {
return getH264NalUnits(data, dataOffset, length, new ArrayList<>());
}

public static int getH264NalUnits(
@NonNull byte[] data,
Expand Down Expand Up @@ -391,38 +392,38 @@ public static int getH264NalUnits(
return nalUnits;
}

// // TODO: Code has a BUG! Sometimes it goes to infinite loop!
// public static int searchForH264NalUnitByType(
// @NonNull byte[] data,
// int offset,
// int length,
// int byUnitType) {
//
// AtomicInteger nalUnitPrefixSize = new AtomicInteger(-1);
// long timestamp = System.currentTimeMillis();
//
// while (true) {
// int nalUnitIndex = searchForH264NalUnitStart(data, offset, length, nalUnitPrefixSize);
// if (nalUnitIndex >= 0) {
// int nalUnitOffset = nalUnitIndex + nalUnitPrefixSize.get();
// byte nalUnitTypeOctet = data[nalUnitOffset];
// byte nalUnitType = (byte)(nalUnitTypeOctet & 0x1f);
// if (nalUnitType == byUnitType) {
// return nalUnitIndex;
// }
// offset = nalUnitOffset;
//
// // Check that we are not too long here
// if (System.currentTimeMillis() - timestamp > 100) {
// Log.w(TAG, "Cannot process data within 100 msec in " + length + " bytes");
// break;
// }
// } else {
// break;
// }
// }
// return -1;
// }
// TODO: Code has a BUG! Sometimes it goes to infinite loop!
public static int searchForH264NalUnitByType(
@NonNull byte[] data,
int offset,
int length,
int byUnitType) {

AtomicInteger nalUnitPrefixSize = new AtomicInteger(-1);
long timestamp = System.currentTimeMillis();

while (true) {
int nalUnitIndex = searchForH264NalUnitStart(data, offset, length, nalUnitPrefixSize);
if (nalUnitIndex >= 0) {
int nalUnitOffset = nalUnitIndex + nalUnitPrefixSize.get();
byte nalUnitTypeOctet = data[nalUnitOffset];
byte nalUnitType = (byte)(nalUnitTypeOctet & 0x1f);
if (nalUnitType == byUnitType) {
return nalUnitIndex;
}
offset = nalUnitOffset;

// Check that we are not too long here
if (System.currentTimeMillis() - timestamp > 100) {
Log.w(TAG, "Cannot process data within 100 msec in " + length + " bytes");
break;
}
} else {
break;
}
}
return -1;
}

// // 00 00 00 01 .. .. .. .. .. .. 00 00 00 01 .. .. .. ..
// // 0 0 0 1 103 66 -128 30 -38 2 -128 -10 -108 -126 -127 1 3 104 80 -102 -128 0 0 0 1 104 -50 6 -30
Expand Down

0 comments on commit 5bf40a2

Please sign in to comment.