SpoutSenderMemory.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. spoutSenderMemory.h
  3. Spout memory map management
  4. For sharing images via shared memory
  5. LJ - leadedge@adam.com.au
  6. Thanks and credit to Malcolm Bechard for the SpoutSharedMemory class
  7. https://github.com/mbechard
  8. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9. Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without modification,
  11. are permitted provided that the following conditions are met:
  12. 1. Redistributions of source code must retain the above copyright notice,
  13. this list of conditions and the following disclaimer.
  14. 2. Redistributions in binary form must reproduce the above copyright notice,
  15. this list of conditions and the following disclaimer in the documentation
  16. and/or other materials provided with the distribution.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  18. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  23. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #pragma once
  28. #ifndef __spoutSenderMemory__
  29. #define __spoutSenderMemory__
  30. #include <windowsx.h>
  31. #include <set>
  32. #include <map>
  33. #include <string>
  34. #include <vector>
  35. #include <unordered_map>
  36. #include "SpoutCommon.h"
  37. #include "SpoutSharedMemory.h"
  38. // functions will finally go into SpoutGLDXinterop
  39. // #include "spoutGLDXinterop.h"
  40. using namespace std;
  41. class SPOUT_DLLEXP spoutSenderMemory {
  42. public:
  43. spoutSenderMemory();
  44. ~spoutSenderMemory();
  45. // SpoutSDK.cpp
  46. // bool InitMemoryShare(const char *sendername, bool bReceiver);
  47. // SpoutMemoryShare
  48. // initialize / release shared memory
  49. // bool Initialize();
  50. // bool DeInitialize();
  51. // Texture equivalent
  52. // bool CreateInterop(hwnd, sendername, width, height, format, true); // true meaning receiver
  53. // bool CreateMemoryShare (sendername, width, height, true); // true meaning receiver
  54. // functions will finally go into SpoutGLDXinterop
  55. // bool CreateMemoryShare(const char *sendername, unsigned int width, unsigned int height, bool bReceiver);
  56. // Create or Close a sender memory map
  57. bool CreateSenderMemory (const char *sendername, unsigned int width, unsigned int height);
  58. bool UpdateSenderMemory (const char* sendername, unsigned int width, unsigned int height);
  59. void CloseSenderMemory (const char *sendername);
  60. // Read and write to a sender memory map
  61. bool GetSenderMemory (const char* sendername, unsigned int &width, unsigned int &height, unsigned char *pixels);
  62. bool SetSenderMemory (const char* sendername, unsigned int width, unsigned int height, unsigned char *pixels);
  63. // A receiver - is a memoryshare sender running ?
  64. bool GetImageSizeFromSharedMemory(const char* sendername, unsigned int &width, unsigned int &height);
  65. // Close all sender maps
  66. void ReleaseSenderMemory();
  67. protected:
  68. // functions will finally go into SpoutGLDXinterop
  69. // spoutGLDXinterop interop;
  70. // SharedTextureInfo m_TextureInfo;
  71. // HANDLE m_hMutex;
  72. // HANDLE m_hMap;
  73. // unsigned char *m_pBuffer;
  74. SpoutSharedMemory *senderMem;
  75. // std::unordered_map<std::string, SpoutSharedMemory*>* m_senders;
  76. };
  77. #endif