FrameVisitor should call .close() ?
ranman opened this issue · 4 comments
Should InternalFrameVisitor call close() to close the implementing frame processors when it reaches an EndSegment ?
I don't think so. MKV streams can have multiple segments in them, so I don't think the frame processors should be closed when a segment end is reached. Are you wanting the frame processor to be notified when a segment boundary is reached?
That makes sense for sure, I phrased my question incorrectly sorry! I'm trying to figure out how I can have various resources get properly closed when I'm done processing a particular stream. I've seen OutputSegmentMerger.java but wasn't really able to figure out how to use that correctly.
I tried making a custom FrameProcessor and adding it to FrameVisitor.create() but .close() is never called on FrameProcessors once the stream is complete.
E.g.
while (streamingMkvReader.mightHaveNext() && !connectExtrasVisitor.isDone()) {
Optional<MkvElement> mkvElementOptional = streamingMkvReader.nextIfAvailable();
if (mkvElementOptional.isPresent()) {
mkvElementOptional.get().accept(myCustomVisitor);
}
}
myCustomVisitor.close();
and in myCustomVisitor
:
private final MyCustomFrameProcessor frameProceessor;
private final FrameVisitor frameVisitor; // set to FrameVisitor.create(new MyCustomFrameProcessor(), ..., ...);
public void close() {
frameProcessor.close();
}
and in MyCustomFrameVisitor
@Overide
public void close() {
// do some stuff
}
But I'm not seeing close ever get called.
I could come up with a full working / reproducible example if needed. But maybe my comments here reveal the dumb things I'm doing and you can push me to the right way of doing things :).
- I assume the last code block is from
MyCustomFrameProcessor
notMyCustomFrameVisitor
, correct? - In
myCustomVisitor
close
method, I think you need to callclose
on theframeVisitor
not theframeProcessor
. The frame visitor will close the frame processor:
- Right - and for some reason I wasn't able to get that call to go through to the frame processor. I tried a few different ways - potentially issues on my end.
I'm going to close this issue and maybe reopen if I can't get things work. Thanks!