Skip to content
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

Add support for RTSP H263 #63

Merged
merged 7 commits into from
Jun 16, 2022
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Fix some minor review comments in RTPH263Reader
Change-Id: I0d728c695c9e11c5a50ef6f211bde614df4bbe71
  • Loading branch information
rakeshnitb committed May 9, 2022
commit aae9f23c79fe1e2ea0bc3274b3604c75f91b0dd8
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package androidx.media3.exoplayer.rtsp.reader;

import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.common.util.Util.castNonNull;

import androidx.media3.common.C;
import androidx.media3.common.ParserException;
Expand Down Expand Up @@ -99,9 +98,9 @@ public void consume(ParsableByteArray data, long timestamp, int sequenceNumber,
return;
}

if (pBitIsSet == true) {
if (pBitIsSet) {
int startCodePayload = data.peekUnsignedByte() & 0xfc;
// Packets that begin with a Picture Start Code(100000). Refer RFC4629 Section 6.1.1.
// Packets that begin with a Picture Start Code(100000). Refer RFC4629 Section 6.1.
if (startCodePayload < PICTURE_START_CODE) {
Log.w(TAG, "Picture start Code (PSC) missing, Dropping packet.");
return;
Expand All @@ -125,7 +124,7 @@ public void consume(ParsableByteArray data, long timestamp, int sequenceNumber,
}

if (fragmentedSampleSizeBytes == 0) {
getBufferFlagsAndResolutionFromVop(data, isOutputFormatSet);
parseVopHeader(data, isOutputFormatSet);
if (!isOutputFormatSet && isKeyFrame) {
if (width != payloadFormat.format.width || height != payloadFormat.format.height) {
trackOutput.format(
Expand Down Expand Up @@ -167,14 +166,21 @@ public void seek(long nextRtpTimestamp, long timeUs) {
/**
* Parses VOP Coding type and resolution.
*/
private void getBufferFlagsAndResolutionFromVop(ParsableByteArray data, boolean gotResolution) {
private void parseVopHeader(ParsableByteArray data, boolean gotResolution) {
// Picture Segment Packets (RFC4629 Section 6.1).
// Search for SHORT_VIDEO_START_MARKER (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0).
rakeshnitb marked this conversation as resolved.
Show resolved Hide resolved
int currDataOffset = data.getPosition();
/**
* Parsing short header.
*
* <p> These values are taken from <a
* href=https://cs.android.com/android/platform/superproject/+/master:frameworks/av/media/codecs/m4v_h263/dec/src/mp4def.h;l=115
* >Android's software H263 decoder</a>.
*/
long shortHeader = data.readUnsignedInt();
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the reason to name this shortHeader? It's not of type short and I can't find reference to any 'short' in the RFC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its taken from h263 decoder. Added link for the same in javaDoc.

if ((shortHeader & 0xffff) >> 10 == 0x20) {
if (((shortHeader >> 10) & 0xffff) == 0x20) {
int header = data.peekUnsignedByte();
rakeshnitb marked this conversation as resolved.
Show resolved Hide resolved
int vopType = ((header >> 1) & 0x01);
int vopType = ((header >> 1) & 0x1);
if (!gotResolution && vopType == I_VOP) {
/**
* Parsing resolution from source format.
Expand Down