1 /*** 2 This file is part of PulseAudio. 3 4 Copyright (C) 2020 Asymptotic <sanchayan@asymptotic.io> 5 6 PulseAudio is free software; you can redistribute it and/or modify 7 it under the terms of the GNU Lesser General Public License as 8 published by the Free Software Foundation; either version 2.1 of the 9 License, or (at your option) any later version. 10 11 PulseAudio is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. 18 ***/ 19 20 #include <gst/gst.h> 21 #include <gst/app/gstappsrc.h> 22 #include <gst/app/gstappsink.h> 23 #include <gst/base/gstadapter.h> 24 #include <pulsecore/fdsem.h> 25 26 enum a2dp_codec_type { 27 AAC = 0, 28 APTX, 29 APTX_HD, 30 LDAC_EQMID_HQ, 31 LDAC_EQMID_SQ, 32 LDAC_EQMID_MQ 33 }; 34 35 struct gst_info { 36 pa_core *core; 37 pa_sample_spec *ss; 38 enum a2dp_codec_type codec_type; 39 union { 40 const a2dp_aac_t *aac_config; 41 const a2dp_aptx_t *aptx_config; 42 const a2dp_aptx_hd_t *aptx_hd_config; 43 const a2dp_ldac_t *ldac_config; 44 } a2dp_codec_t; 45 46 /* The appsink element that accumulates encoded/decoded buffers */ 47 GstElement *app_sink; 48 GstElement *bin; 49 /* The sink pad to push to-be-encoded/decoded buffers into */ 50 GstPad *pad_sink; 51 52 uint16_t seq_num; 53 }; 54 55 bool gst_codec_init(struct gst_info *info, bool for_encoding, GstElement *transcoder); 56 size_t gst_transcode_buffer(void *codec_info, uint32_t timestamp, const uint8_t *input_buffer, size_t input_size, uint8_t *output_buffer, size_t output_size, size_t *processed); 57 void gst_codec_deinit(void *codec_info); 58