Commit Graph

64 Commits

Author SHA1 Message Date
Profpatsch d134219da5 resolver: document the `audioTrack` setters better 2024-01-07 19:59:09 +01:00
Profpatsch e242ad42a8 getFilteredAudioStreams: Use language and tracktype for grouping
Instead of the `trackId`, which is only ever set for the `youtube`
backend, we use the audio stream language and tracktype. These are
`null` for youtube videos without language selector, leading to a
single audio stream being selected.

For media.ccc.de, the language on audio tracks is always set
correctly, meaning for a video with German and English tracks we get
two groups, which are then sorted according to the preferences of
users.

I verified that youtube still works by playing
https://www.youtube.com/watch?v=8bDRVP9xSfc
and selecting the different audio streams, going to background etc.
and also tried with a video without multiple audio tracks.

For media.ccc.de, it will select the right audio track as well.

Unfortunately, media.ccc.de returns videos with multiple audio track
muxed into the video itself, which is still buggy because the wrong
track is selected by default. This is gonna be fixed/worked around in
the next commit.
2024-01-07 19:35:18 +01:00
Profpatsch 2f529919ab getFilteredAudioStreams: reflow & more docs 2024-01-06 23:58:25 +01:00
Profpatsch 982d23674b getFilteredAudioStreams: make list nonNull 2024-01-06 23:57:42 +01:00
Profpatsch 24ac6d57f3 getFilteredAudioStreams: make trackId more obvious and document bug
Why would you serialize objects to avoid a null check, that’s just
weird.
2024-01-06 21:13:54 +01:00
Profpatsch 743e16a8a7 Quality/AudioTrack: ensure correct indices at construction
Instead of allowing to pass arbitrary out-of-bounds indexes to these
bean classes, ensure that the index is always valid for the list.

This is always true for our filter functions, except they all return
`-1` if the list was empty. We have to check/assert that beforehand.

This improves the logic somewhat, because fetching the stream always
returns something now.

Ideally, we wouldn’t be filtering stuff and then passing indices
around everywhere, but that’s the current state of things.

~~~

I took the liberty to remove the `.of`-wrappers, because they don’t
really add much compared to just calling the constructor here.
2024-01-06 19:09:44 +01:00
Profpatsch e0cbddfe54 getAudioIndexByHighestRank: simplify & make list NonNull 2024-01-06 18:33:48 +01:00
Profpatsch 64c68cf2f1 VideoPlaybackResolver: implicit -1 videoIndex
All functions that set videoIndex return `-1` if the list is empty, so
we don’t have to check manually for that case.

I’m somewhat more questioning why `StreamInfoTag.of` allows the index
to be out-of-bounds in the constructor, that should be an error.
2024-01-06 17:37:17 +01:00
Profpatsch 71d88d0bc0 ListHelper: rename functions & variables and add documentation
This should make the purpose of these functions more clear.
2024-01-06 16:49:49 +01:00
Profpatsch e5ac6824e8 Remove null check on getDefaultSharedPreferences
The function never returns `null`.
2024-01-06 16:49:49 +01:00
Profpatsch 0148d65cab Inline getDefaultResolutionWithDefaultFormat 2024-01-06 16:49:49 +01:00
Stypox e784af3e2d
Merge pull request #10446 from AudricV/dl_improve_video_audio_stream_selection
Improve audio stream selection for video-only streams in the downloader
2023-12-07 16:48:57 +01:00
AudricV e5fda35c51
Remove OPUS HLS streams from playable streams
This format is not supported by ExoPlayer when returned as HLS streams, so we
can't play streams using this format and this delivery method.

Also improve the Javadoc of ListHelper.getPlayableStreams.
2023-11-15 23:37:22 +01:00
AudricV cdb79ef78a
Make isLimitingDataUsage method of ListHelper package-private and fix some typos in the class 2023-09-24 18:23:44 +02:00
TobiGr 19640d5e7c Add documentation to increase maintainablilty
Rename a variable
2023-09-18 01:45:53 +02:00
Edward d1a82a85cd Include a high-resolution option in the default resolution settings. 2023-09-18 01:15:22 +02:00
ThetaDev 22671ca16c fix: audio stream cache key, code fmt 2023-05-01 00:04:04 +02:00
ThetaDev c377ffbce8 Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into alang-selector 2023-04-21 23:32:33 +02:00
ThetaDev b567d428ad fix: small codestyle fixes 2023-04-21 23:15:37 +02:00
TobiGr e18a6b09f8 Apply new itag filter only to YouTube streams 2023-04-17 13:10:29 +02:00
TobiGr f8c3ec4be7 Use a whitelist to filter all streams retrieved by the extractor.
NewPipe Extractor now extracts all YouTube Itags and therefore only those which can be handled by the player need to be retrieved from the list of all available streams.
2023-04-17 13:00:11 +02:00
ThetaDev ed06f559ae feat: add track selection to downloader 2023-03-20 21:41:28 +01:00
ThetaDev fdd3b03fe5 fix: audio stream format selection 2023-03-19 23:47:33 +01:00
ThetaDev dbd6e4d11f fix: sonarcloud lint 2023-03-19 22:55:37 +01:00
ThetaDev 61a14765f3 fix: ListHelper tests 2023-03-19 22:31:31 +01:00
ThetaDev 7aed2eed8a feat: add prefer original option, improve audio stream ordering 2023-03-19 20:40:27 +01:00
ThetaDev 87a88e4df7 feat: localized audio track names 2023-03-19 15:45:52 +01:00
ThetaDev 366c39d4c6 feat: add language selector to audio player 2023-03-19 01:15:36 +01:00
ThetaDev 77649d388c fix: reduce complexity 2023-03-18 16:29:22 +01:00
ThetaDev 208887d538 feat: improve audio track sorting, add prefer_descriptive_audio option 2023-03-18 14:50:19 +01:00
ThetaDev de7872d8f2 feat: add audio language selector 2023-03-17 21:51:40 +01:00
Stypox ebd06bdd24
Improve comment 2022-08-06 11:56:00 +02:00
Isira Seneviratne 059cfcbad2 Use Comparator factory methods in ListHelper. 2022-08-05 05:36:21 +05:30
Stypox f4fe5fcb16
Fix ListHelperTest failure caused by immutable list being used 2022-07-22 16:09:43 +02:00
Isira Seneviratne ca26fcb0eb Use List.of(). 2022-07-20 04:39:11 +05:30
Isira Seneviratne c53143ef4f Use Set.of(). 2022-07-19 08:53:15 +05:30
litetex 8b209df253 Changed the code accordingly
+ Removed some unused code
2022-07-15 19:55:19 +02:00
Stypox 4e87f5aabc
Remove misleading first "Non" from getNonUrlAndNonTorrentStreams 2022-06-18 18:52:32 +02:00
AudricV 036196a487
Filter streams using Java 8 Stream's API instead of removing streams with list iterators and add a better toast when there is no audio stream for external players
This ensures to not remove streams from the StreamInfo lists themselves, and so to not have to create list copies.

