Commit 789b574b by tonihei Committed by Ian Baker

Use Util method to infer stream type instead of just mime type.

The MediaMetricsListener currently just looks at the mime type and
doesn't use the inference based on the URI if no mime type is set.

Also change default type to OTHER to avoid classifying streams from
URLs without clear file extension as progressive.

PiperOrigin-RevId: 422373381
parent 085042d6
...@@ -40,6 +40,7 @@ import android.util.Pair; ...@@ -40,6 +40,7 @@ import android.util.Pair;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.C.ContentType;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
...@@ -65,7 +66,6 @@ import com.google.android.exoplayer2.source.TrackGroup; ...@@ -65,7 +66,6 @@ import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.upstream.FileDataSource; import com.google.android.exoplayer2.upstream.FileDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.UdpDataSource; import com.google.android.exoplayer2.upstream.UdpDataSource;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.NetworkTypeObserver; import com.google.android.exoplayer2.util.NetworkTypeObserver;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoSize; import com.google.android.exoplayer2.video.VideoSize;
...@@ -636,19 +636,23 @@ public final class MediaMetricsListener ...@@ -636,19 +636,23 @@ public final class MediaMetricsListener
} }
private static int getStreamType(MediaItem mediaItem) { private static int getStreamType(MediaItem mediaItem) {
if (mediaItem.localConfiguration == null || mediaItem.localConfiguration.mimeType == null) { if (mediaItem.localConfiguration == null) {
return PlaybackMetrics.STREAM_TYPE_UNKNOWN; return PlaybackMetrics.STREAM_TYPE_UNKNOWN;
} }
String mimeType = mediaItem.localConfiguration.mimeType; @ContentType
switch (mimeType) { int contentType =
case MimeTypes.APPLICATION_M3U8: Util.inferContentTypeForUriAndMimeType(
mediaItem.localConfiguration.uri, mediaItem.localConfiguration.mimeType);
switch (contentType) {
case C.TYPE_HLS:
return PlaybackMetrics.STREAM_TYPE_HLS; return PlaybackMetrics.STREAM_TYPE_HLS;
case MimeTypes.APPLICATION_MPD: case C.TYPE_DASH:
return PlaybackMetrics.STREAM_TYPE_DASH; return PlaybackMetrics.STREAM_TYPE_DASH;
case MimeTypes.APPLICATION_SS: case C.TYPE_SS:
return PlaybackMetrics.STREAM_TYPE_SS; return PlaybackMetrics.STREAM_TYPE_SS;
case C.TYPE_RTSP:
default: default:
return PlaybackMetrics.STREAM_TYPE_PROGRESSIVE; return PlaybackMetrics.STREAM_TYPE_OTHER;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment