Menu Home

ios

Build WebRTC

First of All, You have evaded the “WALL”. God bless you. Host OS: Ubuntu 16.04 LTE Build Tools git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git Then add depot_tools to your PATH Checkout Source Set the target OS Here, I will build webrtc for Andorid platform. export GYP_DEFINES=”OS=android” Sync Source mkdir webrtc_android cd webrtc_android fetch […]

iOS:How to get your framework version using code

Add these lines in your Framework header file. eg. PrefixFramework.h //! Project version number for LocalSearch. FOUNDATION_EXPORT double PrefixFrameworkVersionNumber; //! Project version string for LocalSearch. FOUNDATION_EXPORT const unsigned char PrefixFrameworkVersionString[]; There arguments will be filled by iOS framework logic.And you can get the version like this: +(NSString*) playerVersion { NSRange […]

iOS:使用GLES绘制文字

EAGLContext *contextGL; contextGL = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; if (contextGL == nil) { NSLog(@”wangsijie, failed to create EAGLContext”); } else { NSLog(@”wangsijie, create EAGLContext OK”); } CGRect rectGL = CGRectMake(100, 100, 150, 100); GLKView *viewGL = [[GLKView alloc] initWithFrame:rectGL]; viewGL.context = contextGL; viewGL.enableSetNeedsDisplay = NO; [self.view addSubview:viewGL]; [viewGL setDelegate:self]; CADisplayLink *displayLink […]

NALU Type Array

NSString * const naluTypesStrings[] = { @”0: Unspecified (non-VCL)”, @”1: Coded slice of a non-IDR picture (VCL)”, // P frame @”2: Coded slice data partition A (VCL)”, @”3: Coded slice data partition B (VCL)”, @”4: Coded slice data partition C (VCL)”, @”5: Coded slice of an IDR picture (VCL)”, // […]

iOS:Get Memory Information

– (void)refreshMemoryInfo { uint64_t physicalMemorySize; uint64_t userMemorySize; int mib[2]; size_t length; mib[0] = CTL_HW; mib[1] = HW_MEMSIZE; length = sizeof(int64_t); sysctl(mib, 2, &physicalMemorySize, &length, NULL, 0); mib[1] = HW_USERMEM; length = sizeof(int64_t); sysctl(mib, 2, &userMemorySize, &length, NULL, 0); }

iOS:Max Memory Budget

iPad1: 127MB/256MB/49% (crash amount/total amount/percentage of total) iPad2: 275MB/512MB/53% iPad3: 645MB/1024MB/62% iPad4: 585MB/1024MB/57% (iOS 8.1) iPad Mini 1st Generation: 297MB/512MB/58% iPad Mini retina: 696MB/1024MB/68% (iOS 7.1) iPad Air: 697MB/1024MB/68% iPad Air 2: 1195MB/2048MB/58% iPod touch 4th gen: 130MB/256MB/51% (iOS 6.1.1) iPod touch 5th gen: 286MB/512MB/56% (iOS 7.0) iPhone4: 325MB/512MB/63% iPhone5: […]

iOS:截图

– (UIImage*)snapshot { UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0); [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:NO]; UIImage *snap = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return snap; } – (BOOL)drawViewHierarchyInRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates是在iOS7.0才引入的,所有此方法只适合在iOS7.0及以上系统使用。

NSNotification的同步运行

Same Thread – (void)viewDidLoad { [super viewDidLoad]; NSLog(@”viewWillAppear”); [[NSNotificationCenter defaultCenter] addObserverForName:@”Test_NOTIFY” object:self queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) { NSLog(@”In Observer: Thread = %@”, [NSThread currentThread]); [NSThread sleepForTimeInterval:5]; }]; [[NSNotificationCenter defaultCenter] postNotificationName:@”Test_NOTIFY” object:self]; NSLog(@”viewDidLoad Finished”); } Different Thread – (void)viewDidLoad { [super viewDidLoad]; NSLog(@”viewWillAppear”); [[NSNotificationCenter defaultCenter] addObserverForName:@”Test_NOTIFY” object:self queue:[NSOperationQueue mainQueue] […]

iOS: Audio Recorder

设置文件路径 – (NSURL *)soundFileURL { NSArray *dirPaths; NSString *docsDir; dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; NSString *soundFilePath = [docsDir stringByAppendingPathComponent:@”record.m4a”]; return [NSURL fileURLWithPath:soundFilePath]; } 录音部分 – (IBAction)startRecording:(UIButton *)sender { [self.recordButton setHidden:YES]; [self.stopButton setHidden:NO]; [self.playButton setHidden:YES]; NSError *error = nil; AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryRecord error:nil]; […]

iOS: bitcode

什么是bitcode Bitcode is an intermediate representationof a compiled program. Apps you upload to iTunes Connect that contain bitcodewill be compiled and linked on the App Store. Including bitcode will allowApple to re-optimize your app binary in the future without the need to submit anew version of your app to the […]

iOS: create thumbnail by means of offscreen image context

– (void)setThumbnailFromImage:(UIImage *)image { CGSize origImageSize = image.size; CGRect newRect = CGRectMake(0, 0, 40, 40); float ratio = MAX(newRect.size.width / origImageSize.width, newRect.size.height / origImageSize.height); UIGraphicsBeginImageContextWithOptions(newRect.size, NO, ratio); UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:newRect cornerRadius:5.0]; [path addClip]; CGRect thumbRect; thumbRect.size.width = ratio * origImageSize.width; thumbRect.size.height = ratio * origImageSize.height; thumbRect.origin.x = (newRect.size.width […]