gstreamer
Loading...
Searching...
No Matches
gstreamer_example.cc File Reference

Multithreaded example showing how to publish events to gstreamer plugins. More...

#include "gstreamer.h"
#include "glogger.h"
#include "gdynamicdigitization.h"
#include "gutilities.h"
#include "gthreads.h"
#include <atomic>
#include <ranges>
#include <vector>
#include <memory>
#include <unordered_map>
Include dependency graph for gstreamer_example.cc:

Go to the source code of this file.

Functions

void run_simulation_in_threads (int nevents, int nthreads, const std::shared_ptr< GLogger > &log, const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > &dynamicRoutinesMap, const std::shared_ptr< GOptions > &gopts)
 Run a synthetic event simulation in multiple worker threads and publish results via gstreamer.
 
int main (int argc, char *argv[])
 

Variables

const std::string plugin_name = "test_gdynamic_plugin"
 

Detailed Description

This example demonstrates a typical flow:

  • Build a shared GOptions instance including gstreamer options via gstreamer::defineOptions().
  • Initialize one gstreamer map per worker thread using gstreamer::gstreamersMapPtr().
  • Open streamer connections inside the worker thread (one streamer instance per thread).
  • Build synthetic event data (true + digitized hits) using gdynamicdigitization routines.
  • Publish events via publishEventData().
  • Close connections at the end (which also flushes any remaining buffered events).

Definition in file gstreamer_example.cc.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 133 of file gstreamer_example.cc.

◆ run_simulation_in_threads()

void run_simulation_in_threads ( int nevents,
int nthreads,
const std::shared_ptr< GLogger > & log,
const std::shared_ptr< const gdynamicdigitization::dRoutinesMap > & dynamicRoutinesMap,
const std::shared_ptr< GOptions > & gopts )

Threading model:

  • A single atomic counter assigns distinct event numbers to workers.
  • Each worker thread owns its own streamer map (no streamer sharing across threads).
  • Each worker publishes events to all configured streamers, relying on the streamer buffering (configured via the ebuffer option).
Parameters
neventsTotal number of events to produce across all threads.
nthreadsNumber of worker threads.
logLogger used for progress and diagnostics.
dynamicRoutinesMapMap of dynamic digitization routines keyed by plugin name.
goptsOptions container used to configure streamers and other modules.

Definition at line 47 of file gstreamer_example.cc.

Variable Documentation

◆ plugin_name

const std::string plugin_name = "test_gdynamic_plugin"

Definition at line 30 of file gstreamer_example.cc.