127 Commits

Author SHA1 Message Date
michaelkatz
cf3fd1f4dd Added condition to RtspMediaPeriod.isLoading to check RtspState
If a RtspMediaSource is used within a combining source like MergingMediaSource, then it could become stuck in a loop of calling continueLoading when the source has not actually started loading yet.

Issue: androidx/media#577
PiperOrigin-RevId: 561322900
2023-08-30 06:29:53 -07:00
ibaker
9533f5cd1c RtspMediaPeriod: Use a new ExtractorOutput for each SampleQueue
This removes concurrent access from `rtspLoaderWrappers`. Previously
there was a race between the playback thread clearing & re-adding
entries to this list in `retryWithRtpTcp()`, and the loading thread
accessing the entries in `InternalListener.track()` (implemented from
`ExtractorOutput`).

This change means each `ExtractorOutputImpl` uses exactly one
`SampleQueue` for its one `TrackOutput`. When the `RtspLoaderWrapper`
instances are replaced in `retryWithRtpTcp()`, any stale instances will
only be able to access their own (also stale) `SampleQueue` instances
(vs before, where the stale `ExtractorOutput` could accidentally access
'new' `SampleQueue` instances via the `rtspLoaderWrappers` field).

As well as fixing a race condition in the prod code, this also de-flakes
`RtspPlaybackTest`.

#minor-release

PiperOrigin-RevId: 559130479
2023-08-24 09:16:36 +01:00
rohks
481ea4a274 Enhance continueLoading() API to allow passing more information
Modifies the `SequenceableLoader.continueLoading(long)` method in the `SequenceableLoader` interface to `SequenceableLoader.continueLoading(LoadingInfo)`.

`LoadingInfo` contains additional parameters, including `playbackSpeed` and `lastRebufferRealtimeMs` in addition to the existing `playbackPositionUs`. The additional parameters will allow us to pass these information to Common Media Client Data (CMCD) logging.

By using the `LoadingInfo` object, we ensure future flexibility to add more fields without causing any breaking changes to the API.

PiperOrigin-RevId: 555123961
2023-08-10 12:16:41 +00:00
claincly
5ba0ec9b40 Remove stale TODO
It says RTSP doesn't support this in the javadoc.

PiperOrigin-RevId: 551541942
2023-08-01 14:14:34 +01:00
tonihei
3d4bd7ce19 Make MediaItems updateable
This changes all MediaSources in our library to allow updates to
their MediaItems (if supported).

Issue: google/ExoPlayer#9978
Issue: androidx/media#33
PiperOrigin-RevId: 546808812
2023-07-13 15:26:30 +01:00
tonihei
2322462404 Do not trim audio samples by changing their timestamp
MP4 edit lists sometimes ask to start playback between two samples.
If this happens, we currently change the timestamp of the first
sample to zero to trim it (e.g. to display the first frame for a
slightly shorter period of time). However, we can't do this to audio
samples are they have an inherent duration and trimming them this
way is not possible.

#minor-release

PiperOrigin-RevId: 543420218
2023-06-29 22:50:04 +00:00
tonihei
51fb72b00d Replace deprecated NullableType from checkerframework with our own one
The existing NullableType has been deprecated 5 years ago and causes
crashes in Kotlin apps because Kotlin doesn't recognize this annotation
as a nullable type annotation.

While we can't align on a single @Nullable annotation yet, we can at
least replace this one by JSR305's @Nonnull(MAYBE) as it fulfils all
requirements, including full Kotlin compatiblity. To avoid the
cumbersome name, we can redefine it as our own @NullableType
annotation. (We can't use @Nullable to avoid name clashes with the main
@Nullable annotation from AndroidX)

Issue: google/ExoPlayer#6792
PiperOrigin-RevId: 540497469
2023-06-19 16:08:20 +01:00
ibaker
7e6dae7b31 Remove exoplayer2-only javadoc machinery from media3
This introduces whitespace-only changes in exoplayer2 due to the way
copybara stripping works.

