iOS 7.1 imagePicker CameraFlashMode not indicating Flash state - ios

I have iPhone application which overlays the camera with custom view.
I have a button to switch between camera flash mode, this is the code
switch ([self.imagePickerController cameraFlashMode]) {
case UIImagePickerControllerCameraFlashModeAuto:
[self.imagePickerController setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
return #"On";
break;
case UIImagePickerControllerCameraFlashModeOn:
[self.imagePickerController setCameraFlashMode:UIImagePickerControllerCameraFlashModeOff];
return #"Off";
break;
case UIImagePickerControllerCameraFlashModeOff:
[self.imagePickerController setCameraFlashMode:UIImagePickerControllerCameraFlashModeAuto];
return #"Auto";
break;
default:
break;
}
This is my problem: Worked perfectly fine on iOS 7.0x, but in iOS 7.1 the cameraFlashMode property returns UIImagePickerControllerCameraFlashModeAuto regardless of its real state.
The flash mode does change, but i get no indication of that.
Any clues?
Thanks

I solved it like this:
#property (nonatomic) NSInteger flashMode;
if (_flashMode == UIImagePickerControllerCameraFlashModeAuto)
{
_flashMode = UIImagePickerControllerCameraFlashModeOff;
}
else if (_flashMode == UIImagePickerControllerCameraFlashModeOff)
{
_flashMode = UIImagePickerControllerCameraFlashModeOn;
}
else if (_flashMode == UIImagePickerControllerCameraFlashModeOn)
{
_flashMode = UIImagePickerControllerCameraFlashModeAuto;
}
_cameraPicker.cameraFlashMode = (UIImagePickerControllerCameraFlashMode)_flashMode;

Okay, so I researched this in great detail, and stumbled upon this helpful article online:
http://www.c2itconsulting.com/2013/10/ios-flash-setting-on-camera-picker-only-available-after-view-is-displayed/
I took their advice, and now I set the flash setting just before the user takes the picture. Instead of checking to see what the camera's current flash setting is, all I do is check my flash button's titleLabel text to see what the user wants as their flash setting:
Here is the code I came up with, which solves the problem perfectly for me now. I hope this helps out all of you with this same problem that didn't exist on iOS 7.0, but now does on iOS 7.1.
#define deviceHasCameraFlash [UIImagePickerController isFlashAvailableForCameraDevice:UIImagePickerControllerCameraDeviceRear]
- (void)capturePhoto
{
if (self.cameraDevice != UIImagePickerControllerCameraDeviceFront && deviceHasCameraFlash)
{
if ([self.flashButton.titleLabel.text isEqualToString:#"Auto"])
{
self.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
}
else if ([self.flashButton.titleLabel.text isEqualToString:#"Off"])
{
self.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;
}
else if ([self.flashButton.titleLabel.text isEqualToString:#"On"])
{
self.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
}
}
[self takePicture];
}

Try to use AVCaptureDevice:
Class captureDeviceClass = NSClassFromString(#"AVCaptureDevice");
if (captureDeviceClass != nil) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[device lockForConfiguration:nil];
if ([device hasTorch]) {
if (device.torchMode == AVCaptureTorchModeAuto) {
NSLog(#"Auto");
}
if (device.torchMode == AVCaptureTorchModeOn) {
NSLog(#"On");
}
if (device.torchMode == AVCaptureTorchModeOff) {
NSLog(#"Of");
}
}
if ([device hasFlash]) {
if (device.flashMode == AVCaptureFlashModeAuto) {
NSLog(#"Auto");
}
if (device.flashMode == AVCaptureFlashModeOn) {
NSLog(#"On");
}
if (device.flashMode == AVCaptureFlashModeOff) {
NSLog(#"Of");
}
}
[device unlockForConfiguration];
}

The answer above did't worked for me in iOS 7.1 #daidai this is what i did and this worked for me
In your .h-file the property flashMode
- (void)didTapFlash:(id)sender
{
if (self.flashMode == UIImagePickerControllerCameraFlashModeAuto) {
//toggle your button to "on"
[self.imagePicker setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
[self.flashButton setImage:[UIImage imageNamed:#"flashOn"] forState:UIControlStateNormal];
self.flashMode = UIImagePickerControllerCameraFlashModeOn;
NSLog(#"On state: %d", self.flashMode);
}else if (self.flashMode == UIImagePickerControllerCameraFlashModeOn){
//toggle your button to "Off"
[self.imagePicker setCameraFlashMode:UIImagePickerControllerCameraFlashModeOff];
[self.flashButton setImage:[UIImage imageNamed:#"flashOf"] forState:UIControlStateNormal];
self.flashMode = UIImagePickerControllerCameraFlashModeOff;
NSLog(#"Of state: %d", self.flashMode);
}else if (self.flashMode == UIImagePickerControllerCameraFlashModeOff){
//toggle your button to "Auto"
[self.imagePicker setCameraFlashMode:UIImagePickerControllerCameraFlashModeAuto];
[self.flashButton setImage:[UIImage imageNamed:#"flashAuto"] forState:UIControlStateNormal];
self.flashMode = UIImagePickerControllerCameraFlashModeAuto;
NSLog(#"Auto state: %d", self.flashMode);
}
}

Related

Objective-C iOS 14: Setting polarity to stereo yields omnidirectional. Following Apple docs

I'm following along with this doc from Apple on how to implement stereo capture. After setting the polarity, it's still coming back as omnidirectional instead of stereo. All the outErrors from the setters are nil, and all of the individual setters are yielding YES (success) results. So, everything is as expected except for the final check that the polarity is set to "stereo." That one is failing.
if (#available(iOS 14, *)) {
BOOL wasStereoConfigurationSuccessful = [self _configureStereoCapture:outError];
NSLog(#"wasStereoConfigurationSuccessful=%#", wasStereoConfigurationSuccessful ? #"YES" : #"NO");
}
- (BOOL)_configureStereoCapture:(NSError **)outError {
BOOL wasBuiltInMicConfigurationSuccessful = [self _configureBuiltInMic:outError];
if (!wasBuiltInMicConfigurationSuccessful) {
return NO;
}
BOOL wasMicInputDirectionalityConfigurationSuccessful = [self _configureMicrophoneInputDirectionality:outError];
if (!wasMicInputDirectionalityConfigurationSuccessful) {
return NO;
}
return outError == nil;
}
- (BOOL)_configureBuiltInMic:(NSError **)outError {
// Enabling stereo requires either AVAudioSessionCategoryRecord or AVAudioSessionCategoryPlayAndRecord
BOOL canStereoBeEnabled = [_audioSession.category isEqualToString:AVAudioSessionCategoryRecord] || [_audioSession.category isEqualToString:AVAudioSessionCategoryPlayAndRecord];
if (!canStereoBeEnabled) {
return NO;
}
// Get the set of available inputs. If there are no audio accessories attached, there will be
// only one available input -- the built in microphone.
NSArray<AVAudioSessionPortDescription *> *availableMics = [_audioSession availableInputs];
AVAudioSessionPortDescription *builtInMic = nil;
for (AVAudioSessionPortDescription *mic in availableMics) {
if ([mic.portType isEqualToString:AVAudioSessionPortBuiltInMic]) {
builtInMic = mic;
break;
}
}
if (builtInMic == nil) {
return NO;
}
BOOL wasPreferredInputSetSuccessfully = [_audioSession setPreferredInput:builtInMic error:outError];
if (!wasPreferredInputSetSuccessfully) {
return NO;
}
return wasPreferredInputSetSuccessfully;
}
- (BOOL)_configureMicrophoneInputDirectionality:(NSError **)outError {
AVAudioSessionPortDescription *preferredInput = _audioSession.preferredInput;
NSArray<AVAudioSessionDataSourceDescription *> *dataSources = preferredInput.dataSources;
AVAudioSessionDataSourceDescription *newDataSource = nil;
AVAudioSessionOrientation audioSessionOrientation = _AudioSessionOrientation(); // Proprietary C helper
for (AVAudioSessionDataSourceDescription *dataSource in dataSources) {
if ([dataSource.dataSourceName isEqualToString:audioSessionOrientation]) {
newDataSource = dataSource;
break;
}
}
if (newDataSource == nil) {
*outError = [NSError errorWithDomain:#"class_name" code:0 userInfo:#{#"message" : #"dataSource.dataSourceName does not equal any available AVAudioSessionOrientation."}];
return NO;
}
NSArray<AVAudioSessionPolarPattern> *supportedPolarPatterns = newDataSource.supportedPolarPatterns;
BOOL isStereoSupported = NO;
if (#available(iOS 14, *)) {
isStereoSupported = [supportedPolarPatterns containsObject:AVAudioSessionPolarPatternStereo];
}
if (!isStereoSupported) {
return NO;
}
BOOL wasPreferredPolarPatternSuccessfullySet = NO;
if (#available(iOS 14, *)) {
wasPreferredPolarPatternSuccessfullySet = [newDataSource setPreferredPolarPattern:AVAudioSessionPolarPatternStereo error:outError];
}
if (!wasPreferredPolarPatternSuccessfullySet) {
return NO;
}
BOOL wasPreferreredDataSourceSuccessfullySet = [preferredInput setPreferredDataSource:newDataSource error:outError];
if (!wasPreferreredDataSourceSuccessfullySet) {
return NO;
}
BOOL wasPreferredInputOrientationSuccessfullySet = NO;
if (#available(iOS 14, *)) {
wasPreferredInputOrientationSuccessfullySet = [_audioSession setPreferredInputOrientation:_AudioStereoOrientationFromAudioSessionOrientation(audioSessionOrientation) error:outError];
}
if (!wasPreferredInputOrientationSuccessfullySet) {
return NO;
}
NSLog(#"error is nil=%#", outError == nil ? #"YES" : #"NO");
NSLog(#"preferredInput=%#", _audioSession.preferredInput);
NSLog(#"preferredDataSource=%#", _audioSession.preferredInput.preferredDataSource);
NSLog(#"selectedPolarPattern=%#", _audioSession.preferredInput.preferredDataSource.selectedPolarPattern);
return outError == nil;
}
This is the printout:
error is nil=YES
preferredInput=<AVAudioSessionPortDescription: 0x282e1d470, type = MicrophoneBuiltIn; name = iPhone Microphone; UID = Built-In Microphone; selectedDataSource = Bottom>
preferredDataSource=<AVAudioSessionDataSourceDescription: 0x282e1cd60, ID = 1835216946; name = Front>
// *** PROBLEM ***
selectedPolarPattern=Omnidirectional // This should be 'Stereo'
wasStereoConfigurationSuccessful=YES

MPMoviePlayerController initialPlaybackTime property not working in iOS 8.4

After setting initialPlaybackTime property, the video(HTTP streaming) still plays from the beginning.
The same code works well in iOS <= 8.3:
self.moviePlayer.initialPlaybackTime = self.lastPlaybackTime;
[self.moviePlayer play];
This works for me, basically you need to setCurrentPlaybackTime when the movie starts playing, But you also need a flag playbackDurationSet which is set to NO when you present movieplayer and it is set to YES when the movie is seeked to the playbackDuration for the first time.
NOTE: this flag is required because when you seek the movie from the seek scrubber the moviePlayerPlaybackStateChanged is fired with playbackState of
MPMoviePlaybackStatePlaying.
BOOL playbackDurationSet = NO;
- (void)moviePlayerPlaybackStateChanged:(NSNotification*)notification
{
MPMoviePlayerController* player = (MPMoviePlayerController*)notification.object;
switch ( player.playbackState ) {
case MPMoviePlaybackStatePlaying:
if(!playbackDurationSet){
[self.moviePlayer setCurrentPlaybackTime:yourStartTime];
playbackDurationSet = YES;
}
break;
}
}
- (void)moviePlayerPresented
{
playbackDurationSet = NO;
}
I've seen some of these issues as well. Since MPMoviePlayerController is deprecated in iOS 9, they're unlikely to be fixed.
hariszaman answer worked for me:
- (void)moviePlaybackStateChanged:(NSNotification*)notif
{
//...
if (self.videoPlayer.playbackState == MPMoviePlaybackStatePlaying) {
if (self.currentBookmark) {
if ([[PSDeviceInfo sharedInstance] is_iOSatLeast84]){
NSTimeInterval toTime = [self.currentBookmark.seconds doubleValue];
[self.videoPlayer setCurrentPlaybackTime:toTime];
self.currentBookmark = nil;
}
}
}
if (self.videoPlayer.playbackState == MPMoviePlaybackStatePaused) {
//...
}
if (self.videoPlayer.playbackState == MPMoviePlaybackStateStopped) {
//...
}
}
also:
- (void)configureMoviePlayer
{
if (self.currentBookmark) {
if ([[PSDeviceInfo sharedInstance] is_iOSatLeast84]){
// will set start after did start
}else {
NSTimeInterval toTime = [self.currentBookmark.seconds doubleValue];
self.videoPlayer.initialPlaybackTime = toTime;
self.currentBookmark = nil;
}
}
else {
self.videoPlayer.initialPlaybackTime = 0;
}
//...
}
the method is_iOSatLeast84:
- (BOOL)is_iOSatLeast84
{
// version 8.4
NSString *version = [[UIDevice currentDevice] systemVersion];
BOOL isAtLeast84 = [version floatValue] >= 8.35;
return isAtLeast84;
}
Although all of this is a workaround, it gets the job done.

Setting a Row as Selected Based off of NSUserDefaults Value?

I'm currently working on a view where a player can choose a character to play with. I have a tableView where each row represents a character. Inside each row is a button that a player taps to select that respective character. The first time a user loads it, only one character is available (first row) and I do the following in viewDidLoad:
//If not selected character exists set it to the default character
if (![[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"]) {
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:#"Current Character"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
NSLog(#"Value: %d", [[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"]);
By default all of the buttons in each row are hidden revealing a lock image behind it. So I do the following in the cellForRowAtIndexPath method:
//CHECK FOR UNLOCKED ITEMS
switch (indexPath.row) {
case 0: {
//Always show since it will always be available
cell.playerButton.hidden = NO;
break;
}
case 1: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item2Unlocked"]) {
cell.playerButton.hidden = NO;
} else {
cell.playerButton.hidden = YES;
}
break;
}
case 2: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item3Unlocked"]) {
cell.playerButton.hidden = NO;
} else {
cell.playerButton.hidden = YES;
}
break;
}
case 3: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item4Unlocked"]) {
cell.playerButton.hidden = NO;
} else {
cell.playerButton.hidden = YES;
}
break;
}
default:
break;
}
Everything is working great so far. The problem that I'm facing is figuring out how to update the button in the correct row to a selected state. I've tried doing the following, but it ends up updating more than one button:
//CHECK FOR UNLOCKED ITEMS
switch (indexPath.row) {
case 0: {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 0) {
cell.playerButton.selected = YES;
} else {
cell.playerButton.selected = NO;
}
break;
}
case 1: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item1Unlocked"]) {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 1) {
cell.playerButton.selected = YES;
} else {
cell.playerButton.selected = NO;
}
} else {
cell.playerButton.hidden = YES;
}
break;
}
case 2: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item2Unlocked"]) {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 2) {
cell.playerButton.selected = YES;
} else {
cell.playerButton.selected = NO;
}
} else {
cell.playerButton.hidden = YES;
}
break;
}
case 3: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item3Unlocked"]) {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 3) {
cell.playerButton.selected = YES;
} else {
cell.playerButton.selected = NO;
}
} else {
cell.playerButton.hidden = YES;
}
break;
}
default:
break;
}
What's wrong here?
UPDATE
Doing the following, the selected state finally worked:
//CHECK FOR UNLOCKED ITEMS
switch (indexPath.row) {
case 0: {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 0) {
cell.playerButton.selected = YES;
NSLog(#"Character is selected.");
} else {
cell.playerButton.selected = NO;
}
break;
}
case 1: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item1Unlocked"]) {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 1) {
cell.playerButton.selected = YES;
NSLog(#"Character B is selected.");
} else {
cell.playerButton.selected = NO;
}
} else {
cell.playerButton.hidden = YES;
}
break;
}
case 2: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item3Unlocked"]) {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 2) {
cell.playerButton.selected = YES;
NSLog(#"character C is selected.");
} else {
cell.playerButton.selected = NO;
}
} else {
cell.playerButton.hidden = YES;
}
break;
}
case 3: {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"item4Unlocked"]) {
cell.playerButton.hidden = NO;
if ([[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"] == 3) {
cell.playerButton.selected = YES;
NSLog(#"Character D is selected.");
} else {
cell.playerButton.selected = NO;
}
} else {
cell.playerButton.hidden = YES;
}
break;
}
default:
break;
}
However how can I disable the button or user interaction if button is selected?
This should do the same thing and is a lot simpler
//CHECK FOR UNLOCKED ITEMS
int currentCharacter=[[NSUserDefaults standardUserDefaults] integerForKey:#"Current Character"];
BOOL unlocked=NO;
if (indexPath.row == 0)
{
unlocked=YES; // Character 0 is always unlocked
}
else {
unlocked=[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithFormat:"%#item%dUnlocked",indexPath.row]]
}
if (unlocked)
{
cell.playerButton.hidden=NO;
if (indexPath.row == currentCharacter)
{
cell.playerButton.selected=YES;
cell.playerButton.enabled=NO; //Cannot select if already selected
}
else
{
cell.playerButton.selected=NO;
cell.playerButton.enabled=YES;
}
}
else
{
cell.playerButton.hidden=YES;
}

Matchmaking works on wifi but doesn't work on 3g

For some reason game center matchMaking works well when both devices on the same wifi but does not work when one of the devices is on 3g (the devices keep searching and cannot find each other).
I am using:
1. iPad 2 with iOS 7.0.4 with sandbox account (compatible to the device's app store account)
2. Iphone 4s with iOS 7.0.4 with sandbox account (compatible to the device's app store account but different from the iPad account).
The code that create the match goes like this:
- (IBAction)continueButtonPressed:(id)sender {
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 4;
request.defaultNumberOfPlayers = 2;
if(([[self.gameTypeSegmentControl objectAtIndex:0] selectedSegmentIndex] == 0) ||
([[self.gameTypeSegmentControl objectAtIndex:1] selectedSegmentIndex] == 0))
{
int temp = [self.allLanguages indexOfObject:[[self.languages objectAtIndex:selectedRow] primaryLanguage]];
if ((temp > 0) && (temp <= self.allLanguages.count))
{
request.playerGroup = temp;
}else
{
request.playerGroup = ENGLISH_US_LANG;//50
}
}
if(([[self.gameTypeSegmentControl objectAtIndex:0] selectedSegmentIndex] == 1) ||
([[self.gameTypeSegmentControl objectAtIndex:1] selectedSegmentIndex] == 1))
{
request.playerGroup = 255;
}
if (isJoining)// Not the creator of the game
{
request.playerAttributes = JOIN_ATTRIBUTE;
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
if (error)
{
NSLog(#"findMatchForRequest ended with error");
// Process the error.
}
else if (match != nil)
{
self.myMatch = match; // Use a retaining property to retain the match.
match.delegate = self;
if (!self.matchStarted && match.expectedPlayerCount == 0)
{
self.matchStarted = YES;
NSLog(#"match begin");
// Insert game-specific code to begin the match.
}
}
}];
}else //The creator of the game
{
request.playerAttributes = CREATE_ATTRIBUTE;
GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
mmvc.matchmakerDelegate = self;
[self presentViewController:mmvc animated:YES completion:nil];
}
}
Any idea what causing the problem???

Uploading 5 second video intervals to server

I have converted the Apple RosyWriter example code to comply with ARC and modern objective C. I've been reading up on how people upload 5-10 second clips to a server with the captureOutput:didOutputSampleBuffer:fromConnection method, but I'm unsure what to do within... from my RosyWriter hybrid:
-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);
if (connection == _videoConnection) {
CMTime timeStamp = CMSampleBufferGetPresentationTimeStamp(sampleBuffer);
[self calculateFramerateAtTimestamp:timeStamp];
if (_videoDimensions.height == 0 && _videoDimensions.width == 0)
_videoDimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
if (_videoType == 0)
_videoType = CMFormatDescriptionGetMediaSubType(formatDescription);
}
CFRetain(sampleBuffer);
CFRetain(formatDescription);
dispatch_async(movieWritingQueue, ^{
if (_assetWriter) {
BOOL wasReadyToRecord = (_readyToRecordAudio && _readyToRecordVideo);
if (connection == _videoConnection) {
if (!_readyToRecordVideo)
_readyToRecordVideo = [self setupAssetWriterVideoInput:formatDescription];
if (_readyToRecordAudio && _readyToRecordVideo)
[self writeSampleBuffer:sampleBuffer ofType:AVMediaTypeVideo];
}else if (connection == _audioConnection) {
if (!_readyToRecordAudio)
_readyToRecordAudio = [self setupAssetWriterAudioInput:formatDescription];
if (_readyToRecordVideo && _readyToRecordAudio)
[self writeSampleBuffer:sampleBuffer ofType:AVMediaTypeAudio];
}
BOOL isReadyToRecord = (_readyToRecordAudio && _readyToRecordVideo);
if (!wasReadyToRecord && isReadyToRecord) {
_recordingWillBeStarted = NO;
_recording = YES;
[_delegate recordingDidStart];
}
}
CFRelease(sampleBuffer);
CFRelease(formatDescription);
});
}
Which then writes the sample buffer like so:
-(void)writeSampleBuffer:(CMSampleBufferRef)sampleBuffer ofType:(NSString*)mediaType {
if (_assetWriter.status == AVAssetWriterStatusUnknown) {
if ([_assetWriter startWriting]) {
[_assetWriter startSessionAtSourceTime:CMSampleBufferGetPresentationTimeStamp(sampleBuffer)];
}else {
[self showError:[_assetWriter error] source:#"Write sample buffer"];
}
}
if (_assetWriter.status == AVAssetWriterStatusWriting) {
if (mediaType == AVMediaTypeVideo) {
if (_videoInput.readyForMoreMediaData) {
if (![_videoInput appendSampleBuffer:sampleBuffer]) {
[self showError:[_assetWriter error] source:#"set up video asset writer"];
}
}
}else if (mediaType == AVMediaTypeAudio) {
if (_audioInput.readyForMoreMediaData) {
if (![_audioInput appendSampleBuffer:sampleBuffer]) {
[self showError:[_assetWriter error] source:#"set up audio asset writer"];
}
}
}
}
}
Now my question is... Should i be creating and swapping assetWriter's in the captureOutput:didOutputSampleBuffer:fromConnection: or the writeSampleBuffer:ofType: method? From what I can see within ffmpeg-ios, it implements a class that has a custom writeSampleBuffer:ofType method on separate assetWriter classes, one of which is a segmented encoder every 5 seconds... but how do I make this upload to a server?

Resources