Audacity 3.2.0
Classes | Macros | Typedefs | Functions | Variables
ImportGStreamer.cpp File Reference
#include "../Audacity.h"
#include "ImportGStreamer.h"
#include <wx/window.h>
#include <wx/log.h>
#include "../Tags.h"
#include "../WaveTrack.h"
#include <gst/app/gstappsink.h>
#include <gst/audio/audio-format.h>
Include dependency graph for ImportGStreamer.cpp:

Go to the source code of this file.

Classes

struct  g_mutex_locker
 
struct  Deleter< T, Fn >
 
struct  GStreamContext
 
class  GStreamerImportFileHandle
 ! Does actual import, returned by GStreamerImportPlugin::Open More...
 
class  GStreamerImportPlugin
 An ImportPlugin for GStreamer data. More...
 

Macros

#define DESC   XO("GStreamer-compatible files")
 
#define AUDCTX   "audacity::context"
 
#define GETCTX(o)   (GStreamContext *) g_object_get_data(G_OBJECT((o)), AUDCTX)
 
#define SETCTX(o, c)   g_object_set_data(G_OBJECT((o)), AUDCTX, (gpointer) (c))
 
#define WARN(e, msg)   GST_ELEMENT_WARNING((e), STREAM, FAILED, msg, (NULL));
 

Typedefs

using GstString = std::unique_ptr< gchar, Deleter< void, g_free > >
 
using GErrorHandle = std::unique_ptr< GError, Deleter< GError, g_error_free > >
 
using ParseFn = void(*)(GstMessage *message, GError **gerror, gchar **debug)
 
template<typename T >
using GstObjHandle = std::unique_ptr< T, Deleter< void, gst_object_unref > >
 
using GstCapsHandle = std::unique_ptr< GstCaps, Deleter< GstCaps, GstCapsUnref > >
 

Functions

void GstMessageParse (ParseFn fn, GstMessage *msg, GErrorHandle &err, GstString &debug)
 
static gint GStreamerAutoplugSelectCallback (GstElement *WXUNUSED(element), GstPad *WXUNUSED(pad), GstCaps *WXUNUSED(caps), GstElementFactory *factory, gpointer WXUNUSED(data))
 
static void GStreamerPadAddedCallback (GstElement *WXUNUSED(element), GstPad *pad, gpointer data)
 
static void GStreamerPadRemovedCallback (GstElement *WXUNUSED(element), GstPad *pad, gpointer data)
 
void GstSampleUnref (GstSample *p)
 
static GstFlowReturn GStreamerNewSample (GstAppSink *appsink, gpointer data)
 
void GstCapsUnref (GstCaps *p)
 
void GstMessageUnref (GstMessage *p)
 

Variables

static GstStaticCaps supportedCaps
 
static GstAppSinkCallbacks AppSinkCallbacks
 
static GstAppSinkCallbacks AppSinkBitBucket
 

Macro Definition Documentation

◆ AUDCTX

#define AUDCTX   "audacity::context"

Definition at line 60 of file ImportGStreamer.cpp.

◆ DESC

#define DESC   XO("GStreamer-compatible files")

Definition at line 34 of file ImportGStreamer.cpp.

◆ GETCTX

#define GETCTX (   o)    (GStreamContext *) g_object_get_data(G_OBJECT((o)), AUDCTX)

Definition at line 61 of file ImportGStreamer.cpp.

◆ SETCTX

#define SETCTX (   o,
 
)    g_object_set_data(G_OBJECT((o)), AUDCTX, (gpointer) (c))

Definition at line 62 of file ImportGStreamer.cpp.

◆ WARN

#define WARN (   e,
  msg 
)    GST_ELEMENT_WARNING((e), STREAM, FAILED, msg, (NULL));

Definition at line 63 of file ImportGStreamer.cpp.

Typedef Documentation

◆ GErrorHandle

using GErrorHandle = std::unique_ptr < GError, Deleter<GError, g_error_free> >

Definition at line 109 of file ImportGStreamer.cpp.

◆ GstCapsHandle

using GstCapsHandle = std::unique_ptr < GstCaps, Deleter<GstCaps, GstCapsUnref> >

Definition at line 530 of file ImportGStreamer.cpp.

◆ GstObjHandle

template<typename T >
using GstObjHandle = std::unique_ptr < T, Deleter<void, gst_object_unref > >

Definition at line 154 of file ImportGStreamer.cpp.

◆ GstString

using GstString = std::unique_ptr < gchar, Deleter<void, g_free> >

Definition at line 108 of file ImportGStreamer.cpp.

◆ ParseFn

using ParseFn = void (*)(GstMessage *message, GError **gerror, gchar **debug)

Definition at line 111 of file ImportGStreamer.cpp.

Function Documentation

◆ GstCapsUnref()

void GstCapsUnref ( GstCaps *  p)
inline

Definition at line 529 of file ImportGStreamer.cpp.

529{ gst_caps_unref(p); } // I can't use the static function name directly...

◆ GstMessageParse()

void GstMessageParse ( ParseFn  fn,
GstMessage *  msg,
GErrorHandle err,
GstString debug 
)
inline

