IosSafeHttpDataSource: log the bounded DataSpec at open() for diagnosis

vc=17 still 403s even with buildUpon().setLength() bounded ranges.
Add Log.i tracing so we can see the exact position, length, and URL
that ExoPlayer's data-source layer is asking for, and capture inner
HttpDataSource exceptions before they propagate.
This commit is contained in:
Kayos 2026-05-24 14:13:39 -07:00
parent 7d2cf5d9bc
commit 0964de4c2d

View file

@ -21,11 +21,14 @@
package com.sulkta.straw.net
import android.util.Log
import androidx.media3.common.C
import androidx.media3.common.util.UnstableApi
import androidx.media3.datasource.DataSpec
import androidx.media3.datasource.HttpDataSource
private const val TAG = "IosSafeDS"
@UnstableApi
class IosSafeHttpDataSource(
private val inner: HttpDataSource,
@ -57,11 +60,23 @@ class IosSafeHttpDataSource(
// come out as `bytes=N-M` (closed, accepted by googlevideo iOS URLs)
// instead of `bytes=N-` (open, rejected with 403).
val bounded = dataSpec.buildUpon().setLength(requestLen).build()
Log.i(
TAG,
"open: pos=${bounded.position} len=${bounded.length} " +
"(origLen=${dataSpec.length}, chunkBytes=$chunkBytes) " +
"url=${dataSpec.uri.toString().take(120)}",
)
originalSpec = dataSpec
totalRead = 0
// inner.open() returns the BOUNDED chunk's length. Track it so we
// know when to roll to the next chunk.
chunkRemaining = inner.open(bounded)
chunkRemaining = try {
inner.open(bounded)
} catch (t: Throwable) {
Log.w(TAG, "open failed: ${t.javaClass.simpleName}: ${t.message}")
throw t
}
Log.i(TAG, "open: inner returned chunkRemaining=$chunkRemaining")
// Report the original (potentially unbounded) length to the caller —
// ExoPlayer cares about the overall length, not our internal chunking.
return if (dataSpec.length == C.LENGTH_UNSET.toLong()) {