]> git.vomp.tv Git - vompclient.git/commitdiff
Screenshot support for vector based osd on raspberry pi
authorMarten Richter <marten.richter@freenet.de>
Sun, 5 Oct 2014 10:43:06 +0000 (12:43 +0200)
committerMarten Richter <marten.richter@freenet.de>
Sun, 5 Oct 2014 10:43:06 +0000 (12:43 +0200)
command.cc
main.cc
osdopenvg.cc
osdopenvg.h
osdvector.cc
osdvector.h

index f9f894611067fc387ba5ea80fe6edf24dda025dc..4c41ce13558317cfd8203fd22ed245f8a3aa4a28 100644 (file)
@@ -417,7 +417,12 @@ void Command::processMessage(Message* m)
       }
       case Message::SCREENSHOT:
       {
+#ifdef VOMP_PLATTFORM_MVP
         Osd::getInstance()->screenShot("/out.jpg");
+#else
+        logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
+        Osd::getInstance()->screenShot("out.jpg");
+#endif
         break;
       }
       case Message::CONNECTION_LOST:
diff --git a/main.cc b/main.cc
index 360eea6c5a1362ddb7cf6c990fcabbc1806be90f..b8d193a2321c99f5642c9e3f92aded403ecfdd39 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -429,6 +429,7 @@ void sighandler(int signalReceived)
     }
     case SIGUSR1:
     {
+      logger->log("Core", Log::NOTICE, "USR1 signal, screenshot...");
       command->sig1();
       break;
     }
index 86d2dc44ba54d158569ee02c10a4028ff92aee0e..ca67d8d401030e4d9bc1344c8967498ae8fad8eb 100644 (file)
@@ -328,6 +328,41 @@ void OsdOpenVG::getScreenSize(int &width, int &height)
        height=BACKBUFFER_HEIGHT;
 }
 
+void OsdOpenVG::getRealScreenSize(int &width, int &height)
+{
+       width=display_width;
+       height=display_height;
+}
+
+bool OsdOpenVG::screenShot(void *buffer, int width, int height, bool osd /*include osd*/)
+{
+       if (!initted) return false;
+       if (!buffer) return false;
+
+       DISPMANX_RESOURCE_HANDLE_T res;
+       DISPMANX_DISPLAY_HANDLE_T display;
+
+       uint32_t image_ptr;
+       VC_RECT_T rect;
+       res=vc_dispmanx_resource_create(VC_IMAGE_RGBA32,width,height,&image_ptr);
+       display=vc_dispmanx_display_open(0);
+       if (!osd ) {
+               vc_dispmanx_snapshot(display, res,
+                               (DISPMANX_TRANSFORM_T)(DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL/*|DISPMANX_SNAPSHOT_PACK*/));
+       }
+       else
+       {
+               vc_dispmanx_snapshot(display, res,
+                               (DISPMANX_TRANSFORM_T)(DISPMANX_SNAPSHOT_FILL));
+       }
+       vc_dispmanx_rect_set(&rect,0,0,width,height);
+       vc_dispmanx_resource_read_data(res, &rect, buffer, width*4);
+       vc_dispmanx_resource_delete(res);
+       vc_dispmanx_display_close(display);
+       return true;
+
+}
+
 
 void OsdOpenVG::initPaths()
 {
index 49fdfe60d90682e6070b357d74f7b122ccc2a51b..cd21c3d0f454263646014742d9ea8445fcd61e49 100644 (file)
@@ -86,6 +86,7 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE, public EGLPictureCreator
     int shutdown();
     int stopUpdate();
 
+    bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/);
 
 
 
@@ -125,6 +126,7 @@ protected:
        long long  lastrendertime;
        void InternalRendering();
        void getScreenSize(int &width, int &height);
+       void getRealScreenSize(int &width, int &height);
 
 
 
index da4212cf80ad0c83cb305944d34fee0dab2d2884..01f4d9a5a0d205ad353627040a8db570afafa2a2 100644 (file)
@@ -122,7 +122,30 @@ int OsdVector::getFD()
 
 void OsdVector::screenShot(const char* fileName)
 {
-       //Do nothing,
+       //Do nothing, if no libmagick is there
+#ifdef PICTURE_DECODER_MAGICK
+       int width,height;
+       getRealScreenSize(width,height);
+       size_t length=width*height*4;
+       void *mem=malloc(length);
+
+       try {
+               Blob myblob;
+               if (!screenShot(mem,width,height,true)) {
+                       Log::getInstance()->log("OsdVector", Log::DEBUG, "Screenshot failed!");
+                       free(mem);
+                       return;
+               }
+               myblob.updateNoCopy(mem,length,Blob::MallocAllocator);
+               Image image(myblob,Geometry(width,height),8,"RGBA");
+               image.write(fileName);
+       }catch( Exception &error_ )
+       {
+               Log::getInstance()->log("MagickEncoder", Log::DEBUG, "Libmagick: %s",error_.what());
+
+       }
+
+#endif
 }
 
 Surface * OsdVector::createNewSurface()
index b8d3f2156fe093788a9c2698633fa4d9685d41c8..a3e193ce619a962d84f7eb5f0ce6f86c3092697d 100644 (file)
@@ -212,6 +212,7 @@ class OsdVector : public Osd
     int getFD();
 
     void screenShot(const char* fileName);
+    virtual bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/)=0;
 
     Surface * createNewSurface();
        void BeginPainting();
@@ -241,6 +242,7 @@ class OsdVector : public Osd
        unsigned int getStyleRef(const DrawStyle &c);
        virtual void removeStyleRef(unsigned int ref);
        virtual void getScreenSize(int &width, int &height)=0;
+       virtual void getRealScreenSize(int &width, int &height)=0;
 
        // should be only called from command thread
        void informPicture(LoadIndex index, ImageIndex i_index);