libcm is a C development framework with an emphasis on audio signal processing applications.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cmVirtNet.h 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef cmVirtNet_h
  2. #define cmVirtNet_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkVnRC = cmOkRC,
  9. kUdpNetFailVnRC,
  10. kNodeNotFoundVnRC,
  11. kDuplicateNodeIdVnRC,
  12. kDuplicateNodeLabelVnRC,
  13. kQueueFailVnRC
  14. };
  15. typedef cmHandle_t cmVnH_t;
  16. typedef cmRC_t cmVnRC_t;
  17. extern cmVnH_t cmVnNullHandle;
  18. //
  19. typedef cmVnRC_t (*cmVnCb_t)( void* cbArg, unsigned srcNodeId, unsigned byteCnt, const char* buf );
  20. // Create a virtual network with a single node that represents the owner.
  21. // cbFunc() will be called to receive incoming msg's when the owning thread calls cmVnReceive().
  22. cmVnRC_t cmVnCreate(
  23. cmCtx_t* ctx,
  24. cmVnH_t* hp,
  25. cmVnCb_t cbFunc, // owner msg receive callback function
  26. void* cbArg, // owner supplied callback argument for cbFunc
  27. const cmChar_t* ownerNodelabel, // owners node label (must be unique among all nodes)
  28. unsigned ownerNodeId, // owners node id (must be unique among all nodes)
  29. unsigned udpRecvBufByteCnt, // size of the UDP incoming data buffer
  30. unsigned updRecvTimeOutMs, // UDP time out period while waiting for incoming data
  31. const cmChar_t* ipAddr, // this machines IP
  32. unsigned ipPort ); // this nodes port (must be unique among all local nodes)
  33. // Destroy and release any resources held by a virtual net created with cmVnCreate().
  34. cmVnRC_t cmVnDestroy( cmVnH_t* hp );
  35. bool cmVnIsValid( cmVnH_t h );
  36. // Put the network into listening mode. This function enables and disables
  37. // the UDP port listening thread.
  38. cmVnRC_t cmVnEnableListen( cmVnH_t h, bool enableFl );
  39. // Local nodes are nodes which are in the owners address space but controlled by a different thread.
  40. //
  41. cmVnRC_t cmVnCreateLocalNode( cmVnH_t h, const cmChar_t* label, unsigned nodeId, cmVnH_t localNet, unsigned queBufByteCnt );
  42. // Remote nodes are outside the owners address space and are communicated with via UDP.
  43. cmVnRC_t cmVnCreateRemoteNode( cmVnH_t h, const cmChar_t* label, unsigned nodeId, const cmChar_t* ipAddr, unsigned ipPort );
  44. // Send a msg from the owner node to another node.
  45. cmVnRC_t cmVnSendById( cmVnH_t h, unsigned nodeId, unsigned byteCnt, const cmChar_t* buf );
  46. cmVnRC_t cmVnSendByLabel( cmVnH_t h, const cmChar_t* nodeLabel, unsigned byteCnt, const cmChar_t* buf );
  47. // Recv a msg from a local node. This function may be called outside the 'owner' thread.
  48. // This function stores the incoming msg in a muliple-producer single-consumer queue.
  49. cmVnRC_t cmVnRecvFromLocal( cmVnH_t h, unsigned srcNodeId, unsigned byteCnt, const cmChar_t* buf );
  50. // Calling this function results in callback's to the cmVnCb_t function.
  51. cmVnRC_t cmVnReceive( cmVnH_t h, unsigned* msgCntPtr );
  52. cmVnRC_t cmVnTest( cmCtx_t* ctx );
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif