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 * hrmode Return true when high-resolution mode enabled 33 * nchannels Return number of channels 34 * nsamples Return count of source samples by channels 35 * return 0: Ok -1: Bad LC3 File 36 */ 37 int lc3bin_read_header(FILE *fp, 38 int *frame_us, int *srate_hz, bool *hrmode, 39 int *nchannels, int *nsamples); 40 41 /** 42 * Read LC3 block of data 43 * fp Opened file 44 * nchannels Number of channels 45 * buffer Output buffer of `nchannels * LC3_HR_MAX_FRAME_BYTES` 46 * return Size of the frames block, -1 on error 47 */ 48 int lc3bin_read_data(FILE *fp, int nchannels, void *buffer); 49 50 /** 51 * Write LC3 binary header 52 * fp Opened file, moved after header on return 53 * frame_us Frame duration, in us 54 * srate_hz Samplerate, in Hz 55 * hrmode True when high-resolution mode enabled 56 * bitrate Bitrate indication of the stream, in bps 57 * nchannels Number of channels 58 * nsamples Count of source samples by channels 59 */ 60 void lc3bin_write_header(FILE *fp, 61 int frame_us, int srate_hz, bool hrmode, 62 int bitrate, int nchannels, int nsamples); 63 64 /** 65 * Write LC3 block of data 66 * fp Opened file 67 * data The frames data 68 * nbytes Size of the frames block 69 */ 70 void lc3bin_write_data(FILE *fp, const void *data, int nbytes); 71 72 73 #endif /* __LC3BIN_H */ 74