Definition at line 112 of file ImportGStreamer.cpp.

113{
114 GError *error;
115 gchar *string;
116 fn(msg, &error, &string);
117 err.reset(error);
118 debug.reset(string);
119}
static const auto fn

References fn.

Referenced by GStreamerImportFileHandle::ProcessBusMessage().

Here is the caller graph for this function:

◆ GstMessageUnref()

void GstMessageUnref ( GstMessage *  p)
inline

Definition at line 1158 of file ImportGStreamer.cpp.

1158{ gst_message_unref(p); }

◆ GStreamerAutoplugSelectCallback()

static gint GStreamerAutoplugSelectCallback ( GstElement *  WXUNUSEDelement,
GstPad *  WXUNUSEDpad,
GstCaps *  WXUNUSEDcaps,
GstElementFactory *  factory,
gpointer   WXUNUSEDdata 
)
static

Definition at line 445 of file ImportGStreamer.cpp.

450{
451 // Check factory class
452 const gchar *fclass = gst_element_factory_get_klass(factory);
453
454 // Skip video decoding
455 if (g_strrstr(fclass,"Video"))
456 {
457 return 2; // GST_AUTOPLUG_SELECT_SKIP
458 }
459
460 return 0; // GST_AUTOPLUG_SELECT_TRY
461}
static RegisteredToolbarFactory factory

References cloud::factory.

Referenced by GStreamerImportFileHandle::Init().

Here is the caller graph for this function:

◆ GStreamerNewSample()

static GstFlowReturn GStreamerNewSample ( GstAppSink *  appsink,
gpointer  data 
)
static

Definition at line 492 of file ImportGStreamer.cpp.

493{
494 // Don't let C++ exceptions propagate through GStreamer
495 return GuardedCall< GstFlowReturn > ( [&] {
497 static GMutex mutex;
498
499 // Get the sample
500 std::unique_ptr < GstSample, Deleter< GstSample, GstSampleUnref> >
501 sample{ gst_app_sink_pull_sample(appsink) };
502
503 // We must single thread here to prevent concurrent use of the
504 // Audacity track functions.
505 g_mutex_locker locker{ mutex };
506
507 handle->OnNewSample(GETCTX(appsink), sample.get());
508
509 return GST_FLOW_OK;
510 }, MakeSimpleGuard(GST_FLOW_ERROR) );
511}
SimpleGuard< R > MakeSimpleGuard(R value) noexcept(noexcept(SimpleGuard< R >{ value }))
Convert a value to a handler function returning that value, suitable for GuardedCall<R>
#define GETCTX(o)
! Does actual import, returned by GStreamerImportPlugin::Open
void OnNewSample(GStreamContext *c, GstSample *sample)

References GETCTX, MakeSimpleGuard(), and GStreamerImportFileHandle::OnNewSample().

Here is the call graph for this function:

◆ GStreamerPadAddedCallback()

static void GStreamerPadAddedCallback ( GstElement *  WXUNUSEDelement,
GstPad *  pad,
gpointer  data 
)
static

Definition at line 466 of file ImportGStreamer.cpp.

469{
470 ((GStreamerImportFileHandle *) data)->OnPadAdded(pad);
471
472 return;
473}

Referenced by GStreamerImportFileHandle::Init().

Here is the caller graph for this function:

◆ GStreamerPadRemovedCallback()

static void GStreamerPadRemovedCallback ( GstElement *  WXUNUSEDelement,
GstPad *  pad,
gpointer  data 
)
static

Definition at line 478 of file ImportGStreamer.cpp.

481{
482 ((GStreamerImportFileHandle *) data)->OnPadRemoved(pad);
483
484 return;
485}

Referenced by GStreamerImportFileHandle::Init().

Here is the caller graph for this function:

◆ GstSampleUnref()

void GstSampleUnref ( GstSample *  p)
inline

Definition at line 489 of file ImportGStreamer.cpp.

489{ gst_sample_unref(p); } // I can't use the static function name directly...

Variable Documentation

◆ AppSinkBitBucket

GstAppSinkCallbacks AppSinkBitBucket
static
Initial value:
=
{
NULL,
NULL,
NULL
}

Definition at line 522 of file ImportGStreamer.cpp.

Referenced by GStreamerImportFileHandle::Import().

◆ AppSinkCallbacks

GstAppSinkCallbacks AppSinkCallbacks
static
Initial value:
=
{
NULL,
NULL,
}
static GstFlowReturn GStreamerNewSample(GstAppSink *appsink, gpointer data)

Definition at line 515 of file ImportGStreamer.cpp.

Referenced by GStreamerImportFileHandle::OnPadAdded().

◆ supportedCaps

GstStaticCaps supportedCaps
static
Initial value:
=
GST_STATIC_CAPS(
GST_AUDIO_CAPS_MAKE(
"{"
GST_AUDIO_NE(S16) ", "
GST_AUDIO_NE(S24_32) ", "
"}"
)
)

Definition at line 74 of file ImportGStreamer.cpp.

Referenced by GStreamerImportFileHandle::OnPadAdded().