[ekiga/opal_plugins_hook] Ported the opal plugins hook code to ptlib v2.14's new organisation



commit db4a1e8ff144d999e917bf3552c5628766c4e152
Author: Julien Puydt <julien puydt laposte net>
Date:   Wed Aug 13 17:25:24 2014 +0200

    Ported the opal plugins hook code to ptlib v2.14's new organisation

 lib/engine/components/opal/opal-audio.cpp        |    6 ++
 lib/engine/components/opal/opal-audio.h          |    1 +
 lib/engine/components/opal/opal-plugins-hook.cpp |   86 +++++++---------------
 lib/engine/components/opal/opal-videoinput.cpp   |    6 ++
 lib/engine/components/opal/opal-videoinput.h     |    2 +
 lib/engine/components/opal/opal-videooutput.cpp  |    7 ++
 lib/engine/components/opal/opal-videooutput.h    |    2 +
 7 files changed, 52 insertions(+), 58 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-audio.cpp b/lib/engine/components/opal/opal-audio.cpp
index c3125da..fdbdf76 100644
--- a/lib/engine/components/opal/opal-audio.cpp
+++ b/lib/engine/components/opal/opal-audio.cpp
@@ -40,6 +40,12 @@
 
 #include "opal-audio.h"
 
+PSoundChannel_EKIGA::PSoundChannel_EKIGA()
+{
+  // FIXME: this is due to opal's PFactory design
+  PAssertAlways("This constructor is not to be called");
+}
+
 PSoundChannel_EKIGA::PSoundChannel_EKIGA (boost::shared_ptr<Ekiga::AudioInputCore> _audioinput_core,
                                          boost::shared_ptr<Ekiga::AudioOutputCore> _audiooutput_core):
   audioinput_core (_audioinput_core),
diff --git a/lib/engine/components/opal/opal-audio.h b/lib/engine/components/opal/opal-audio.h
index 62dc17e..ca078d0 100644
--- a/lib/engine/components/opal/opal-audio.h
+++ b/lib/engine/components/opal/opal-audio.h
@@ -48,6 +48,7 @@
 class PSoundChannel_EKIGA : public PSoundChannel {
   PCLASSINFO(PSoundChannel_EKIGA, PSoundChannel); 
 public:
+  PSoundChannel_EKIGA();
   PSoundChannel_EKIGA(boost::shared_ptr<Ekiga::AudioInputCore> audioinput_core,
                      boost::shared_ptr<Ekiga::AudioOutputCore> audiooutput_core);
   PSoundChannel_EKIGA(const PString &device,
diff --git a/lib/engine/components/opal/opal-plugins-hook.cpp 
b/lib/engine/components/opal/opal-plugins-hook.cpp
index e543169..d2851eb 100644
--- a/lib/engine/components/opal/opal-plugins-hook.cpp
+++ b/lib/engine/components/opal/opal-plugins-hook.cpp
@@ -41,18 +41,19 @@
 
 #include "opal-plugins-hook.h"
 
-// we first declare the three plugin service descriptor classes
+// we first declare the three plugin service factory worker classes
 
-class PSoundChannel_EKIGA_PluginServiceDescriptor : public PDevicePluginServiceDescriptor
+class workerSoundChannelEkiga: public PFactory<PSoundChannel>::Worker<PSoundChannel_EKIGA>
 {
 public:
 
-  PSoundChannel_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core):
-    audioinput_core(core.get<Ekiga::AudioInputCore> ("audioinput-core")),
-    audiooutput_core(core.get<Ekiga::AudioOutputCore> ("audiooutput-core"))
+  workerSoundChannelEkiga(Ekiga::ServiceCore& core):
+    PFactory<PSoundChannel>::Worker<PSoundChannel_EKIGA>("EKIGA"),
+    audioinput_core(core.get<Ekiga::AudioInputCore>("audioinput-core")),
+    audiooutput_core(core.get<Ekiga::AudioOutputCore>("audiooutput-core"))
   {}
 
-  virtual PObject* CreateInstance (int) const
+  PFactory<PSoundChannel>::Abstract_T* Create (PFactory<PSoundChannel>::Param_T) const
   {
     // FIXME: if that happens in a thread, that's bad...
     boost::shared_ptr<Ekiga::AudioInputCore> input = audioinput_core.lock ();
@@ -63,60 +64,46 @@ public:
       return NULL;
   }
 
-  virtual PStringArray GetDeviceNames(int) const
-  { return PStringList ("EKIGA"); }
-
-  virtual bool ValidateDeviceName (const PString & deviceName,
-                                  int) const
-  { return deviceName.Find ("EKIGA") == 0; }
-
 private:
   boost::weak_ptr<Ekiga::AudioInputCore> audioinput_core;
   boost::weak_ptr<Ekiga::AudioOutputCore> audiooutput_core;
 };
 
-class PVideoInputDevice_EKIGA_PluginServiceDescriptor : public PDevicePluginServiceDescriptor
+class workerVideoInputDeviceEkiga: public PFactory<PVideoInputDevice>::Worker<PVideoInputDevice_EKIGA>
 {
 public:
 
-  PVideoInputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core):
-    videoinput_core(core.get<Ekiga::VideoInputCore> ("videoinput-core"))
+  workerVideoInputDeviceEkiga(Ekiga::ServiceCore& core):
+    PFactory<PVideoInputDevice>::Worker<PVideoInputDevice_EKIGA>("EKIGA"),
+    videoinput_core(core.get<Ekiga::VideoInputCore>("videoinput-core"))
   {}
 
-  virtual PObject* CreateInstance (int) const
+  PFactory<PVideoInputDevice>::Abstract_T* Create (PFactory<PVideoInputDevice>::Param_T) const
   {
-    // FIXME: if it happens in a thread, that's bad...
-    boost::shared_ptr<Ekiga::VideoInputCore> output = videoinput_core.lock ();
-    if (output)
-      return new PVideoInputDevice_EKIGA (output);
+    // FIXME: if that happens in a thread, that's bad...
+    boost::shared_ptr<Ekiga::VideoInputCore> input = videoinput_core.lock ();
+    if (input)
+      return new PVideoInputDevice_EKIGA (input);
     else
       return NULL;
   }
 
-
-  virtual PStringArray GetDeviceNames (int) const
-  { return PStringList ("EKIGA"); }
-
-  virtual bool ValidateDeviceName (const PString & deviceName,
-                                  int) const
-  { return deviceName.Find ("EKIGA") == 0; }
-
 private:
-
   boost::weak_ptr<Ekiga::VideoInputCore> videoinput_core;
 };
 