PiperOrigin-RevId: 537296933
2023-06-05 09:47:58 +00:00
michaelkatz
85f83b1208 Use base Uri from the RTSP DESCRIBE response header for relative paths
Issue: google/ExoPlayer#11160

#minor-release

PiperOrigin-RevId: 534896789
2023-05-25 09:58:12 +01:00
ibaker
d5f9cf4f19 Add singleVariant publishing config to all published gradle files
Docs:
* https://developer.android.com/build/publish-library/configure-pub-variants#single-pub-var
* https://developer.android.com/reference/tools/gradle-api/8.0/com/android/build/api/dsl/PublishingOptions

This resolves the following warning from Android Gradle Plugin 7.2.2 and
helps unblock the upgrade to AGP 8.0.1:

> Software Components will not be created automatically for Maven
> publishing from Android Gradle Plugin 8.0. To opt-in to the future
> behavior, set the Gradle property
> `android.disableAutomaticComponentCreation=true` in the
> `gradle.properties` file or use the new publishing DSL.
>
> Affected Modules: `lib-cast`, `lib-common`, `lib-container`,
> `lib-database`, `lib-datasource`, `lib-datasource-cronet`,
> `lib-datasource-okhttp`, `lib-datasource-rtmp`, `lib-decoder`,
> `lib-effect`, `lib-exoplayer`, `lib-exoplayer-all (legacy)`,
> `lib-exoplayer-dash`, `lib-exoplayer-hls`, `lib-exoplayer-ima`,
> `lib-exoplayer-rtsp`, `lib-exoplayer-smoothstreaming`,
> `lib-exoplayer-workmanager`, `lib-extractor`, `lib-media2 (legacy)`,
> `lib-mediasession (legacy)`, `lib-muxer`, `lib-session`,
> `lib-transformer`, `lib-ui`, `lib-ui-leanback`, `test-utils`,
> `test-utils-robolectric`

Issue: androidx/media#409
PiperOrigin-RevId: 533464133
2023-05-19 17:22:21 +01:00
ibaker
b3db85133a Add android.namespace to all build.gradle files
This is a pre-requisite for the Android Studio upgrade assistant to
upgrade from AGP 7.2.2 to 8.0.1, otherwise it fails and complains
this is missing.

Issue: androidx/media#409
PiperOrigin-RevId: 533463246
2023-05-19 17:19:15 +01:00
sheenachhabra
e0d6f67dd9 Move NAL unit related methods from common to container module
PiperOrigin-RevId: 532750099
2023-05-17 16:32:46 +01:00
claincly
29fc16484a Handle seek after playback ends
Reusing the loader wrappers allows us to use the current RTSP connection
without having to set up a new RTSP connection. Consequently, the Extractors,
RTP readers are also preserved.

PiperOrigin-RevId: 524663012
2023-04-17 17:14:21 +01:00
michaelkatz
165f4f2fd4 Use default profile-level-id if absent in Describe SDP for MPEG4-LATM
PiperOrigin-RevId: 524003092
2023-04-17 17:00:52 +01:00
sheenachhabra
28aa5e847b Move NAL unit utility classes into common
Need to use NAL unit util methods in muxer module.

PiperOrigin-RevId: 521772831
2023-04-05 15:45:35 +01:00
rohks
766e7d7d35 Add media3 guide entries in README files
PiperOrigin-RevId: 520650881
2023-03-30 17:28:03 +00:00
rohks
6a928805d4 Fix javadoc links in media README files
Also fixed the javadoc link in devsite and removed javadoc links from decoder extensions as it is not published yet on developer.android.com.

#minor-release

PiperOrigin-RevId: 520636868
2023-03-30 17:26:40 +00:00
michaelkatz
ecf4d8b891 Retry RTSP Setup with TCP if response with UDP is UnsupportedTransport
If RTSP Setup Request with UDP receives HTTP Error Status 461 UnsupportedTransport, then client will retry with TCP.

Issue: google/ExoPlayer#11069
PiperOrigin-RevId: 518807829
2023-03-30 17:04:07 +00:00
michaelkatz
a8c87453db Catch IllegalArgumentExceptions in RTSP Response parsing
In parsing Describe RTSP response messages, IllegalArgumentExceptions are thrown for invalid parameters and values. These exceptions were not caught and crashed the Playback thread. Now these exceptions will be caught and their errors forwarded to the proper error handling listeners.

