NSMutableDictionary *dictionary=[[NSMutableDictionary alloc]init];
[dictionary setValue:[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
[dictionary setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[dictionary setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
我使用AVAudioRecorder
对象进行输入,我需要将其转换为udp数据包。怎么做?
答案 0 :(得分:0)
CocoaAsyncSocket是一个很好的库,它包含一个名为AsyncUdpSocket的类,它是一个围绕低级套接字API的Obj-C包装器。
包含AsyncUdpSocket后,只需在标题中添加:
AsyncUdpSocket *socket;
主要是:
NSData *data = [NSData dataWithContentsOfURL:YourURL];//Convert Recieved Audio into NSData
[socket sendData:data toHost:@"192.168.x.x" port:5002 withTimeout:-1 tag:1];
测试时不要忘记在服务器防火墙上允许UDP通信!