pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Audio::GstreamerSimplePipeline Class Reference

Base class for gstreamer pipelines. More...

#include <gstreamplayer.h>

Inheritance diagram for Audio::GstreamerSimplePipeline:
Inheritance graph
[legend]

Public Member Functions

 GstreamerSimplePipeline ()
 
virtual ~GstreamerSimplePipeline ()
 

Protected Member Functions

void add (GstElement *element)
 
void throwDeferredException (const GstreamerAudioException &exception, bool asynchronously=false) const
 "Throw" an exception from an asyncrhonous player thread. More...
 
void throwAsyncException (const GstreamerAudioException &exception)
 
void push (GstElement *item)
 Wire an item to the pipeline/filter graph. More...
 
GstElement * createElement (const char *name, const std::string &overrides="")
 Create a gstreamer element and add it to the pipeline/bin, unwired. More...
 
GstState currentPipelineState () const
 Query the pipeline's current state. More...
 
void setPipelineState (GstState state)
 Set the pipeline's state. More...
 

Protected Attributes

GstElement * pipeline
 Filter graph for elements. More...
 
GstElement * chain_start = nullptr
 First item pushed on the stream after setup. More...
 
GstElement * pipeline_last = nullptr
 Last item pushed on the stream. More...
 
std::recursive_mutex state_mutex
 
std::unique_ptr< GstreamerAudioExceptionpipeline_exception
 Asynchronous exception. More...
 

Detailed Description

Base class for gstreamer pipelines.

Constructor & Destructor Documentation

◆ GstreamerSimplePipeline()

Audio::GstreamerSimplePipeline::GstreamerSimplePipeline ( )

◆ ~GstreamerSimplePipeline()

Audio::GstreamerSimplePipeline::~GstreamerSimplePipeline ( )
virtual
Here is the call graph for this function:

Member Function Documentation

◆ add()

void Audio::GstreamerSimplePipeline::add ( GstElement *  element)
protected
Here is the caller graph for this function:

◆ createElement()

GstElement * Audio::GstreamerSimplePipeline::createElement ( const char *  name,
const std::string &  overrides = "" 
)
protected

Create a gstreamer element and add it to the pipeline/bin, unwired.

Parameters
nameThe name of the element.
overridesA user-specified alternate element to use.
Returns
Reference with constructed element.
Exceptions
GstreamerAudioExceptionif the element creation fails.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentPipelineState()

GstState Audio::GstreamerSimplePipeline::currentPipelineState ( ) const
protected

Query the pipeline's current state.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push()

void Audio::GstreamerSimplePipeline::push ( GstElement *  item)
protected

Wire an item to the pipeline/filter graph.

Items are wired in the order they are pushed.

Parameters
itemThe item to insert into to the pipeline.
Exceptions
AudioExceptionif the item can't be linked.
Here is the caller graph for this function:

◆ setPipelineState()

void Audio::GstreamerSimplePipeline::setPipelineState ( GstState  state)
protected

Set the pipeline's state.

We need locking at this point, because the state may be set by a bus message or the pianod main thread. This creates a race condition where an error shuts it down, then pianod requests playback start/resume.

Furthermore, hammering state changes causes Gstreamer to become deranged and deadlock waiting on a condition variable. To avoid this, give the prior state transition a chance to complete.

But as a bonus, some elements only get to READY state; perhaps they need stream data to move on, but we're done and need to tear them down and move on. Whatever, the case, we occasionally need to go ahead with a state change, even if the last one is unfinished. Hence, we have a 1-second timeout for the last state change to finish, before proceeding recklessly with a state change.

Parameters
stateThe new state.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ throwAsyncException()

void Audio::GstreamerSimplePipeline::throwAsyncException ( const GstreamerAudioException exception)
inlineprotected
Here is the call graph for this function:

◆ throwDeferredException()

void Audio::GstreamerSimplePipeline::throwDeferredException ( const GstreamerAudioException exception,
bool  asynchronously = false 
) const
protected

"Throw" an exception from an asyncrhonous player thread.

This stores a copy of the exception for throwing later, when getting the thread's completion status.

Here is the caller graph for this function:

Member Data Documentation

◆ chain_start

GstElement* Audio::GstreamerSimplePipeline::chain_start = nullptr
protected

First item pushed on the stream after setup.

◆ pipeline

GstElement* Audio::GstreamerSimplePipeline::pipeline
protected

Filter graph for elements.

◆ pipeline_exception

std::unique_ptr<GstreamerAudioException> Audio::GstreamerSimplePipeline::pipeline_exception
mutableprotected

Asynchronous exception.

◆ pipeline_last

GstElement* Audio::GstreamerSimplePipeline::pipeline_last = nullptr
protected

Last item pushed on the stream.

◆ state_mutex

std::recursive_mutex Audio::GstreamerSimplePipeline::state_mutex
mutableprotected

The documentation for this class was generated from the following files: