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

Shall we play any kind of rtsp url by using this ExoPlayer? #9346

Closed
SreeniMannem opened this issue Aug 27, 2021 · 9 comments
Closed

Shall we play any kind of rtsp url by using this ExoPlayer? #9346

SreeniMannem opened this issue Aug 27, 2021 · 9 comments
Assignees

Comments

@SreeniMannem
Copy link

HI Team, I am using this ExoPlayer and try to load and play Rtsp content from different sources. Some of the Rtsp urls are playing properly. But some of the Urls are not playing throwing me "Source error".

If we generate Rtsp url form Rtsp url generator app and/or from other streaming engine portal, it will be working as expected.

But if we generate url from real IP Camera like rtsp://192.168.0.26:554/11, with these kind of urls we are getting Source error and unable to stream.

The same url rtsp://192.168.0.26:554/11 is playing in Android VLC player without fail.
But we want to go with ExoPlayer because it provides extra surface to record the stream, but VLC is not.

Below is the Exception:

ExoPlayerImplInternal: Playback error
ExoPlayerImplInternal: com.google.android.exoplayer2.ExoPlaybackException:
ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:624)
ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:600)
ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:103)
ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:237)
ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:67)
ExoPlayerImplInternal: Caused by: java.net.ConnectException: failed to connect to /192.168.0.26 (port 5540) from /:: (port 46404): connect failed: ECONNREFUSED (Connection refused)
ExoPlayerImplInternal: at libcore.io.IoBridge.connect(IoBridge.java:143)
ExoPlayerImplInternal: at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
ExoPlayerImplInternal: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
ExoPlayerImplInternal: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
ExoPlayerImplInternal: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
ExoPlayerImplInternal: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
ExoPlayerImplInternal: at java.net.Socket.connect(Socket.java:621)
ExoPlayerImplInternal: at java.net.Socket.connect(Socket.java:570)
ExoPlayerImplInternal: at java.net.Socket.(Socket.java:450)
ExoPlayerImplInternal: at java.net.Socket.(Socket.java:218)
ExoPlayerImplInternal: at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:279)
ExoPlayerImplInternal: at com.google.android.exoplayer2.source.rtsp.RtspClient.getSocket(RtspClient.java:248)
ExoPlayerImplInternal: at com.google.android.exoplayer2.source.rtsp.RtspClient.start(RtspClient.java:157)
ExoPlayerImplInternal: at com.google.android.exoplayer2.source.rtsp.RtspMediaPeriod.prepare(RtspMediaPeriod.java:144)
ExoPlayerImplInternal: at com.google.android.exoplayer2.source.MaskingMediaPeriod.prepare(MaskingMediaPeriod.java:145)
ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeUpdateLoadingPeriod(ExoPlayerImplInternal.java:1965)
ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.updatePeriods(ExoPlayerImplInternal.java:1945)
ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:944)
ExoPlayerImplInternal: at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:482)
ExoPlayerImplInternal: ... 3 more
ExoPlayerImplInternal: Caused by: android.system.ErrnoException: connect failed: ECONNREFUSED (Connection refused)
ExoPlayerImplInternal: at libcore.io.Linux.connect(Native Method)
ExoPlayerImplInternal: at libcore.io.ForwardingOs.connect(ForwardingOs.java:95)
ExoPlayerImplInternal: at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:136)
ExoPlayerImplInternal: at libcore.io.ForwardingOs.connect(ForwardingOs.java:95)
ExoPlayerImplInternal: at libcore.io.IoBridge.connectErrno(IoBridge.java:157)
ExoPlayerImplInternal: at libcore.io.IoBridge.connect(IoBridge.java:135)

Not getting exact reason behind this... is there any problem with the Url or ExoPlayer?

Please help me on this, to understand more on Rtsp with ExoPlayer.

Any help is appreciated...

Thanks in advance

@claincly
Copy link
Contributor

ExoPlayer should be able to play the URI. Could you try playing the RTSP link with our demo app? Just change any of the URIs in

