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