File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,7 +128,6 @@ function Receiver({ onBack }: { onBack: () => void }) {
128128 useEffect ( ( ) => {
129129 if ( ! stream ) return ;
130130 if ( ! captureRef . current ) captureRef . current = document . createElement ( 'canvas' ) ;
131- let collected = 0 ;
132131
133132 const scan = ( ) => {
134133 const video = videoRef . current ;
@@ -149,13 +148,9 @@ function Receiver({ onBack }: { onBack: () => void }) {
149148 decoderRef . current = new LtDecoder ( frame . k , BLOCK_SIZE ) ;
150149 }
151150 if ( frame . session === metaRef . current . session && decoderRef . current ) {
152- const before = decoderRef . current . solvedCount ;
153151 const done = decoderRef . current . addFrame ( frame . seq , frame . payload ) ;
154- if ( decoderRef . current . solvedCount !== before || decoderRef . current . progress ( ) > 0 ) {
155- collected ++ ;
156- setFrames ( collected ) ;
157- setProgress ( decoderRef . current . progress ( ) ) ;
158- }
152+ setFrames ( decoderRef . current . framesSeen ) ;
153+ setProgress ( decoderRef . current . progress ( ) ) ;
159154 if ( done ) finish ( ) ;
160155 }
161156 }
Original file line number Diff line number Diff line change @@ -127,8 +127,20 @@ export class LtDecoder {
127127 return this . solvedCount >= this . k ;
128128 }
129129
130+ /** Unique frames received so far. */
131+ get framesSeen ( ) : number {
132+ return this . seenSeq . size ;
133+ }
134+
135+ /**
136+ * Collection progress 0..1. LT codes solve almost nothing until they avalanche
137+ * near the end, so reporting solved-blocks looks stuck at 0%. Report frames
138+ * collected vs. the ~k×1.15 typically needed instead (capped below 1 until done).
139+ */
130140 progress ( ) : number {
131- return this . k === 0 ? 1 : this . solvedCount / this . k ;
141+ if ( this . done ) return 1 ;
142+ if ( this . k === 0 ) return 1 ;
143+ return Math . min ( 0.99 , this . framesSeen / ( this . k * 1.15 ) ) ;
132144 }
133145
134146 /** Feed one frame. Returns true once the whole file is solved. */
You can’t perform that action at this time.
0 commit comments