14930cef6SMatthias Ringwald /****************************************************************************** 24930cef6SMatthias Ringwald * 34930cef6SMatthias Ringwald * Copyright 2022 Google LLC 44930cef6SMatthias Ringwald * 54930cef6SMatthias Ringwald * Licensed under the Apache License, Version 2.0 (the "License"); 64930cef6SMatthias Ringwald * you may not use this file except in compliance with the License. 74930cef6SMatthias Ringwald * You may obtain a copy of the License at: 84930cef6SMatthias Ringwald * 94930cef6SMatthias Ringwald * http://www.apache.org/licenses/LICENSE-2.0 104930cef6SMatthias Ringwald * 114930cef6SMatthias Ringwald * Unless required by applicable law or agreed to in writing, software 124930cef6SMatthias Ringwald * distributed under the License is distributed on an "AS IS" BASIS, 134930cef6SMatthias Ringwald * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 144930cef6SMatthias Ringwald * See the License for the specific language governing permissions and 154930cef6SMatthias Ringwald * limitations under the License. 164930cef6SMatthias Ringwald * 174930cef6SMatthias Ringwald ******************************************************************************/ 184930cef6SMatthias Ringwald 194930cef6SMatthias Ringwald #ifndef __LC3BIN_H 204930cef6SMatthias Ringwald #define __LC3BIN_H 214930cef6SMatthias Ringwald 224930cef6SMatthias Ringwald #include <stdio.h> 234930cef6SMatthias Ringwald #include <stdint.h> 244930cef6SMatthias Ringwald #include <lc3.h> 254930cef6SMatthias Ringwald 264930cef6SMatthias Ringwald 274930cef6SMatthias Ringwald /** 284930cef6SMatthias Ringwald * Read LC3 binary header 294930cef6SMatthias Ringwald * fp Opened file, moved after header on return 304930cef6SMatthias Ringwald * frame_us Return frame duration, in us 314930cef6SMatthias Ringwald * srate_hz Return samplerate, in Hz 32*6897da5cSDirk Helbig * hrmode Return true when high-resolution mode enabled 334930cef6SMatthias Ringwald * nchannels Return number of channels 344930cef6SMatthias Ringwald * nsamples Return count of source samples by channels 354930cef6SMatthias Ringwald * return 0: Ok -1: Bad LC3 File 364930cef6SMatthias Ringwald */ 374930cef6SMatthias Ringwald int lc3bin_read_header(FILE *fp, 38*6897da5cSDirk Helbig int *frame_us, int *srate_hz, bool *hrmode, 39*6897da5cSDirk Helbig int *nchannels, int *nsamples); 404930cef6SMatthias Ringwald 414930cef6SMatthias Ringwald /** 424930cef6SMatthias Ringwald * Read LC3 block of data 434930cef6SMatthias Ringwald * fp Opened file 444930cef6SMatthias Ringwald * nchannels Number of channels 45*6897da5cSDirk Helbig * buffer Output buffer of `nchannels * LC3_HR_MAX_FRAME_BYTES` 46*6897da5cSDirk Helbig * return Size of the frames block, -1 on error 474930cef6SMatthias Ringwald */ 484930cef6SMatthias Ringwald int lc3bin_read_data(FILE *fp, int nchannels, void *buffer); 494930cef6SMatthias Ringwald 504930cef6SMatthias Ringwald /** 514930cef6SMatthias Ringwald * Write LC3 binary header 524930cef6SMatthias Ringwald * fp Opened file, moved after header on return 534930cef6SMatthias Ringwald * frame_us Frame duration, in us 544930cef6SMatthias Ringwald * srate_hz Samplerate, in Hz 55*6897da5cSDirk Helbig * hrmode True when high-resolution mode enabled 564930cef6SMatthias Ringwald * bitrate Bitrate indication of the stream, in bps 574930cef6SMatthias Ringwald * nchannels Number of channels 584930cef6SMatthias Ringwald * nsamples Count of source samples by channels 594930cef6SMatthias Ringwald */ 604930cef6SMatthias Ringwald void lc3bin_write_header(FILE *fp, 61*6897da5cSDirk Helbig int frame_us, int srate_hz, bool hrmode, 62*6897da5cSDirk Helbig int bitrate, int nchannels, int nsamples); 634930cef6SMatthias Ringwald 644930cef6SMatthias Ringwald /** 654930cef6SMatthias Ringwald * Write LC3 block of data 664930cef6SMatthias Ringwald * fp Opened file 674930cef6SMatthias Ringwald * data The frames data 68*6897da5cSDirk Helbig * nbytes Size of the frames block 694930cef6SMatthias Ringwald */ 70*6897da5cSDirk Helbig void lc3bin_write_data(FILE *fp, const void *data, int nbytes); 714930cef6SMatthias Ringwald 724930cef6SMatthias Ringwald 734930cef6SMatthias Ringwald #endif /* __LC3BIN_H */ 74