Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pili-engineering/PLCameraStreamin…
Browse files Browse the repository at this point in the history
…gKit
  • Loading branch information
0dayZh committed Dec 28, 2015
2 parents 6772bcc + c726d1d commit 3292b52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Pod/Classes/PLCameraStreamingSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ - (void)initMicophoneSource {
}

self.microphoneSource = [[PLMicrophoneSource alloc] initWithSampleRate:self.audioConfiguration.audioSampleRate
channelsPerFrame:2];
channelsPerFrame:1];
self.microphoneSource.delegate = self;

dispatch_async(dispatch_get_main_queue(), ^{
Expand Down
9 changes: 7 additions & 2 deletions Pod/Classes/PLMicrophoneSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static OSStatus handleInputBuffer(void *inRefCon,
AudioBuffer buffer;
buffer.mData = NULL;
buffer.mDataByteSize = 0;
buffer.mNumberChannels = 2;
buffer.mNumberChannels = 1;

AudioBufferList buffers;
buffers.mNumberBuffers = 1;
Expand Down Expand Up @@ -139,6 +139,7 @@ - (instancetype)initWithSampleRate:(PLAACSampleRate)sampleRate channelsPerFrame:
self.tsBase = 0;

AVAudioSession *session = [AVAudioSession sharedInstance];
[session setActive:YES withOptions:kAudioSessionSetActiveFlag_NotifyOthersOnDeactivation error:nil];

[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(handleRouteChange:)
Expand All @@ -156,10 +157,14 @@ - (instancetype)initWithSampleRate:(PLAACSampleRate)sampleRate channelsPerFrame:
NSError *error = nil;

[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionMixWithOthers error:nil];

[session setMode:AVAudioSessionModeVideoRecording error:&error];

if (![session setActive:YES error:&error]) {
[self handleAudioComponentCreationFailure];
}


AudioComponentDescription acd;
acd.componentType = kAudioUnitType_Output;
acd.componentSubType = kAudioUnitSubType_RemoteIO;
Expand All @@ -184,7 +189,7 @@ - (instancetype)initWithSampleRate:(PLAACSampleRate)sampleRate channelsPerFrame:
desc.mSampleRate = self.sampleRate;
desc.mFormatID = kAudioFormatLinearPCM;
desc.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;
desc.mChannelsPerFrame = self.channelsPerFrame;
desc.mChannelsPerFrame = (UInt32)self.channelsPerFrame;
desc.mFramesPerPacket = 1;
desc.mBitsPerChannel = 16;
desc.mBytesPerFrame = desc.mBitsPerChannel / 8 * desc.mChannelsPerFrame;
Expand Down

0 comments on commit 3292b52

Please sign in to comment.