1 /* 2 * 3 * Copyright 2017 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H 20 #define GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include <grpc/impl/codegen/compression_types.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 typedef enum { 31 GRPC_MESSAGE_COMPRESS_NONE = 0, 32 GRPC_MESSAGE_COMPRESS_DEFLATE, 33 GRPC_MESSAGE_COMPRESS_GZIP, 34 /* TODO(ctiller): snappy */ 35 GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT 36 } grpc_message_compression_algorithm; 37 38 /** Stream compresssion algorithms supported by gRPC */ 39 typedef enum { 40 GRPC_STREAM_COMPRESS_NONE = 0, 41 GRPC_STREAM_COMPRESS_GZIP, 42 GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT 43 } grpc_stream_compression_algorithm; 44 45 /* Interfaces performing transformation between compression algorithms and 46 * levels. */ 47 48 grpc_message_compression_algorithm 49 grpc_compression_algorithm_to_message_compression_algorithm( 50 grpc_compression_algorithm algo); 51 52 grpc_stream_compression_algorithm 53 grpc_compression_algorithm_to_stream_compression_algorithm( 54 grpc_compression_algorithm algo); 55 56 uint32_t grpc_compression_bitset_to_message_bitset(uint32_t bitset); 57 58 uint32_t grpc_compression_bitset_to_stream_bitset(uint32_t bitset); 59 60 uint32_t grpc_compression_bitset_from_message_stream_compression_bitset( 61 uint32_t message_bitset, uint32_t stream_bitset); 62 63 int grpc_compression_algorithm_from_message_stream_compression_algorithm( 64 grpc_compression_algorithm* algorithm, 65 grpc_message_compression_algorithm message_algorithm, 66 grpc_stream_compression_algorithm stream_algorithm); 67 68 /* Interfaces for message compression. */ 69 70 int grpc_message_compression_algorithm_name( 71 grpc_message_compression_algorithm algorithm, const char** name); 72 73 grpc_message_compression_algorithm grpc_message_compression_algorithm_for_level( 74 grpc_compression_level level, uint32_t accepted_encodings); 75 76 int grpc_message_compression_algorithm_parse( 77 grpc_slice value, grpc_message_compression_algorithm* algorithm); 78 79 /* Interfaces for stream compression. */ 80 81 int grpc_stream_compression_algorithm_parse( 82 grpc_slice value, grpc_stream_compression_algorithm* algorithm); 83 84 #ifdef __cplusplus 85 } 86 #endif 87 88 #endif /* GRPC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H */ 89