Freeframe to shared memory

Hi all, is it possible to copy the pframe into a shared memory when usign freeframe plugins ?
pframe is already a byte array 32, isnt 'it ?

thank you all in advance

should definitely be possible. you’d just need to find out how to write to shared-memory with c.

i did it already for another plugin, I’ll have the files this evening to check them out, just need to know what is , in the freeframe structure, the byte array to copy.

i’m using code like this, already used :

HANDLE hMapFile;
   LPCTSTR pBuf;

   hMapFile = CreateFileMapping(
                 INVALID_HANDLE_VALUE,    // use paging file
                 NULL,                    // default security
                 PAGE_READWRITE,          // read/write access
                 0,                       // maximum object size (high-order DWORD)
                 BUF_SIZE,                // maximum object size (low-order DWORD)
                 szName);                 // name of mapping object

   if (hMapFile == NULL)
   {
      _tprintf(TEXT("Could not create file mapping object (%d).\n"),
             GetLastError());
      return 1;
   }
   pBuf = (LPTSTR) MapViewOfFile(hMapFile,   // handle to map object
                        FILE_MAP_ALL_ACCESS, // read/write permission
                        0,
                        0,
                        BUF_SIZE);

   if (pBuf == NULL)
   {
      _tprintf(TEXT("Could not map view of file (%d).\n"),
             GetLastError());

	   CloseHandle(hMapFile);

      return 1;
   }

   CopyMemory[PVOID)pBuf, pFrame, (FVideoInfo.frameWidth*FVideoInfo.frameHeight*FVideoInfo.bitDepth](https://vvvv.org/documentation/PVOID)pBuf,-pFrame,-(FVideoInfo.frameWidth*FVideoInfo.frameHeight*FVideoInfo.bitDepth);
    _getch();

   UnmapViewOfFile((PVOID)pBuf);

   CloseHandle(hMapFile);

   return FF_SUCCESS;

here pFrame should be the byteArray representing videoframe

CopyMemory[PVOID)pBuf, pFrame, (FVideoInfo.frameWidth*FVideoInfo.frameHeight*FVideoInfo.bitDepth](https://vvvv.org/documentation/PVOID)pBuf,-pFrame,-(FVideoInfo.frameWidth*FVideoInfo.frameHeight*FVideoInfo.bitDepth);

but it doesn’t work, nor give errors, but no shared frame is received, any hints ?

for the C++ people, is the pFrame a pointer or a data struct ?

have to say, never wrote a freeframe plugin, but looking at your code the following line doesn’t look right to me:

CopyMemory[PVOID)pBuf, pFrame, (FVideoInfo.frameWidth*FVideoInfo.frameHeight*FVideoInfo.bitDepth](https://vvvv.org/documentation/PVOID)pBuf,-pFrame,-(FVideoInfo.frameWidth*FVideoInfo.frameHeight*FVideoInfo.bitDepth);

i guess FVideoInfo is of type VideoInfoStruct. if that’s the case then the field bitDepth is either 0, 1 or 2 (from http://freeframe.sourceforge.net/spec.html). so if you use a 16bit image, bitDepth is 0 -> 0 bytes are copied. if you use 24 or 32bit you still copy the wrong amount of data. in case of 16bit you want to multiply it with 2, in case of 24 with 3 and in case of 32 with 4.

try this instead:

CopyMemory[PVOID)pBuf, pFrame, (FVideoInfo.frameWidth*FVideoInfo.frameHeight*(FVideoInfo.bitDepth + 2)](https://vvvv.org/documentation/PVOID)pBuf,-pFrame,-(FVideoInfo.frameWidth*FVideoInfo.frameHeight*(FVideoInfo.bitDepth-+-2));

and pFrame is of type LPVOID, i think that’s the same as void * -> just a pointer.

I would like to use this plugin to stream from other VJ apps into VVVV. Is it available somewhere? Is there still problems with page tearing or does vvvv “sync” chain below properly if you only use one instance of SharedMemory (EX9.Texture)?

that sounds lovely
does it work?

i’m currently using the clr’ing the c# implementation of shared memory from the plugin utils project into openFrameworks http://www.youtube.com/watch?v=bnvxFJ-YPTg

cpp would be much tidier!