Creating a Media Plug-in

From LinuxMCE
Jump to: navigation, search

To create the Media Plug-In, you must

  • Create the DCE Skeleton
  • Implement the methods. at very least, the base plugin subclass, and a media stream subclass.

Implementing DCE Skeleton

First, you must create the appropriate information in the database so that the DCEGen tool can create a C++ skeleton for you. The new templates can be created using the Device Templates menu.

The Necessary DCE Parameters

  • Create a DCE device implemented in C++, make sure to use the category "Media Router Plugins < Plugins for the Router"
  • Plug-ins traditionally have the name of the paired media player and the name "Plug-In" i.e. "MAME Plug-In"
  • Use the following form as a template:
    • This Device is Controlled by Category: DCERouter
    • Is PlugIn should be selected
    • Device Data should have the following added to it:
      • #85 Priority - set a default value of 70, check Allowed to Modify
    • Events should have the following added to it:
      • Playback Info Changed

Once this is done, use DCEGen to create the appropriate devices.

Now that the code is created, you need to implement the following methods:

This is inside MAME_Plugin.h


//<-dceag-d-b->
#ifndef MAME_PlugIn_h
#define MAME_PlugIn_h

//	DCE Implemenation for #1906 MAME Plug-In

#include "Gen_Devices/MAME_PlugInBase.h"
//<-dceag-d-e->

#include "../Media_Plugin/Media_Plugin.h"
#include "../Media_Plugin/MediaStream.h"
#include "../Media_Plugin/MediaHandlerBase.h"

#include "MAMEMediaStream.h"

//<-dceag-decl-b->
namespace DCE
{
	class MAME_PlugIn : public MAME_PlugIn_Command, public MediaHandlerBase
	{
//<-dceag-decl-e->

		pluto_pthread_mutex_t m_MAMEMediaMutex; //protect us from ourselves

//<-dceag-const-b->
public:
		// Constructors/Destructor
		MAME_PlugIn(int DeviceID, string ServerAddress,bool bConnectEventHandler=true,bool bLocalMode=false,class Router *pRouter=NULL);
		virtual ~MAME_PlugIn();
		virtual bool GetConfig();
		virtual bool Register();
		virtual void ReceivedCommandForChild(DeviceData_Impl *pDeviceData_Impl,string &sCMD_Result,Message *pMessage);
		virtual void ReceivedUnknownCommand(string &sCMD_Result,Message *pMessage);
//<-dceag-const-e->

	// Private member variables

	protected:

		class Orbiter_Plugin *m_pOrbiter_Plugin;


	/** Mandatory implementations */

		/**
		* @brief
		*/
		virtual class MediaStream *CreateMediaStream( class MediaHandlerInfo *pMediaHandlerInfo, int iPK_MediaProvider, vector<class EntertainArea *> &vectEntertainArea, MediaDevice *pMediaDevice, int iPK_Users, deque<MediaFile *> *dequeFilenames, int StreamID );

		/**
		* @brief Start media playback
		*/
		virtual bool StartMedia( class MediaStream *pMediaStream,string &sError );

		/**
		* @brief Stop media playback
		*/
		virtual bool StopMedia( class MediaStream *pMediaStream );

		virtual MediaDevice *FindMediaDeviceForEntertainArea(EntertainArea *pEntertainArea);
		/**
		* @brief We need to see all media inserted events so we can start the appropriate media devices
		*/

		MAMEMediaStream *ConvertToMAMEMediaStream(MediaStream *pMediaStream, string callerIdMessage = "");

//<-dceag-h-b->
	/*
				AUTO-GENERATED SECTION
				Do not change the declarations
	*/

	/*
			*****DATA***** accessors inherited from base class
	int DATA_Get_Priority();

			*****EVENT***** accessors inherited from base class
	void EVENT_Playback_Info_Changed(string sMediaDescription,string sSectionDescription,string sSynposisDescription);

			*****COMMANDS***** we need to implement
	*/

//<-dceag-h-e->
	};

//<-dceag-end-b->
}
#endif
//<-dceag-end-e->
//<-dceag-const2-b->!

Some notes here, basically, these are the methods you need to get a working media plugin.

  • continue*