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

Feat/add rtsp support #3677

Merged
merged 17 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ dependencies {
implementation "androidx.media3:media3-exoplayer-dash:$media3_version"
// For HLS playback support with ExoPlayer
implementation "androidx.media3:media3-exoplayer-hls:$media3_version"

implementation "androidx.media3:media3-exoplayer-rtsp:$media3_version"
// For ad insertion using the Interactive Media Ads SDK with ExoPlayer
if (useExoplayerIMA) {
implementation "androidx.media3:media3-exoplayer-ima:$media3_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static androidx.media3.common.C.CONTENT_TYPE_DASH;
import static androidx.media3.common.C.CONTENT_TYPE_HLS;
import static androidx.media3.common.C.CONTENT_TYPE_OTHER;
import static androidx.media3.common.C.CONTENT_TYPE_RTSP;
import static androidx.media3.common.C.CONTENT_TYPE_SS;
import static androidx.media3.common.C.TIME_END_OF_SOURCE;

Expand Down Expand Up @@ -68,6 +69,7 @@
import androidx.media3.exoplayer.ima.ImaAdsLoader;
import androidx.media3.exoplayer.mediacodec.MediaCodecInfo;
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
import androidx.media3.exoplayer.rtsp.RtspMediaSource;
import androidx.media3.exoplayer.smoothstreaming.DefaultSsChunkSource;
import androidx.media3.exoplayer.smoothstreaming.SsMediaSource;
import androidx.media3.exoplayer.source.ClippingMediaSource;
Expand Down Expand Up @@ -792,8 +794,13 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension, DrmSessi
if (uri == null) {
throw new IllegalStateException("Invalid video uri");
}
int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
: uri.getLastPathSegment());
int type;
if ("rtsp".equals(overrideExtension)) {
type = C.TYPE_RTSP;
} else {
type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
: uri.getLastPathSegment());
}
config.setDisableDisconnectError(this.disableDisconnectError);

MediaItem.Builder mediaItemBuilder = new MediaItem.Builder().setUri(uri);
Expand Down Expand Up @@ -836,6 +843,9 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension, DrmSessi
mediaDataSourceFactory
);
break;
case CONTENT_TYPE_RTSP:
mediaSourceFactory = new RtspMediaSource.Factory();
break;
default: {
throw new IllegalStateException("Unsupported type: " + type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ private boolean startsWithValidScheme(String uriString) {
|| lowerCaseUri.startsWith("https://")
|| lowerCaseUri.startsWith("content://")
|| lowerCaseUri.startsWith("file://")
|| lowerCaseUri.startsWith("rtsp://")
|| lowerCaseUri.startsWith("asset://");
}
}
12 changes: 12 additions & 0 deletions examples/basic/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ android {
configurations.all {
resolutionStrategy { force 'androidx.core:core:1.9.0' }
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude("META-INF/*.kotlin_module")
}
}


Expand Down
2 changes: 1 addition & 1 deletion examples/basic/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
5 changes: 5 additions & 0 deletions examples/basic/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ class VideoPlayer extends Component {
'https://proxy.uat.widevine.com/proxy?provider=widevine_test',
},
},
{
description: 'rtsp big bug bunny',
uri: 'rtsp://rtspstream:3cfa3c36a9c00f4aa38f3cd35816b287@zephyr.rtsp.stream/movie',
type: 'rtsp',
}
];

srcList = this.srcAllPlatformList.concat(
Expand Down
2 changes: 1 addition & 1 deletion src/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!uri) {
console.log('Trying to load empty source');
}
const isNetwork = !!(uri && uri.match(/^https?:/));
const isNetwork = !!(uri && uri.match(/^(rtp|rtsp|http|https):/));
const isAsset = !!(
uri &&
uri.match(
Expand Down
Loading