-class PVideoOutputDevice_EKIGA_PluginServiceDescriptor : public PDevicePluginServiceDescriptor
+class workerVideoOutputDeviceEkiga: public PFactory<PVideoOutputDevice>::Worker<PVideoOutputDevice_EKIGA>
 {
 public:
 
-  PVideoOutputDevice_EKIGA_PluginServiceDescriptor (Ekiga::ServiceCore& core):
-    videooutput_core(core.get<Ekiga::VideoOutputCore> ("videooutput-core"))
+  workerVideoOutputDeviceEkiga(Ekiga::ServiceCore& core):
+    PFactory<PVideoOutputDevice>::Worker<PVideoOutputDevice_EKIGA>("EKIGA"),
+    videooutput_core(core.get<Ekiga::VideoOutputCore>("videooutput-core"))
   {}
 
-  virtual PObject *CreateInstance (int) const
+  PFactory<PVideoOutputDevice>::Abstract_T* Create (PFactory<PVideoOutputDevice>::Param_T) const
   {
-    // FIXME: if it happens in a thread, that's bad...
+    // FIXME: if that happens in a thread, that's bad...
     boost::shared_ptr<Ekiga::VideoOutputCore> output = videooutput_core.lock ();
     if (output)
       return new PVideoOutputDevice_EKIGA (output);
@@ -124,37 +111,20 @@ public:
       return NULL;
   }
 
-  virtual PStringArray GetDeviceNames (int) const
-  { return PStringList("EKIGA"); }
-
-  virtual bool ValidateDeviceName (const PString & deviceName,
-                                  int) const
-  { return deviceName.Find ("EKIGA") == 0; }
-
 private:
-
   boost::weak_ptr<Ekiga::VideoOutputCore> videooutput_core;
 };
 
 // now, let's rock :
 
