Audacity  2.3.1
Public Member Functions | List of all members
GStreamerImportPlugin Class Referencefinal

An ImportPlugin for GStreamer data. More...

Inheritance diagram for GStreamerImportPlugin:
ImportPlugin

Public Member Functions

 GStreamerImportPlugin ()
 ! Constructor More...
 
virtual ~GStreamerImportPlugin ()
 ! Destructor More...
 
wxString GetPluginFormatDescription ()
 
wxString GetPluginStringID ()
 
wxArrayString GetSupportedExtensions ()
 
std::unique_ptr< ImportFileHandleOpen (const wxString &Filename) override
 ! Probes the file and opens it if appropriate More...
 
- Public Member Functions inherited from ImportPlugin
bool SupportsExtension (const wxString &extension)
 
virtual ~ImportPlugin ()
 

Additional Inherited Members

- Protected Member Functions inherited from ImportPlugin
 ImportPlugin (wxArrayString supportedExtensions)
 
- Protected Attributes inherited from ImportPlugin
wxArrayString mExtensions
 

Detailed Description

An ImportPlugin for GStreamer data.

A representative of GStreamer loader in the Audacity import plugin list

Definition at line 240 of file ImportGStreamer.cpp.

Constructor & Destructor Documentation

GStreamerImportPlugin::GStreamerImportPlugin ( )

! Constructor

Definition at line 318 of file ImportGStreamer.cpp.

319 : ImportPlugin(wxArrayString())
320 {
321 }
ImportPlugin(wxArrayString supportedExtensions)
Definition: ImportPlugin.h:110
GStreamerImportPlugin::~GStreamerImportPlugin ( )
virtual

! Destructor

Definition at line 325 of file ImportGStreamer.cpp.

326 {
327 }

Member Function Documentation

wxString GStreamerImportPlugin::GetPluginFormatDescription ( )
virtual

Implements ImportPlugin.

Definition at line 332 of file ImportGStreamer.cpp.

References DESC.

333 {
334  return DESC;
335 }
#define DESC
wxString GStreamerImportPlugin::GetPluginStringID ( )
virtual

Implements ImportPlugin.

Definition at line 340 of file ImportGStreamer.cpp.

341 {
342  return wxT("gstreamer");
343 }
wxArrayString GStreamerImportPlugin::GetSupportedExtensions ( )
virtual

Reimplemented from ImportPlugin.

Definition at line 348 of file ImportGStreamer.cpp.

References factory, and ImportPlugin::mExtensions.

349 {
350  // We refresh the extensions each time this is called in case the
351  // user had installed additional gstreamer plugins while Audacity
352  // was active.
353  mExtensions.Empty();
354 
355  // Gather extensions from all factories that support audio
356  {
357  std::unique_ptr < GList, Deleter<GList, gst_plugin_feature_list_free> >
358  factories{ gst_type_find_factory_get_list() };
359 
360  for (GList *list = factories.get(); list != NULL; list = g_list_next(list))
361  {
362  GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY(list->data);
363 
364  // We need the capabilities to determine if it handles audio
365  GstCaps *caps = gst_type_find_factory_get_caps(factory);
366  if (!caps)
367  {
368  continue;
369  }
370 
371  // Check each structure in the caps for audio
372  for (guint c = 0, clen = gst_caps_get_size(caps); c < clen; c++)
373  {
374  // Bypass if it isn't for audio
375  GstStructure *str = gst_caps_get_structure(caps, c);
376  if (!g_str_has_prefix(gst_structure_get_name(str), "audio"))
377  {
378  continue;
379  }
380 
381  // This factory can handle audio, so get the extensions
382  const gchar *const *extensions = gst_type_find_factory_get_extensions(factory);
383  if (!extensions)
384  {
385  continue;
386  }
387 
388  // Add each extension to the list
389  for (guint i = 0; extensions[i] != NULL; i++)
390  {
391  wxString extension = wxString::FromUTF8(extensions[i]);
392  if (mExtensions.Index(extension, false) == wxNOT_FOUND)
393  {
394  mExtensions.Add(extension);
395  }
396  }
397  }
398  }
399  }
400 
401  // Get them in a decent order
402  mExtensions.Sort();
403 
404  // Log it for debugging
405  wxString extensions = wxT("Extensions:");
406  for (size_t i = 0; i < mExtensions.GetCount(); i++)
407  {
408  extensions = extensions + wxT(" ") + mExtensions[i];
409  }
410  wxLogMessage(wxT("%s"), extensions);
411 
412  return mExtensions;
413 }
static const AudacityProject::RegisteredAttachedObjectFactory factory
wxArrayString mExtensions
Definition: ImportPlugin.h:115
std::unique_ptr< ImportFileHandle > GStreamerImportPlugin::Open ( const wxString &  Filename)
overridevirtual

! Probes the file and opens it if appropriate

Implements ImportPlugin.

Definition at line 417 of file ImportGStreamer.cpp.

418 {
419  auto handle = std::make_unique<GStreamerImportFileHandle>(filename);
420 
421  // Initialize the handle
422  if (!handle->Init())
423  {
424  return nullptr;
425  }
426 
427  // This std::move is needed to "upcast" the pointer type
428  return std::move(handle);
429 }

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