GeckoMediaPlugins: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Created page with "= Gecko Media Plugins (GMPs) = == On Disk Layout == GMPs consist of a directory on disk containing two files, at a minimum: a dynamic library and a meta-data file. The plug...")
 
Line 18: Line 18:
typedef GMPErr (*GMPInitFunc)(void);
typedef GMPErr (*GMPInitFunc)(void);
typedef GMPErr (*GMPGetAPIFunc)(const char* apiName,
typedef GMPErr (*GMPGetAPIFunc)(const char* apiName,
                                    void* apiStruct,
                                void* apiStruct,
                                    size_t structSize);
                                size_t structSize);
typedef void  (*GMPShutdownFunc)(void);
typedef void  (*GMPShutdownFunc)(void);
</pre>
</pre>

Revision as of 16:04, 9 January 2014

Gecko Media Plugins (GMPs)

On Disk Layout

GMPs consist of a directory on disk containing two files, at a minimum: a dynamic library and a meta-data file.

The plugin directory name must start with "gmp-", and the rest of the name will be considered the plugin's "base name." For example - "gmp-foobar" has a base name of "foobar".

The dynamic library's name must be the plugin's base name surrounded by platform conventions for a dynamic library. Given our "foobar" example, this would be "libfoobar.dylib" on OS X, "foobar.dll" on Windows, and "libfoobar.so" on Linux.

The plugin meta-data file is a UTF-8 text file named with ".info" after the plugin base name. Given our "foobar" example, this would be "foobar.info".

The Dynamic Library

The main dynamic library needs to expose three C functions publicly:

typedef GMPErr (*GMPInitFunc)(void);
typedef GMPErr (*GMPGetAPIFunc)(const char* apiName,
                                void* apiStruct,
                                size_t structSize);
typedef void   (*GMPShutdownFunc)(void);

The Meta-Data File

GMP meta data is stored in a UTF-8 text file with platform-appropriate line breaks. Each line is a record. Name, description, version, and capability records are required, in order. An example:

Name: Cisco OpenH264
Description: Provides encoding and decoding of h.264 video via code licensed by Cisco.
Version: 2.1
Capability: encode-video, decode-video

The capability record lists strings used to identify APIs provided by the GMP.

How Gecko Loads a GMP

Gecko scans known locations either on disk or in the Windows registry for GMPs. It maintains a list of known GMPs, and when an API is requested by a consumer it scans the list for a GMP that can provide the API.

Gecko will then spin up a child process for the GMP. GMPs can only be loaded out-of-process, there is no in-process option. Furthermore, child processes may be sandboxed, so GMPs cannot depend on being able to do things outside of the sandbox (like write to disk).

The child process will load the GMP's DLL into the process, then call the publicly exposed GMPInit function. Next Gecko will call the publicly exposed GMPGetAPI function, requesting the desired API data (see the Base API section for more info).

At this point Gecko and the GMP will start doing actual work via the information in the API object. When all consumers are done with the GMP, Gecko will call the publicly exposed GMPShutdown function before closing the child process.

Base API