137 void publishEventData(
const std::shared_ptr<GEventDataCollection>& event_data);
147 void publishRunData(
const std::shared_ptr<GRunDataCollection>& run_data);
201 bufferFlushLimit = g->getScalarInt(
"ebuffer");
217 [[nodiscard]]
bool startEvent([[maybe_unused]]
const std::shared_ptr<GEventDataCollection>& event_data) {
219 if (!event_data->getHeader()) {
233 virtual bool startEventImpl([[maybe_unused]]
const std::shared_ptr<GEventDataCollection>& event_data) {
243 [[nodiscard]]
bool endEvent([[maybe_unused]]
const std::shared_ptr<GEventDataCollection>& event_data) {
254 virtual bool endEventImpl([[maybe_unused]]
const std::shared_ptr<GEventDataCollection>& event_data) {
267 [[nodiscard]]
bool publishEventHeader([[maybe_unused]]
const std::unique_ptr<GEventHeader>& gevent_header) {
294 [[maybe_unused]]
const std::vector<const GTrueInfoData*>& trueInfoData) {
295 log->
debug(
NORMAL,
"GStreamer::publishEventTrueInfoData for detector ", detectorName);
307 [[maybe_unused]]
const std::vector<const GTrueInfoData*>& trueInfoData) {
322 [[maybe_unused]]
const std::vector<const GDigitizedData*>& digitizedData) {
323 log->
debug(
NORMAL,
"GStreamer::publishEventDigitizedData for detector ", detectorName);
335 [[maybe_unused]]
const std::vector<const GDigitizedData*>& digitizedData) {
345 [[nodiscard]]
bool startRun([[maybe_unused]]
const std::shared_ptr<GRunDataCollection>& run_data) {
347 if (!run_data->getHeader()) {
361 virtual bool startRunImpl([[maybe_unused]]
const std::shared_ptr<GRunDataCollection>& run_data) {
371 [[nodiscard]]
bool endRun([[maybe_unused]]
const std::shared_ptr<GRunDataCollection>& run_data) {
382 virtual bool endRunImpl([[maybe_unused]]
const std::shared_ptr<GRunDataCollection>& run_data) {
415 [[maybe_unused]]
const std::vector<const GDigitizedData*>& digitizedData) {
416 log->
debug(
NORMAL,
"GStreamer::publishRunDigitizedData for detector ", detectorName);
428 [[maybe_unused]]
const std::vector<const GDigitizedData*>& digitizedData) {
480 [[nodiscard]]
bool publishPayload([[maybe_unused]]
const std::vector<GIntegralPayload*>* payload) {
491 virtual bool publishPayloadImpl([[maybe_unused]]
const std::vector<GIntegralPayload*>* payload) {
return false; }
530 [[nodiscard]]
virtual std::string filename()
const = 0;
533 std::vector<std::shared_ptr<GEventDataCollection>> eventBuffer;
536 size_t bufferFlushLimit = 10;
550 if (!h)
return nullptr;
551 using fptr =
GStreamer* (*)(std::shared_ptr<GOptions>);
553 auto sym = dlsym(h,
"GStreamerFactory");
554 if (!sym)
return nullptr;
556 auto func =
reinterpret_cast<fptr
>(sym);
564 using gstreamersMap = std::unordered_map<std::string, std::shared_ptr<GStreamer>>;
581 inline std::shared_ptr<const gstreamersMap>
gstreamersMapPtr(
const std::shared_ptr<GOptions>& gopts,
582 int thread_id = -1) {
583 auto log = std::make_shared<GLogger>(gopts,
"gstreamersMap worker for thread id" + std::to_string(thread_id),
588 auto gstreamers = std::make_shared<gstreamersMap>();
592 std::string gstreamer_plugin = gstreamer_def_thread.gstreamerPluginName();
596 gstreamers->emplace(gstreamer_plugin, streamer);
std::shared_ptr< GLogger > log
void debug(debug_type type, Args &&... args) const
void error(int exit_code, Args &&... args) const
std::shared_ptr< T > LoadAndRegisterObjectFromLibrary(std::string_view name, const std::shared_ptr< GOptions > &gopts)
Abstract base class for all gstreamer output plugins.
virtual bool publishPayloadImpl(const std::vector< GIntegralPayload * > *payload)
Plugin-specific implementation hook for serializing one frame payload.
bool publishFrameHeader(const GFrameHeader *gframeHeader)
Publish one frame header.
static const std::vector< std::string > & supported_formats()
Return the list of output format tokens supported by the module.
virtual bool startStreamImpl(const GFrameDataCollection *frameRunData)
Plugin-specific implementation hook called at the start of a frame stream record.
bool publishEventDigitizedData(const std::string &detectorName, const std::vector< const GDigitizedData * > &digitizedData)
Publish the digitized hit bank for one detector.
std::string getStreamType() const
Return the semantic stream type associated with this streamer instance.
bool startStream(const GFrameDataCollection *frameRunData)
Begin publishing one frame stream record.
virtual ~GStreamer()=default
Virtual destructor.
void publishEventData(const std::shared_ptr< GEventDataCollection > &event_data)
Queue one event for publication.
virtual bool closeConnectionImpl()
Plugin-specific close implementation hook.
bool publishRunDigitizedData(const std::string &detectorName, const std::vector< const GDigitizedData * > &digitizedData)
Publish run-level digitized data for one detector.
virtual bool publishEventTrueInfoDataImpl(const std::string &detectorName, const std::vector< const GTrueInfoData * > &trueInfoData)
Plugin-specific implementation hook for one detector true-information collection.
bool endRun(const std::shared_ptr< GRunDataCollection > &run_data)
End publishing one run-level collection.
virtual bool endStreamImpl(const GFrameDataCollection *frameRunData)
Plugin-specific implementation hook called at the end of a frame stream record.
void flushEventBuffer()
Flush all buffered events to the backend in publish order.
static bool is_valid_format(const std::string &format)
Validate whether a format token is supported.
bool endEvent(const std::shared_ptr< GEventDataCollection > &event_data)
End publishing one buffered event.
bool publishEventHeader(const std::unique_ptr< GEventHeader > &gevent_header)
Publish the event header for the current event sequence.
void define_gstreamer(const GStreamerDefinition &gstreamerDefinition, int tid=-1)
Assign the output definition used by this streamer instance.
GStreamer(const std::shared_ptr< GOptions > &g)
Construct the streamer base and initialize module logging.
bool startRun(const std::shared_ptr< GRunDataCollection > &run_data)
Begin publishing one run-level collection.
void publishRunData(const std::shared_ptr< GRunDataCollection > &run_data)
Publish one run-level data collection immediately.
virtual bool publishRunDigitizedDataImpl(const std::string &detectorName, const std::vector< const GDigitizedData * > &digitizedData)
Plugin-specific implementation hook for one detector run-level digitized collection.
virtual bool publishRunHeaderImpl(const std::unique_ptr< GRunHeader > &run_header)
Plugin-specific implementation hook for serializing one run header.
GStreamerDefinition gstreamer_definitions
Output definition currently bound to this streamer instance.
bool publishRunHeader(const std::unique_ptr< GRunHeader > &run_header)
Publish the run header for the current run sequence.
virtual bool endEventImpl(const std::shared_ptr< GEventDataCollection > &event_data)
Plugin-specific implementation hook called at the end of one event publish sequence.
virtual bool publishFrameHeaderImpl(const GFrameHeader *gframeHeader)
Plugin-specific implementation hook for serializing one frame header.
bool endStream(const GFrameDataCollection *frameRunData)
End publishing one frame stream record.
virtual bool publishEventHeaderImpl(const std::unique_ptr< GEventHeader > &gevent_header)
Plugin-specific implementation hook for serializing one event header.
bool startEvent(const std::shared_ptr< GEventDataCollection > &event_data)
Begin publishing one buffered event.
virtual bool startEventImpl(const std::shared_ptr< GEventDataCollection > &event_data)
Plugin-specific implementation hook called at the start of one event publish sequence.
static GStreamer * instantiate(const dlhandle h, std::shared_ptr< GOptions > g)
Instantiate a streamer plugin from a dynamic library handle.
virtual bool openConnection()
Open the output medium used by this streamer.
bool publishPayload(const std::vector< GIntegralPayload * > *payload)
Publish one frame payload.
bool publishEventTrueInfoData(const std::string &detectorName, const std::vector< const GTrueInfoData * > &trueInfoData)
Publish the true-information hit bank for one detector.
virtual bool publishEventDigitizedDataImpl(const std::string &detectorName, const std::vector< const GDigitizedData * > &digitizedData)
Plugin-specific implementation hook for one detector digitized collection.
virtual bool startRunImpl(const std::shared_ptr< GRunDataCollection > &run_data)
Plugin-specific implementation hook called at the start of a run publish sequence.
virtual bool endRunImpl(const std::shared_ptr< GRunDataCollection > &run_data)
Plugin-specific implementation hook called at the end of a run publish sequence.
bool closeConnection()
Close the output medium after flushing buffered events.
void set_loggers(const std::shared_ptr< GOptions > &g)
Load streamer runtime settings from the parsed options container.
std::shared_ptr< const gstreamersMap > gstreamersMapPtr(const std::shared_ptr< GOptions > &gopts, int thread_id=-1)
Create a per-thread map of configured streamer instances.
vector< GStreamerDefinition > getGStreamerDefinition(const std::shared_ptr< GOptions > &gopts)
Parse all configured gstreamer output definitions from the options container.
Shared constants and error codes for the gstreamer module.
#define ERR_PUBLISH_ERROR
Publish sequence encountered invalid state or invalid input data.
Option and configuration helpers for the gstreamer module.
constexpr const char * GSTREAMER_LOGGER
Logger category name used by gstreamer components.
std::unordered_map< std::string, std::shared_ptr< GStreamer > > gstreamersMap
Lightweight description of one configured gstreamer output.
std::string type
Semantic output type, typically "event" or "stream".