https://github.com/google/ExoPlayer/blob/02f7aafe67b4893134a31ea55a3ba0f0535df145/demos/main/src/main/assets/media.exolist.json

to your URI, and run the demo app.

My initial guess: have you set

  <uses-permission android:name="android.permission.INTERNET"/>

in your AndroidManifest.xml?

@SreeniMannem
Copy link
Author

Yes @claincly, i have set <uses-permission android:name="android.permission.INTERNET"/> permission in the AndroidManifest.xml file.

Somehow we are able to resolve the ExoPlayerImplInternal: Caused by: java.net.ConnectException: failed to connect to /192.168.0.26 (port 5540) from /:: (port 46404): connect failed: ECONNREFUSED (Connection refused)

BTW, i have cloned and run this code and provided my Rtsp Url in the media.exolist.json file.

Here the problem comes.

My IP Camera streams in the H.264(video) and PCMA-8 bit(audio) formats. Due to the PCMA audio format, we are unable to build tracks and hence no streaming.

Logs:

RtspClient: a=rtpmap:96 H264/90000
RtspClient: a=rtpmap:8 PCMA/8000/1

RtspClient: rtsp buildTrackList mediaDescription: video, payloadType: 96, com.google.android.exoplayer2.source.rtsp.MediaDescription@8306f1a3, H264
RtspClient: rtsp buildTrackList isFormatSupported and added : rtsp://192.168.0.13:554/11
RtspMediaTrack: rtsp generatePayloadFormat mimeType : video/avc
RtspClient: rtsp buildTrackList mediaDescription: audio, payloadType: 8, com.google.android.exoplayer2.source.rtsp.MediaDescription@1ae565aa, PCMA
RtspClient: rtsp onDescribeResponseReceived tracks.size(): 1

ExoPlayerImplInternal: rtsp IOException PlaybackException.ERROR_CODE_IO_UNSPECIFIED: 
ExoPlayerImplInternal:   com.google.android.exoplayer2.source.rtsp.RtspMediaSource$RtspPlaybackException: com.google.android.exoplayer2.ParserException: url=192.168.0.13/trackID=0;seq=1;rtptime=10000
ExoPlaybackException: rtsp deriveMessage type: 0
ExoPlaybackException: rtsp deriveMessage message: Source error
ExoPlayerImplInternal: rtsp handleIoException playingPeriod is not null
ExoPlayerImplInternal: rtsp Playback error

we did not find any PCMA reader to parse g711-alaw (pcma) related RTP packets and extracts individual samples.

Or else is there any conversion to convert this pcma into our desired AAC and/or AC3 MimeType?

Please suggest the way to overcome this, Thanks in advance!!!

@claincly
Copy link
Contributor

claincly commented Sep 1, 2021

There are two things here -

  1. The player should be able to play your stream without sound. We currently don't have an RTP reader that handles G711 audio. But since we do have a H264 reader, the video should play.
  2. The fail case is in your RTSP PLAY response's Rtp-Info header: url=192.168.0.13/trackID=0;seq=1;rtptime=10000. RTSP spec mandates the url field to be a URL, where yours is missing a rtsp:// prefix. To bypass this check, you can remove the line here:

|| uri.getScheme() == null // Checks if the URI is a URL.

For G711, you need to add an RtpPayloadReader that processes the G711 RTP packets in a way outlined in RFC7655. I am afraid we don't currently have a plan to support it.

@SreeniMannem
Copy link
Author

Hi @claincly, thanks for your tremendous support.
Scenario 1
i have removed the line uri.getScheme() == null // Checks if the URI is a URL

|| uri.getScheme() == null // Checks if the URI is a URL.

After removing this, strange again new issue arrived.

Logs for reference:

