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

An ImportPlugin for GStreamer data. More...

Inheritance diagram for GStreamerImportPlugin:
[legend]
Collaboration diagram for GStreamerImportPlugin:
[legend]

Public Member Functions

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

Additional Inherited Members

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

Detailed Description

An ImportPlugin for GStreamer data.

A representative of GStreamer loader in the Audacity import plugin list

Definition at line 234 of file ImportGStreamer.cpp.

Constructor & Destructor Documentation

◆ GStreamerImportPlugin()

GStreamerImportPlugin::GStreamerImportPlugin ( )

! Constructor

Definition at line 313 of file ImportGStreamer.cpp.

314 : ImportPlugin( {} )
315 {
316 }

◆ ~GStreamerImportPlugin()

GStreamerImportPlugin::~GStreamerImportPlugin ( )
virtual

! Destructor

Definition at line 320 of file ImportGStreamer.cpp.

321 {
322 }

Member Function Documentation

◆ GetPluginFormatDescription()

TranslatableString GStreamerImportPlugin::GetPluginFormatDescription ( )
overridevirtual

Implements ImportPlugin.

Definition at line 327 of file ImportGStreamer.cpp.

328 {
329  return DESC;
330 }

References DESC.

◆ GetPluginStringID()

wxString GStreamerImportPlugin::GetPluginStringID ( )
overridevirtual

Implements ImportPlugin.

Definition at line 335 of file ImportGStreamer.cpp.

336 {
337  return wxT("gstreamer");
338 }

◆ GetSupportedExtensions()

FileExtensions GStreamerImportPlugin::GetSupportedExtensions ( )
overridevirtual

Reimplemented from ImportPlugin.

Definition at line 343 of file ImportGStreamer.cpp.

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

References factory, ImportPlugin::mExtensions, and str.

◆ Open()

std::unique_ptr< ImportFileHandle > GStreamerImportPlugin::Open ( const wxString &  Filename,
AudacityProject  
)
overridevirtual

! Probes the file and opens it if appropriate

Implements ImportPlugin.

Definition at line 412 of file ImportGStreamer.cpp.

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

The documentation for this class was generated from the following file:
str
#define str(a)
Definition: DBConnection.cpp:30
ImportPlugin::mExtensions
const FileExtensions mExtensions
Definition: ImportPlugin.h:99
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:820
DESC
#define DESC
Definition: ImportGStreamer.cpp:34
ImportPlugin::ImportPlugin
ImportPlugin(FileExtensions supportedExtensions)
Definition: ImportPlugin.cpp:18