objc2_avf_audio/generated/AVAudioConverter.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// values for the primeMethod property. See further discussion under AVAudioConverterPrimeInfo.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioconverterprimemethod?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct AVAudioConverterPrimeMethod(pub NSInteger);
17impl AVAudioConverterPrimeMethod {
18 /// Primes with leading + trailing input frames.
19 #[doc(alias = "AVAudioConverterPrimeMethod_Pre")]
20 pub const Pre: Self = Self(0);
21 /// Only primes with trailing (zero latency). Leading frames are assumed to be silence.
22 #[doc(alias = "AVAudioConverterPrimeMethod_Normal")]
23 pub const Normal: Self = Self(1);
24 /// Acts in "latency" mode. Both leading and trailing frames assumed to be silence.
25 #[doc(alias = "AVAudioConverterPrimeMethod_None")]
26 pub const None: Self = Self(2);
27}
28
29unsafe impl Encode for AVAudioConverterPrimeMethod {
30 const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for AVAudioConverterPrimeMethod {
34 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37/// This struct is the value of the primeInfo property and specifies priming information.
38///
39/// When using convertToBuffer:error:withInputFromBlock: (either a single call or a series of calls), some
40/// conversions, particularly involving sample-rate conversion, ideally require a certain
41/// number of input frames previous to the normal start input frame and beyond the end of
42/// the last expected input frame in order to yield high-quality results.
43///
44/// These are expressed in the leadingFrames and trailingFrames members of the structure.
45///
46/// The very first call to convertToBuffer:error:withInputFromBlock:, or first call after
47/// reset, will request additional input frames beyond those normally
48/// expected in the input proc callback to fulfill this first AudioConverterFillComplexBuffer()
49/// request. The number of additional frames requested, depending on the prime method, will
50/// be approximately:
51///
52/// Prime method | Additional frames
53/// ------------------------------------|----------------------
54/// AVAudioConverterPrimeMethod_Pre | leadingFrames + trailingFrames
55/// AVAudioConverterPrimeMethod_Normal | trailingFrames
56/// AVAudioConverterPrimeMethod_None | 0
57///
58/// Thus, in effect, the first input proc callback(s) may provide not only the leading
59/// frames, but also may "read ahead" by an additional number of trailing frames depending
60/// on the prime method.
61///
62/// AVAudioConverterPrimeMethod_None is useful in a real-time application processing live input,
63/// in which case trailingFrames (relative to input sample rate) of through latency will be
64/// seen at the beginning of the output of the AudioConverter. In other real-time
65/// applications such as DAW systems, it may be possible to provide these initial extra
66/// audio frames since they are stored on disk or in memory somewhere and
67/// AVAudioConverterPrimeMethod_Pre may be preferable. The default method is
68/// AVAudioConverterPrimeMethod_Normal, which requires no pre-seeking of the input stream and
69/// generates no latency at the output.
70///
71/// Field: leadingFrames
72/// Specifies the number of leading (previous) input frames, relative to the normal/desired
73/// start input frame, required by the converter to perform a high quality conversion. If
74/// using AVAudioConverterPrimeMethod_Pre, the client should "pre-seek" the input stream provided
75/// through the input proc by leadingFrames. If no frames are available previous to the
76/// desired input start frame (because, for example, the desired start frame is at the very
77/// beginning of available audio), then provide "leadingFrames" worth of initial zero frames
78/// in the input proc. Do not "pre-seek" in the default case of
79/// AVAudioConverterPrimeMethod_Normal or when using AVAudioConverterPrimeMethod_None.
80///
81/// Field: trailingFrames
82/// Specifies the number of trailing input frames (past the normal/expected end input frame)
83/// required by the converter to perform a high quality conversion. The client should be
84/// prepared to provide this number of additional input frames except when using
85/// AVAudioConverterPrimeMethod_None. If no more frames of input are available in the input stream
86/// (because, for example, the desired end frame is at the end of an audio file), then zero
87/// (silent) trailing frames will be synthesized for the client.
88///
89/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioconverterprimeinfo?language=objc)
90#[cfg(feature = "AVAudioTypes")]
91#[repr(C)]
92#[derive(Clone, Copy, Debug, PartialEq)]
93pub struct AVAudioConverterPrimeInfo {
94 pub leadingFrames: AVAudioFrameCount,
95 pub trailingFrames: AVAudioFrameCount,
96}
97
98#[cfg(feature = "AVAudioTypes")]
99unsafe impl Encode for AVAudioConverterPrimeInfo {
100 const ENCODING: Encoding = Encoding::Struct(
101 "AVAudioConverterPrimeInfo",
102 &[<AVAudioFrameCount>::ENCODING, <AVAudioFrameCount>::ENCODING],
103 );
104}
105
106#[cfg(feature = "AVAudioTypes")]
107unsafe impl RefEncode for AVAudioConverterPrimeInfo {
108 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
109}
110
111/// You must return one of these codes from your AVAudioConverterInputBlock.
112///
113/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioconverterinputstatus?language=objc)
114// NS_ENUM
115#[repr(transparent)]
116#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
117pub struct AVAudioConverterInputStatus(pub NSInteger);
118impl AVAudioConverterInputStatus {
119 /// This is the normal case where you supply data to the converter.
120 #[doc(alias = "AVAudioConverterInputStatus_HaveData")]
121 pub const HaveData: Self = Self(0);
122 /// If you are out of data for now, set *ioNumberOfPackets = 0 and return
123 /// AVAudioConverterInputStatus_NoDataNow; it is possible that some of the supplied input data
124 /// may not be converted to output immediately, but instead may be converted to output only
125 /// if/when more input is provided or the end-of-stream is indicated with the
126 /// AVAudioConverterInputStatus_EndOfStream status code.
127 #[doc(alias = "AVAudioConverterInputStatus_NoDataNow")]
128 pub const NoDataNow: Self = Self(1);
129 /// If you are at the end of stream, set *ioNumberOfPackets = 0 and return
130 /// AVAudioConverterInputStatus_EndOfStream.
131 #[doc(alias = "AVAudioConverterInputStatus_EndOfStream")]
132 pub const EndOfStream: Self = Self(2);
133}
134
135unsafe impl Encode for AVAudioConverterInputStatus {
136 const ENCODING: Encoding = NSInteger::ENCODING;
137}
138
139unsafe impl RefEncode for AVAudioConverterInputStatus {
140 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
141}
142
143/// These values are returned from convertToBuffer:error:withInputFromBlock:
144///
145/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioconverteroutputstatus?language=objc)
146// NS_ENUM
147#[repr(transparent)]
148#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
149pub struct AVAudioConverterOutputStatus(pub NSInteger);
150impl AVAudioConverterOutputStatus {
151 /// All of the requested data was returned.
152 #[doc(alias = "AVAudioConverterOutputStatus_HaveData")]
153 pub const HaveData: Self = Self(0);
154 /// Not enough input was available to satisfy the request at the current time. The output buffer
155 /// contains as much as could be converted.
156 #[doc(alias = "AVAudioConverterOutputStatus_InputRanDry")]
157 pub const InputRanDry: Self = Self(1);
158 /// The end of stream has been reached. No data was returned.
159 #[doc(alias = "AVAudioConverterOutputStatus_EndOfStream")]
160 pub const EndOfStream: Self = Self(2);
161 /// An error occurred.
162 #[doc(alias = "AVAudioConverterOutputStatus_Error")]
163 pub const Error: Self = Self(3);
164}
165
166unsafe impl Encode for AVAudioConverterOutputStatus {
167 const ENCODING: Encoding = NSInteger::ENCODING;
168}
169
170unsafe impl RefEncode for AVAudioConverterOutputStatus {
171 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
172}
173
174/// A block which will be called by convertToBuffer:error:withInputFromBlock: to get input data as needed.
175///
176///
177/// Parameter `inNumberOfPackets`: This will be the number of packets required to complete the request. You may supply more or
178/// less that this amount. If less, then the input block will get called again.
179///
180///
181/// Parameter `outStatus`: The block must set the appropriate AVAudioConverterInputStatus enum value.
182///
183/// If you have supplied data, set outStatus to AVAudioConverterInputStatus_HaveData and return
184/// an AVAudioBuffer.
185///
186/// If you are out of data for now, set outStatus to AVAudioConverterInputStatus_NoDataNow and
187/// return nil, and the conversion routine will return as much output as could be converted with
188/// the input already supplied.
189///
190/// If you are at the end of stream, set outStatus to AVAudioConverterInputStatus_EndOfStream,
191/// and return nil.
192///
193///
194/// Returns: An AVAudioBuffer containing data to be converted, or nil if at end of stream or no data is
195/// available. The data in the returned buffer must not be cleared or re-filled until the input
196/// block is called again or the conversion has finished.
197///
198/// convertToBuffer:error:withInputFromBlock: will return as much output as could be converted
199/// with the input already supplied.
200///
201/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioconverterinputblock?language=objc)
202#[cfg(all(
203 feature = "AVAudioBuffer",
204 feature = "AVAudioTypes",
205 feature = "block2"
206))]
207pub type AVAudioConverterInputBlock = *mut block2::DynBlock<
208 dyn Fn(AVAudioPacketCount, NonNull<AVAudioConverterInputStatus>) -> *mut AVAudioBuffer,
209>;
210
211extern_class!(
212 /// Converts streams of audio between various formats.
213 ///
214 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avaudioconverter?language=objc)
215 #[unsafe(super(NSObject))]
216 #[derive(Debug, PartialEq, Eq, Hash)]
217 pub struct AVAudioConverter;
218);
219
220unsafe impl Send for AVAudioConverter {}
221
222unsafe impl Sync for AVAudioConverter {}
223
224extern_conformance!(
225 unsafe impl NSObjectProtocol for AVAudioConverter {}
226);
227
228impl AVAudioConverter {
229 extern_methods!(
230 #[cfg(feature = "AVAudioFormat")]
231 /// Initialize from input and output formats.
232 ///
233 /// Parameter `fromFormat`: The input format.
234 ///
235 /// Parameter `toFormat`: The output format.
236 ///
237 /// Returns nil if the format conversion is not possible.
238 #[unsafe(method(initFromFormat:toFormat:))]
239 #[unsafe(method_family = init)]
240 pub unsafe fn initFromFormat_toFormat(
241 this: Allocated<Self>,
242 from_format: &AVAudioFormat,
243 to_format: &AVAudioFormat,
244 ) -> Option<Retained<Self>>;
245
246 /// Resets the converter so that a new stream may be converted.
247 #[unsafe(method(reset))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn reset(&self);
250
251 #[cfg(feature = "AVAudioFormat")]
252 /// The format of the input audio stream. (NB. AVAudioFormat includes the channel layout)
253 ///
254 /// This property is not atomic.
255 ///
256 /// # Safety
257 ///
258 /// This might not be thread-safe.
259 #[unsafe(method(inputFormat))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn inputFormat(&self) -> Retained<AVAudioFormat>;
262
263 #[cfg(feature = "AVAudioFormat")]
264 /// The format of the output audio stream. (NB. AVAudioFormat includes the channel layout)
265 ///
266 /// This property is not atomic.
267 ///
268 /// # Safety
269 ///
270 /// This might not be thread-safe.
271 #[unsafe(method(outputFormat))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn outputFormat(&self) -> Retained<AVAudioFormat>;
274
275 /// An array of integers indicating from which input to derive each output.
276 ///
277 /// The array has size equal to the number of output channels. Each element's value is the input
278 /// channel number, starting with zero, that is to be copied to that output. A negative value
279 /// means that the output channel will have no source and will be silent. Setting a channel map
280 /// overrides channel mapping due to any channel layouts in the input and output formats that
281 /// may have been supplied.
282 ///
283 /// This property is not atomic.
284 ///
285 /// # Safety
286 ///
287 /// This might not be thread-safe.
288 #[unsafe(method(channelMap))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn channelMap(&self) -> Retained<NSArray<NSNumber>>;
291
292 /// Setter for [`channelMap`][Self::channelMap].
293 ///
294 /// # Safety
295 ///
296 /// This might not be thread-safe.
297 #[unsafe(method(setChannelMap:))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn setChannelMap(&self, channel_map: &NSArray<NSNumber>);
300
301 /// Decoders require some data in the form of a magicCookie in order to decode properly.
302 /// Encoders will produce a magicCookie.
303 ///
304 /// This property is not atomic.
305 ///
306 /// # Safety
307 ///
308 /// This might not be thread-safe.
309 #[unsafe(method(magicCookie))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn magicCookie(&self) -> Option<Retained<NSData>>;
312
313 /// Setter for [`magicCookie`][Self::magicCookie].
314 ///
315 /// # Safety
316 ///
317 /// This might not be thread-safe.
318 #[unsafe(method(setMagicCookie:))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn setMagicCookie(&self, magic_cookie: Option<&NSData>);
321
322 /// If YES and channel remapping is necessary, then channels will be mixed as
323 /// appropriate instead of remapped. Default value is NO.
324 ///
325 /// This property is not atomic.
326 ///
327 /// # Safety
328 ///
329 /// This might not be thread-safe.
330 #[unsafe(method(downmix))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn downmix(&self) -> bool;
333
334 /// Setter for [`downmix`][Self::downmix].
335 ///
336 /// # Safety
337 ///
338 /// This might not be thread-safe.
339 #[unsafe(method(setDownmix:))]
340 #[unsafe(method_family = none)]
341 pub unsafe fn setDownmix(&self, downmix: bool);
342
343 /// Setting YES will turn on dither, if dither makes sense in given the current formats
344 /// and settings. Default value is NO.
345 ///
346 /// This property is not atomic.
347 ///
348 /// # Safety
349 ///
350 /// This might not be thread-safe.
351 #[unsafe(method(dither))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn dither(&self) -> bool;
354
355 /// Setter for [`dither`][Self::dither].
356 ///
357 /// # Safety
358 ///
359 /// This might not be thread-safe.
360 #[unsafe(method(setDither:))]
361 #[unsafe(method_family = none)]
362 pub unsafe fn setDither(&self, dither: bool);
363
364 /// An AVAudioQuality value as defined in AVAudioSettings.h.
365 ///
366 /// This property is not atomic.
367 ///
368 /// # Safety
369 ///
370 /// This might not be thread-safe.
371 #[unsafe(method(sampleRateConverterQuality))]
372 #[unsafe(method_family = none)]
373 pub unsafe fn sampleRateConverterQuality(&self) -> NSInteger;
374
375 /// Setter for [`sampleRateConverterQuality`][Self::sampleRateConverterQuality].
376 ///
377 /// # Safety
378 ///
379 /// This might not be thread-safe.
380 #[unsafe(method(setSampleRateConverterQuality:))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn setSampleRateConverterQuality(
383 &self,
384 sample_rate_converter_quality: NSInteger,
385 );
386
387 /// An AVSampleRateConverterAlgorithmKey value as defined in AVAudioSettings.h.
388 ///
389 /// This property is not atomic.
390 ///
391 /// # Safety
392 ///
393 /// This might not be thread-safe.
394 #[unsafe(method(sampleRateConverterAlgorithm))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn sampleRateConverterAlgorithm(&self) -> Option<Retained<NSString>>;
397
398 /// Setter for [`sampleRateConverterAlgorithm`][Self::sampleRateConverterAlgorithm].
399 ///
400 /// # Safety
401 ///
402 /// This might not be thread-safe.
403 #[unsafe(method(setSampleRateConverterAlgorithm:))]
404 #[unsafe(method_family = none)]
405 pub unsafe fn setSampleRateConverterAlgorithm(
406 &self,
407 sample_rate_converter_algorithm: Option<&NSString>,
408 );
409
410 /// Indicates the priming method to be used by the sample rate converter or decoder.
411 ///
412 /// This property is not atomic.
413 ///
414 /// # Safety
415 ///
416 /// This might not be thread-safe.
417 #[unsafe(method(primeMethod))]
418 #[unsafe(method_family = none)]
419 pub unsafe fn primeMethod(&self) -> AVAudioConverterPrimeMethod;
420
421 /// Setter for [`primeMethod`][Self::primeMethod].
422 ///
423 /// # Safety
424 ///
425 /// This might not be thread-safe.
426 #[unsafe(method(setPrimeMethod:))]
427 #[unsafe(method_family = none)]
428 pub unsafe fn setPrimeMethod(&self, prime_method: AVAudioConverterPrimeMethod);
429
430 #[cfg(feature = "AVAudioTypes")]
431 /// Indicates the the number of priming frames.
432 ///
433 /// This property is not atomic.
434 ///
435 /// # Safety
436 ///
437 /// This might not be thread-safe.
438 #[unsafe(method(primeInfo))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn primeInfo(&self) -> AVAudioConverterPrimeInfo;
441
442 #[cfg(feature = "AVAudioTypes")]
443 /// Setter for [`primeInfo`][Self::primeInfo].
444 ///
445 /// # Safety
446 ///
447 /// This might not be thread-safe.
448 #[unsafe(method(setPrimeInfo:))]
449 #[unsafe(method_family = none)]
450 pub unsafe fn setPrimeInfo(&self, prime_info: AVAudioConverterPrimeInfo);
451
452 /// Number of packets between consecutive sync packets.
453 ///
454 /// A sync packet is an independently-decodable packet that completely refreshes the decoder without
455 /// needing to decode other packets. When compressing to a format which supports it (such as APAC),
456 /// the audio sync packet frequency indicates the distance in packets between two sync packets, with
457 /// non-sync packets between. This is useful to set when saving compressed packets to a file and
458 /// efficient random access is desired. Note: Separating sync packets by at least one second of
459 /// encoded audio (e.g. 75 packets) is recommended.
460 ///
461 /// This property is not atomic.
462 ///
463 /// # Safety
464 ///
465 /// This might not be thread-safe.
466 #[unsafe(method(audioSyncPacketFrequency))]
467 #[unsafe(method_family = none)]
468 pub unsafe fn audioSyncPacketFrequency(&self) -> NSInteger;
469
470 /// Setter for [`audioSyncPacketFrequency`][Self::audioSyncPacketFrequency].
471 ///
472 /// # Safety
473 ///
474 /// This might not be thread-safe.
475 #[unsafe(method(setAudioSyncPacketFrequency:))]
476 #[unsafe(method_family = none)]
477 pub unsafe fn setAudioSyncPacketFrequency(&self, audio_sync_packet_frequency: NSInteger);
478
479 #[cfg(feature = "AVAudioSettings")]
480 /// Index to select a pre-defined content source type that describes the content type and
481 /// how it was generated. Note: This is only supported when compressing audio to formats
482 /// which support it.
483 ///
484 /// This property is not atomic.
485 ///
486 /// # Safety
487 ///
488 /// This might not be thread-safe.
489 #[unsafe(method(contentSource))]
490 #[unsafe(method_family = none)]
491 pub unsafe fn contentSource(&self) -> AVAudioContentSource;
492
493 #[cfg(feature = "AVAudioSettings")]
494 /// Setter for [`contentSource`][Self::contentSource].
495 ///
496 /// # Safety
497 ///
498 /// This might not be thread-safe.
499 #[unsafe(method(setContentSource:))]
500 #[unsafe(method_family = none)]
501 pub unsafe fn setContentSource(&self, content_source: AVAudioContentSource);
502
503 #[cfg(feature = "AVAudioSettings")]
504 /// Encoder Dynamic Range Control (DRC) configuration.
505 ///
506 /// When supported by the encoder, this property controls which configuration is applied when a
507 /// bitstream is generated. Note: This is only supported when compressing audio to formats
508 /// which support it.
509 ///
510 /// This property is not atomic.
511 ///
512 /// # Safety
513 ///
514 /// This might not be thread-safe.
515 #[unsafe(method(dynamicRangeControlConfiguration))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn dynamicRangeControlConfiguration(
518 &self,
519 ) -> AVAudioDynamicRangeControlConfiguration;
520
521 #[cfg(feature = "AVAudioSettings")]
522 /// Setter for [`dynamicRangeControlConfiguration`][Self::dynamicRangeControlConfiguration].
523 ///
524 /// # Safety
525 ///
526 /// This might not be thread-safe.
527 #[unsafe(method(setDynamicRangeControlConfiguration:))]
528 #[unsafe(method_family = none)]
529 pub unsafe fn setDynamicRangeControlConfiguration(
530 &self,
531 dynamic_range_control_configuration: AVAudioDynamicRangeControlConfiguration,
532 );
533
534 #[cfg(feature = "AVAudioBuffer")]
535 /// Perform a simple conversion. That is, a conversion which does not involve codecs or sample rate conversion.
536 ///
537 /// Parameter `inputBuffer`: The input buffer.
538 ///
539 /// Parameter `outputBuffer`: The output buffer.
540 ///
541 /// Parameter `outError`: An error if the conversion fails.
542 ///
543 /// Returns: YES is returned on success, NO when an error has occurred.
544 ///
545 /// The output buffer's frameCapacity should be at least at large as the inputBuffer's frameLength.
546 /// If the conversion involves a codec or sample rate conversion, you instead must use
547 /// convertToBuffer:error:withInputFromBlock:.
548 #[unsafe(method(convertToBuffer:fromBuffer:error:_))]
549 #[unsafe(method_family = none)]
550 pub unsafe fn convertToBuffer_fromBuffer_error(
551 &self,
552 output_buffer: &AVAudioPCMBuffer,
553 input_buffer: &AVAudioPCMBuffer,
554 ) -> Result<(), Retained<NSError>>;
555
556 #[cfg(all(
557 feature = "AVAudioBuffer",
558 feature = "AVAudioTypes",
559 feature = "block2"
560 ))]
561 /// Perform any supported conversion.
562 ///
563 /// Parameter `inputBlock`: A block which will be called to get input data as needed. See description for AVAudioConverterInputBlock.
564 ///
565 /// Parameter `outputBuffer`: The output buffer.
566 ///
567 /// Parameter `outError`: An error if the conversion fails.
568 ///
569 /// Returns: An AVAudioConverterOutputStatus is returned.
570 ///
571 /// It attempts to fill the buffer to its capacity. On return, the buffer's length indicates the number of
572 /// sample frames successfully converted.
573 ///
574 /// # Safety
575 ///
576 /// `input_block` must be a valid pointer.
577 #[unsafe(method(convertToBuffer:error:withInputFromBlock:))]
578 #[unsafe(method_family = none)]
579 pub unsafe fn convertToBuffer_error_withInputFromBlock(
580 &self,
581 output_buffer: &AVAudioBuffer,
582 out_error: Option<&mut Option<Retained<NSError>>>,
583 input_block: AVAudioConverterInputBlock,
584 ) -> AVAudioConverterOutputStatus;
585 );
586}
587
588/// Methods declared on superclass `NSObject`.
589impl AVAudioConverter {
590 extern_methods!(
591 #[unsafe(method(init))]
592 #[unsafe(method_family = init)]
593 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
594
595 #[unsafe(method(new))]
596 #[unsafe(method_family = new)]
597 pub unsafe fn new() -> Retained<Self>;
598 );
599}
600
601/// Encoding.
602impl AVAudioConverter {
603 extern_methods!(
604 /// bitRate in bits per second. Only applies when encoding.
605 ///
606 /// This property is not atomic.
607 ///
608 /// # Safety
609 ///
610 /// This might not be thread-safe.
611 #[unsafe(method(bitRate))]
612 #[unsafe(method_family = none)]
613 pub unsafe fn bitRate(&self) -> NSInteger;
614
615 /// Setter for [`bitRate`][Self::bitRate].
616 ///
617 /// # Safety
618 ///
619 /// This might not be thread-safe.
620 #[unsafe(method(setBitRate:))]
621 #[unsafe(method_family = none)]
622 pub unsafe fn setBitRate(&self, bit_rate: NSInteger);
623
624 /// When encoding, an AVEncoderBitRateStrategyKey value constant as defined in AVAudioSettings.h. Returns nil if not encoding.
625 ///
626 /// This property is not atomic.
627 ///
628 /// # Safety
629 ///
630 /// This might not be thread-safe.
631 #[unsafe(method(bitRateStrategy))]
632 #[unsafe(method_family = none)]
633 pub unsafe fn bitRateStrategy(&self) -> Option<Retained<NSString>>;
634
635 /// Setter for [`bitRateStrategy`][Self::bitRateStrategy].
636 ///
637 /// # Safety
638 ///
639 /// This might not be thread-safe.
640 #[unsafe(method(setBitRateStrategy:))]
641 #[unsafe(method_family = none)]
642 pub unsafe fn setBitRateStrategy(&self, bit_rate_strategy: Option<&NSString>);
643
644 /// The maximum size of an output packet, in bytes.
645 ///
646 /// When encoding it is useful to know how large a packet can be in order to allocate a buffer to receive the output.
647 ///
648 /// This property is not atomic.
649 ///
650 /// # Safety
651 ///
652 /// This might not be thread-safe.
653 #[unsafe(method(maximumOutputPacketSize))]
654 #[unsafe(method_family = none)]
655 pub unsafe fn maximumOutputPacketSize(&self) -> NSInteger;
656
657 /// When encoding, an NSArray of NSNumber of all bit rates provided by the codec. Returns nil if not encoding.
658 ///
659 /// This property is not atomic.
660 ///
661 /// # Safety
662 ///
663 /// This might not be thread-safe.
664 #[unsafe(method(availableEncodeBitRates))]
665 #[unsafe(method_family = none)]
666 pub unsafe fn availableEncodeBitRates(&self) -> Option<Retained<NSArray<NSNumber>>>;
667
668 /// When encoding, an NSArray of NSNumber of bit rates that can be applied based on the current formats and settings. Returns nil if not encoding.
669 ///
670 /// This property is not atomic.
671 ///
672 /// # Safety
673 ///
674 /// This might not be thread-safe.
675 #[unsafe(method(applicableEncodeBitRates))]
676 #[unsafe(method_family = none)]
677 pub unsafe fn applicableEncodeBitRates(&self) -> Option<Retained<NSArray<NSNumber>>>;
678
679 /// When encoding, an NSArray of NSNumber of all output sample rates provided by the codec. Returns nil if not encoding.
680 ///
681 /// This property is not atomic.
682 ///
683 /// # Safety
684 ///
685 /// This might not be thread-safe.
686 #[unsafe(method(availableEncodeSampleRates))]
687 #[unsafe(method_family = none)]
688 pub unsafe fn availableEncodeSampleRates(&self) -> Option<Retained<NSArray<NSNumber>>>;
689
690 /// When encoding, an NSArray of NSNumber of output sample rates that can be applied based on the current formats and settings. Returns nil if not encoding.
691 ///
692 /// This property is not atomic.
693 ///
694 /// # Safety
695 ///
696 /// This might not be thread-safe.
697 #[unsafe(method(applicableEncodeSampleRates))]
698 #[unsafe(method_family = none)]
699 pub unsafe fn applicableEncodeSampleRates(&self) -> Option<Retained<NSArray<NSNumber>>>;
700
701 /// When encoding, an NSArray of NSNumber of all output channel layout tags provided by the codec. Returns nil if not encoding.
702 ///
703 /// This property is not atomic.
704 ///
705 /// # Safety
706 ///
707 /// This might not be thread-safe.
708 #[unsafe(method(availableEncodeChannelLayoutTags))]
709 #[unsafe(method_family = none)]
710 pub unsafe fn availableEncodeChannelLayoutTags(
711 &self,
712 ) -> Option<Retained<NSArray<NSNumber>>>;
713 );
714}