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

[fix] SDP parsing issue #90

Merged

Conversation

minwinmin
Copy link
Contributor

Description

I used a network camera without audio interface.
However, sample app for rtsp-client-android was unable to stream video.

The cause is the failure to parse a SDP line regarding audio.

Problem

I used my network camera, then I can acquire SDP lines below.

[Pair{v 0}, 
Pair{o - 294741794 1 IN IP4 192.168.0.0}, 
Pair{s IGCSMS}, Pair{i }, Pair{t 0 0}, 
Pair{a tool:IGCSMS}, 
Pair{m video 0 RTP/AVP 96}, 
Pair{c IN IP4 192.168.0.0}, 
Pair{b AS:2},
Pair{a rtpmap:96 H264/90000}, 
Pair{a fmtp:96 packetization-mode=1;profile-level-id=64001E;sprop-parameter-sets=Z2QAHqwsaoKAv+WbgICAgQ==,aO4xshs=}, 
Pair{a control:track=1}, 
Pair{m audio 0 RTP/AVP (null)}, 
Pair{c IN IP4 0.0.0.0}, 
Pair{b AS:64}, 
Pair{a rtpmap}, 
Pair{a control:track=2}]

And this line including "(null)" is problem.

Pair{m audio 0 RTP/AVP (null)}, 

The original code cannot parse this line properly.

Changes

I added a exception handling.

if (currentTrack != null) {
    // m=<media> <port>/<number of ports> <proto> <fmt> ...
    String[] values = TextUtils.split(param.second, " ");
    // add this line ↓
    try{
        currentTrack.payloadType = (values.length > 3 ? Integer.parseInt(values[3]) : -1);
    }catch (Exception e){
        currentTrack.payloadType = -1;
    }
    if (currentTrack.payloadType == -1)
    Log.e(TAG, "Failed to get payload type from \"m=" + param.second + "\"");
}

@alexeyvasilyev alexeyvasilyev merged commit d761af9 into alexeyvasilyev:master Nov 18, 2024
@alexeyvasilyev
Copy link
Owner

Thanks for PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants