// // Check the details of an existing sender // // 1) Find the sender // 2) Get it's texture info // 3) Return the sharehandle, width, height, and format // // Returns : // true - all OK. // width and height are returned changed for sender size change // false - sender not found or size changed // width and height are returned zero for sender not found // bool spoutSenderNames::CheckSender(const char *sendername, unsigned int &theWidth, unsigned int &theHeight, HANDLE &hSharehandle, DWORD &dwFormat) { SharedTextureInfo info; // Is the given sender registered ? if(FindSenderName(sendername)) { // Does it still exist ? if(getSharedInfo(sendername, &info)) { // Return the texture info theWidth = (unsigned int)info.width; theHeight = (unsigned int)info.height; #ifdef _M_X64 hSharehandle = (HANDLE)(LongToHandle((long)info.shareHandle)); #else hSharehandle = (HANDLE)info.shareHandle; #endif // hSharehandle = (HANDLE)info.shareHandle; dwFormat = (DWORD)info.format; return true; } else { // Sender is registered but does not exist so close it ReleaseSenderName(sendername); } } // Return zero width and height to indicate sender not found theHeight = 0; theWidth = 0; return false; } // end CheckSender
// // Check the details of an existing sender // // 1) Find the sender // 2) Get it's texture info // 3) Return the sharehandle, width, height, and format // // Returns : // true - all OK. // width and height are returned changed for sender size change // false - sender not found or size changed // width and height are returned zero for sender not found // bool spoutSenderNames::CheckSender(const char *sendername, unsigned int &theWidth, unsigned int &theHeight, HANDLE &hSharehandle, DWORD &dwFormat) { SharedTextureInfo info; char sname[SpoutMaxSenderNameLen]; // Is the given sender registered ? if(FindSenderName(sendername)) { // Does it still exist ? if(getSharedInfo(sendername, &info)) { // Return the texture info // strcpy_s(sendername, 256, sname); theWidth = (unsigned int)info.width; theHeight = (unsigned int)info.height; hSharehandle = (HANDLE)info.shareHandle; dwFormat = (DWORD)info.format; return true; } else { // Sender is registered but does not exist so close it ReleaseSenderName(sname); } } // Return zero width and height to indicate sender not found theHeight = 0; theWidth = 0; return false; } // end CheckSender
// Find a sender and return the name, width and height, sharhandle and format bool spoutSenderNames::FindSender(char *sendername, unsigned int &width, unsigned int &height, HANDLE &hSharehandle, DWORD &dwFormat) { SharedTextureInfo info; // --------------------------------------------------------- // For a receiver check the user entered Sender name, if one, to see if it exists if(sendername[0] == 0) { // Passed name was null, so find the active sender if(!GetActiveSender(sendername)) { return false; } } // now we have either an existing sender name or the active sender name // 01.08.15 - Is the given sender registered ? if(!FindSenderName(sendername)) return false; // Sender is registered so try to get the sender information if(getSharedInfo(sendername, &info)) { width = (unsigned int)info.width; // pass back sender size height = (unsigned int)info.height; hSharehandle = (HANDLE)info.shareHandle; dwFormat = (DWORD)info.format; return true; } // 01.08.15 - Registered sender is no longer there so release it ReleaseSenderName(sendername); return false; } // end FindSender
int spoutSenderNames::GetSenderCount() { std::set<string> SenderSet; std::set<string>::iterator iter; string namestring; char name[SpoutMaxSenderNameLen]; SharedTextureInfo info; // Create the shared memory for the sender name set if it does not exist if(!CreateSenderSet()) { return 0; } // Doing multiple operations on the sender list, keep it locked if (!m_senderNames.Lock()) { return 0; } // get the name list in shared memory into a local list GetSenderNames(&SenderSet); // Now we have a local set of names // 27.12.13 - noted that if a Processing sketch is stopped by closing the window // all is OK and either the "stop" or "dispose" overrides work, but if STOP is used, // or the sketch is closed, neither the exit or dispose functions are called and // the sketch does not release the sender. // So here we run through again and check whether the sender exists and if it does not // release the sender from the local sender list if(SenderSet.size() > 0) { for(iter = SenderSet.begin(); iter != SenderSet.end(); iter++) { namestring = *iter; // the Sender name string strcpy_s(name, namestring.c_str()); // we have the name already, so look for it's info if(!getSharedInfo(name, &info)) { // Sender does not exist any more ReleaseSenderName(name); // release from the shared memory list } } } // Get the new set back if(GetSenderNames(&SenderSet)) { m_senderNames.Unlock(); return(SenderSet.size()); } m_senderNames.Unlock(); return 0; }