Problem
Several functions in src/lib_ccx/file_functions.c rely on the global ccx_options struct for configuration values, specifically:
ccx_options.live_stream
ccx_options.buffer_input
ccx_options.input_source
ccx_options.binary_concat
This creates tight coupling between the demuxer logic and global application state.
Current Behavior
Functions such as:
buffered_read_opt()
switch_to_next_file()
ccx_demuxer_open()
ccx_demuxer_close()
directly access the global ccx_options struct instead of receiving configuration through the demuxer context.
Why This Is Problematic
- Testability — Functions relying on globals are difficult to unit test in isolation.
- Encapsulation — The demuxer's behavior depends on external state it does not own.
- Thread safety — Global state increases the risk of race conditions in multi-threaded scenarios.
- Library reuse — Tight coupling makes
lib_ccx harder to use as a standalone library.
Proposed Solution
- Add
live_stream, buffer_input, input_source, and binary_concat fields to struct ccx_demuxer.
- Initialize these fields from
ccx_options during demuxer initialization (e.g., in init_demuxer()).
- Update affected functions to read configuration from the demuxer context (
ctx->) instead of the global ccx_options.
Affected Files
src/lib_ccx/ccx_demuxer.h
src/lib_ccx/ccx_demuxer.c
src/lib_ccx/file_functions.c
Problem
Several functions in
src/lib_ccx/file_functions.crely on the globalccx_optionsstruct for configuration values, specifically:ccx_options.live_streamccx_options.buffer_inputccx_options.input_sourceccx_options.binary_concatThis creates tight coupling between the demuxer logic and global application state.
Current Behavior
Functions such as:
buffered_read_opt()switch_to_next_file()ccx_demuxer_open()ccx_demuxer_close()directly access the global
ccx_optionsstruct instead of receiving configuration through the demuxer context.Why This Is Problematic
lib_ccxharder to use as a standalone library.Proposed Solution
live_stream,buffer_input,input_source, andbinary_concatfields tostruct ccx_demuxer.ccx_optionsduring demuxer initialization (e.g., ininit_demuxer()).ctx->) instead of the globalccx_options.Affected Files
src/lib_ccx/ccx_demuxer.hsrc/lib_ccx/ccx_demuxer.csrc/lib_ccx/file_functions.c