32 Commits

Author SHA1 Message Date
claincly
1ca0efdd9b Move RtspClient creation into RtspPeriod.
RtspMediaSource uses the timeline update paradigm from ProgressiveMediaPeriod.

#minor-release

PiperOrigin-RevId: 378150758
2021-06-08 16:40:54 +01:00
claincly
d0dc72fb6a Fix TCP retry bug when some RTSP tracks are not selected.
The size of rtspLoaderWrappers must match the number of tracks exposed by the
RTSP session (a track is exposed if its media description entry appears in
DESCRIBE's SDP response).

When retrying with TCP, the old code will start loading all exposed RTSP
tracks, regardless of whether they are selected.
The fixed code will only start loading selected tracks.

#minor-release

PiperOrigin-RevId: 377931030
2021-06-08 13:03:51 +01:00
claincly
efdd55fad5 Propagate duplicated keys error in SDP better.
The current code does not catch the IAE thrown when building a MediaDescription
or SessionDescription. This CL catches the IAE and propagates it as a
ParserException.

Issue: #9014.

#minor-release

PiperOrigin-RevId: 377544439
2021-06-08 13:00:38 +01:00
claincly
95c0c5caa5 Allow TCP retry when using authentication.
The old version's retry logic will not work if using authentication.
Specifically, we use the same authentication parameters from the previous
session, and the RTSP server will reject such parameter.

In this fix, we reset the authentication info on retry. Further, we retry the
last request on receiving a 401 Unauthorized, rather than sending out another
DESCRIBE request.

#minor-release

PiperOrigin-RevId: 377539711
2021-06-08 12:58:39 +01:00
claincly
cc3cd702ff Add factory method to for using TCP streaming.
#minor-release

PiperOrigin-RevId: 377476603
2021-06-08 12:52:21 +01:00
claincly
69f9e23268 Allow reading RTSP message body by Content-Length.
Related to Issue: #8941.

RTSP message body's format is not regulated by the RTSP spec, meaning it can
use either CRLF or LF as its line terminator. The old code assumes every line
ends with CRLF (RTSP message and the message body); the new code will rely on
the Content-Length information to receive the bytes for the message body.

#minor-release

PiperOrigin-RevId: 377475565
2021-06-08 12:51:15 +01:00
claincly
016983ca9a Fallback to generate profile-level-id using H264 SPS if it's missing
Related to: Issue: #9010

Profile-level-id (Format.codecs) can be generated from SPS if SDP does not
include it.

#minor-release

PiperOrigin-RevId: 377251211
2021-06-03 13:53:42 +01:00
olly
d515e2c1f0 Register RTSP module
PiperOrigin-RevId: 377106891
2021-06-03 13:50:37 +01:00
olly
e8ee4e6e6c Add DoNotInstrument annotations to RTSP tests
PiperOrigin-RevId: 377026587
2021-06-02 18:15:47 +01:00
claincly
1dddb8eb1e Allow RtspServer read a RTP dump file.
#minor-release

PiperOrigin-RevId: 377001305
2021-06-02 18:11:27 +01:00
claincly
6d04b998f9 Use more factory method to create ParserException.
ParserException's constructor methods are deprecated.

#minor-release

PiperOrigin-RevId: 376150191
2021-05-27 16:04:10 +01:00
claincly
4f59394f51 Use factory method to create ParserException.
ParserException's constructor methods are deprecated.

#minor-release

PiperOrigin-RevId: 376127494
2021-05-27 16:01:38 +01:00
claincly
0fb5fa75cf Support basic and digest authentication.
Authentication sequence in RTSP:

- Server replies "Unauthorized" to our DESCRIBE request, and includes the
  necessary information (i.e. realm, digest nonce, etc) in WWW-Authenticate
  header

- After `RtspClient` receives the response, we

  - Parse the WWW-Authenticate header, stores the auth info. The info is saved
    for all further RTSP requests (that all need to carry authorization headers)
  - send the second DESCRIBE request with the Authorization header.

#minor-release

PiperOrigin-RevId: 376116302
2021-05-27 10:47:18 +01:00
olly
ee2af43a54 Fix file formatting
PiperOrigin-RevId: 375919564
2021-05-27 10:40:54 +01:00
claincly
614f9d8d55 Rename RtspMessageChannel.openSocket() to open().
The method openSocket in RtspMessageChannel does not actually open a socket.
The 'open' term refers more to opening the message channel.

#minor-release

PiperOrigin-RevId: 375908999
2021-05-27 10:38:56 +01:00
claincly
cfb90e4b70 Remove the default RTSP message handling off playback thread.
The callbacks received RTSP messages and RTSP sending errors are now invoked
directly from RtspMessageChannel's internal threads. It's up to the handler
implementation to decide which thread to handle the messages.

#minor-release

PiperOrigin-RevId: 375908282
2021-05-27 10:38:17 +01:00
claincly
68b2875a42 Move RTP packet forwarding off playback thread.
Previously, RTSP interleaved binary data is posted onto the playback thread
for handling, the playback thread then adds the received data to a queue.
A loader thread will later dequeue the data and process it.

In this CL, the binary data is sent through a separate listener, on
RtspMessageChannel's RTSP receiving thread.

#minor-release

PiperOrigin-RevId: 375907609
2021-05-27 10:37:39 +01:00
claincly
4a780fb90a Allow RtspHeaders to take multiple header values under the same name.
Some RTSP servers will offer multiple WWW-Authenticate options. We wanted to
be able to pick them up.

#minor-release

PiperOrigin-RevId: 375907276
2021-05-27 10:37:00 +01:00
claincly
e383b0031d Define the default RTSP character set.
#minor-release

PiperOrigin-RevId: 374433331
2021-05-19 20:24:04 +01:00
claincly
497eb72c35 Remove RTSP message logging.
#minor-release

PiperOrigin-RevId: 373336127
2021-05-12 11:53:55 +01:00
claincly
fe74f690ec Allow RTSP streaming using TCP.
NAT will block off incoming UDP connection because the router has no knowledge
of the necessary port mapping (the mapping is never set up because UDP is
connectionless).

The end result is, the UDP socket to receive RTP data will timeout. After the
`SocketTimeoutException` is caught, the following takes place to try streaming
with TCP (or, RTP over RTSP).

- `RtspClient` sends TEARDOWN to tear down the current session.
- `RtspClient` re-connect to the RTSP server.
- `RtspMediaPeriod` cancels all loading `RtpDataLoadables` (that are using UDP)
- `RtspMediaPeriod` constructs new `RtpDataLoadables` that use
    `TransferRtpDataChannel`, and starts loading.
- Once the `RtpDataLoadables` are up and running, we are ready to receive.
  `RtspClient` sends the SETUP requests.

- The rest of the flow is unchanged.

#minor-release

PiperOrigin-RevId: 373310774
2021-05-12 11:53:14 +01:00
claincly
beeb6e829d Enable reading interleaved message in RtspMessageChannel.
RTSP interleaving enables RTP packets to be sent using RTSP's TCP connection.
The interleaving RTSP messages contain binary data only and always start with a
'$'. Normal RTSP messages contain line breaks (CRLFs) that indicate complete
lines.

#minor-release

PiperOrigin-RevId: 372990181
2021-05-10 23:42:31 +01:00
olly
01f85394d2 Clean up RtspMediaSource.Factory
- Don't deprecate methods not deprecated in the base class and that
  could one day be useful.
- Better document deprecation of other methods.

#minor-release

PiperOrigin-RevId: 372919080
2021-05-10 23:39:45 +01:00
olly
782c1739c8 Use correct Log class
#minor-release

PiperOrigin-RevId: 372314890
2021-05-06 13:35:40 +01:00
bachinger
4c1a294b2e Format Java source files
PiperOrigin-RevId: 372127633
2021-05-06 13:32:25 +01:00
claincly
4bf7477e3e Flatten packages within the RTSP package.
#minor-release

PiperOrigin-RevId: 371337762
2021-04-30 18:56:17 +01:00
claincly
dfb87638e7 Introduce RtpDataChannel interface.
#minor-release

PiperOrigin-RevId: 371326814
2021-04-30 18:55:59 +01:00
claincly
4eccc0356c Allow retry opening RTP ports.
In RtpDataLoadable.load, the second UDP data source is opened on the port we
specify. If the port is already in use, a BindException is thrown.

#minor-release

PiperOrigin-RevId: 371319522
2021-04-30 18:55:42 +01:00
claincly
537e8aadd5 Allow the extractor deplete the reordering queue as much as possible.
#minor-release

PiperOrigin-RevId: 370673852
2021-04-27 17:42:54 +01:00
claincly
13a34b8b4a Relax session timing requirement.
Some RTSP servers do not include the RANGE attribute for live contents.

#minor-release

PiperOrigin-RevId: 370662587
2021-04-27 17:42:23 +01:00
claincly
bf04bb5bc0 Fix that loadingFinished is never set to true.
Previously loadingFinished will never be set to true because it started in
false, and we are and'ing it with `canceled`.

#minor-release

PiperOrigin-RevId: 370662456
2021-04-27 17:42:09 +01:00
claincly
8135b9c273 Publish ExoPlayer's support for RTSP.
Allow ExoPlayer to open URIs starting with rtsp://

PiperOrigin-RevId: 370653248
2021-04-27 17:41:38 +01:00