1 /****************************************************************************** 2 * 3 * Copyright 2022 Google LLC 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 __LC3BIN_H 20 #define __LC3BIN_H 21 22 #include <stdio.h> 23 #include <stdint.h> 24 #include <lc3.h> 25 26 27 /** 28 * Read LC3 binary header 29 * fp Opened file, moved after header on return 30 * frame_us Return frame duration, in us 31 * srate_hz Return samplerate, in Hz 32 * nchannels Return number of channels 33 * nsamples Return count of source samples by channels 34 * return 0: Ok -1: Bad LC3 File 35 */ 36 int lc3bin_read_header(FILE *fp, 37 int *frame_us, int *srate_hz, int *nchannels, int *nsamples); 38 39 /** 40 * Read LC3 block of data 41 * fp Opened file 42 * nchannels Number of channels 43 * buffer Output buffer of `nchannels * LC3_MAX_FRAME_BYTES` 44 * return Size of each 'nchannels` frames, -1 on error 45 */ 46 int lc3bin_read_data(FILE *fp, int nchannels, void *buffer); 47 48 /** 49 * Write LC3 binary header 50 * fp Opened file, moved after header on return 51 * frame_us Frame duration, in us 52 * srate_hz Samplerate, in Hz 53 * bitrate Bitrate indication of the stream, in bps 54 * nchannels Number of channels 55 * nsamples Count of source samples by channels 56 */ 57 void lc3bin_write_header(FILE *fp, 58 int frame_us, int srate_hz, int bitrate, int nchannels, int nsamples); 59 60 /** 61 * Write LC3 block of data 62 * fp Opened file 63 * data The frames data 64 * nchannels Number of channels 65 * frame_bytes Size of each `nchannels` frames 66 */ 67 void lc3bin_write_data(FILE *fp, 68 const void *data, int nchannels, int frame_bytes); 69 70 71 #endif /* __LC3BIN_H */ 72