jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.6KB

  1. /*
  2. Copyright (C) 2016-2019 Christoph Kuhr
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #ifndef _AVB_DEFINITIONS_H_
  16. #define _AVB_DEFINITIONS_H_
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif
  21. #define _GNU_SOURCE
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <errno.h>
  25. #include <stdbool.h>
  26. #include <sys/mman.h>
  27. #include <sys/ioctl.h>
  28. #include <ifaddrs.h>
  29. #include <linux/if_packet.h>
  30. #include <linux/net_tstamp.h>
  31. #include <linux/sockios.h>
  32. #include <linux/filter.h>
  33. #include <poll.h>
  34. #include <netinet/in.h>
  35. #include <linux/if.h>
  36. #include <jack/transport.h>
  37. #include "jack/jslist.h"
  38. #include "OpenAvnu/daemons/mrpd/mrpd.h"
  39. #include "OpenAvnu/daemons/mrpd/mrp.h"
  40. #define RETURN_VALUE_FAILURE 0
  41. #define RETURN_VALUE_SUCCESS 1
  42. #define MILISLEEP_TIME 1000000
  43. #define USLEEP_TIME 1000
  44. #define MAX_DEV_STR_LEN 32
  45. #define BUFLEN 1500
  46. #define ETHERNET_Q_HDR_LENGTH 18
  47. #define ETHERNET_HDR_LENGTH 14
  48. #define IP_HDR_LENGTH 20
  49. #define UDP_HDR_LENGTH 8
  50. #define AVB_ETHER_TYPE 0x22f0
  51. #define ARRAYSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  52. typedef struct etherheader_q
  53. {
  54. unsigned char ether_dhost[6]; // destination eth addr
  55. unsigned char ether_shost[6]; // source ether addr
  56. unsigned int vlan_id; // VLAN ID field
  57. unsigned short int ether_type; // packet type ID field
  58. } etherheader_q_t;
  59. typedef struct etherheader
  60. {
  61. unsigned char ether_dhost[6]; // destination eth addr
  62. unsigned char ether_shost[6]; // source ether addr
  63. unsigned short int ether_type; // packet type ID field
  64. } etherheader_t;
  65. typedef struct mrp_ctx{
  66. volatile int mrp_status;
  67. volatile int domain_a_valid;
  68. volatile int domain_b_valid;
  69. int domain_class_a_id;
  70. int domain_class_a_priority;
  71. u_int16_t domain_class_a_vid;
  72. int domain_class_b_id;
  73. int domain_class_b_priority;
  74. u_int16_t domain_class_b_vid;
  75. }mrp_ctx_t;
  76. typedef enum mrpStatus{
  77. TL_UNDEFINED,
  78. TALKER_IDLE,
  79. TALKER_ADVERTISE,
  80. TALKER_ASKFAILED,
  81. TALKER_READYFAILED,
  82. TALKER_CONNECTING,
  83. TALKER_CONNECTED,
  84. TALKER_ERROR,
  85. LISTENER_IDLE,
  86. LISTENER_WAITING,
  87. LISTENER_READY,
  88. LISTENER_CONNECTED,
  89. LISTENER_ERROR,
  90. LISTENER_FAILED
  91. } mrpStatus_t;
  92. typedef struct _avb_driver_state avb_driver_state_t;
  93. struct _avb_driver_state {
  94. uint8_t streamid8[8];
  95. uint8_t destination_mac_address[6];
  96. unsigned char serverMACAddress[6];
  97. char avbdev[MAX_DEV_STR_LEN];
  98. struct sockaddr_in si_other_avb;
  99. int raw_transport_socket;
  100. struct ifreq if_idx;
  101. struct ifreq if_mac;
  102. pthread_t thread;
  103. pthread_mutex_t threadLock;
  104. pthread_cond_t dataReady;
  105. jack_nframes_t sample_rate;
  106. jack_nframes_t period_size;
  107. jack_time_t period_usecs;
  108. int num_packets;
  109. int adjust;
  110. unsigned int capture_channels;
  111. unsigned int playback_channels;
  112. JSList *capture_ports;
  113. JSList *playback_ports;
  114. JSList *playback_srcs;
  115. JSList *capture_srcs;
  116. jack_client_t *client;
  117. };
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif // _AVB_DEFINITIONS_H_