Skip to content

Instantly share code, notes, and snippets.

@rfistman
rfistman / AudioOutputs.m
Created April 26, 2018 09:44
trying to figure out if the two iPhone 7 speakers are addressable
NSError *error = nil;
if (![[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryMultiRoute error: &error]) {
NSLog(@"setCategory: %@", error);
}
if (![[AVAudioSession sharedInstance] setActive: YES error: &error]) {
NSLog(@"setActive: %@", error);
}
#import "AppDelegate.h"
#import <AVFoundation/AVFoundation.h>
@interface AppDelegate ()
@property (nonatomic) AVAssetWriter *writer;
@property (nonatomic) AVAssetWriterInputPixelBufferAdaptor *adaptor;
@property (nonatomic) dispatch_queue_t q;
@rfistman
rfistman / PacketAudioBitRate.m
Last active March 29, 2018 07:15
Trying to get bitrate of mp3/aac packetized audio with AVFoundation/CoreMedia
// Was hoping to find at least bitrate in packet data, maybe in attachments
// via AVFoundation/CoreMedia. This data is in every mp3 and (I think) aac packet
// yet it seems to be discarded. Anyone know where I can find it without parsing
// by hand or inferring from file duration and size?
// sample rate and number of channels is available.
NSString *path = @"path to mp3/aac/whatevs";
AVAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:path] options:nil];
[asset loadValuesAsynchronouslyForKeys:@[@"duration"] completionHandler:^{
@rfistman
rfistman / curl IAP receipt verifier
Last active March 25, 2022 19:20
Test production IAP receipts with curl
# IAP
curl -s -d "{ \"receipt-data\" : \"$(base64 receipt)\" }" https://buy.itunes.apple.com/verifyReceipt | python -mjson.tool
# autorenewing subscription
curl -s -d "{ \"password\" : \"shared-secret\", \"receipt-data\" : \"$(base64 receipt)\" }" https://buy.itunes.apple.com/verifyReceipt | python -mjson.tool
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>rules</key>
<dict>
<key>.*</key>
<true/>
<key>Info.plist</key>
<dict>