@@ -129,12 +129,14 @@ namespace intrometry::pjmsg_mcap::sink
129129 {
130130 rate_ = 500 ;
131131 id_ = id;
132+ compression_ = Compression::NONE;
132133 }
133134
134135 Parameters::Parameters (const char *id)
135136 {
136137 rate_ = 500 ;
137138 id_ = id;
139+ compression_ = Compression::NONE;
138140 }
139141
140142 Parameters &Parameters::rate (const std::size_t value)
@@ -154,6 +156,12 @@ namespace intrometry::pjmsg_mcap::sink
154156 directory_ = value;
155157 return (*this );
156158 }
159+
160+ Parameters &Parameters::compression (const Compression value)
161+ {
162+ compression_ = value;
163+ return (*this );
164+ }
157165} // namespace intrometry::pjmsg_mcap::sink
158166
159167
@@ -171,7 +179,11 @@ namespace intrometry::pjmsg_mcap::sink
171179 tut::thread::Supervisor<> thread_supervisor_;
172180
173181 public:
174- Implementation (const std::filesystem::path &directory, const std::string &sink_id, const std::size_t rate)
182+ Implementation (
183+ const std::filesystem::path &directory,
184+ const std::string &sink_id,
185+ const std::size_t rate,
186+ const Parameters::Compression compression)
175187 {
176188 names_version_ = intrometry::backend::getRandomUInt32 ();
177189
@@ -193,7 +205,13 @@ namespace intrometry::pjmsg_mcap::sink
193205 intrometry::backend::getDateString (),
194206 " .mcap" );
195207
196- mcap_writer_.initialize (filename, topic_prefix);
208+ // Create writer parameters with the specified compression
209+ pjmsg_mcap_wrapper::Writer::Parameters writer_params;
210+ if (Parameters::Compression::ZSTD == compression)
211+ {
212+ writer_params.compression_ = pjmsg_mcap_wrapper::Writer::Parameters::Compression::ZSTD;
213+ }
214+ mcap_writer_.initialize (filename, topic_prefix, writer_params);
197215
198216 thread_supervisor_.add (
199217 tut::thread::Parameters (
@@ -247,7 +265,7 @@ namespace intrometry::pjmsg_mcap
247265 {
248266 return (false );
249267 }
250- make_pimpl (parameters_.directory_ , parameters_.id_ , parameters_.rate_ );
268+ make_pimpl (parameters_.directory_ , parameters_.id_ , parameters_.rate_ , parameters_. compression_ );
251269 return (true );
252270 }
253271
0 commit comments