I know that exoplayer has support for RTSP, but I need C++ code that works on players from lots of OSs, so I need to parse the RTP packet in C++ to NAL units before passing to exoplayer
I found a way to decode RTP packets using live555 and extract its NAL units. According to ExoPlayer's documentation:
Components common to all ExoPlayer implementations are:
A MediaSource that defines the media to be played, loads the media, and from which the loaded media can be read.
A MediaSource is injected via ExoPlayer.prepare at the start of playback. ...
So I need a custom MediaSource
that can extract NAL units from my C++ code.
At the class reference for MediaSource we can see that there are already some MediaSource
s available. I though maybe SmoothStreaming MediaSource could work but there's no description of what it does exactly and in its constructor I have to provide an Uri
or an SsManifest
(what).
I can see that there exists a NAL unit utility in this library so maybe things are already half done
So how to build or use an already available MediaSource to read NAL units for ExoPlayer to play?
As an additinal, how would you pass the NAL units from C++ to Java? In the code I found it's simply storing them in a C++ buffer. Should I read this buffer in Java somehow?
UPDATE:
I've been researching how this library works. It all begins with a MediaSource which have objects like Extractor and DataSource. Seems that ExtractorMediaSource is a MediaSource
where you can provide your own Extractor
and DataSource
.
As I understood, DataSource
is a class that gets the raw bytes from any possible place, be it a file read or a network packet. Based on the available Extractor
classes on the library like Mp4Extractor
and Mp3Extractor
, an Extractor
is something that will interpret the data read from DataSource
. The two main methods from the Extractor
interface are:
void init(ExtractorOutput output)
int read(ExtractorInput input, PositionHolder seekPosition)
I don't know what are ExtractorInput
and ExtractorInput
for, but they look important.
So somehow Extractor
reads from DataSource
, parses it and sends to Renderer in a common format?
I need to know how is this common format so I can parse the NAL units that I read from a custom DataSource
.