2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #import <Adium/AIVideoConfControllerProtocol.h>
20 #import <Adium/AIPreferenceControllerProtocol.h>
21 #import <Adium/AIVideoConf.h>
22 #import <Adium/AIListObject.h>
23 #import <AIUtilities/AIDictionaryAdditions.h>
24 #import <AIUtilities/AIAttributedStringAdditions.h>
26 #import <QuickTime/QuickTime.h>
28 #import "QTConnection.h"
29 #import "QTRTPConnection.h"
30 #import "QTAdvancedPreferences.h"
35 @implementation QTPlugin
37 ////////////////////////////////////////////////////////////////////////////////
38 #pragma mark QuickTime Initialization
39 ////////////////////////////////////////////////////////////////////////////////
42 * Initialize QuickTime
44 - (void) startupQuickTime
46 NSLog(@"QuickTime startup");
53 - (void) shutdownQuickTime
55 NSLog(@"QuickTime shutdown");
59 ////////////////////////////////////////////////////////////////////////////////
60 #pragma mark QuickTime Properties
61 ////////////////////////////////////////////////////////////////////////////////
64 * @brief Set the mic volume
66 - (void) setDefaultMicVolumeTo: (int)volume
72 * @brief Set the output volume
74 - (void) setDefaultOutVolumeTo: (int)volume
80 * @brief Set the connection speed
82 - (void) setConnectionSpeed
85 QTAtomContainer prefs;
89 ConnectionSpeedPrefsRecord prefrec;
91 err = GetQuickTimePreference (ConnectionSpeedPrefsType, &prefs);
93 prefsAtom = QTFindChildByID (prefs,
94 kParentAtomIsContainer,
95 ConnectionSpeedPrefsType,
100 // set the default setting to 28.8kpbs
101 prefrec.connectionSpeed = kDataRate288ModemRate;
103 err = QTGetAtomDataPtr (prefs, prefsAtom, &dataSize, &atomData);
104 if (dataSize != sizeof(ConnectionSpeedPrefsRecord)) {
105 // the prefs record wasn't the right size,
106 // so it must be corrupt -- set to the default
107 prefrec.connectionSpeed = kDataRate288ModemRate;
109 // everything was fine -- read the connection speed
110 prefrec = *(ConnectionSpeedPrefsRecord *)atomData;
114 QTDisposeAtomContainer (prefs);
119 ////////////////////////////////////////////////////////////////////////////////
120 #pragma mark QuickTime General Information
121 ////////////////////////////////////////////////////////////////////////////////
122 - (NSArray*) getAudioPayloadsForProtocol:(VCProtocol)protocol
124 // So far, we only support RTP audio connections: get the list of payloads
126 if (protocol == VC_RTP) {
127 return [QTAudioRTPConnection getSupportedAudioPayloads];
129 NSLog (@"Unsupported protocol in getAudioPayloadsForProtocol.");
134 - (NSArray*) getVideoPayloadsForProtocol:(VCProtocol)protocol
136 // TODO: we dont currently support any video codec...
137 NSLog (@"Warning: asking for video payloads to QTPlugin.");
141 ////////////////////////////////////////////////////////////////////////////////
142 #pragma mark Connections Management
143 ////////////////////////////////////////////////////////////////////////////////
145 * Create a connection between two transport points, with the specified payload
146 * type. It should return the new connection, or nil if the protocol can not
147 * create this connection.
149 - (id) createConnectionWithProtocol:(VCProtocol)protocol
150 payload:(VCPayload*)payload
151 from:(VCTransport*)local
152 to:(VCTransport*)remote;
154 id<VCConnection> connection = nil;
156 if (protocol == VC_RTP) {
157 QTAudioRTPConnection *rtpConnection;
159 // Create the audio connection
160 rtpConnection = [QTAudioRTPConnection createWithProtocol:protocol
164 // ...and set some media properties
165 if(rtpConnection != nil) {
166 [rtpConnection setMicVolumeTo:micVolume];
167 [rtpConnection setOutVolumeTo:outVolume];
169 NSLog(@"Error: creating an RTP audio connection.");
172 connection = rtpConnection;
174 NSLog(@"The supplied protocol is not supported yet.");
181 * Create a set of connections between several transport points, with the
182 * specified payload types. It should return "nil" if the protocol can not create
185 - (NSArray*) createConnectionsWithProtocol:(VCProtocol)protocol
186 payloads:(NSArray*)payload
190 NSLog(@"createConnectionsWithProtocol not implemented.");
195 ////////////////////////////////////////////////////////////////////////////////
196 #pragma mark Plugin Management
197 ////////////////////////////////////////////////////////////////////////////////
202 - (void)installPlugin
204 // Observe workspace activity changes so we can mute sounds as necessary
205 NSNotificationCenter *workspaceCenter;
207 // Register this for some protocols
208 [[adium vcController] registerProvider:self forProtocol:VC_RTP];
210 // Install some preferences
211 [[adium preferenceController] registerDefaults:[NSDictionary dictionaryNamed:QUICKTIME_PREFS
212 forClass:[self class]]
213 forGroup:QUICKTIME_PREFS];
215 advancedPreferences = [[QTAdvancedPreferences preferencePane] retain];
217 // Watch for preferences changes
218 [[adium preferenceController] registerPreferenceObserver:self forGroup:QUICKTIME_PREFS];
220 workspaceCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
222 [workspaceCenter addObserver:self
223 selector:@selector(workspaceSessionDidBecomeActive:)
224 name:NSWorkspaceSessionDidBecomeActiveNotification
227 [workspaceCenter addObserver:self
228 selector:@selector(workspaceSessionDidResignActive:)
229 name:NSWorkspaceSessionDidResignActiveNotification
232 [self startupQuickTime];
236 * Uninstall the plugin
238 - (void) uninstallPlugin
240 [self shutdownQuickTime];
242 [[adium vcController] unregisterProviderForProtocol:VC_RTP];
244 [[adium preferenceController] unregisterPreferenceObserver:self];
246 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
251 * Preferences have changed
253 - (void) preferencesChangedForGroup:(NSString *)group
255 object:(AIListObject *)object
256 preferenceDict:(NSDictionary *)prefDict
257 firstTime:(BOOL)firstTime
259 [self setDefaultMicVolumeTo: [[prefDict objectForKey:KEY_MIC_VOLUME] intValue]];
260 [self setDefaultOutVolumeTo: [[prefDict objectForKey:KEY_OUT_VOLUME] intValue]];
263 - (void)workspaceSessionDidBecomeActive:(NSNotification *)inNotification
268 - (void)workspaceSessionDidResignActive:(NSNotification *)inNotification