Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[video_player_android] Add RTSP support #7081

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

beroso
Copy link
Contributor

@beroso beroso commented Jul 9, 2024

Add RTSP support to DataSourceType.network videos on Android platform.

I'm using this patch on my projects and it works well, but I need some feedback if the approach used is correct. If so, I will continue writing the tests.

This PR implements the Android part of this feature request: flutter/flutter#18061 .

I added a RTSP tab on the example app:

screen-20240708-224336.mp4

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@matanlurey matanlurey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory this is trivial and seems OK to do.

Some feedback below. I do not have formal ownership of this plugin, and I'm not sure what our process is for deciding what support is added (versus what support is not, and we ask folks to maintain their own plugin(s)).

@reidbaker thoughts^?

In general I'm supportive, some specific comments left.

@@ -59,6 +61,9 @@ MediaItem getMediaItem() {

@Override
MediaSource.Factory getMediaSourceFactory(Context context) {
if (assetUrl.toLowerCase(Locale.US).startsWith("rtsp://")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the need to do this:

assetUrl.toLowerCase(Locale.US)

We aren't doing a similar massaging for asset or http/s URLs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need be a separate asset, i.e. RtspVideoAsset, and we might want to rename RemoteVideoAsset to HttpVideoAsset accordingly.

When done, this will need a test that verifies that, when rstp:// is passed, the right factory is used:

Starting point: https://github.com/flutter/packages/blob/main/packages/video_player/video_player_android/android/src/test/java/io/flutter/plugins/videoplayer/VideoAssetTest.java.

import androidx.media3.exoplayer.source.DefaultMediaSourceFactory;
import androidx.media3.exoplayer.source.MediaSource;
import java.util.Locale;
import java.util.Map;

final class RemoteVideoAsset extends VideoAsset {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does MIME types work with RSTP?

If they are orthogonal, we will likely want to split this into multiple asset classes.

@camsim99
Copy link
Contributor

Some feedback below. I do not have formal ownership of this plugin, and I'm not sure what our process is for deciding what support is added (versus what support is not, and we ask folks to maintain their own plugin(s)).

@stuartmorgan any thoughts here?

@stuartmorgan
Copy link
Contributor

We generally support formats that the underlying player supports. Unless the added dependency has a substantial code size impact, I don't see any issue here.

@@ -1,3 +1,7 @@
## 2.5.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New features are minor versions in semver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants