File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ class muxer tracks =
87
87
let pos, frame =
88
88
List. fold_left
89
89
(fun (pos , frame ) { fields; source } ->
90
- let buf = source#get_frame in
90
+ let buf = source#peek_frame in
91
91
( min pos (Frame. position buf),
92
92
List. fold_left
93
93
(fun frame { source_field; target_field; processor } ->
@@ -97,7 +97,10 @@ class muxer tracks =
97
97
(length, Frame. create ~length Frame.Fields. empty)
98
98
tracks
99
99
in
100
- Frame. slice frame pos
100
+ let frame = Frame. slice frame pos in
101
+ let consumed = Frame. position frame in
102
+ List. iter (fun { source } -> source#consumed consumed) tracks;
103
+ frame
101
104
end
102
105
103
106
let muxer_operator p =
Original file line number Diff line number Diff line change @@ -613,6 +613,7 @@ class virtual operator ?pos ?(name = "src") sources =
613
613
consumed < - max consumed (Frame. position data);
614
614
data
615
615
616
+ method consumed n = consumed < - max consumed n
616
617
method get_frame = self#get_partial_frame (fun f -> f)
617
618
618
619
method get_mutable_content field =
Original file line number Diff line number Diff line change @@ -258,12 +258,21 @@ class virtual source :
258
258
that was effectively used. This method is used when a consumer of the source's data
259
259
only uses an initial chunk of the frame. In this case, the remaining data is cached
260
260
whenever possible and returned during the next streaming cycle. Final returned value
261
- is the same as the partial chunk returned for the callback for easy method call chaining. *)
261
+ is the same as the partial chunk returned from the callback for easy method call chaining.
262
+
263
+ Calling this method is equivalent to doing: {[
264
+ let frame = Frame.slice source#peek_frame len in
265
+ source#consumed (Frame.position frame);
266
+ frame
267
+ ]} *)
262
268
method get_partial_frame : (Frame. t -> Frame. t ) -> Frame. t
263
269
264
270
(* * Check a frame without consuming any of its data. *)
265
271
method peek_frame : Frame. t
266
272
273
+ (* * Manually mark amount of consumed data from the source. *)
274
+ method consumed : int -> unit
275
+
267
276
(* * This method requests a specific field of the frame that can be mutated. It is used
268
277
by a consumer of the source that will modify the source's data (e.g. [amplify]). The
269
278
source will do its best to minimize data copy according to the streaming context. Typically,
You can’t perform that action at this time.
0 commit comments