-static boost::shared_ptr<PSoundChannel_EKIGA_PluginServiceDescriptor> audio;
-static boost::shared_ptr<PVideoInputDevice_EKIGA_PluginServiceDescriptor> videoinput;
-static boost::shared_ptr<PVideoOutputDevice_EKIGA_PluginServiceDescriptor> videooutput;
+static boost::shared_ptr<workerSoundChannelEkiga> audio;
+static boost::shared_ptr<workerVideoInputDeviceEkiga> videoinput;
+static boost::shared_ptr<workerVideoOutputDeviceEkiga> videooutput;
 
 void
 hook_ekiga_plugins_to_opal (Ekiga::ServiceCore& core)
 {
-  /*
-  audio = boost::shared_ptr<PSoundChannel_EKIGA_PluginServiceDescriptor> (new 
PSoundChannel_EKIGA_PluginServiceDescriptor (core));
-  videoinput = boost::shared_ptr<PVideoInputDevice_EKIGA_PluginServiceDescriptor> (new 
PVideoInputDevice_EKIGA_PluginServiceDescriptor (core));
-  videooutput = boost::shared_ptr<PVideoOutputDevice_EKIGA_PluginServiceDescriptor> (new 
PVideoOutputDevice_EKIGA_PluginServiceDescriptor (core));
-
-  PPluginManager::GetPluginManager().RegisterService ("EKIGA", "PSoundChannel",
-                                                     audio.get ());
-  PPluginManager::GetPluginManager().RegisterService ("EKIGA", "PVideoInputDevice",
-                                                     videoinput.get ());
-  PPluginManager::GetPluginManager().RegisterService ("EKIGA", "PVideoOutputDevice",
-                                                     videooutput.get ());
-  */
+  audio = boost::shared_ptr<workerSoundChannelEkiga> (new workerSoundChannelEkiga(core));
+  videoinput = boost::shared_ptr<workerVideoInputDeviceEkiga> (new workerVideoInputDeviceEkiga(core));
+  videooutput = boost::shared_ptr<workerVideoOutputDeviceEkiga> (new workerVideoOutputDeviceEkiga(core));
 }
diff --git a/lib/engine/components/opal/opal-videoinput.cpp b/lib/engine/components/opal/opal-videoinput.cpp
index 88a8137..8405505 100644
--- a/lib/engine/components/opal/opal-videoinput.cpp
+++ b/lib/engine/components/opal/opal-videoinput.cpp
@@ -40,6 +40,12 @@
 
 int PVideoInputDevice_EKIGA::devices_nbr = 0;
 
+PVideoInputDevice_EKIGA::PVideoInputDevice_EKIGA ()
+{
+  // FIXME: this is due to opal's PFactory design
+  PAssertAlways("This constructor is not to be called");
+}
+
 PVideoInputDevice_EKIGA::PVideoInputDevice_EKIGA (boost::shared_ptr<Ekiga::VideoInputCore> _videoinput_core):
   videoinput_core(_videoinput_core)
 {
diff --git a/lib/engine/components/opal/opal-videoinput.h b/lib/engine/components/opal/opal-videoinput.h
index 17929a0..57bff41 100644
--- a/lib/engine/components/opal/opal-videoinput.h
+++ b/lib/engine/components/opal/opal-videoinput.h
@@ -51,6 +51,8 @@ class PVideoInputDevice_EKIGA : public PVideoInputDevice
 
  public:
 
+  PVideoInputDevice_EKIGA ();
+
   /* DESCRIPTION  :  The constructor.
    * BEHAVIOR     :  Creates the Fake Input Device.
    * PRE          :  /
diff --git a/lib/engine/components/opal/opal-videooutput.cpp b/lib/engine/components/opal/opal-videooutput.cpp
index 5b2fa46..78e33cf 100644
--- a/lib/engine/components/opal/opal-videooutput.cpp
+++ b/lib/engine/components/opal/opal-videooutput.cpp
@@ -47,6 +47,13 @@ int PVideoOutputDevice_EKIGA::devices_nbr = 0;
 PMutex PVideoOutputDevice_EKIGA::videoDisplay_mutex;
 
 /* The Methods */
+
+PVideoOutputDevice_EKIGA::PVideoOutputDevice_EKIGA ()
+{
+  // FIXME: this is due to opal's PFactory design
+  PAssertAlways("This constructor is not to be called");
+}
+
 PVideoOutputDevice_EKIGA::PVideoOutputDevice_EKIGA (boost::shared_ptr<Ekiga::VideoOutputCore> 
_videooutput_core):
   videooutput_core(_videooutput_core)
 {
diff --git a/lib/engine/components/opal/opal-videooutput.h b/lib/engine/components/opal/opal-videooutput.h
index e3e3a0a..5bd72af 100644
--- a/lib/engine/components/opal/opal-videooutput.h
+++ b/lib/engine/components/opal/opal-videooutput.h
@@ -48,6 +48,8 @@ class PVideoOutputDevice_EKIGA : public PVideoOutputDevice
 
   public:
 
+  PVideoOutputDevice_EKIGA ();
+
   /* DESCRIPTION  :  The constructor.
    * BEHAVIOR     :  /
    * PRE          :  /


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]