Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumblekit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2012-01-31 04:43:27 +0400
committerMikkel Krautz <mikkel@krautz.dk>2012-01-31 04:43:27 +0400
commit4a674c43db0d1a52ddedcb469990bc9c5fd2c97c (patch)
tree7dc1d055bdf585f67d9c884c7bccf5307e86dd1b
parent137f75a9d291dba5109c346cf6bf36036e84f1cd (diff)
Add self-mute and self-deafen actions for the connected user to MKServerModel. Convey mute state to MKServerModel (currently a hack, needs rewriting).
-rw-r--r--src/MKAudio.m11
-rw-r--r--src/MKAudioInput.h4
-rw-r--r--src/MKAudioInput.m21
-rw-r--r--src/MKServerModel.m35
-rw-r--r--src/MumbleKit/MKServerModel.h6
5 files changed, 77 insertions, 0 deletions
diff --git a/src/MKAudio.m b/src/MKAudio.m
index 8440c97..b84eb71 100644
--- a/src/MKAudio.m
+++ b/src/MKAudio.m
@@ -307,5 +307,16 @@ static void MKAudio_AudioRouteChangedCallback(MKAudio *audio, AudioSessionProper
return [_audioInput peakCleanMic];
}
+- (void) setSelfMuted:(BOOL)selfMuted {
+ [_audioInput setSelfMuted:selfMuted];
+}
+
+- (void) setSuppressed:(BOOL)suppressed {
+ [_audioInput setSuppressed:suppressed];
+}
+
+- (void) setMuted:(BOOL)muted {
+ [_audioInput setMuted:muted];
+}
@end
diff --git a/src/MKAudioInput.h b/src/MKAudioInput.h
index d48c8d2..d632e68 100644
--- a/src/MKAudioInput.h
+++ b/src/MKAudioInput.h
@@ -56,4 +56,8 @@
- (float) peakCleanMic;
- (float) speechProbability;
+- (void) setSelfMuted:(BOOL)selfMuted;
+- (void) setSuppressed:(BOOL)suppressed;
+- (void) setMuted:(BOOL)muted;
+
@end
diff --git a/src/MKAudioInput.m b/src/MKAudioInput.m
index e705794..07833fb 100644
--- a/src/MKAudioInput.m
+++ b/src/MKAudioInput.m
@@ -92,6 +92,8 @@ struct MKAudioInputPrivate {
float _speechProbability;
float _peakCleanMic;
+
+ BOOL _selfMuted, _muted, _suppressed;
}
- (BOOL) setupMacDevice;
- (BOOL) setupiOSDevice;
@@ -724,6 +726,13 @@ static OSStatus inputCallback(void *udata, AudioUnitRenderActionFlags *flags, co
_doTransmit = _forceTransmit;
}
+ if (_selfMuted)
+ _doTransmit = NO;
+ if (_suppressed)
+ _doTransmit = NO;
+ if (_muted)
+ _doTransmit = NO;
+
if (_lastTransmit != _doTransmit) {
// fixme(mkrautz): Handle more talkstates
MKTalkState talkState = _doTransmit ? MKTalkStateTalking : MKTalkStatePassive;
@@ -815,4 +824,16 @@ static OSStatus inputCallback(void *udata, AudioUnitRenderActionFlags *flags, co
return _peakCleanMic;
}
+- (void) setSelfMuted:(BOOL)selfMuted {
+ _selfMuted = selfMuted;
+}
+
+- (void) setSuppressed:(BOOL)suppressed {
+ _suppressed = suppressed;
+}
+
+- (void) setMuted:(BOOL)muted {
+ _muted = muted;
+}
+
@end
diff --git a/src/MKServerModel.m b/src/MKServerModel.m
index 825c13b..dff448f 100644
--- a/src/MKServerModel.m
+++ b/src/MKServerModel.m
@@ -46,6 +46,13 @@
#import "MulticastDelegate.h"
+// fixme(mkrautz): Refactor once 1.0's out the door.
+@interface MKAudio ()
+- (void) setSelfMuted:(BOOL)selfMuted;
+- (void) setSuppressed:(BOOL)suppressed;
+- (void) setMuted:(BOOL)muted;
+@end
+
@interface MKServerModel () {
MKConnection *_connection;
MKChannel *_rootChannel;
@@ -105,6 +112,11 @@
_connection = [conn retain];
[_connection setMessageHandler:self];
+
+ // fixme(mkrautz): Refactor this once 1.0's out the door.
+ [[MKAudio sharedAudio] setSelfMuted:NO];
+ [[MKAudio sharedAudio] setMuted:NO];
+ [[MKAudio sharedAudio] setSuppressed:NO];
// Listens to notifications form MKAudioOutput and MKAudioInput
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationUserTalkStateChanged:) name:@"MKAudioUserTalkStateChanged" object:nil];
@@ -530,6 +542,10 @@
[_delegate serverModel:self userRemovedSelfMute:user];
}
+ if (user == _connectedUser) {
+ [[MKAudio sharedAudio] setSelfMuted:[user isSelfMuted]];
+ }
+
[_delegate serverModel:self userSelfMuteDeafenStateChanged:user];
}
}
@@ -584,6 +600,13 @@
}
}
}
+
+ if (user == _connectedUser) {
+ [[MKAudio sharedAudio] setMuted:[user isMuted]];
+ }
+ if (user == _connectedUser) {
+ [[MKAudio sharedAudio] setSuppressed:[user isSuppressed]];
+ }
[_delegate serverModel:self userMuteStateChanged:user];
}
@@ -887,4 +910,16 @@
return [_connection peerCertificates];
}
+#pragma mark -
+#pragma mark Mute/deafen operations
+
+- (void) setSelfMuted:(BOOL)selfMuted andSelfDeafened:(BOOL)selfDeafened {
+ MPUserState_Builder *mpus = [MPUserState builder];
+ [mpus setSelfMute:selfMuted];
+ [mpus setSelfDeaf:selfDeafened];
+
+ NSData *data = [[mpus build] data];
+ [_connection sendMessageWithType:UserStateMessage data:data];
+}
+
@end
diff --git a/src/MumbleKit/MKServerModel.h b/src/MumbleKit/MKServerModel.h
index 10f003f..a1a9ab6 100644
--- a/src/MumbleKit/MKServerModel.h
+++ b/src/MumbleKit/MKServerModel.h
@@ -729,4 +729,10 @@ typedef enum {
*/
- (NSArray *) serverCertificates;
+///-----------------------------
+/// @name Mute/deafen operations
+///-----------------------------
+
+- (void) setSelfMuted:(BOOL)selfMuted andSelfDeafened:(BOOL)selfDeafened;
+
@end