小编IOS*_*DEV的帖子

将CMSampleBufferRef数据传递到音频输出插孔

我正在开发一个应用程序,我需要通过输出音频插孔同时通过音频捕获记录和保存视频.

我已经研究了aurio touch apple示例代码并实现了音频直通.

我也通过实施视频录制AVCaptureSession.以上两个功能单独完成并且完美地工作.

但是当我合并功能音频通过不工作因为音频会话AVCapturesession.

我还试图通过AVCaptureSession委托方法传递音频数据.以下是我的代码:

OSStatus err = noErr;


AudioBufferList audioBufferList;
CMBlockBufferRef blockBuffer;
CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
CMItemCount numberOfFrames = CMSampleBufferGetNumSamples(sampleBuffer); // corresponds to the number of CoreAudio audio frames

currentSampleTime += (double)numberOfFrames;

AudioTimeStamp timeStamp;
memset(&timeStamp, 0, sizeof(AudioTimeStamp));
timeStamp.mSampleTime = currentSampleTime;
timeStamp.mFlags |= kAudioTimeStampSampleTimeValid;

AudioUnitRenderActionFlags flags = 0;
aurioTouchAppDelegate *THIS = (aurioTouchAppDelegate *)[[UIApplication sharedApplication]delegate];
 err = AudioUnitRender(self.rioUnit, &flags, &timeStamp, 1, numberOfFrames, &audioBufferList);

if (err) { printf("PerformThru: error %d\n", …
Run Code Online (Sandbox Code Playgroud)

core-audio avfoundation ios

13
推荐指数
1
解决办法
1103
查看次数

使用Base64和JSON上传大图像

我正在使用此功能将图像上传到服务器JSON.为此,我首先将图像转换为NSData然后再NSString使用Base64.当图像不是很大时,该方法可以正常工作,但是当我尝试上传2Mb图像时,它会崩溃.

问题是,即使didReceiveResponse调用该方法以及didReceiveData返回该方法,服务器也不会接收我的图像(null).起初我认为这是一个超时问题,但即使将其设置为1000.0它仍然不起作用.任何的想法?谢谢你的时间!

这是我目前的代码:

 - (void) imageRequest {

   NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.myurltouploadimage.com/services/v1/upload.json"]];

   NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
   NSString *path = [NSString stringWithFormat:@"%@/design%i.png",docDir, designNum];
   NSLog(@"%@",path);

   NSData *imageData = UIImagePNGRepresentation([UIImage imageWithContentsOfFile:path]);
   [Base64 initialize];
   NSString *imageString = [Base64 encode:imageData];

   NSArray *keys = [NSArray arrayWithObjects:@"design",nil];
   NSArray *objects = [NSArray arrayWithObjects:imageString,nil];
   NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];

   NSError *error;
   NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDictionary options:kNilOptions error:&error];

   [request setHTTPMethod:@"POST"]; …
Run Code Online (Sandbox Code Playgroud)

base64 json objective-c nsurlconnection ios

6
推荐指数
1
解决办法
1万
查看次数

核心数据获取请求优化

我正在开发和应用程序,需要检查字符串是否已保存到数据库.这似乎是一个简单的操作,但它需要半秒才能返回任何我认为非常多的响应.我的问题是,是否有任何方法可以缩短时间.谢谢你的关注.

这是我目前的代码:

- (BOOL) isDeleted:(int)i {

    NSString *value = [NSString stringWithFormat:@"deleted.*.%i", i];

    MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSManagedObjectContext *context = [appDelegate managedObjectContext];

    NSString *entityName = @"Deleted";
    NSEntityDescription *entityDesc = [NSEntityDescription entityForName:entityName inManagedObjectContext:context];
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:entityDesc];

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"(deletedpics like %@)", value];
    [request setPredicate:pred];

    NSError *error;
    NSArray *objects = [context executeFetchRequest:request error:&error];

    BOOL returnBool = [objects count] >= 1 ? YES : NO;
    return returnBool;

}
Run Code Online (Sandbox Code Playgroud)

optimization core-data objective-c nsfetchrequest ios

6
推荐指数
1
解决办法
2019
查看次数

NSMutableArray(iOS)中的NSDictionary

结果我需要以下内容:

(

    "some_key" = {
        "another_key" = "another_value";
    };

);
Run Code Online (Sandbox Code Playgroud)

为了做到这一点,我有这个代码,但它不起作用:

NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"another_value", @"another_key", nil];
NSMutableArray *array = [[NSMutableArray alloc] init];
[array setValue:dictionary forKey:@"some_key"];
Run Code Online (Sandbox Code Playgroud)

任何的想法?谢谢!

objective-c nsdictionary nsmutablearray ios

6
推荐指数
1
解决办法
2万
查看次数

Socket.IO与Twisted

我的想法是为iOS和Android构建一个简单的聊天应用程序.无论如何,我的问题与服务器端有关.根据我的阅读,做聊天应用程序的最佳选择是构建套接字.参考数据库,我的目的是使用MySQL,考虑到选择其中一种可能性,这也很重要.

我的问题是,在可扩展性,速度和安全性方面,这是最好的选择:使用Twisted或使用Socket.IO使用NodeJS构建套接字套接字?

我想可能还有其他可能性来构建一个有效的套接字,但到现在为止我正在考虑这两个.如果你能给我一些建议,我真的很感激.

python sockets twisted node.js socket.io

6
推荐指数
1
解决办法
3210
查看次数

socket.IO-objc与AZSocketIO

其他语言的Socket.IO实现列表中,我们可以看到有两种选择Objective-C.我的问题与这两个图书馆的优点和缺点有关.

socket.IO-objc似乎更完整,文档更好,但我也想知道AZSocketIO提供哪些优势来考虑这些优势是否足以让我的项目选择其中一个.

如果有人使用其中一个可以给我一些建议,我真的很感激.谢谢!

sockets objective-c node.js ios socket.io

5
推荐指数
1
解决办法
1215
查看次数