ExoPlayerImplInternal: rtsp IOException PlaybackException.ERROR_CODE_IO_UNSPECIFIED:
ExoPlayerImplInternal:   com.google.android.exoplayer2.source.rtsp.RtspMediaSource$RtspPlaybackException: Server did not provide timing for track rtsp://192.168.0.13:554/11/trackID=0
ExoPlayerImplInternal:       at com.google.android.exoplayer2.source.rtsp.RtspMediaPeriod$InternalListener.onPlaybackStarted(RtspMediaPeriod.java:518)
ExoPlayerImplInternal:       at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.onPlayResponseReceived(RtspClient.java:594)
ExoPlaybackException: rtsp deriveMessage message: Source error
ExoPlayerImplInternal: rtsp handleIoException playingPeriod is not null
ExoPlayerImplInternal: rtsp Playback error

"Server did not provide timing for track " + loadInfo.getTrackUri());

If we leave about the Audio, playing video is still nightmare for me.

Scenario 2
We keep this line as it is uri.getScheme() == null // Checks if the URI is a URL
And we are providing the proper url rtsp://192.168.0.13:554/11 to the MediaSource

Even we tried with Authentication, rtsp://xxxx:xxxx@192.168.0.13:554/11, Still same

Logs:

ExoPlayerImplInternal: rtsp IOException PlaybackException.ERROR_CODE_IO_UNSPECIFIED: 
ExoPlayerImplInternal:   com.google.android.exoplayer2.source.rtsp.RtspMediaSource$RtspPlaybackException: com.google.android.exoplayer2.ParserException: url=192.168.1.88/trackID=0;seq=1;rtptime=10000

Could you please let me know how this uri scheme is missing with rtsp:// prefix, may i know we are missing something to form this uri scheme with proper prefix.

Really appreciated your support and need your help!!!

@claincly
Copy link
Contributor

claincly commented Sep 2, 2021

Can you use scenario 1 and comment out line 511-519 of RtspMediaPeriod and see if it plays?

@SreeniMannem
Copy link
Author

Hi @claincly, We are able to see live video in player by commenting the line 511-519 of RtspMediaPeriod code.

All this happens after customizing the ExoPlayer library App.

I have included ExoPlayerLib/2.15.0 in my App and it is not working. So to make it work like this in my App, do i need to make this as library and include in my App or do i need to make changes in the existing calling APIs?

My main requirement is to take direct feed into the player with the given RTSP MediaSource.

Thank you !!!

@claincly
Copy link
Contributor

claincly commented Sep 2, 2021

Sorry I don't understand, if you get it work, it's good then. I'm not sure about the part of "include in my app"?

I think what you mean is how can you keep using the latest version of ExoPlayer and still keep this change?

As an aside, we will be rolling out a patch to support this.

@SreeniMannem
Copy link
Author

"include in my app" - means we have developed an app to stream RTSP and we are trying to use ExoPlayer in this to stream RTSP.

"I think what you mean is how can you keep using the latest version of ExoPlayer and still keep this change?" - YES, you are correct. I wanted to check if there is a way to use latest ExoPlayer libraries and keep this change, so the stream works.

It's great to hear that you are rolling out a patch for this issue, Could you please let me know timeline of the patch release.

Thanks a lot for your help @claincly.

@claincly
Copy link
Contributor

claincly commented Sep 3, 2021

We don't have a rigid timeline for this, but I suspect it'll be out soon.

I would think forking ExoPlayer will be the easiest option. And since this is more of a git-usage issue rather than an ExoPlayer issue, I'll close it for now. Feel free to re-open if you have further questions!

@claincly claincly closed this as completed Sep 3, 2021
@ojw28 ojw28 removed the needs triage label Sep 6, 2021
icbaker pushed a commit that referenced this issue Sep 8, 2021
Some server will send partial URIs in the RTP-Info header, while the RTSP spec
requires absolute URLs.

Issue: #9346

#exofixit

PiperOrigin-RevId: 395452741
christosts pushed a commit that referenced this issue Sep 21, 2021
Some server will send partial URIs in the RTP-Info header, while the RTSP spec
requires absolute URLs.

Issue: #9346

PiperOrigin-RevId: 395452741
@google google locked and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants