Interference sound after switching to speaker in pjsip - objective-c

I use pjsip library and try to turn on speaker. After this during 10 seconds users could hear interference sound. Is it way to fix it?
I am using next code:
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
Also I try to change category with option AVAudioSessionCategoryOptionDefaultToSpeaker without success.
This is happened only during call, for example, I couldn't reproduce this problem for static video (with AVPlayer).

Related

Capture screen and audio with objective-c

I'm using an AVCaptureSession to create a screen recording (OSX), but i'd also like to add the computer audio to it (not the microphone, but anything that's playing through the speakers) i'm not really sure how to do that so the first thing i tried was adding an audio device like so:
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
After adding this device the audio was recorded, but it sounded like it was captured through the microphone. Is it possible to actually capture the computer's output sound this way? like quicktime does.
Here's an open source framework that supposedly makes it as easy to capture speaker output as it is a screenshot.
https://github.com/pje/WavTap
The home page for WavTap does mention that it requires kernel extension signing privileges to run under MacOS 10.10 & newer, and that requires signing into your Apple Developer Account and submitting this form. More information can be found here.

UIVideoAtPathIsCompatibleWithSavedPhotosAlbum returns false when deploying on the iPhone

One of my app's features is to download a mp4 file and store it to the local phone album.
I have tried several approaches since and the result is always the same, it worked on the simulator but not on the actual iPhone. Xcode is version 5.0.1, iPhone 4.
Below is the code I applied on the last attempt before posted here using ASIHttpRequest library and the result is still the same, it worked on the simulator but not the phone itself.
download:
ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:url]; // url is the address to the mp4 file
NSString* filePath = [NSString stringWithFormat:#"%#%#", NSTemporaryDirectory(), filename]; //filename is the file I save to, e.g. xxx.mp4
[request setDownloadDestinationPath:filePath];
[request setDelegate:self];
[request setDidFinishSelector:#selector[ASIRequestDone:)];
[request setDidFailSelector:#select[ASIRequestFail:)];
when download is finished, save it to the photo album (in ASIRequestDone delegate)
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(filePath))
{
//comes to here when running in simulators
UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, #selector(video:didFinishSavingWithError:cotextInfo:),nil);
}
else
{
//always comes to here when running on the actual iPhone.
}
I have checked the pathFile it's this
/private/var/mobile/Applications/xxxxxxxxxx/tmp/xxxxx.mp4
which is alright to me. What I am not getting is it works fine when running on Simulator and hence I am stuck not sure what to do next. (I have also checked the permission accessing the the photo albums and yes the app has it).
I also tried to removed the compatible checking and went straight into the method UISaveVideoAtPathToSavedPhotosAlbum, it didn't throw any error on delegate didFinishSavingWithError. however, the video didn't show up on the photo album either, I am guessing it's correct as the phone seems to say that video is not compatible to be shown on the album. Again, my issue is that it does work on the simulator and how do I fix this on the actual iphone, e.g. why it thinks the video is not compatible? is something to do with the mp4 itself or is it something to do during the download step? What could I do next to resolve the issue? (ps. I also have control over the mp4 files, is there a list of mp4 compatibility on the iphone that you know? I am thinking perhaps it's genuine that the file is not compatible on the phone (but on the simulator!?))
Found the answer to my question and I hope it could help out someone who suffers from the same issue. Turns out video resolution is the factor between the simulator and the actual phone when it comes to store video to the gallery; to be specific:
Compatibility checking UIVideoAtPathIsCompatibleWithSavedPhotosAlbum would FAIL on the actual phone but would PASS on the simulator given a sample clip capturrd as 1080p. I came cross this link a week after my post with luck.
"What video formats are compatible with the assets library?"
And I did the experiment similar to that by capturing 720p video clips instead and all files were able to be saved to the gallery. Weird thing is that the actual iphone can play the HLS stream at 1080p; howeve it won't store clips unless they are 720p, not to me anyway. And the misleading bit is that the simulator can actually do 1080p.

pjsua_conf_disconnect do not mute mic on some Mac

The question:
Is it possible that under specific condition (hardware, ...) the pjsua_conf_disconnect(0, callInfo.conf_slot) function do not mute the mic?
If yes, how can we effectively mute the mic with PJSIP?
The details:
In a OSX SIP application, user can mute the mic, and this will call:
...
pjsua_call_info callInfo;
pjsua_call_get_info([self identifier], &callInfo);
pj_status_t status = pjsua_conf_disconnect(0, callInfo.conf_slot);
...
Where [self identifier] is the pjsua_call_id of the current call.
I know for sure that after those 3 lines, status == PJ_SUCCESS, because only if this condition is true the UI is updated to let the user know the mic is muted.
This project uses the pjlib 1.12.0 for POSIX static libs.
Users that face this problem are on Mac OSX 10.8.1 and 10.8.2. They are all using their built-in MacBook [Pro,Air] mic, no headset.
Note that I am NOT able reproduce this problem myself on an OSX 10.8.2 mid-2009 MBP with the exact same build (from the MacAppStore), this is what making this problem hard to trouble shoot.
Note that it is not a random problem, it is contant: as the mute function never works for users experiencing this issue, and it always work for the others.

I cannot get a QTCaptureSession to Capture when in a Terminal Application

I've got a terminal application that needs to take a webcam picture and then perform some processing on it. I'm having trouble getting it to initialize. There's a fairly complete demo with an app called MyRecorder in the Apple docs that uses QTKit, which I was able to make work fine. I was also able to modify it to grab a single frame instead of a stream.
When I move this to a terminal application, the startRunning of the QTCaptureSession command simply does nothing. There are no errors, and everything reports as successful, but my webcam doesn't light up, and no frames are captured.
Any idea what's going on here? Are there any kind of security restrictions, or other kinds of restrictions that would prevent the QTCaptureSession from working?
So switching to AVFoundation solved my problem. I'm still not certain what the issue is, but for now using AVFoundation seems like the way to go since it was designed to replace QtKit anyways.

AudioServicesPlaySystemSound not playing sounds

I am playing a small .wav file using the AudioToolBox.
AudioServicesPlaySystemSound (soundFileObject);
But sometimes it is not playing.
What is the reason?
If you're in the Simulator, make sure that in System Prefrences → Sound, that "Play user interface sound effects" is not turned off. If you're on the device, check that the ringer switch is not set to silent.
Maybe it's this issue? AudioServicesDisposeSystemSoundID() will stop the sound work before playing.
Building on user1056521's answer, use the following code:
AudioServicesPlaySystemSoundWithCompletion(soundID, ^{
AudioServicesDisposeSystemSoundID(soundID);
});
where soundID is the SystemSoundID value you got when you called AudioServicesCreateSystemSoundID().
The completion block ensures the sound was played and completed playing before it is disposed of.
System Preferences → Sound → [x] Play user interface sound — this checkbox helped for me too, it solved the AudioServicesPlaySystemSound(_) issue. But worth noting was that the sample Apple Xcode project "SysSound" worked just fine without checking this box. I'm using the Xcode 4.4.1 for creating own app from scratch. Could there be differencies between projects created with older and newer Xcode tools?
For those who visit this question later,
AudioServicesPlaySystemSoundID()'s volume is based on system Ringer in range of 0.1 ~ 1.0, not mediaVolume
AudioServicesPlayAlertSoundID()'s volume is based on system Ringer in range of approximately 0.3 ~ 1.0
On the device, go into settings and turn up the volume on Sounds->Ringer and Alerts