mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Migrating to media3 1.4.0
This commit is contained in:
parent
c55c55d775
commit
1a4e94e57a
@ -267,8 +267,8 @@ dependencies {
|
|||||||
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
|
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
|
||||||
}
|
}
|
||||||
if (project.hasProperty('huawei')) huaweiImplementation 'com.huawei.hms:push:6.7.0.300'
|
if (project.hasProperty('huawei')) huaweiImplementation 'com.huawei.hms:push:6.7.0.300'
|
||||||
implementation 'androidx.media3:media3-exoplayer:1.1.1'
|
implementation 'androidx.media3:media3-exoplayer:1.4.0'
|
||||||
implementation 'androidx.media3:media3-ui:1.1.1'
|
implementation 'androidx.media3:media3-ui:1.4.0'
|
||||||
implementation 'org.conscrypt:conscrypt-android:2.5.2'
|
implementation 'org.conscrypt:conscrypt-android:2.5.2'
|
||||||
implementation 'org.signal:aesgcmprovider:0.0.3'
|
implementation 'org.signal:aesgcmprovider:0.0.3'
|
||||||
implementation 'org.webrtc:google-webrtc:1.0.32006'
|
implementation 'org.webrtc:google-webrtc:1.0.32006'
|
||||||
|
@ -83,8 +83,7 @@ public class VideoPlayer extends FrameLayout {
|
|||||||
public void setVideoSource(@NonNull VideoSlide videoSource, boolean autoplay)
|
public void setVideoSource(@NonNull VideoSlide videoSource, boolean autoplay)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT >= 16) setExoViewSource(videoSource, autoplay);
|
setExoViewSource(videoSource, autoplay);
|
||||||
else setVideoViewSource(videoSource, autoplay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause() {
|
public void pause() {
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.video.exo;
|
|
||||||
|
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
|
||||||
import androidx.media3.datasource.DataSource;
|
|
||||||
import androidx.media3.datasource.DataSpec;
|
|
||||||
import androidx.media3.datasource.DefaultDataSource;
|
|
||||||
import androidx.media3.datasource.TransferListener;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@UnstableApi
|
|
||||||
public class AttachmentDataSource implements DataSource {
|
|
||||||
|
|
||||||
private final DefaultDataSource defaultDataSource;
|
|
||||||
private final PartDataSource partDataSource;
|
|
||||||
|
|
||||||
private DataSource dataSource;
|
|
||||||
|
|
||||||
public AttachmentDataSource(DefaultDataSource defaultDataSource, PartDataSource partDataSource) {
|
|
||||||
this.defaultDataSource = defaultDataSource;
|
|
||||||
this.partDataSource = partDataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTransferListener(TransferListener transferListener) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long open(DataSpec dataSpec) throws IOException {
|
|
||||||
if (PartAuthority.isLocalUri(dataSpec.uri)) dataSource = partDataSource;
|
|
||||||
else dataSource = defaultDataSource;
|
|
||||||
|
|
||||||
return dataSource.open(dataSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(byte[] buffer, int offset, int readLength) throws IOException {
|
|
||||||
return dataSource.read(buffer, offset, readLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uri getUri() {
|
|
||||||
return dataSource.getUri();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<String>> getResponseHeaders() {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException {
|
|
||||||
dataSource.close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.video.exo;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
|
||||||
import androidx.media3.datasource.DataSource;
|
|
||||||
import androidx.media3.datasource.DefaultDataSourceFactory;
|
|
||||||
import androidx.media3.datasource.TransferListener;
|
|
||||||
|
|
||||||
|
|
||||||
@UnstableApi
|
|
||||||
public class AttachmentDataSourceFactory implements DataSource.Factory {
|
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
private final DefaultDataSourceFactory defaultDataSourceFactory;
|
|
||||||
private final TransferListener listener;
|
|
||||||
|
|
||||||
public AttachmentDataSourceFactory(@NonNull Context context,
|
|
||||||
@NonNull DefaultDataSourceFactory defaultDataSourceFactory,
|
|
||||||
@Nullable TransferListener listener)
|
|
||||||
{
|
|
||||||
this.context = context;
|
|
||||||
this.defaultDataSourceFactory = defaultDataSourceFactory;
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AttachmentDataSource createDataSource() {
|
|
||||||
return new AttachmentDataSource(defaultDataSourceFactory.createDataSource(),
|
|
||||||
new PartDataSource(context, listener));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.video.exo;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
|
||||||
import androidx.media3.datasource.DataSource;
|
|
||||||
import androidx.media3.datasource.DataSpec;
|
|
||||||
import androidx.media3.datasource.TransferListener;
|
|
||||||
|
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
|
||||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent;
|
|
||||||
import org.thoughtcrime.securesms.mms.PartUriParser;
|
|
||||||
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@UnstableApi
|
|
||||||
public class PartDataSource implements DataSource {
|
|
||||||
|
|
||||||
private final @NonNull Context context;
|
|
||||||
private final @Nullable TransferListener listener;
|
|
||||||
|
|
||||||
private Uri uri;
|
|
||||||
private InputStream inputSteam;
|
|
||||||
|
|
||||||
PartDataSource(@NonNull Context context, @Nullable TransferListener listener) {
|
|
||||||
this.context = context.getApplicationContext();
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addTransferListener(TransferListener transferListener) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long open(DataSpec dataSpec) throws IOException {
|
|
||||||
this.uri = dataSpec.uri;
|
|
||||||
|
|
||||||
AttachmentDatabase attachmentDatabase = DatabaseComponent.get(context).attachmentDatabase();
|
|
||||||
PartUriParser partUri = new PartUriParser(uri);
|
|
||||||
Attachment attachment = attachmentDatabase.getAttachment(partUri.getPartId());
|
|
||||||
|
|
||||||
if (attachment == null) throw new IOException("Attachment not found");
|
|
||||||
|
|
||||||
this.inputSteam = attachmentDatabase.getAttachmentStream(partUri.getPartId(), dataSpec.position);
|
|
||||||
|
|
||||||
if (listener != null) {
|
|
||||||
listener.onTransferStart(this, dataSpec, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attachment.getSize() - dataSpec.position <= 0) throw new EOFException("No more data");
|
|
||||||
|
|
||||||
return attachment.getSize() - dataSpec.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(byte[] buffer, int offset, int readLength) throws IOException {
|
|
||||||
int read = inputSteam.read(buffer, offset, readLength);
|
|
||||||
|
|
||||||
if (read > 0 && listener != null) {
|
|
||||||
listener.onBytesTransferred(this, null, false, read);
|
|
||||||
}
|
|
||||||
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uri getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, List<String>> getResponseHeaders() {
|
|
||||||
return Collections.emptyMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException {
|
|
||||||
inputSteam.close();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user