removeCodec method
Removes a codec from the pipeline at the specified index.
index
The index of the codec to remove.
Returns a new pipeline with the codec removed.
Throws RangeError if index is out of bounds. Throws StateError if trying to remove the last codec in pipeline.
Implementation
CodecPipeline removeCodec(int index) {
if (index < 0 || index >= codecs.length) {
throw RangeError(
'Index $index is out of bounds for pipeline of length ${codecs.length}');
}
if (codecs.length == 1) {
throw StateError('Cannot remove the last codec from pipeline');
}
final newCodecs = [...codecs];
newCodecs.removeAt(index);
return CodecPipeline(newCodecs);
}