Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cc3cd702
authored
Jun 04, 2021
by
claincly
Committed by
bachinger
Jun 08, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add factory method to for using TCP streaming.
#minor-release PiperOrigin-RevId: 377476603
parent
69f9e232
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
9 deletions
RELEASENOTES.md
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMediaPeriod.java
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMediaSource.java
RELEASENOTES.md
View file @
cc3cd702
...
...
@@ -93,6 +93,7 @@
*
GL demo app:
*
Fix texture transformation to avoid green bars shown on some videos
(
[
#8992
](
https://github.com/google/ExoPlayer/issues/8992
)
).
*
Add
`RtspMediaSource.Factory`
option to force using TCP for streaming.
### 2.14.0 (2021-05-13)
...
...
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMediaPeriod.java
View file @
cc3cd702
...
...
@@ -84,7 +84,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private
boolean
prepared
;
private
boolean
trackSelected
;
private
int
portBindingRetryCount
;
private
boolean
hasRetriedWith
RtpTcp
;
private
boolean
isUsing
RtpTcp
;
/**
* Creates an RTSP media period.
...
...
@@ -514,12 +514,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private
LoadErrorAction
handleSocketTimeout
(
RtpDataLoadable
loadable
)
{
// TODO(b/172331505) Allow for retry when loading is not ending.
if
(
getBufferedPositionUs
()
==
Long
.
MIN_VALUE
)
{
// Retry playback with TCP if no sample has been received so far.
if
(!
hasRetriedWithRtpTcp
)
{
if
(!
isUsingRtpTcp
)
{
// Retry playback with TCP if no sample has been received so far, and we are not already
// using TCP. Retrying will setup new loadables, so will not retry with the current
// loadables.
retryWithRtpTcp
();
hasRetriedWith
RtpTcp
=
true
;
isUsing
RtpTcp
=
true
;
}
// Don't retry with the current UDP backed loadables.
return
Loader
.
DONT_RETRY
;
}
...
...
@@ -685,6 +686,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
RtspMediaTrack
mediaTrack
,
int
trackId
,
RtpDataChannel
.
Factory
rtpDataChannelFactory
)
{
this
.
mediaTrack
=
mediaTrack
;
// This listener runs on the playback thread, posted by the Loader thread.
RtpDataLoadable
.
EventListener
transportEventListener
=
(
transport
,
rtpDataChannel
)
->
{
RtpLoadInfo
.
this
.
transport
=
transport
;
...
...
@@ -695,8 +697,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if
(
interleavedBinaryDataListener
!=
null
)
{
rtspClient
.
registerInterleavedDataChannel
(
rtpDataChannel
.
getLocalPort
(),
interleavedBinaryDataListener
);
isUsingRtpTcp
=
true
;
}
maybeSetupTracks
();
};
...
...
library/rtsp/src/main/java/com/google/android/exoplayer2/source/rtsp/RtspMediaSource.java
View file @
cc3cd702
...
...
@@ -63,6 +63,24 @@ public final class RtspMediaSource extends BaseMediaSource {
*/
public
static
final
class
Factory
implements
MediaSourceFactory
{
private
boolean
forceUseRtpTcp
;
/**
* Sets whether to force using TCP as the default RTP transport.
*
* <p>The default value is {@code false}, the source will first try streaming RTSP with UDP. If
* no data is received on the UDP channel (for instance, when streaming behind a NAT) for a
* while, the source will switch to streaming using TCP. If this value is set to {@code true},
* the source will always use TCP for streaming.
*
* @param forceUseRtpTcp Whether force to use TCP for streaming.
* @return This Factory, for convenience.
*/
public
Factory
setForceUseRtpTcp
(
boolean
forceUseRtpTcp
)
{
this
.
forceUseRtpTcp
=
forceUseRtpTcp
;
return
this
;
}
/** Does nothing. {@link RtspMediaSource} does not support DRM. */
@Override
public
Factory
setDrmSessionManagerProvider
(
...
...
@@ -127,7 +145,11 @@ public final class RtspMediaSource extends BaseMediaSource {
@Override
public
RtspMediaSource
createMediaSource
(
MediaItem
mediaItem
)
{
checkNotNull
(
mediaItem
.
playbackProperties
);
return
new
RtspMediaSource
(
mediaItem
);
return
new
RtspMediaSource
(
mediaItem
,
forceUseRtpTcp
?
new
TransferRtpDataChannelFactory
()
:
new
UdpDataSourceRtpDataChannelFactory
());
}
}
...
...
@@ -153,9 +175,9 @@ public final class RtspMediaSource extends BaseMediaSource {
@Nullable
private
ImmutableList
<
RtspMediaTrack
>
rtspMediaTracks
;
@Nullable
private
IOException
sourcePrepareException
;
private
RtspMediaSource
(
MediaItem
mediaItem
)
{
private
RtspMediaSource
(
MediaItem
mediaItem
,
RtpDataChannel
.
Factory
rtpDataChannelFactory
)
{
this
.
mediaItem
=
mediaItem
;
rtpDataChannelFactory
=
new
UdpDataSourceRtpDataChannelFactory
()
;
this
.
rtpDataChannelFactory
=
rtpDataChannelFactory
;
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment