1c72fcc34Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 2c72fcc34Sopenharmony_ci// 3c72fcc34Sopenharmony_ci// mapper.h - an interface of muxer/demuxer between buffer with data frames and 4c72fcc34Sopenharmony_ci// formatted files. 5c72fcc34Sopenharmony_ci// 6c72fcc34Sopenharmony_ci// Copyright (c) 2018 Takashi Sakamoto <o-takashi@sakamocchi.jp> 7c72fcc34Sopenharmony_ci// 8c72fcc34Sopenharmony_ci// Licensed under the terms of the GNU General Public License, version 2. 9c72fcc34Sopenharmony_ci 10c72fcc34Sopenharmony_ci#ifndef __ALSA_UTILS_AXFER_MAPPER__H_ 11c72fcc34Sopenharmony_ci#define __ALSA_UTILS_AXFER_MAPPER__H_ 12c72fcc34Sopenharmony_ci 13c72fcc34Sopenharmony_ci#include "container.h" 14c72fcc34Sopenharmony_ci 15c72fcc34Sopenharmony_cienum mapper_type { 16c72fcc34Sopenharmony_ci MAPPER_TYPE_MUXER = 0, 17c72fcc34Sopenharmony_ci MAPPER_TYPE_DEMUXER, 18c72fcc34Sopenharmony_ci MAPPER_TYPE_COUNT, 19c72fcc34Sopenharmony_ci}; 20c72fcc34Sopenharmony_ci 21c72fcc34Sopenharmony_cienum mapper_target { 22c72fcc34Sopenharmony_ci MAPPER_TARGET_SINGLE = 0, 23c72fcc34Sopenharmony_ci MAPPER_TARGET_MULTIPLE, 24c72fcc34Sopenharmony_ci MAPPER_TARGET_COUNT, 25c72fcc34Sopenharmony_ci}; 26c72fcc34Sopenharmony_ci 27c72fcc34Sopenharmony_cistruct mapper_ops; 28c72fcc34Sopenharmony_ci 29c72fcc34Sopenharmony_cistruct mapper_context { 30c72fcc34Sopenharmony_ci enum mapper_type type; 31c72fcc34Sopenharmony_ci enum mapper_target target; 32c72fcc34Sopenharmony_ci const struct mapper_ops *ops; 33c72fcc34Sopenharmony_ci unsigned int private_size; 34c72fcc34Sopenharmony_ci 35c72fcc34Sopenharmony_ci void *private_data; 36c72fcc34Sopenharmony_ci unsigned int cntr_count; 37c72fcc34Sopenharmony_ci 38c72fcc34Sopenharmony_ci // A part of parameters of PCM substream. 39c72fcc34Sopenharmony_ci snd_pcm_access_t access; 40c72fcc34Sopenharmony_ci unsigned int bytes_per_sample; 41c72fcc34Sopenharmony_ci unsigned int samples_per_frame; 42c72fcc34Sopenharmony_ci snd_pcm_uframes_t frames_per_buffer; 43c72fcc34Sopenharmony_ci 44c72fcc34Sopenharmony_ci unsigned int verbose; 45c72fcc34Sopenharmony_ci}; 46c72fcc34Sopenharmony_ci 47c72fcc34Sopenharmony_ciint mapper_context_init(struct mapper_context *mapper, 48c72fcc34Sopenharmony_ci enum mapper_type type, unsigned int cntr_count, 49c72fcc34Sopenharmony_ci unsigned int verbose); 50c72fcc34Sopenharmony_ciint mapper_context_pre_process(struct mapper_context *mapper, 51c72fcc34Sopenharmony_ci snd_pcm_access_t access, 52c72fcc34Sopenharmony_ci unsigned int bytes_per_sample, 53c72fcc34Sopenharmony_ci unsigned int samples_per_frame, 54c72fcc34Sopenharmony_ci unsigned int frames_per_buffer, 55c72fcc34Sopenharmony_ci struct container_context *cntrs); 56c72fcc34Sopenharmony_ciint mapper_context_process_frames(struct mapper_context *mapper, 57c72fcc34Sopenharmony_ci void *frame_buffer, 58c72fcc34Sopenharmony_ci unsigned int *frame_count, 59c72fcc34Sopenharmony_ci struct container_context *cntrs); 60c72fcc34Sopenharmony_civoid mapper_context_post_process(struct mapper_context *mapper); 61c72fcc34Sopenharmony_civoid mapper_context_destroy(struct mapper_context *mapper); 62c72fcc34Sopenharmony_ci 63c72fcc34Sopenharmony_ci// For internal use in 'mapper' module. 64c72fcc34Sopenharmony_ci 65c72fcc34Sopenharmony_cistruct mapper_ops { 66c72fcc34Sopenharmony_ci int (*pre_process)(struct mapper_context *mapper, 67c72fcc34Sopenharmony_ci struct container_context *cntrs, 68c72fcc34Sopenharmony_ci unsigned int cntr_count); 69c72fcc34Sopenharmony_ci int (*process_frames)(struct mapper_context *mapper, 70c72fcc34Sopenharmony_ci void *frame_buffer, unsigned int *frame_count, 71c72fcc34Sopenharmony_ci struct container_context *cntrs, 72c72fcc34Sopenharmony_ci unsigned int cntr_count); 73c72fcc34Sopenharmony_ci void (*post_process)(struct mapper_context *mapper); 74c72fcc34Sopenharmony_ci}; 75c72fcc34Sopenharmony_ci 76c72fcc34Sopenharmony_cistruct mapper_data { 77c72fcc34Sopenharmony_ci struct mapper_ops ops; 78c72fcc34Sopenharmony_ci unsigned int private_size; 79c72fcc34Sopenharmony_ci}; 80c72fcc34Sopenharmony_ci 81c72fcc34Sopenharmony_ciextern const struct mapper_data mapper_muxer_single; 82c72fcc34Sopenharmony_ciextern const struct mapper_data mapper_demuxer_single; 83c72fcc34Sopenharmony_ci 84c72fcc34Sopenharmony_ciextern const struct mapper_data mapper_muxer_multiple; 85c72fcc34Sopenharmony_ciextern const struct mapper_data mapper_demuxer_multiple; 86c72fcc34Sopenharmony_ci 87c72fcc34Sopenharmony_ci#endif 88