Debian Codegraph @

gi-types/gstbadaudio-1.0.d.ts

raw symbols SCIP
1 /// <reference path="./gstbase-1.0.d.ts" />
2 /// <reference path="./gst-1.0.d.ts" />
3 /// <reference path="./gobject-2.0.d.ts" />
4 /// <reference path="./glib-2.0.d.ts" />
5 /// <reference path="./gmodule-2.0.d.ts" />
6 /// <reference path="./gstaudio-1.0.d.ts" />
7
8 /**
9 * Type Definitions for Gjs (https://gjs.guide/)
10 *
11 * These type definitions are automatically generated, do not edit them by hand.
12 * If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gir
13 *
14 * The based EJS template file is used for the generated .d.ts file of each GIR module like Gtk-4.0, GObject-2.0, ...
15 */
16
17 declare module 'gi://GstBadAudio?version=1.0' {
18 // Module dependencies
19 import type GstBase from 'gi://GstBase?version=1.0';
20 import type Gst from 'gi://Gst?version=1.0';
21 import type GObject from 'gi://GObject?version=2.0';
22 import type GLib from 'gi://GLib?version=2.0';
23 import type GModule from 'gi://GModule?version=2.0';
24 import type GstAudio from 'gi://GstAudio?version=1.0';
25
26 export namespace GstBadAudio {
27 /**
28 * GstBadAudio-1.0
29 */
30
31 /**
32 * The output mode defines how the output behaves with regards to looping. Either the playback position is
33 * moved back to the beginning of the loop, acting like a backwards seek, or it increases steadily, as if
34 * loop were "unrolled".
35 */
36
37 /**
38 * The output mode defines how the output behaves with regards to looping. Either the playback position is
39 * moved back to the beginning of the loop, acting like a backwards seek, or it increases steadily, as if
40 * loop were "unrolled".
41 */
42 export namespace NonstreamAudioOutputMode {
43 export const $gtype: GObject.GType<NonstreamAudioOutputMode>;
44 }
45
46 enum NonstreamAudioOutputMode {
47 /**
48 * Playback position is moved back to the beginning of the loop
49 */
50 LOOPING,
51 /**
52 * Playback position increases steadily, even when looping
53 */
54 STEADY,
55 }
56 /**
57 * The subsong mode defines how the decoder shall handle subsongs.
58 */
59
60 /**
61 * The subsong mode defines how the decoder shall handle subsongs.
62 */
63 export namespace NonstreamAudioSubsongMode {
64 export const $gtype: GObject.GType<NonstreamAudioSubsongMode>;
65 }
66
67 enum NonstreamAudioSubsongMode {
68 /**
69 * Only the current subsong is played
70 */
71 SINGLE,
72 /**
73 * All subsongs are played (current subsong index is ignored)
74 */
75 ALL,
76 /**
77 * Use decoder specific default behavior
78 */
79 DECODER_DEFAULT,
80 }
81 /**
82 * The name of the template for the sink pad.
83 */
84 const NONSTREAM_AUDIO_DECODER_SINK_NAME: string;
85 /**
86 * The name of the template for the source pad.
87 */
88 const NONSTREAM_AUDIO_DECODER_SRC_NAME: string;
89 namespace NonstreamAudioDecoder {
90 // Constructor properties interface
91
92 interface ConstructorProps extends Gst.Element.ConstructorProps {
93 current_subsong: number;
94 currentSubsong: number;
95 num_loops: number;
96 numLoops: number;
97 }
98 }
99
100 /**
101 * This base class is for decoders which do not operate on a streaming model.
102 * That is: they load the encoded media at once, as part of an initialization,
103 * and afterwards can decode samples (sometimes referred to as "rendering the
104 * samples").
105 *
106 * This sets it apart from GstAudioDecoder, which is a base class for
107 * streaming audio decoders.
108 *
109 * The base class is conceptually a mix between decoder and parser. This is
110 * unavoidable, since virtually no format that isn't streaming based has a
111 * clear distinction between parsing and decoding. As a result, this class
112 * also handles seeking.
113 *
114 * Non-streaming audio formats tend to have some characteristics unknown to
115 * more "regular" bitstreams. These include subsongs and looping.
116 *
117 * Subsongs are a set of songs-within-a-song. An analogy would be a multitrack
118 * recording, where each track is its own song. The first subsong is typically
119 * the "main" one. Subsongs were popular for video games to enable context-
120 * aware music; for example, subsong `#0` would be the "main" song, `#1` would be
121 * an alternate song playing when a fight started, `#2` would be heard during
122 * conversations etc. The base class is designed to always have at least one
123 * subsong. If the subclass doesn't provide any, the base class creates a
124 * "pseudo" subsong, which is actually the whole song.
125 * Downstream is informed about the subsong using a table of contents (TOC),
126 * but only if there are at least 2 subsongs.
127 *
128 * Looping refers to jumps within the song, typically backwards to the loop
129 * start (although bi-directional looping is possible). The loop is defined
130 * by a chronological start and end; once the playback position reaches the
131 * loop end, it jumps back to the loop start.
132 * Depending on the subclass, looping may not be possible at all, or it
133 * may only be possible to enable/disable it (that is, either no looping, or
134 * an infinite amount of loops), or it may allow for defining a finite number
135 * of times the loop is repeated.
136 * Looping can affect output in two ways. Either, the playback position is
137 * reset to the start of the loop, similar to what happens after a seek event.
138 * Or, it is not reset, so the pipeline sees playback steadily moving forwards,
139 * the playback position monotonically increasing. However, seeking must
140 * always happen within the confines of the defined subsong duration; for
141 * example, if a subsong is 2 minutes long, steady playback is at 5 minutes
142 * (because infinite looping is enabled), then seeking will still place the
143 * position within the 2 minute period.
144 * Loop count 0 means no looping. Loop count -1 means infinite looping.
145 * Nonzero positive values indicate how often a loop shall occur.
146 *
147 * If the initial subsong and loop count are set to values the subclass does
148 * not support, the subclass has a chance to correct these values.
149 * `get_property` then reports the corrected versions.
150 *
151 * The base class operates as follows:
152 * * Unloaded mode
153 * - Initial values are set. If a current subsong has already been
154 * defined (for example over the command line with gst-launch), then
155 * the subsong index is copied over to current_subsong .
156 * Same goes for the num-loops and output-mode properties.
157 * Media is NOT loaded yet.
158 * - Once the sinkpad is activated, the process continues. The sinkpad is
159 * activated in push mode, and the class accumulates the incoming media
160 * data in an adapter inside the sinkpad's chain function until either an
161 * EOS event is received from upstream, or the number of bytes reported
162 * by upstream is reached. Then it loads the media, and starts the decoder
163 * output task.
164 * - If upstream cannot respond to the size query (in bytes) of `load_from_buffer`
165 * fails, an error is reported, and the pipeline stops.
166 * - If there are no errors, `load_from_buffer` is called to load the media. The
167 * subclass must at least call gst_nonstream_audio_decoder_set_output_format()
168 * there, and is free to make use of the initial subsong, output mode, and
169 * position. If the actual output mode or position differs from the initial
170 * value,it must set the initial value to the actual one (for example, if
171 * the actual starting position is always 0, set *initial_position to 0).
172 * If loading is unsuccessful, an error is reported, and the pipeline
173 * stops. Otherwise, the base class calls `get_current_subsong` to retrieve
174 * the actual current subsong, `get_subsong_duration` to report the current
175 * subsong's duration in a duration event and message, and `get_subsong_tags`
176 * to send tags downstream in an event (these functions are optional; if
177 * set to NULL, the associated operation is skipped). Afterwards, the base
178 * class switches to loaded mode, and starts the decoder output task.
179 *
180 * * Loaded mode</title>
181 * - Inside the decoder output task, the base class repeatedly calls `decode,`
182 * which returns a buffer with decoded, ready-to-play samples. If the
183 * subclass reached the end of playback, `decode` returns FALSE, otherwise
184 * TRUE.
185 * - Upon reaching a loop end, subclass either ignores that, or loops back
186 * to the beginning of the loop. In the latter case, if the output mode is set
187 * to LOOPING, the subclass must call gst_nonstream_audio_decoder_handle_loop()
188 * *after* the playback position moved to the start of the loop. In
189 * STEADY mode, the subclass must *not* call this function.
190 * Since many decoders only provide a callback for when the looping occurs,
191 * and that looping occurs inside the decoding operation itself, the following
192 * mechanism for subclass is suggested: set a flag inside such a callback.
193 * Then, in the next `decode` call, before doing the decoding, check this flag.
194 * If it is set, gst_nonstream_audio_decoder_handle_loop() is called, and the
195 * flag is cleared.
196 * (This function call is necessary in LOOPING mode because it updates the
197 * current segment and makes sure the next buffer that is sent downstream
198 * has its DISCONT flag set.)
199 * - When the current subsong is switched, `set_current_subsong` is called.
200 * If it fails, a warning is reported, and nothing else is done. Otherwise,
201 * it calls `get_subsong_duration` to get the new current subsongs's
202 * duration, `get_subsong_tags` to get its tags, reports a new duration
203 * (i.e. it sends a duration event downstream and generates a duration
204 * message), updates the current segment, and sends the subsong's tags in
205 * an event downstream. (If `set_current_subsong` has been set to NULL by
206 * the subclass, attempts to set a current subsong are ignored; likewise,
207 * if `get_subsong_duration` is NULL, no duration is reported, and if
208 * `get_subsong_tags` is NULL, no tags are sent downstream.)
209 * - When an attempt is made to switch the output mode, it is checked against
210 * the bitmask returned by `get_supported_output_modes`. If the proposed
211 * new output mode is supported, the current segment is updated
212 * (it is open-ended in STEADY mode, and covers the (sub)song length in
213 * LOOPING mode), and the subclass' `set_output_mode` function is called
214 * unless it is set to NULL. Subclasses should reset internal loop counters
215 * in this function.
216 *
217 * The relationship between (sub)song duration, output mode, and number of loops
218 * is defined this way (this is all done by the base class automatically):
219 *
220 * * Segments have their duration and stop values set to GST_CLOCK_TIME_NONE in
221 * STEADY mode, and to the duration of the (sub)song in LOOPING mode.
222 *
223 * * The duration that is returned to a DURATION query is always the duration
224 * of the (sub)song, regardless of number of loops or output mode. The same
225 * goes for DURATION messages and tags.
226 *
227 * * If the number of loops is >0 or -1, durations of TOC entries are set to
228 * the duration of the respective subsong in LOOPING mode and to G_MAXINT64 in
229 * STEADY mode. If the number of loops is 0, entry durations are set to the
230 * subsong duration regardless of the output mode.
231 */
232 abstract class NonstreamAudioDecoder extends Gst.Element {
233 static $gtype: GObject.GType<NonstreamAudioDecoder>;
234
235 // Properties
236
237 get current_subsong(): number;
238 set current_subsong(val: number);
239 get currentSubsong(): number;
240 set currentSubsong(val: number);
241 get num_loops(): number;
242 set num_loops(val: number);
243 get numLoops(): number;
244 set numLoops(val: number);
245
246 // Fields
247
248 element: Gst.Element;
249 sinkpad: Gst.Pad;
250 srcpad: Gst.Pad;
251 upstream_size: number;
252 loaded_mode: boolean;
253 input_data_adapter: GstBase.Adapter;
254 subsong_duration: Gst.ClockTime;
255 output_format_changed: boolean;
256 cur_pos_in_samples: number;
257 num_decoded_samples: number;
258 discont: boolean;
259 allocator: Gst.Allocator;
260
261 // Constructors
262
263 constructor(properties?: Partial<NonstreamAudioDecoder.ConstructorProps>, ...args: any[]);
264
265 _init(...args: any[]): void;
266
267 // Virtual methods
268
269 /**
270 * Optional.
271 * Sets up the allocation parameters for allocating output
272 * buffers. The passed in query contains the result of the
273 * downstream allocation query.
274 * Subclasses should chain up to the parent implementation to
275 * invoke the default handler.
276 * @param query
277 */
278 vfunc_decide_allocation(query: Gst.Query): boolean;
279 /**
280 * Always required.
281 * Allocates an output buffer, fills it with decoded audio samples, and must be passed on to
282 * *buffer . The number of decoded samples must be passed on to *num_samples.
283 * If decoding finishes or the decoding is no longer possible (for example, due to an
284 * unrecoverable error), this function returns FALSE, otherwise TRUE.
285 * @param buffer
286 * @param num_samples
287 */
288 vfunc_decode(buffer: Gst.Buffer, num_samples: number): boolean;
289 /**
290 * Optional.
291 * Returns the current subsong.
292 * If the current subsong mode is not GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE, this
293 * function's return value is undefined.
294 * If this function is implemented by the subclass,
295 * `get_num_subsongs` should be implemented as well.
296 */
297 vfunc_get_current_subsong(): number;
298 /**
299 * Optional.
300 * Returns a tag list containing the main song tags, or NULL if there are
301 * no such tags. Returned tags will be unref'd. Use this vfunc instead of
302 * manually pushing a tag event downstream to avoid edge cases where not yet
303 * pushed sticky tag events get overwritten before they are pushed (can for
304 * example happen with decodebin if tags are pushed downstream before the
305 * decodebin pads are linked).
306 */
307 vfunc_get_main_tags(): Gst.TagList;
308 /**
309 * Optional.
310 * Returns the number of loops for playback.
311 */
312 vfunc_get_num_loops(): number;
313 /**
314 * Optional.
315 * Returns the number of subsongs available.
316 * The return values 0 and 1 have a similar, but distinct, meaning.
317 * If this function returns 0, then this decoder does not support subsongs at all.
318 * `get_current_subsong` must then also always return 0. In other words, this function
319 * either never returns 0, or never returns anything else than 0.
320 * A return value of 1 means that the media contains either only one or no subsongs
321 * (the entire song is then considered to be one single subsong). 1 also means that only
322 * this very media has no or just one subsong, and the decoder itself can
323 * support multiple subsongs.
324 */
325 vfunc_get_num_subsongs(): number;
326 /**
327 * Optional.
328 * Returns the duration of a subsong. Returns GST_CLOCK_TIME_NONE if duration is unknown.
329 * @param subsong
330 */
331 vfunc_get_subsong_duration(subsong: number): Gst.ClockTime;
332 /**
333 * Optional.
334 * Returns tags for a subsong, or NULL if there are no tags.
335 * Returned tags will be unref'd.
336 * @param subsong
337 */
338 vfunc_get_subsong_tags(subsong: number): Gst.TagList;
339 /**
340 * Always required.
341 * Returns a bitmask containing the output modes the subclass supports.
342 * The mask is formed by a bitwise OR combination of integers, which can be calculated
343 * this way: 1 << GST_NONSTREAM_AUDIO_OUTPUT_MODE_<mode> , where mode is either STEADY or LOOPING
344 */
345 vfunc_get_supported_output_modes(): number;
346 /**
347 * Required if loads_from_sinkpad is set to TRUE (the default value).
348 * Loads the media from the given buffer. The entire media is supplied at once,
349 * so after this call, loading should be finished. This function
350 * can also make use of a suggested initial subsong & subsong mode and initial
351 * playback position (but isn't required to). In case it chooses a different starting
352 * position, the function must pass this position to *initial_position.
353 * The subclass does not have to unref the input buffer; the base class does that
354 * already.
355 * @param source_data
356 * @param initial_subsong
357 * @param initial_subsong_mode
358 * @param initial_position
359 * @param initial_output_mode
360 * @param initial_num_loops
361 */
362 vfunc_load_from_buffer(
363 source_data: Gst.Buffer,
364 initial_subsong: number,
365 initial_subsong_mode: NonstreamAudioSubsongMode,
366 initial_position: Gst.ClockTime,
367 initial_output_mode: NonstreamAudioOutputMode,
368 initial_num_loops: number,
369 ): boolean;
370 /**
371 * Required if loads_from_sinkpad is set to FALSE.
372 * Loads the media in a way defined by the custom sink. Data is not supplied;
373 * the derived class has to handle this on its own. Otherwise, this function is
374 * identical to `load_from_buffer`.
375 * @param initial_subsong
376 * @param initial_subsong_mode
377 * @param initial_position
378 * @param initial_output_mode
379 * @param initial_num_loops
380 */
381 vfunc_load_from_custom(
382 initial_subsong: number,
383 initial_subsong_mode: NonstreamAudioSubsongMode,
384 initial_position: Gst.ClockTime,
385 initial_output_mode: NonstreamAudioOutputMode,
386 initial_num_loops: number,
387 ): boolean;
388 vfunc_negotiate(): boolean;
389 /**
390 * Optional.
391 * Proposes buffer allocation parameters for upstream elements.
392 * Subclasses should chain up to the parent implementation to
393 * invoke the default handler.
394 * @param query
395 */
396 vfunc_propose_allocation(query: Gst.Query): boolean;
397 /**
398 * Optional.
399 * Called when a seek event is received by the parent class.
400 * new_position is a pointer to a GstClockTime integer which
401 * contains a position relative to the current subsong.
402 * Minimum is 0, maximum is the subsong length.
403 * After this function finishes, new_position is set to the
404 * actual new position (which may differ from the request
405 * position, depending on the decoder).
406 * @param new_position
407 */
408 vfunc_seek(new_position: Gst.ClockTime): boolean;
409 /**
410 * Optional.
411 * Sets the current subsong. This function is allowed to switch to a different
412 * subsong than the required one, and can optionally make use of the suggested initial
413 * position. In case it chooses a different starting position, the function must pass
414 * this position to *initial_position.
415 * This function switches the subsong mode to GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE
416 * automatically.
417 * If this function is implemented by the subclass, `get_current_subsong` and
418 * `get_num_subsongs` should be implemented as well.
419 * @param subsong
420 * @param initial_position
421 */
422 vfunc_set_current_subsong(subsong: number, initial_position: Gst.ClockTime): boolean;
423 /**
424 * Optional.
425 * Sets the number of loops for playback. If this is called during playback,
426 * the subclass must set any internal loop counters to zero. A loop value of -1
427 * means infinite looping; 0 means no looping; and when the num_loops is greater than 0,
428 * playback should loop exactly num_loops times. If this function is implemented,
429 * `get_num_loops` should be implemented as well. The function can ignore the given values
430 * and choose another; however, `get_num_loops` should return this other value afterwards.
431 * It is up to the subclass to define where the loop starts and ends. It can mean that only
432 * a subset at the end or in the middle of a song is repeated, for example.
433 * If the current subsong mode is GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE, then the subsong
434 * is repeated this many times. If it is GST_NONSTREAM_AUDIO_SUBSONG_MODE_ALL, then all
435 * subsongs are repeated this many times. With GST_NONSTREAM_AUDIO_SUBSONG_MODE_DECODER_DEFAULT,
436 * the behavior is decoder specific.
437 * @param num_loops
438 */
439 vfunc_set_num_loops(num_loops: number): boolean;
440 /**
441 * Optional.
442 * Sets the output mode the subclass has to use. Unlike with most other functions, the subclass
443 * cannot choose a different mode; it must use the requested one.
444 * If the output mode is set to LOOPING, `gst_nonstream_audio_decoder_handle_loop`
445 * must be called after playback moved back to the start of a loop.
446 * @param mode
447 * @param current_position
448 */
449 vfunc_set_output_mode(mode: NonstreamAudioOutputMode, current_position: Gst.ClockTime): boolean;
450 /**
451 * Optional.
452 * Sets the current subsong mode. Since this might influence the current playback position,
453 * this function must set the initial_position integer argument to a defined value.
454 * If the playback position is not affected at all, it must be set to GST_CLOCK_TIME_NONE.
455 * If the subsong is restarted after the mode switch, it is recommended to set the value
456 * to the position in the playback right after the switch (or 0 if the subsongs are always
457 * reset back to the beginning).
458 * @param mode
459 * @param initial_position
460 */
461 vfunc_set_subsong_mode(mode: NonstreamAudioSubsongMode, initial_position: Gst.ClockTime): boolean;
462 /**
463 * Optional.
464 * Called when a position query is received by the parent class.
465 * The position that this function returns must be relative to
466 * the current subsong. Thus, the minimum is 0, and the maximum
467 * is the subsong length.
468 */
469 vfunc_tell(): Gst.ClockTime;
470
471 // Methods
472
473 /**
474 * Allocates an output buffer with the internally configured buffer pool.
475 *
476 * This function may only be called from within `load_from_buffer,`
477 * `load_from_custom,` and `decode`.
478 * @param size Size of the output buffer, in bytes
479 * @returns Newly allocated output buffer, or NULL if allocation failed
480 */
481 allocate_output_buffer(size: number): Gst.Buffer | null;
482 /**
483 * Gets sample format, sample rate, channel count from the allowed srcpad caps.
484 *
485 * This is useful for when the subclass wishes to adjust one or more output
486 * parameters to whatever downstream is supporting. For example, the output
487 * sample rate is often a freely adjustable value in module players.
488 *
489 * This function tries to find a value inside the srcpad peer's caps for
490 * `format,` `sample_rate,` `num_chnanels` . Any of these can be NULL; they
491 * (and the corresponding downstream caps) are then skipped while retrieving
492 * information. Non-fixated caps are fixated first; the value closest to
493 * their present value is then chosen. For example, if the variables pointed
494 * to by the arguments are GST_AUDIO_FORMAT_16, 48000 Hz, and 2 channels,
495 * and the downstream caps are:
496 *
497 * "audio/x-raw, format={S16LE,S32LE}, rate=[1,32000], channels=[1,MAX]"
498 *
499 * Then `format` and `channels` stay the same, while `sample_rate` is set to 32000 Hz.
500 * This way, the initial values the the variables pointed to by the arguments
501 * are set to can be used as default output values. Note that if no downstream
502 * caps can be retrieved, then this function does nothing, therefore it is
503 * necessary to ensure that `format,` `sample_rate,` and `channels` have valid
504 * initial values.
505 *
506 * Decoder lock is not held by this function, so it can be called from within
507 * any of the class vfuncs.
508 * @param format #GstAudioFormat value to fill with a sample format
509 * @param sample_rate Integer to fill with a sample rate
510 * @param num_channels Integer to fill with a channel count
511 */
512 get_downstream_info(format: GstAudio.AudioFormat | null, sample_rate: number, num_channels: number): void;
513 /**
514 * Reports that a loop has been completed and creates a new appropriate
515 * segment for the next loop.
516 *
517 * `new_position` exists because a loop may not start at the beginning.
518 *
519 * This function is only useful for subclasses which can be in the
520 * GST_NONSTREAM_AUDIO_OUTPUT_MODE_LOOPING output mode, since in the
521 * GST_NONSTREAM_AUDIO_OUTPUT_MODE_STEADY output mode, this function
522 * does nothing. See #GstNonstreamAudioOutputMode for more details.
523 *
524 * The subclass calls this during playback when it loops. It produces
525 * a new segment with updated base time and internal time values, to allow
526 * for seamless looping. It does *not* check the number of elapsed loops;
527 * this is up the subclass.
528 *
529 * Note that if this function is called, then it must be done after the
530 * last samples of the loop have been decoded and pushed downstream.
531 *
532 * This function must be called with the decoder mutex lock held, since it
533 * is typically called from within `decode` (which in turn are called with
534 * the lock already held).
535 * @param new_position
536 */
537 handle_loop(new_position: Gst.ClockTime): void;
538 /**
539 * Sets the output caps by means of a GstAudioInfo structure.
540 *
541 * This must be called latest in the first `decode` call, to ensure src caps are
542 * set before decoded samples are sent downstream. Typically, this is called
543 * from inside `load_from_buffer` or `load_from_custom`.
544 *
545 * This function must be called with the decoder mutex lock held, since it
546 * is typically called from within the aforementioned vfuncs (which in turn
547 * are called with the lock already held).
548 * @param audio_info Valid audio info structure containing the output format
549 * @returns TRUE if setting the output format succeeded, FALSE otherwise
550 */
551 set_output_format(audio_info: GstAudio.AudioInfo): boolean;
552 /**
553 * Convenience function; sets the output caps by means of common parameters.
554 *
555 * Internally, this fills a GstAudioInfo structure and calls
556 * gst_nonstream_audio_decoder_set_output_format().
557 * @param sample_rate Output sample rate to use, in Hz
558 * @param sample_format Output sample format to use
559 * @param num_channels Number of output channels to use
560 * @returns TRUE if setting the output format succeeded, FALSE otherwise
561 */
562 set_output_format_simple(
563 sample_rate: number,
564 sample_format: GstAudio.AudioFormat | null,
565 num_channels: number,
566 ): boolean;
567 }
568
569 namespace PlanarAudioAdapter {
570 // Constructor properties interface
571
572 interface ConstructorProps extends GObject.Object.ConstructorProps {}
573 }
574
575 /**
576 * This class is similar to GstAdapter, but it is made to work with
577 * non-interleaved (planar) audio buffers. Before using, an audio format
578 * must be configured with gst_planar_audio_adapter_configure()
579 */
580 class PlanarAudioAdapter extends GObject.Object {
581 static $gtype: GObject.GType<PlanarAudioAdapter>;
582
583 // Constructors
584
585 constructor(properties?: Partial<PlanarAudioAdapter.ConstructorProps>, ...args: any[]);
586
587 _init(...args: any[]): void;
588
589 static ['new'](): PlanarAudioAdapter;
590
591 // Methods
592
593 /**
594 * Gets the maximum amount of samples available, that is it returns the maximum
595 * value that can be supplied to gst_planar_audio_adapter_get_buffer() without
596 * that function returning %NULL.
597 * @returns number of samples available in @adapter
598 */
599 available(): number;
600 /**
601 * Removes all buffers from `adapter`.
602 */
603 clear(): void;
604 /**
605 * Sets up the `adapter` to handle audio data of the specified audio format.
606 * Note that this will internally clear the adapter and re-initialize it.
607 * @param info a #GstAudioInfo describing the format of the audio data
608 */
609 configure(info: GstAudio.AudioInfo): void;
610 distance_from_discont(): number;
611 /**
612 * Get the DTS that was on the last buffer with the GST_BUFFER_FLAG_DISCONT
613 * flag, or GST_CLOCK_TIME_NONE.
614 * @returns The DTS at the last discont or GST_CLOCK_TIME_NONE.
615 */
616 dts_at_discont(): Gst.ClockTime;
617 /**
618 * Flushes the first `to_flush` samples in the `adapter`. The caller must ensure
619 * that at least this many samples are available.
620 * @param to_flush the number of samples to flush
621 */
622 flush(to_flush: number): void;
623 /**
624 * Returns a #GstBuffer containing the first `nsamples` of the `adapter,` but
625 * does not flush them from the adapter.
626 * Use gst_planar_audio_adapter_take_buffer() for flushing at the same time.
627 *
628 * The map `flags` can be used to give an optimization hint to this function.
629 * When the requested buffer is meant to be mapped only for reading, it might
630 * be possible to avoid copying memory in some cases.
631 *
632 * Caller owns a reference to the returned buffer. gst_buffer_unref() after
633 * usage.
634 *
635 * Free-function: gst_buffer_unref
636 * @param nsamples the number of samples to get
637 * @param flags hint the intended use of the returned buffer
638 * @returns a #GstBuffer containing the first @nsamples of the adapter, or %NULL if @nsamples samples are not available. gst_buffer_unref() when no longer needed.
639 */
640 get_buffer(nsamples: number, flags: Gst.MapFlags | null): Gst.Buffer | null;
641 /**
642 * Get the offset that was on the last buffer with the GST_BUFFER_FLAG_DISCONT
643 * flag, or GST_BUFFER_OFFSET_NONE.
644 * @returns The offset at the last discont or GST_BUFFER_OFFSET_NONE.
645 */
646 offset_at_discont(): number;
647 /**
648 * Get the dts that was before the current sample in the adapter. When
649 * `distance` is given, the amount of bytes between the dts and the current
650 * position is returned.
651 *
652 * The dts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when
653 * the adapter is first created or when it is cleared. This also means that
654 * before the first sample with a dts is removed from the adapter, the dts
655 * and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.
656 * @returns The previously seen dts.
657 */
658 prev_dts(): [Gst.ClockTime, number];
659 /**
660 * Get the offset that was before the current sample in the adapter. When
661 * `distance` is given, the amount of samples between the offset and the current
662 * position is returned.
663 *
664 * The offset is reset to GST_BUFFER_OFFSET_NONE and the distance is set to 0
665 * when the adapter is first created or when it is cleared. This also means that
666 * before the first sample with an offset is removed from the adapter, the
667 * offset and distance returned are GST_BUFFER_OFFSET_NONE and 0 respectively.
668 * @returns The previous seen offset.
669 */
670 prev_offset(): [number, number];
671 /**
672 * Get the pts that was before the current sample in the adapter. When
673 * `distance` is given, the amount of samples between the pts and the current
674 * position is returned.
675 *
676 * The pts is reset to GST_CLOCK_TIME_NONE and the distance is set to 0 when
677 * the adapter is first created or when it is cleared. This also means that before
678 * the first sample with a pts is removed from the adapter, the pts
679 * and distance returned are GST_CLOCK_TIME_NONE and 0 respectively.
680 * @returns The previously seen pts.
681 */
682 prev_pts(): [Gst.ClockTime, number];
683 /**
684 * Get the PTS that was on the last buffer with the GST_BUFFER_FLAG_DISCONT
685 * flag, or GST_CLOCK_TIME_NONE.
686 * @returns The PTS at the last discont or GST_CLOCK_TIME_NONE.
687 */
688 pts_at_discont(): Gst.ClockTime;
689 /**
690 * Adds the data from `buf` to the data stored inside `adapter` and takes
691 * ownership of the buffer.
692 * @param buf a #GstBuffer to queue in the adapter
693 */
694 push(buf: Gst.Buffer): void;
695 /**
696 * Returns a #GstBuffer containing the first `nsamples` bytes of the
697 * `adapter`. The returned bytes will be flushed from the adapter.
698 *
699 * See gst_planar_audio_adapter_get_buffer() for more details.
700 *
701 * Caller owns a reference to the returned buffer. gst_buffer_unref() after
702 * usage.
703 *
704 * Free-function: gst_buffer_unref
705 * @param nsamples the number of samples to take
706 * @param flags hint the intended use of the returned buffer
707 * @returns a #GstBuffer containing the first @nsamples of the adapter, or %NULL if @nsamples samples are not available. gst_buffer_unref() when no longer needed.
708 */
709 take_buffer(nsamples: number, flags: Gst.MapFlags | null): Gst.Buffer | null;
710 }
711
712 type NonstreamAudioDecoderClass = typeof NonstreamAudioDecoder;
713 type PlanarAudioAdapterClass = typeof PlanarAudioAdapter;
714 /**
715 * Name of the imported GIR library
716 * `see` https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
717 */
718 const __name__: string;
719 /**
720 * Version of the imported GIR library
721 * `see` https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
722 */
723 const __version__: string;
724 }
725
726 export default GstBadAudio;
727 }
728
729 declare module 'gi://GstBadAudio' {
730 import GstBadAudio10 from 'gi://GstBadAudio?version=1.0';
731 export default GstBadAudio10;
732 }
733 // END