Skip to content

Commit 8bbf3ba

Browse files
authored
Merge pull request ypresto#29 from spiritedRunning/pull_request
Process specified device sps nal data
2 parents 3c3f60c + 762429e commit 8bbf3ba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/main/java/net/ypresto/androidtranscoder/utils/AvcCsdUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class AvcCsdUtils {
2929
private static final byte[] AVC_START_CODE_4 = {0x00, 0x00, 0x00, 0x01};
3030
// Refer: http://www.cardinalpeak.com/blog/the-h-264-sequence-parameter-set/
3131
private static final byte AVC_SPS_NAL = 103; // 0<<7 + 3<<5 + 7<<0
32+
// https://tools.ietf.org/html/rfc6184
33+
private static final byte AVC_SPS_NAL_2 = 39; // 0<<7 + 1<<5 + 7<<0
34+
private static final byte AVC_SPS_NAL_3 = 71; // 0<<7 + 2<<5 + 7<<0
3235

3336
/**
3437
* @return ByteBuffer contains SPS without NAL header.
@@ -40,9 +43,12 @@ public static ByteBuffer getSpsBuffer(MediaFormat format) {
4043
prefixedSpsBuffer.flip();
4144

4245
skipStartCode(prefixedSpsBuffer);
43-
if (prefixedSpsBuffer.get() != AVC_SPS_NAL) {
46+
47+
byte spsNalData = prefixedSpsBuffer.get();
48+
if (spsNalData != AVC_SPS_NAL && spsNalData != AVC_SPS_NAL_2 && spsNalData != AVC_SPS_NAL_3) {
4449
throw new IllegalStateException("Got non SPS NAL data.");
4550
}
51+
4652
return prefixedSpsBuffer.slice();
4753
}
4854

0 commit comments

Comments
 (0)