#minor-release

Issue: google/ExoPlayer#10971
PiperOrigin-RevId: 509207881
2023-02-13 14:18:53 +00:00
ibaker
636a4a8538 Add javadoc links to README files
Fix some other link titles and destinations spotted along the way.

#minor-release

PiperOrigin-RevId: 493276172
2022-12-12 11:19:23 +00:00
ibaker
4f04a284ed Add missing IntDef on MediaSource.Factory.getSupportedTypes overrides
Without this the annotation isn't shown in javadoc (same in Dackka)

No annotation:
https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.html#getSupportedTypes()

Annotation present:
https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/source/MediaSource.Factory.html#getSupportedTypes()

#minor-release

PiperOrigin-RevId: 487498450
2022-11-10 14:56:54 +00:00
ibaker
dbfc0cc770 Fix Dackka/Metalava errors in the HLS and RTSP modules
This makes two fixes:
1. Remove `HlsSampleStreamWrapper.Callback` (package-private) from the
   list of interfaces implemented by `HlsMediaPeriod` (`public`) and
   move the implementation to a private inner class instead. This avoids
   Metalava complaining about a public class that inherits from a
   package-private type.
2. Reduce the visibility of
   `RtpPayloadFormat.isFormatSupported(MediaDescription)` from `public`
   to package-private. The `MediaDescription` type is already
   package-private, so this method was already unusable outside the
   package.

#minor-release

PiperOrigin-RevId: 487472781
2022-11-10 14:43:04 +00:00
Rohit Singh
d21c9488df Merge pull request #162 from ittiam-systems:rtp-mp4a-latm
PiperOrigin-RevId: 482490230
2022-10-24 10:49:25 +00:00
Rakesh Kumar
ce98d6da84 Fix review comment in CSD parsing of Mp4a-Latm
Change-Id: I70c412870952e18826f43d218b074b2829127e10
2022-10-04 17:45:59 +05:30
Rakesh Kumar
0ac84fe16f Fix review comment in mp4a-latm Reader
Change-Id: I004f4a9ed9bd7cc48708d82a01c945789d1e9e5e
2022-10-03 17:38:22 +05:30
claincly
b9bcf5224f Fix outdated RtpDataLoadable javadoc
PiperOrigin-RevId: 469443086
2022-09-30 16:59:12 +00:00
claincly
a62cf312b7 Handle initial RTSP seek
PiperOrigin-RevId: 469143613
2022-09-30 16:55:19 +00:00
Rakesh Kumar
9f8d69929d Fix review comment in CSD parsing of Mp4a-Latm Reader
Change-Id: I6fc07d88a7dbc52fc2fbe0e5ad45a53f8f25c4fd
2022-09-30 14:07:27 +05:30
Rakesh Kumar
4880057f92 Fix some more review comment in RTP Mp4a-Latm Reader
Change-Id: I9033d0bd93c6129c64c41ce70fef26bf8a6e4b6e
2022-09-30 14:05:53 +05:30
Rakesh Kumar
97afe69e92 Added support for CSD parsing in RTSP Mp4a-Latm Reader
Added support for parsing CSD data to get sample Rate and Channel
Count.

Change-Id: I69fb0fa2cb11453d3b9e416925d3776eb6dc19a3
2022-09-21 15:37:29 +05:30
Rakesh Kumar
15f9655e9f Added Rtp Mp4a-Latm Reader Test
Change-Id: I0054e54183df0bb9370bf3fe7047076e285e1e8f
2022-09-08 11:22:30 +05:30
Rakesh Kumar
9648529591 Fix review comment in RTP Mp4a-latm Reader
Change-Id: I7c5c12d86589bdc3f88c336573759bcfb0e7ce1b
2022-09-08 11:21:13 +05:30
Rakesh Kumar
048aaf34dc Add support for RTSP Mp4a-Latm
Added Mp4a-latm RTP Packet reader and added support for Mp4a-latm
playback through RTSP.