The toast shown in RouterActivity, when there is no audio stream available for external players, is now shown, in the same case, when pressing the background button in VideoDetailFragment.
2022-06-17 22:01:29 +02:00
AudricV 210834fbe9
Add support of other delivery methods than progressive HTTP (in the player only)
Detailed changes:

- External players:

  - Add a message instruction about stream selection;
  - Add a message when there is no stream available for external players;
  - Return now HLS, DASH and SmoothStreaming URL contents, in addition to progressive HTTP ones.

- Player:

  - Support DASH, HLS and SmoothStreaming streams for videos, whether they are content URLs or the manifests themselves, in addition to progressive HTTP ones;
  - Use a custom HttpDataSource to play YouTube contents, based of ExoPlayer's default one, which allows better spoofing of official clients (custom user-agent and headers (depending of the client used), use of range and rn (set dynamically by the DataSource) parameters);
  - Fetch YouTube progressive contents as DASH streams, like official clients, support fully playback of livestreams which have ended recently and OTF streams;
  - Use ExoPlayer's default retries count for contents on non-fatal errors (instead of Integer.MAX_VALUE for non-live contents and 5 for live contents).

- Download dialog:

  - Add message about support of progressive HTTP streams only for downloading;
  - Remove several duplicated code and update relevant usages;
  - Support downloading of contents with an unknown media format.

- ListHelper:

  - Catch NumberFormatException when trying to compare two video streams between them.

- Tests:

  - Update ListHelperTest and StreamItemAdapterTest to fix breaking changes in the extractor.

- Other places:

  - Fixes deprecation of changes made in the extractor;
  - Improve some code related to the files changed.

- Issues fixed and/or improved with the changes:

  - Seeking of PeerTube HLS streams (the duration shown was the one from the stream duration and not the one parsed, incomplete because HLS streams are fragmented MP4s with multiple sidx boxes, for which seeking is not supported by ExoPlayer) (the app now uses the HLS manifest returned for each quality, in the master playlist (not fetched and computed by the extractor));
  - Crash when loading PeerTube streams with a separated audio;
  - Lack of some streams on some YouTube videos (OTF streams);
  - Loading times of YouTube streams, after a quality change or a playback start;
  - View count of YouTube ended livestreams interpreted as watching count (this type of streams is not interpreted anymore as livestreams);
  - Watchable time of YouTube ended livestreams;
  - Playback of SoundCloud HLS-only tracks (which cannot be downloaded anymore because the workaround which was used is being removed by SoundCloud, so it has been removed from the extractor).
2022-06-17 22:00:22 +02:00
litetex 7a356412d5
Fixed typo 2022-02-20 19:40:01 +01:00
litetex a489f40b76
Fixed checkstyle problems
Unable to compile!

* Cleaned up ``getMostCompactAudioIndex`` and ``getHighestQualityAudioIndex`` into a new method ``getAudioIndexByHighestRank``
* Removed unreadable code and use Java Streams API
* Tests work as expected
2022-02-20 19:38:40 +01:00
litetex 8ed87e7fbb
Improved ``ListHelper#getSortedStreamVideosList`` 2022-02-20 19:38:40 +01:00
TiA4f8R 79f8270c35
Prefer video-only streams to video streams
Prefering video-only streams to video streams for our player will allow us to make seamless transitions on 360 and 720p qualities on YouTube.
External players and the downloader are not affected by this change.
2022-02-20 19:38:40 +01:00
TiA4f8R 79e98db3bd
Apply the requested changes and little improvements
Apply the requested changes, use ShareUtils.shareText to share an stream in the play queue and optimize imports for Java files, using Android Studio functionality.

Apply the requested changes and do little improvements
Apply the requested changes, use ShareUtils.shareText to share an stream in the play queue and optimize imports for Java files, using Android Studio functionality.
2021-01-16 13:23:42 +01:00
TobiGr 7a8dab2d58 Fix typos 2020-11-22 10:39:00 +01:00
Isira Seneviratne abcacf8c74 Use Comparator's comparing(), nullsLast() and reversed() methods. 2020-11-01 14:44:04 +05:30
Isira Seneviratne 58b720b004 Use ContextCompat.getSystemService() and the Context.getSystemService() extension function. 2020-10-09 08:52:05 +05:30
TacoTheDank ba6c7de35a
Use AndroidX preference 2020-09-06 12:52:42 +02:00
wb9688 87228673b4 Use final where possible 2020-08-16 10:25:09 +02:00