Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // BMHttpAudioStreamManager.h
- // Радио СВЕТ
- //
- // Created by Bogdan Michalchuk on 8/21/14.
- // Copyright (c) 2014 Радио CBET. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- #import <stdio.h>
- #import <string.h>
- #import <netdb.h>
- #import <netinet/in.h>
- #import <unistd.h>
- #import <pthread.h>
- #import <AudioToolbox/AudioToolbox.h>
- #import <CFNetwork/CFHTTPMessage.h>
- #import <AVFoundation/AVFoundation.h>
- #import <MediaPlayer/MediaPlayer.h>
- #define kNumAQBufs 3 // number of audio queue buffers we allocate
- #define kAQBufSize 128*1024 // number of bytes in each audio queue buffer
- #define kAQMaxPacketDescs 512 // number of packet descriptions in our array
- typedef struct {
- AudioFileStreamID audioFileStream; // the audio file stream parser
- AudioQueueRef audioQueue; // the audio queue
- AudioQueueBufferRef audioQueueBuffer[kNumAQBufs]; // audio queue buffers
- AudioStreamPacketDescription packetDescs[kAQMaxPacketDescs]; // packet descriptions for enqueuing audio
- unsigned int fillBufferIndex; // the index of the audioQueueBuffer that is being filled
- unsigned int bytesFilled; // how many bytes have been filled
- unsigned int packetsFilled; // how many packets have been filled
- bool inuse[kNumAQBufs]; // flags to indicate that a buffer is still in use
- bool started; // flag to indicate that the queue has been started
- bool failed; // flag to indicate an error occurred
- pthread_mutex_t mutex; // a mutex to protect the inuse flags
- pthread_cond_t cond; // a condition varable for handling the inuse flags
- pthread_cond_t done; // a condition varable for handling the inuse flags
- } AudioData;
- @interface BMHttpAudioStreamManager : NSObject
- -(void) connectionStart;
- -(void) stopRadio;
- //void MyPacketsProc(void * inClientData,
- // UInt32 inNumberBytes,
- // UInt32 inNumberPackets,
- // const void * inInputData,
- // AudioStreamPacketDescription *inPacketDescriptions);
- + (void) myPacketsProcWithData:(AudioData *) audioData
- forNumberBytes:(UInt32) inNumberBytes
- forNumberPackets:(inNumberPackets) inNumberPackets
- forInputData:(const void *) inInputData
- withPacketDescription:(AudioStreamPacketDescription *) inPacketDescription;
- //int MyFindQueueBuffer(AudioData* audioData, AudioQueueBufferRef inBuffer);
- - (int) myFindQueueBufferWithAudioData:(AudioData *) audioData
- withBuffer:(AudioQueueBufferRef) inBuffer;
- //void MyPropertyListenerProc(void * inClientData,
- // AudioFileStreamID inAudioFileStream,
- // AudioFileStreamPropertyID inPropertyID,
- // UInt32 * ioFlags);
- + (void) myPropertyListerProcForData:(AudioData *) audioData //note this parameter
- forStreamID:(AudioFileStreamID) inAudioFileStream
- forPropertyID:(AudioFileStreamPropertyID) inPropertyID
- forIOFlags:(UInt32) ioFlags;
- //void MyAudioQueueIsRunningCallback(void* inClientData,
- // AudioQueueRef inAQ,
- // AudioQueuePropertyID inID);
- + (void) myAudioQueueIsRunningCallbackWithData:(AudioData *) audioData
- withRef:(AudioQueueRef) inAQ
- withPropertyID:(AudioQueuePropertyID) inID;
- //OSStatus MyEnqueueBuffer(AudioData* audioData);
- //void WaitForFreeBuffer(AudioData* audioData);
- + (void) waitForFreeBufferForData:(AudioData *) audioData;
- //void MyAudioQueueOutputCallback(void* inClientData,
- // AudioQueueRef inAQ,
- // AudioQueueBufferRef inBuffer);
- + (void) myAudioQueueOutputCallbackWithData:(BMHttpAudioStreamManager *) inClientData
- WithQueue:(AudioQueueRef) inAQ
- withBuffer:(AudioQueueBufferRef) inBuffer;
- //OSStatus StartQueueIfNeeded(AudioData* audioData);
- + (OSStatus) startQueueifNeededWithData:(AudioData *) audioData;
- + (void) readStreamClientCallBackWithData:(CFReadStreamRef) stream
- withType:(CFStreamEventType) type
- withClientCallBackInfo:(void *) clientCallBackInfo;
- @end
Add Comment
Please, Sign In to add comment