Change-Id: Ia590393f53ca880af926907843f6bea9ff0f4b35
2022-09-05 00:04:28 +05:30
claincly
80ec64696e Factor out RTP timestamp to sample time method
PiperOrigin-RevId: 465337074
2022-08-04 16:49:03 +00:00
claincly
ed60c885f2 Clean up NOP constructor lines in RTP readers
PiperOrigin-RevId: 465067191
2022-08-03 15:51:48 +00:00
tonihei
92816023f1 Merge pull request #115 from ittiam-systems:rtp_vp9fix
PiperOrigin-RevId: 463852948
2022-08-08 08:23:56 +00:00
claincly
e848352a3e Fix VP8 reader fragment packet size
Merging c37a767fdf

PiperOrigin-RevId: 463826373
2022-08-08 08:21:15 +00:00
tonihei
e54d2f5658 Merge pull request #119 from ittiam-systems:rtp_h263_test_and_fix
PiperOrigin-RevId: 463146426
2022-08-08 08:01:44 +00:00
ibaker
2deb435625 Annotate methods that always return this with @CanIgnoreReturnValue
It's always safe to ignore the result of these methods, because the
caller already has a reference to the returned value.

PiperOrigin-RevId: 462388947
2022-08-08 07:55:25 +00:00
Manisha Jajoo
ef57a061b7 Pass local copy of input to RtpH263ReaderTest's consume method
This change is done to keep the frame data unchanged.
RtpH263Reader changes the header data in input, so to send the same
RTP packet across multiple tests, each test copies the frame data
into a new packet and sends that to the reader.
2022-07-19 11:45:39 +05:30
Manisha Jajoo
c7fbf3437f Revert "Keep the input data constant in consume method"
This reverts commit 3bacb1646c9ecd01e403465c7643888e83a9e79d.
2022-07-19 11:40:01 +05:30
Manisha Jajoo
69a716f633 fix review comments in RtpH263ReaderTest 2022-07-18 10:44:51 +05:30
Manisha Jajoo
3bacb1646c Keep the input data constant in consume method
Earlier, the consume method of RtpH263Reader was changing the bytes of the
input bitstream during header parse. This commit copies the input into
local context and changes the local variable as per the specifications
thus keeping the input constant.
2022-07-18 10:43:41 +05:30
Manisha Jajoo
da47771d10 Add test for Rtp H263 Reader
Change-Id: I57d57881ef5c158d41be1bf1e3714332d50cd3a9
2022-07-14 09:36:32 +05:30
claincly
40fd3ffa6c Fix two typos in RtpVp8Reader and test
PiperOrigin-RevId: 460662425
2022-07-13 17:43:29 +00:00
Rohit Singh
9d9bbe3d33 Merge pull request #110 from ittiam-systems:rtp_vp8_test
PiperOrigin-RevId: 460513413
2022-07-13 17:40:18 +00:00
Manisha Jajoo
a38059d109 Update H263 Reader to handle missing frames/fragments.
Change-Id: I43dfbabcbe686c31cb54e6b95688af1fa35a3d24
2022-07-13 17:46:31 +05:30
Manisha Jajoo
db5ff90167 Update VP9 Reader to handle missing frames/fragments.
Change-Id: I3cdc738b25fda1292ae07769656a3b18721b2402
2022-07-08 17:14:05 +05:30
Shraddha Basantwani
1de4ee3af5 Add RTP VP8 Reader Test
Update VP8 Reader to handle missing frames/fragments.

Change-Id: I9eede8f1e3a20fb0ff2e7add0dfc60f0780ec769
2022-07-06 14:25:14 +05:30
Shraddha Basantwani
ff3d7dff12 Fix VP8 Reader
Update VP8 header to check if the S bit is set.

Variable fragmentedSampleSizeBytes is initialised with -1, and reader
is directly adding fragmentSize to this variable.
Updated it to check if the size is unset.

Bug: 238153477
Test: manual
Change-Id: I9d5735422a4a0eeb2967af93809b879b434e3c57
2022-07-06 14:25:14 +05:30