Type Definitions

The following type definitions are available globally.

  • Undocumented

    Declaration

    Objective-C

    typedef void (^BAWebServiceSuccessResponse)(NSArray *result)

    Swift

    typealias BAWebServiceSuccessResponse = ([Any]?) -> Void
  • Undocumented

    Declaration

    Objective-C

    typedef void (^BAWebServiceFailureResponse)(BAWebServiceError *error)

    Swift

    typealias BAWebServiceFailureResponse = (BAWebServiceError?) -> Void
  • Undocumented

    Declaration

    Objective-C

    typedef NSUInteger EAEContentType

    Swift

    typealias EAEContentType = UInt
  • Undocumented

    Declaration

    Objective-C

    typedef void (^EAEConnectionSuccessResponse)(NSArray *array)

    Swift

    typealias EAEConnectionSuccessResponse = (UnsafeMutablePointer<Int32>?) -> Void
  • Undocumented

    Declaration

    Objective-C

    typedef void (^EAEConnectionFailureResponse)(NSError *error)

    Swift

    typealias EAEConnectionFailureResponse = (UnsafeMutablePointer<Int32>?) -> Void
    • You may optionally set a receive filter for the socket.
    • A filter can provide several useful features:

    • 1. Many times udp packets need to be parsed.

    Since

    Since the filter can run in its own independent queue, you can parallelize this parsing quite easily.
    • The end result is a parallel socket io, datagram parsing, and packet processing.
    • 2. Many times udp packets are discarded because they are duplicate/unneeded/unsolicited.
    • The filter can prevent such packets from arriving at the delegate.
    • And because the filter can run in its own independent queue, this doesn’t slow down the delegate.
    • - Since the udp protocol does not guarantee delivery, udp packets may be lost.
    • Many protocols built atop udp thus provide various resend/re-request algorithms.
    • This sometimes results in duplicate packets arriving.
    • A filter may allow you to architect the duplicate detection code to run in parallel to normal processing.

    • - Since the udp socket may be connectionless, its possible for unsolicited packets to arrive.
    • Such packets need to be ignored.
    • 3. Sometimes traffic shapers are needed to simulate real world environments.
    • A filter allows you to write custom code to simulate such environments.
    • The ability to code this yourself is especially helpful when your simulated environment
    • is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router),
    • or the system tools to handle this aren’t available (e.g. on a mobile device).
    • - parameter: data - The packet that was received.
    • - parameter: address - The address the data was received from.

    See

    See utilities section for methods to extract info from address.
    • - parameter: context - Out parameter you may optionally set, which will then be passed to the delegate method.
    • For example, filter block can parse the data and then,
    • pass the parsed data to the delegate.
    • @returns - YES if the received packet should be passed onto the delegate.
    • NO if the received packet should be discarded, and not reported to the delegete.
    • Example:
    • GCDAsyncUdpSocketReceiveFilterBlock filter = ^BOOL (NSData *data, NSData *address, id *context) {
    • MyProtocolMessage *msg = [MyProtocol parseMessage:data];

    • *context = response;
    • return (response != nil);
    • };
    • [udpSocket setReceiveFilter:filter withQueue:myParsingQueue];

    Declaration

    Objective-C

    typedef BOOL (^GCDAsyncUdpSocketReceiveFilterBlock)(NSData *, NSData *, id *)

    Swift

    typealias GCDAsyncUdpSocketReceiveFilterBlock = (Data?, Data?, AutoreleasingUnsafeMutablePointer<AnyObject?>?) -> Bool
    • You may optionally set a send filter for the socket.
    • A filter can provide several interesting possibilities:
    • 1. Optional caching of resolved addresses for domain names.
    • The cache could later be consulted, resulting in fewer system calls to getaddrinfo.
    • 2. Reusable modules of code for bandwidth monitoring.
    • 3. Sometimes traffic shapers are needed to simulate real world environments.
    • A filter allows you to write custom code to simulate such environments.
    • The ability to code this yourself is especially helpful when your simulated environment
    • is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router),
    • or the system tools to handle this aren’t available (e.g. on a mobile device).
    • - parameter: data - The packet that was received.
    • - parameter: address - The address the data was received from.

    See

    See utilities section for methods to extract info from address.
    • - parameter: tag - The tag that was passed in the send method.
    • @returns - YES if the packet should actually be sent over the socket.
    • NO if the packet should be silently dropped (not sent over the socket).
    • Regardless of the return value, the delegate will be informed that the packet was successfully sent. *

    Declaration

    Objective-C

    typedef BOOL (^GCDAsyncUdpSocketSendFilterBlock)(NSData *, NSData *, long)

    Swift

    typealias GCDAsyncUdpSocketSendFilterBlock = (Data?, Data?, Int) -> Bool
  • Undocumented

    See more

    Declaration

    Objective-C

    typedef struct {
        void             *buffer;
        int32_t           length;
        int32_t           tail;
        int32_t           head;
        volatile int32_t  fillCount;
    } TPCircularBuffer
  • Undocumented

    Declaration

    Objective-C

    typedef void(^TyphoonMatcherBlock)(TyphoonOptionMatcher *matcher)

    Swift

    typealias TyphoonMatcherBlock = (TyphoonOptionMatcher?) -> Void
  • Undocumented

    Declaration

    Objective-C

    typedef void(^TyphoonDefinitionBlock)(TyphoonDefinition *definition)

    Swift

    typealias TyphoonDefinitionBlock = (TyphoonDefinition?) -> Void
  • Opus encoder state.

    • This contains the complete state of an Opus encoder.
    • It is position independent and can be freely copied.
    • - see: opus_encoder_create,opus_encoder_init

    Declaration

    Objective-C

    typedef struct OpusEncoder OpusEncoder
  • Opus decoder state.

    • This contains the complete state of an Opus decoder.
    • It is position independent and can be freely copied.
    • - see: opus_decoder_create,opus_decoder_init

    Declaration

    Objective-C

    typedef struct OpusDecoder OpusDecoder
  • @defgroup opus_repacketizer Repacketizer

    • @{ *
    • The repacketizer can be used to merge multiple Opus packets into a single
    • packet or alternatively to split Opus packets that have previously been
    • merged. Splitting valid Opus packets is always guaranteed to succeed,
    • whereas merging valid packets only succeeds if all frames have the same
    • mode, bandwidth, and frame size, and when the total duration of the merged
    • packet is no more than 120 ms.
    • The repacketizer currently only operates on elementary Opus
    • streams. It will not manipualte multistream packets successfully, except in
    • the degenerate case where they consist of data from a single stream. *
    • The repacketizing process starts with creating a repacketizer state, either
    • by calling opus_repacketizer_create() or by allocating the memory yourself,
    • e.g.,
    • “`
    • OpusRepacketizer *rp;
    • rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size());
    • if (rp != NULL)
    • opus_repacketizer_init(rp);
    • ”` *
    • Then the application should submit packets with opus_repacketizer_cat(),
    • extract new packets with opus_repacketizer_out() or
    • opus_repacketizer_out_range(), and then reset the state for the next set of
    • input packets via opus_repacketizer_init(). *
    • For example, to split a sequence of packets into individual frames:
    • “`
    • unsigned char *data;
    • int len;
    • while (get_next_packet(&data, &len))
    • {
    • unsigned char out[1276];
    • opus_int32 out_len;
    • int nb_frames;
    • int err;
    • int i;
    • err = opus_repacketizer_cat(rp, data, len);
    • if (err != OPUS_OK)
    • {
    • release_packet(data);
    • return err;
    • }
    • nb_frames = opus_repacketizer_get_nb_frames(rp);
    • for (i = 0; i < nb_frames; i++)
    • {
    • out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out));
    • if (out_len < 0)
    • {
    • release_packet(data);
    • return (int)out_len;
    • }
    • output_next_packet(out, out_len);
    • }
    • opus_repacketizer_init(rp);
    • release_packet(data);
    • }
    • ”` *
    • Alternatively, to combine a sequence of frames into packets that each
    • contain up to TARGET_DURATION_MS milliseconds of data:
    • “`
    • // The maximum number of packets with duration TARGET_DURATION_MS occurs
    • // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
    • // packets.
    • unsigned char *data[(TARGET_DURATION_MS*2/5)+1];
    • opus_int32 len[(TARGET_DURATION_MS*2/5)+1];
    • int nb_packets;
    • unsigned char out[1277*(TARGET_DURATION_MS*2/2)];
    • opus_int32 out_len;
    • int prev_toc;
    • nb_packets = 0;
    • while (get_next_packet(data+nb_packets, len+nb_packets))
    • {
    • int nb_frames;
    • int err;
    • nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]);
    • if (nb_frames < 1)
    • {
    • release_packets(data, nb_packets+1);
    • return nb_frames;
    • }
    • nb_frames += opus_repacketizer_get_nb_frames(rp);
    • // If adding the next packet would exceed our target, or it has an
    • // incompatible TOC sequence, output the packets we already have before
    • // submitting it.
    • // N.B., The nb_packets > 0 check ensures we’ve submitted at least one
    • // packet since the last call to opus_repacketizer_init(). Otherwise a
    • // single packet longer than TARGET_DURATION_MS would cause us to try to
    • // output an (invalid) empty packet. It also ensures that prev_toc has
    • // been set to a valid value. Additionally, len[nb_packets] > 0 is
    • // guaranteed by the call to opus_packet_get_nb_frames() above, so the
    • // reference to data[nb_packets][0] should be valid.
    • if (nb_packets > 0 && (
    • ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) ||
    • opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames >
    • TARGET_DURATION_MS*48))
    • {
    • out_len = opus_repacketizer_out(rp, out, sizeof(out));
    • if (out_len < 0)
    • {
    • release_packets(data, nb_packets+1);
    • return (int)out_len;
    • }
    • output_next_packet(out, out_len);
    • opus_repacketizer_init(rp);
    • release_packets(data, nb_packets);
    • data[0] = data[nb_packets];
    • len[0] = len[nb_packets];
    • nb_packets = 0;
    • }
    • err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]);
    • if (err != OPUS_OK)
    • {
    • release_packets(data, nb_packets+1);
    • return err;
    • }
    • prev_toc = data[nb_packets][0];
    • nb_packets++;
    • }
    • // Output the final, partial packet.
    • if (nb_packets > 0)
    • {
    • out_len = opus_repacketizer_out(rp, out, sizeof(out));
    • release_packets(data, nb_packets);
    • if (out_len < 0)
    • return (int)out_len;
    • output_next_packet(out, out_len);
    • }
    • ”` *
    • An alternate way of merging packets is to simply call opus_repacketizer_cat()
    • unconditionally until it fails. At that point, the merged packet can be
    • obtained with opus_repacketizer_out() and the input packet for which
    • opus_repacketizer_cat() needs to be re-added to a newly reinitialized
    • repacketizer state.

    Declaration

    Objective-C

    typedef struct OpusRepacketizer OpusRepacketizer
  • Undocumented

    Declaration

    Objective-C

    typedef int16_t opus_int16

    Swift

    typealias opus_int16 = Int16
  • Undocumented

    Declaration

    Objective-C

    typedef uint16_t opus_uint16

    Swift

    typealias opus_uint16 = UInt16
  • Undocumented

    Declaration

    Objective-C

    typedef int32_t opus_int32

    Swift

    typealias opus_int32 = Int32
  • Undocumented

    Declaration

    Objective-C

    typedef uint32_t opus_uint32

    Swift

    typealias opus_uint32 = UInt32