├── VBAN_ESP8266_I2SDAC_PCM5102.png ├── .gitignore ├── README.md ├── packet.h ├── vban.h ├── VBAN-Receptor-ESP8266-I2S.ino └── LICENSE /VBAN_ESP8266_I2SDAC_PCM5102.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyingKenny/VBAN-Receptor-ESP8266-I2S/HEAD/VBAN_ESP8266_I2SDAC_PCM5102.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wireless sound card with EESP8266 and VBAN protocol 2 | The target of this project is to build a WiFi speaker, which is directly fed via UDP stream. 3 | Application are 4 | * reducing long analog wires 5 | * multiroom speakers for home automation 6 | * using multiply devices with one speaker e.g. two PC's and RaspberryPI media center 7 | 8 | ## Used resources 9 | * [ESP8266 core for Arduino](https://github.com/esp8266/Arduino) 10 | * [VBAN protocol open-source implementation](https://github.com/quiniouben/vban) with release [v2.1.0](https://github.com/quiniouben/vban/releases/tag/v2.1.0) 11 | * [ESP8266 WiFi Connection manager with web captive portal](https://github.com/tzapu/WiFiManager) 12 | 13 | 14 | ## Wiring 15 | 16 | |ESP8266 / nodemcu|to|I2S DAC PCM5102| 17 | |---:|:---:|:---| 18 | |GPIO2 / D4|-> |LCK| 19 | |GPIO15 / D8|-> |BCK| 20 | |GPIO2 / RX|->| DIN| 21 | |GND / G|-> |GND| 22 | |3V3 / 3V|-> |VIN| 23 | | | |SCK -> GND| 24 | 25 | ![Image](https://github.com/flyingKenny/VBAN-Receptor-ESP8266-I2S/blob/master/VBAN_ESP8266_I2SDAC_PCM5102.png "image") 26 | 27 | ## Arduino settings 28 | * CPU Frequency: 80MHz 29 | * Flash Size: 4M (3MSPIFFS) 30 | * lwIP Variant: v2 Higher Bandwidth 31 | 32 | ## Usage 33 | Use [VB-AUDIO Software](https://www.vb-audio.com/index.htm) to generate a VBAN Stream. I recommend the [Banana Software](https://www.vb-audio.com/Voicemeeter/banana.htm). 34 | Setup the VBAN Stream: 35 | * Source: e.g. BUS A1 36 | * Stream Name: Stream1 "Stream1 is hard programmed in software" 37 | * IP Address To: IP of your ESP device 38 | * Port: 6980 39 | * Sample Rate: 11024Hz to 64000Hz works (22050Hz to 48000Hz is recommended) 40 | * CH: 1 or 2 is supported 41 | * Format: PCM 16 bits 42 | * Net Quality: Optimal to Very Solw works on my side 43 | -------------------------------------------------------------------------------- /packet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of vban. 3 | * Copyright (c) 2017 by Benoît Quiniou 4 | * 5 | * vban is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * vban is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with vban. If not, see . 17 | */ 18 | 19 | #ifndef __PACKET_H__ 20 | #define __PACKET_H__ 21 | 22 | #include 23 | #include "vban.h" 24 | //#include "stream.h" 25 | 26 | /** 27 | * Check packet content and only return valid return value if this is an audio pcm packet 28 | * @param streamname string pointer holding streamname 29 | * @param buffer pointer to data to check 30 | * @param size of the data in buffer; 31 | * @return 0 if packet is valid, negative value otherwise 32 | */ 33 | int packet_check(char const* streamname, char const* buffer, size_t size); 34 | 35 | /** Return VBanHeader pointer from buffer */ 36 | #define PACKET_HEADER_PTR(_buffer) ((struct VBanHeader*)_buffer) 37 | 38 | /** Return payload pointer of a Vban packet from buffer pointer */ 39 | #define PACKET_PAYLOAD_PTR(_buffer) ((char*)(PACKET_HEADER_PTR(_buffer)+1)) 40 | 41 | /** Return paylod size from total packet size */ 42 | #define PACKET_PAYLOAD_SIZE(_size) (_size - sizeof(struct VBanHeader)) 43 | 44 | /** 45 | * Fill @p stream_config with the values corresponding to the data ini the packet 46 | * @param buffer pointer to data 47 | * @param stream_config pointer 48 | * @return 0 upon success, negative value otherwise 49 | */ 50 | int packet_get_stream_config(char const* buffer, struct stream_config_t* stream_config); 51 | 52 | /** 53 | * Get max payload_size from packet header 54 | * @param buffer pointer to packet 55 | * @return size upon success, negative value otherwise 56 | */ 57 | int packet_get_max_payload_size(char const* buffer); 58 | 59 | /** 60 | * Init header content. 61 | * @param buffer pointer to data 62 | * @param stream_config pointer 63 | * @return 0 upon success, negative value otherwise 64 | */ 65 | int packet_init_header(char* buffer, struct stream_config_t const* stream_config, char const* streamname); 66 | 67 | /** 68 | * Fill the packet withe values corresponding to stream_config 69 | * @param buffer pointer to data 70 | * @param payload_size size of the payload 71 | * @return 0 upon success, negative value otherwise 72 | */ 73 | int packet_set_new_content(char* buffer, size_t payload_size); 74 | 75 | #endif /*__PACKET_H__*/ 76 | -------------------------------------------------------------------------------- /vban.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of vban. 3 | * Copyright (c) 2015 by Benoît Quiniou 4 | * 5 | * vban is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * vban is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with vban. If not, see . 17 | */ 18 | 19 | #ifndef __VBAN_H__ 20 | #define __VBAN_H__ 21 | 22 | #include 23 | 24 | #define VBAN_HEADER_SIZE (4 + 4 + 16 + 4) 25 | #define VBAN_HEADER_FOURC 'NABV' 26 | #define VBAN_STREAM_NAME_SIZE 16 27 | #define VBAN_PROTOCOL_MAX_SIZE 1464 28 | #define VBAN_DATA_MAX_SIZE (VBAN_PROTOCOL_MAX_SIZE - VBAN_HEADER_SIZE) 29 | #define VBAN_CHANNELS_MAX_NB 256 30 | #define VBAN_SAMPLES_MAX_NB 256 31 | 32 | struct VBanHeader 33 | { 34 | uint32_t vban; /* contains 'V' 'B', 'A', 'N' */ 35 | uint8_t format_SR; /* SR index (see SRList above) */ 36 | uint8_t format_nbs; /* nb sample per frame (1 to 256) */ 37 | uint8_t format_nbc; /* nb channel (1 to 256) */ 38 | uint8_t format_bit; /* mask = 0x07 (nb Byte integer from 1 to 4) */ 39 | char streamname[VBAN_STREAM_NAME_SIZE]; /* stream name */ 40 | uint32_t nuFrame; /* growing frame number. */ 41 | } __attribute__((packed)); 42 | 43 | 44 | #define VBAN_SR_MASK 0x1F 45 | #define VBAN_SR_MAXNUMBER 21 46 | static long const VBanSRList[VBAN_SR_MAXNUMBER]= 47 | { 48 | 6000, 12000, 24000, 48000, 96000, 192000, 384000, 49 | 8000, 16000, 32000, 64000, 128000, 256000, 512000, 50 | 11025, 22050, 44100, 88200, 176400, 352800, 705600 51 | }; 52 | 53 | #define VBAN_PROTOCOL_MASK 0xE0 54 | enum VBanProtocol 55 | { 56 | VBAN_PROTOCOL_AUDIO = 0x00, 57 | VBAN_PROTOCOL_SERIAL = 0x20, 58 | VBAN_PROTOCOL_TXT = 0x40, 59 | VBAN_PROTOCOL_UNDEFINED_1 = 0x80, 60 | VBAN_PROTOCOL_UNDEFINED_2 = 0xA0, 61 | VBAN_PROTOCOL_UNDEFINED_3 = 0xC0, 62 | VBAN_PROTOCOL_UNDEFINED_4 = 0xE0 63 | }; 64 | 65 | #define VBAN_BIT_RESOLUTION_MASK 0x07 66 | enum VBanBitResolution 67 | { 68 | VBAN_BITFMT_8_INT = 0, 69 | VBAN_BITFMT_16_INT, 70 | VBAN_BITFMT_24_INT, 71 | VBAN_BITFMT_32_INT, 72 | VBAN_BITFMT_32_FLOAT, 73 | VBAN_BITFMT_64_FLOAT, 74 | VBAN_BITFMT_12_INT, 75 | VBAN_BITFMT_10_INT, 76 | VBAN_BIT_RESOLUTION_MAX, 77 | }; 78 | 79 | static int const VBanBitResolutionSize[VBAN_BIT_RESOLUTION_MAX] = 80 | { 81 | 1, 2, 3, 4, 4, 8, 82 | }; 83 | 84 | #define VBAN_RESERVED_MASK 0x08 85 | 86 | #define VBAN_CODEC_MASK 0xF0 87 | enum VBanCodec 88 | { 89 | VBAN_CODEC_PCM = 0x00, 90 | VBAN_CODEC_VBCA = 0x10, 91 | VBAN_CODEC_VBCV = 0x20, 92 | VBAN_CODEC_UNDEFINED_3 = 0x30, 93 | VBAN_CODEC_UNDEFINED_4 = 0x40, 94 | VBAN_CODEC_UNDEFINED_5 = 0x50, 95 | VBAN_CODEC_UNDEFINED_6 = 0x60, 96 | VBAN_CODEC_UNDEFINED_7 = 0x70, 97 | VBAN_CODEC_UNDEFINED_8 = 0x80, 98 | VBAN_CODEC_UNDEFINED_9 = 0x90, 99 | VBAN_CODEC_UNDEFINED_10 = 0xA0, 100 | VBAN_CODEC_UNDEFINED_11 = 0xB0, 101 | VBAN_CODEC_UNDEFINED_12 = 0xC0, 102 | VBAN_CODEC_UNDEFINED_13 = 0xD0, 103 | VBAN_CODEC_UNDEFINED_14 = 0xE0, 104 | VBAN_CODEC_USER = 0xF0 105 | }; 106 | 107 | 108 | /******************************************************** 109 | * TEXT SUB PROTOCOL * 110 | ********************************************************/ 111 | 112 | #define VBAN_BPS_MASK 0xE0 113 | #define VBAN_BPS_MAXNUMBER 25 114 | static long const VBanBPSList[VBAN_BPS_MAXNUMBER] = 115 | { 116 | 0, 110, 150, 300, 600, 117 | 1200, 2400, 4800, 9600, 14400, 118 | 19200, 31250, 38400, 57600, 115200, 119 | 128000, 230400, 250000, 256000, 460800, 120 | 921600,1000000,1500000,2000000, 3000000 121 | }; 122 | 123 | #define VBAN_DATATYPE_MASK 0x07 124 | #define VBAN_DATATYPE_MAXNUMBER 1 125 | enum VBanDataTypeList 126 | { 127 | VBAN_DATATYPE_8BITS = 0 128 | }; 129 | 130 | #define VBAN_STREAMTYPE_MASK 0xF0 131 | enum VBanStreamType 132 | { 133 | VBAN_TXT_ASCII = 0x00, 134 | VBAN_TXT_UTF8 = 0x10, 135 | VBAN_TXT_WCHAR = 0x20, 136 | VBAN_TXT_UNDEFINED_3 = 0x30, 137 | VBAN_TXT_UNDEFINED_4 = 0x40, 138 | VBAN_TXT_UNDEFINED_5 = 0x50, 139 | VBAN_TXT_UNDEFINED_6 = 0x60, 140 | VBAN_TXT_UNDEFINED_7 = 0x70, 141 | VBAN_TXT_UNDEFINED_8 = 0x80, 142 | VBAN_TXT_UNDEFINED_9 = 0x90, 143 | VBAN_TXT_UNDEFINED_10 = 0xA0, 144 | VBAN_TXT_UNDEFINED_11 = 0xB0, 145 | VBAN_TXT_UNDEFINED_12 = 0xC0, 146 | VBAN_TXT_UNDEFINED_13 = 0xD0, 147 | VBAN_TXT_UNDEFINED_14 = 0xE0, 148 | VBAN_TXT_USER = 0xF0 149 | }; 150 | 151 | #endif /*__VBAN_H__*/ 152 | -------------------------------------------------------------------------------- /VBAN-Receptor-ESP8266-I2S.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | #include "VBAN.h" 9 | #include "packet.h" 10 | 11 | #define VBAN_BIT_RESOLUTION_MAX 2 12 | #define EINVAL 22 13 | 14 | 15 | unsigned int localPort = 6980; // local port to listen on 16 | 17 | // buffers for receiving and sending data 18 | int VBANBuffer[VBAN_PROTOCOL_MAX_SIZE]; 19 | 20 | WiFiUDP Udp; 21 | 22 | void setup() { 23 | Serial.begin(115200); 24 | wifiman_setup(); 25 | 26 | Serial.println("VBAN WiFi receptor"); 27 | Serial.print("Connected! IP address: "); 28 | Serial.println(WiFi.localIP()); 29 | Udp.begin(localPort); 30 | 31 | i2s_begin(); 32 | } 33 | 34 | 35 | void wifiman_setup(void) 36 | { 37 | //WiFiManager 38 | //Local intialization. Once its business is done, there is no need to keep it around 39 | WiFiManager wifiManager; 40 | //reset saved settings SSID and password 41 | //wifiManager.resetSettings(); 42 | 43 | //fetches ssid and pass from eeprom and tries to connect 44 | //if it does not connect it starts an access point with the specified name 45 | //here "AutoConnectAP" 46 | //and goes into a blocking loop awaiting configuration 47 | wifiManager.autoConnect("VBAN WiFi receptor"); 48 | 49 | //if you get here you have connected to the WiFi 50 | Serial.println(F("connected")); 51 | } 52 | 53 | 54 | static int packet_pcm_check(char const* buffer, size_t size) 55 | { 56 | /** the packet is already a valid vban packet and buffer already checked before */ 57 | 58 | struct VBanHeader const* const hdr = PACKET_HEADER_PTR(buffer); 59 | enum VBanBitResolution const bit_resolution = (VBanBitResolution)(hdr->format_bit & VBAN_BIT_RESOLUTION_MASK); 60 | int const sample_rate = hdr->format_SR & VBAN_SR_MASK; 61 | int const nb_samples = hdr->format_nbs + 1; 62 | int const nb_channels = hdr->format_nbc + 1; 63 | size_t sample_size = 0; 64 | size_t payload_size = 0; 65 | 66 | //logger_log(LOG_DEBUG, "%s: packet is vban: %u, sr: %d, nbs: %d, nbc: %d, bit: %d, name: %s, nu: %u", 67 | // __func__, hdr->vban, hdr->format_SR, hdr->format_nbs, hdr->format_nbc, hdr->format_bit, hdr->streamname, hdr->nuFrame); 68 | 69 | if (bit_resolution >= VBAN_BIT_RESOLUTION_MAX) 70 | { 71 | Serial.println("invalid bit resolution"); 72 | return -EINVAL; 73 | } 74 | 75 | if (sample_rate >= VBAN_SR_MAXNUMBER) 76 | { 77 | Serial.println("invalid sample rate"); 78 | return -EINVAL; 79 | } 80 | 81 | sample_size = VBanBitResolutionSize[bit_resolution]; 82 | payload_size = nb_samples * sample_size * nb_channels; 83 | 84 | if (payload_size != (size - VBAN_HEADER_SIZE)) 85 | { 86 | // logger_log(LOG_WARNING, "%s: invalid payload size, expected %d, got %d", __func__, payload_size, (size - VBAN_HEADER_SIZE)); 87 | Serial.println("invalid payload size"); 88 | return -EINVAL; 89 | } 90 | 91 | return 0; 92 | } 93 | 94 | int vban_packet_check(char const* streamname, char const* buffer, size_t size) 95 | { 96 | struct VBanHeader const* const hdr = PACKET_HEADER_PTR(buffer); 97 | enum VBanProtocol protocol = VBAN_PROTOCOL_UNDEFINED_4; 98 | enum VBanCodec codec = (VBanCodec)VBAN_BIT_RESOLUTION_MAX; 99 | 100 | if ((streamname == 0) || (buffer == 0)) 101 | { 102 | Serial.println("null pointer argument"); 103 | return -EINVAL; 104 | } 105 | 106 | if (size <= VBAN_HEADER_SIZE) 107 | { 108 | Serial.println("packet too small"); 109 | return -EINVAL; 110 | } 111 | 112 | if (hdr->vban != VBAN_HEADER_FOURC) 113 | { 114 | Serial.println("invalid vban magic fourc"); 115 | return -EINVAL; 116 | } 117 | 118 | if (strncmp(streamname, hdr->streamname, VBAN_STREAM_NAME_SIZE)) 119 | { 120 | Serial.println("different streamname"); 121 | return -EINVAL; 122 | } 123 | 124 | /** check the reserved bit : it must be 0 */ 125 | if (hdr->format_bit & VBAN_RESERVED_MASK) 126 | { 127 | Serial.println("reserved format bit invalid value"); 128 | return -EINVAL; 129 | } 130 | 131 | /** check protocol and codec */ 132 | protocol = (VBanProtocol)(hdr->format_SR & VBAN_PROTOCOL_MASK); 133 | codec = (VBanCodec)(hdr->format_bit & VBAN_CODEC_MASK); 134 | 135 | switch (protocol) 136 | { 137 | case VBAN_PROTOCOL_AUDIO: 138 | return (codec == VBAN_CODEC_PCM) ? packet_pcm_check(buffer, size) : -EINVAL; 139 | /*Serial.print("OK: VBAN_PROTOCOL_AUDIO"); 140 | Serial.print(": nuFrame "); 141 | Serial.print(hdr->nuFrame); 142 | Serial.print(": format_SR "); 143 | Serial.print(hdr->format_SR); 144 | Serial.print(": format_nbs "); 145 | Serial.print(hdr->format_nbs); 146 | Serial.print(": format_nbc "); 147 | Serial.println(hdr->format_nbc); 148 | */ 149 | return 0; 150 | case VBAN_PROTOCOL_SERIAL: 151 | case VBAN_PROTOCOL_TXT: 152 | case VBAN_PROTOCOL_UNDEFINED_1: 153 | case VBAN_PROTOCOL_UNDEFINED_2: 154 | case VBAN_PROTOCOL_UNDEFINED_3: 155 | case VBAN_PROTOCOL_UNDEFINED_4: 156 | /** not supported yet */ 157 | return -EINVAL; 158 | 159 | default: 160 | Serial.println("packet with unknown protocol"); 161 | return -EINVAL; 162 | } 163 | } 164 | 165 | 166 | uint8_t VBANSample = 0; 167 | int* VBANData; 168 | int16_t* VBANData1Ch; 169 | int VBANValue; 170 | void loop() { 171 | // if there's data available, read a packet 172 | int packetSize = Udp.parsePacket(); 173 | if (packetSize) { 174 | // read the packet into VBANBuffer 175 | Udp.read((char*)VBANBuffer, VBAN_PROTOCOL_MAX_SIZE); 176 | 177 | if (vban_packet_check("Stream1", (char*)VBANBuffer, packetSize) == 0) 178 | { 179 | struct VBanHeader const* const hdr = PACKET_HEADER_PTR((char*)VBANBuffer); 180 | i2s_set_rate((int)VBanSRList[hdr->format_SR & VBAN_SR_MASK]); 181 | 182 | //copy the received data to i2s buffer 183 | VBANSample = 0; 184 | VBANData = (int*)(((char*)VBANBuffer) + VBAN_HEADER_SIZE); 185 | VBANData1Ch = (int16_t*)VBANData; 186 | for (VBANSample = 0; VBANSample < hdr->format_nbs;VBANSample++) 187 | { 188 | switch (hdr->format_nbc) 189 | { 190 | case 0: //one channel 191 | VBANData1Ch = (int16_t*)VBANData; 192 | VBANValue = (int)VBANData1Ch[VBANSample]<<16 | VBANData1Ch[VBANSample]; 193 | break; 194 | case 1: //two channels 195 | VBANValue = VBANData[VBANSample]; 196 | break; 197 | } 198 | i2s_write_sample(VBANValue); 199 | } 200 | } 201 | else 202 | { 203 | Serial.println("VBAN Error"); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------