corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) 2006-2014, openmetaverse.org
3 * All rights reserved.
4 *
5 * - Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * - Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 * - Neither the name of the openmetaverse.org nor the names
11 * of its contributors may be used to endorse or promote products derived from
12 * this software without specific prior written permission.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26  
27 using System;
28 using System.Collections.Generic;
29 using System.Xml;
30 using System.Xml.Serialization;
31  
32 namespace OpenMetaverse.Voice
33 {
34 public partial class VoiceGateway
35 {
36 #region Enums
37  
38 public enum LoginState
39 {
40 LoggedOut = 0,
41 LoggedIn = 1,
42 Error = 4
43 }
44  
45 public enum SessionState
46 {
47 Idle = 1,
48 Answering = 2,
49 InProgress = 3,
50 Connected = 4,
51 Disconnected = 5,
52 Hold = 6,
53 Refer = 7,
54 Ringing = 8
55 }
56  
57 public enum ParticipantState
58 {
59 Idle = 1,
60 Pending = 2,
61 Incoming = 3,
62 Answering = 4,
63 InProgress = 5,
64 Ringing = 6,
65 Connected = 7,
66 Disconnecting = 8,
67 Disconnected = 9
68 }
69  
70 public enum ParticipantType
71 {
72 User = 0,
73 Moderator = 1,
74 Focus = 2
75 }
76  
77 public enum ResponseType
78 {
79 None = 0,
80 ConnectorCreate,
81 ConnectorInitiateShutdown,
82 MuteLocalMic,
83 MuteLocalSpeaker,
84 SetLocalMicVolume,
85 SetLocalSpeakerVolume,
86 GetCaptureDevices,
87 GetRenderDevices,
88 SetRenderDevice,
89 SetCaptureDevice,
90 CaptureAudioStart,
91 CaptureAudioStop,
92 SetMicLevel,
93 SetSpeakerLevel,
94 AccountLogin,
95 AccountLogout,
96 RenderAudioStart,
97 RenderAudioStop,
98 SessionCreate,
99 SessionConnect,
100 SessionTerminate,
101 SetParticipantVolumeForMe,
102 SetParticipantMuteForMe,
103 Set3DPosition
104 }
105 #endregion Enums
106  
107 #region Logging
108  
109 public class VoiceLoggingSettings
110 {
111 /// <summary>Enable logging</summary>
112 public bool Enabled;
113 /// <summary>The folder where any logs will be created</summary>
114 public string Folder;
115 /// <summary>This will be prepended to beginning of each log file</summary>
116 public string FileNamePrefix;
117 /// <summary>The suffix or extension to be appended to each log file</summary>
118 public string FileNameSuffix;
119 /// <summary>
120 /// 0: NONE - No logging
121 /// 1: ERROR - Log errors only
122 /// 2: WARNING - Log errors and warnings
123 /// 3: INFO - Log errors, warnings and info
124 /// 4: DEBUG - Log errors, warnings, info and debug
125 /// </summary>
126 public int LogLevel;
127  
128 /// <summary>
129 /// Constructor for default logging settings
130 /// </summary>
131 public VoiceLoggingSettings()
132 {
133 Enabled = false;
134 Folder = String.Empty;
135 FileNamePrefix = "Connector";
136 FileNameSuffix = ".log";
137 LogLevel = 0;
138 }
139 }
140  
141 #endregion Logging
142  
143 public class VoiceResponseEventArgs : EventArgs
144 {
145 public readonly ResponseType Type;
146 public readonly int ReturnCode;
147 public readonly int StatusCode;
148 public readonly string Message;
149  
150 // All Voice Response events carry these properties.
151 public VoiceResponseEventArgs(ResponseType type, int rcode, int scode, string text)
152 {
153 this.Type = type;
154 this.ReturnCode = rcode;
155 this.StatusCode = scode;
156 this.Message = text;
157 }
158 }
159  
160 #region Session Event Args
161 public class VoiceSessionEventArgs : VoiceResponseEventArgs
162 {
163 public readonly string SessionHandle;
164  
165 public VoiceSessionEventArgs(int rcode, int scode, string text, string shandle) :
166 base(ResponseType.SessionCreate, rcode, scode, text)
167 {
168 this.SessionHandle = shandle;
169 }
170 }
171  
172 public class NewSessionEventArgs : EventArgs
173 {
174 public readonly string AccountHandle;
175 public readonly string SessionHandle;
176 public readonly string URI;
177 public readonly string Name;
178 public readonly string AudioMedia;
179  
180 public NewSessionEventArgs(string AccountHandle, string SessionHandle, string URI, bool IsChannel, string Name, string AudioMedia)
181 {
182 this.AccountHandle = AccountHandle;
183 this.SessionHandle = SessionHandle;
184 this.URI = URI;
185 this.Name = Name;
186 this.AudioMedia = AudioMedia;
187 }
188 }
189  
190 public class SessionMediaEventArgs : EventArgs
191 {
192 public readonly string SessionHandle;
193 public readonly bool HasText;
194 public readonly bool HasAudio;
195 public readonly bool HasVideo;
196 public readonly bool Terminated;
197  
198 public SessionMediaEventArgs(string SessionHandle, bool HasText, bool HasAudio, bool HasVideo, bool Terminated)
199 {
200 this.SessionHandle = SessionHandle;
201 this.HasText = HasText;
202 this.HasAudio = HasAudio;
203 this.HasVideo = HasVideo;
204 this.Terminated = Terminated;
205 }
206 }
207  
208 public class SessionStateChangeEventArgs : EventArgs
209 {
210 public readonly string SessionHandle;
211 public readonly int StatusCode;
212 public readonly string StatusString;
213 public readonly SessionState State;
214 public readonly string URI;
215 public readonly bool IsChannel;
216 public readonly string ChannelName;
217 public SessionStateChangeEventArgs(string SessionHandle, int StatusCode, string StatusString, SessionState State, string URI, bool IsChannel, string ChannelName)
218 {
219 this.SessionHandle = SessionHandle;
220 this.StatusCode = StatusCode;
221 this.StatusString = StatusString;
222 this.State = State;
223 this.URI = URI;
224 this.IsChannel = IsChannel;
225 this.ChannelName = ChannelName;
226 }
227 }
228  
229 // Participants
230 public class ParticipantAddedEventArgs : EventArgs
231 {
232 public readonly string SessionHandle;
233 public readonly string SessionGroupHandle;
234 public readonly string URI;
235 public readonly string AccountName;
236 public readonly string DisplayName;
237 public readonly ParticipantType Type;
238 public readonly string Appllication;
239 public ParticipantAddedEventArgs(
240 string SessionGroupHandle,
241 string SessionHandle,
242 string ParticipantUri,
243 string AccountName,
244 string DisplayName,
245 ParticipantType type,
246 string Application)
247 {
248 this.SessionGroupHandle = SessionGroupHandle;
249 this.SessionHandle = SessionHandle;
250 this.URI = ParticipantUri;
251 this.AccountName = AccountName;
252 this.DisplayName = DisplayName;
253 this.Type = type;
254 this.Appllication = Application;
255 }
256 }
257  
258 public class ParticipantRemovedEventArgs : EventArgs
259 {
260 public readonly string SessionGroupHandle;
261 public readonly string SessionHandle;
262 public readonly string URI;
263 public readonly string AccountName;
264 public readonly string Reason;
265  
266 public ParticipantRemovedEventArgs(
267 string SessionGroupHandle,
268 string SessionHandle,
269 string ParticipantUri,
270 string AccountName,
271 string Reason)
272 {
273 this.SessionGroupHandle = SessionGroupHandle;
274 this.SessionHandle = SessionHandle;
275 this.URI = ParticipantUri;
276 this.AccountName = AccountName;
277 this.Reason = Reason;
278 }
279 }
280  
281 public class ParticipantStateChangeEventArgs : EventArgs
282 {
283 public readonly string SessionHandle;
284 public readonly int StatusCode;
285 public readonly string StatusString;
286 public readonly ParticipantState State;
287 public readonly string URI;
288 public readonly string AccountName;
289 public readonly string DisplayName;
290 public readonly ParticipantType Type;
291  
292 public ParticipantStateChangeEventArgs(string SessionHandle, int StatusCode, string StatusString,
293 ParticipantState State, string ParticipantURI, string AccountName,
294 string DisplayName, ParticipantType ParticipantType)
295 {
296 this.SessionHandle = SessionHandle;
297 this.StatusCode = StatusCode;
298 this.StatusString = StatusString;
299 this.State = State;
300 this.URI = ParticipantURI;
301 this.AccountName = AccountName;
302 this.DisplayName = DisplayName;
303 this.Type = ParticipantType;
304 }
305 }
306  
307 public class ParticipantPropertiesEventArgs : EventArgs
308 {
309 public readonly string SessionHandle;
310 public readonly string URI;
311 public readonly bool IsLocallyMuted;
312 public readonly bool IsModeratorMuted;
313 public readonly bool IsSpeaking;
314 public readonly int Volume;
315 public readonly float Energy;
316  
317 public ParticipantPropertiesEventArgs(string SessionHandle, string ParticipantURI,
318 bool IsLocallyMuted, bool IsModeratorMuted, bool IsSpeaking, int Volume, float Energy)
319 {
320 this.SessionHandle = SessionHandle;
321 this.URI = ParticipantURI;
322 this.IsLocallyMuted = IsLocallyMuted;
323 this.IsModeratorMuted = IsModeratorMuted;
324 this.IsSpeaking = IsSpeaking;
325 this.Volume = Volume;
326 this.Energy = Energy;
327 }
328  
329 }
330  
331 public class ParticipantUpdatedEventArgs : EventArgs
332 {
333 public readonly string SessionHandle;
334 public readonly string URI;
335 public readonly bool IsMuted;
336 public readonly bool IsSpeaking;
337 public readonly int Volume;
338 public readonly float Energy;
339  
340 public ParticipantUpdatedEventArgs(string sessionHandle, string URI, bool isMuted, bool isSpeaking, int volume, float energy)
341 {
342 this.SessionHandle = sessionHandle;
343 this.URI = URI;
344 this.IsMuted = isMuted;
345 this.IsSpeaking = isSpeaking;
346 this.Volume = volume;
347 this.Energy = energy;
348 }
349 }
350  
351 public class SessionAddedEventArgs : EventArgs
352 {
353 public readonly string SessionGroupHandle;
354 public readonly string SessionHandle;
355 public readonly string URI;
356 public readonly bool IsChannel;
357 public readonly bool IsIncoming;
358  
359 public SessionAddedEventArgs(string sessionGroupHandle, string sessionHandle,
360 string URI, bool isChannel, bool isIncoming)
361 {
362 this.SessionGroupHandle = sessionGroupHandle;
363 this.SessionHandle = sessionHandle;
364 this.URI = URI;
365 this.IsChannel = isChannel;
366 this.IsIncoming = isIncoming;
367 }
368 }
369  
370 public class SessionRemovedEventArgs : EventArgs
371 {
372 public readonly string SessionGroupHandle;
373 public readonly string SessionHandle;
374 public readonly string URI;
375 public SessionRemovedEventArgs(
376 string SessionGroupHandle,
377 string SessionHandle,
378 string Uri)
379 {
380 this.SessionGroupHandle = SessionGroupHandle;
381 this.SessionHandle = SessionHandle;
382 this.URI = Uri;
383 }
384 }
385  
386 public class SessionUpdatedEventArgs : EventArgs
387 {
388 public readonly string SessionGroupHandle;
389 public readonly string SessionHandle;
390 public readonly string URI;
391 public readonly bool IsMuted;
392 public readonly int Volume;
393 public readonly bool TransmitEnabled;
394 public readonly bool IsFocused;
395 public SessionUpdatedEventArgs(string SessionGroupHandle,
396 string SessionHandle, string URI, bool IsMuted, int Volume,
397 bool TransmitEnabled, bool IsFocused)
398 {
399 this.SessionGroupHandle = SessionGroupHandle;
400 this.SessionHandle = SessionHandle;
401 this.URI = URI;
402 this.IsMuted = IsMuted;
403 this.Volume = Volume;
404 this.TransmitEnabled = TransmitEnabled;
405 this.IsFocused = IsFocused;
406 }
407  
408 }
409  
410 public class SessionGroupAddedEventArgs : EventArgs
411 {
412 public readonly string AccountHandle;
413 public readonly string SessionGroupHandle;
414 public readonly string Type;
415 public SessionGroupAddedEventArgs(string acctHandle, string sessionGroupHandle, string type)
416 {
417 this.AccountHandle = acctHandle;
418 this.SessionGroupHandle = sessionGroupHandle;
419 this.Type = type;
420 }
421 }
422 #endregion Session Event Args
423  
424 #region Connector Delegates
425 public class VoiceConnectorEventArgs : VoiceResponseEventArgs
426 {
427 private readonly string m_Version;
428 private readonly string m_ConnectorHandle;
429 public string Version { get { return m_Version; } }
430 public string Handle { get { return m_ConnectorHandle; } }
431  
432 public VoiceConnectorEventArgs(int rcode, int scode, string text, string version, string handle) :
433 base(ResponseType.ConnectorCreate, rcode, scode, text)
434 {
435 m_Version = version;
436 m_ConnectorHandle = handle;
437 }
438 }
439  
440 #endregion Connector Delegates
441  
442  
443 #region Aux Event Args
444 public class VoiceDevicesEventArgs : VoiceResponseEventArgs
445 {
446 private readonly string m_CurrentDevice;
447 private readonly List<string> m_Available;
448 public string CurrentDevice { get { return m_CurrentDevice; } }
449 public List<string> Devices { get { return m_Available; } }
450  
451 public VoiceDevicesEventArgs(ResponseType type, int rcode, int scode, string text, string current, List<string> avail) :
452 base(type, rcode, scode, text)
453 {
454 m_CurrentDevice = current;
455 m_Available = avail;
456 }
457 }
458  
459  
460 /// Audio Properties Events are sent after audio capture is started. These events are used to display a microphone VU meter
461 public class AudioPropertiesEventArgs : EventArgs
462 {
463 public readonly bool IsMicActive;
464 public readonly float MicEnergy;
465 public readonly int MicVolume;
466 public readonly int SpeakerVolume;
467 public AudioPropertiesEventArgs(bool MicIsActive, float MicEnergy, int MicVolume, int SpeakerVolume)
468 {
469 this.IsMicActive = MicIsActive;
470 this.MicEnergy = MicEnergy;
471 this.MicVolume = MicVolume;
472 this.SpeakerVolume = SpeakerVolume;
473 }
474 }
475  
476 #endregion Aux Event Args
477  
478 #region Account Event Args
479 public class VoiceAccountEventArgs : VoiceResponseEventArgs
480 {
481 private readonly string m_AccountHandle;
482 public string AccountHandle { get { return m_AccountHandle; } }
483  
484 public VoiceAccountEventArgs(int rcode, int scode, string text, string ahandle) :
485 base(ResponseType.AccountLogin, rcode, scode, text)
486 {
487 this.m_AccountHandle = ahandle;
488 }
489 }
490  
491 public class AccountLoginStateChangeEventArgs : EventArgs
492 {
493 public readonly string AccountHandle;
494 public readonly int StatusCode;
495 public readonly string StatusString;
496 public readonly LoginState State;
497 public AccountLoginStateChangeEventArgs(string AccountHandle, int StatusCode, string StatusString, LoginState State)
498 {
499 this.AccountHandle = AccountHandle;
500 this.StatusCode = StatusCode;
501 this.StatusString = StatusString;
502 this.State = State;
503 }
504 }
505  
506 #endregion Account Event Args
507  
508 /// <summary>
509 /// Event for most mundane request reposnses.
510 /// </summary>
511 public event EventHandler<VoiceResponseEventArgs> OnVoiceResponse;
512  
513 #region Session Events
514 public event EventHandler<VoiceSessionEventArgs> OnSessionCreateResponse;
515 public event EventHandler<NewSessionEventArgs> OnSessionNewEvent;
516 public event EventHandler<SessionStateChangeEventArgs> OnSessionStateChangeEvent;
517 public event EventHandler<ParticipantStateChangeEventArgs> OnSessionParticipantStateChangeEvent;
518 public event EventHandler<ParticipantPropertiesEventArgs> OnSessionParticipantPropertiesEvent;
519 public event EventHandler<ParticipantUpdatedEventArgs> OnSessionParticipantUpdatedEvent;
520 public event EventHandler<ParticipantAddedEventArgs> OnSessionParticipantAddedEvent;
521 public event EventHandler<ParticipantRemovedEventArgs> OnSessionParticipantRemovedEvent;
522 public event EventHandler<SessionGroupAddedEventArgs> OnSessionGroupAddedEvent;
523 public event EventHandler<SessionAddedEventArgs> OnSessionAddedEvent;
524 public event EventHandler<SessionRemovedEventArgs> OnSessionRemovedEvent;
525 public event EventHandler<SessionUpdatedEventArgs> OnSessionUpdatedEvent;
526 public event EventHandler<SessionMediaEventArgs> OnSessionMediaEvent;
527 #endregion Session Events
528  
529 #region Connector Events
530  
531 /// <summary>Response to Connector.Create request</summary>
532 public event EventHandler<VoiceConnectorEventArgs> OnConnectorCreateResponse;
533  
534 #endregion Connector Events
535  
536 #region Aux Events
537  
538 /// <summary>Response to Aux.GetCaptureDevices request</summary>
539 public event EventHandler<VoiceDevicesEventArgs> OnAuxGetCaptureDevicesResponse;
540 /// <summary>Response to Aux.GetRenderDevices request</summary>
541 public event EventHandler<VoiceDevicesEventArgs> OnAuxGetRenderDevicesResponse;
542  
543 /// <summary>Audio Properties Events are sent after audio capture is started.
544 /// These events are used to display a microphone VU meter</summary>
545 public event EventHandler<AudioPropertiesEventArgs> OnAuxAudioPropertiesEvent;
546  
547 #endregion Aux Events
548  
549 #region Account Events
550  
551 /// <summary>Response to Account.Login request</summary>
552 public event EventHandler<VoiceAccountEventArgs> OnAccountLoginResponse;
553  
554 /// <summary>This event message is sent whenever the login state of the
555 /// particular Account has transitioned from one value to another</summary>
556 public event EventHandler<AccountLoginStateChangeEventArgs> OnAccountLoginStateChangeEvent;
557  
558 #endregion Account Events
559  
560 #region XML Serialization Classes
561  
562 private XmlSerializer EventSerializer = new XmlSerializer(typeof(VoiceEvent));
563 private XmlSerializer ResponseSerializer = new XmlSerializer(typeof(VoiceResponse));
564  
565 [XmlRoot("Event")]
566 public class VoiceEvent
567 {
568 [XmlAttribute("type")]
569 public string Type;
570 public string AccountHandle;
571 public string Application;
572 public string StatusCode;
573 public string StatusString;
574 public string State;
575 public string SessionHandle;
576 public string SessionGroupHandle;
577 public string URI;
578 public string Uri; // Yes, they send it with both capitalizations
579 public string IsChannel;
580 public string IsIncoming;
581 public string Incoming;
582 public string IsMuted;
583 public string Name;
584 public string AudioMedia;
585 public string ChannelName;
586 public string ParticipantUri;
587 public string AccountName;
588 public string DisplayName;
589 public string ParticipantType;
590 public string IsLocallyMuted;
591 public string IsModeratorMuted;
592 public string IsSpeaking;
593 public string Volume;
594 public string Energy;
595 public string MicIsActive;
596 public string MicEnergy;
597 public string MicVolume;
598 public string SpeakerVolume;
599 public string HasText;
600 public string HasAudio;
601 public string HasVideo;
602 public string Terminated;
603 public string Reason;
604 public string TransmitEnabled;
605 public string IsFocused;
606 }
607  
608 [XmlRoot("Response")]
609 public class VoiceResponse
610 {
611 [XmlAttribute("requestId")]
612 public string RequestId;
613 [XmlAttribute("action")]
614 public string Action;
615 public string ReturnCode;
616 public VoiceResponseResults Results;
617 public VoiceInputXml InputXml;
618 }
619  
620 public class CaptureDevice
621 {
622 public string Device;
623 }
624  
625 public class RenderDevice
626 {
627 public string Device;
628 }
629  
630 public class VoiceResponseResults
631 {
632 public string VersionID;
633 public string StatusCode;
634 public string StatusString;
635 public string ConnectorHandle;
636 public string AccountHandle;
637 public string SessionHandle;
638 public List<CaptureDevice> CaptureDevices;
639 public CaptureDevice CurrentCaptureDevice;
640 public List<RenderDevice> RenderDevices;
641 public RenderDevice CurrentRenderDevice;
642 }
643  
644 public class VoiceInputXml
645 {
646 public VoiceRequest Request;
647 }
648  
649 [XmlRoot("Request")]
650 public class VoiceRequest
651 {
652 [XmlAttribute("requestId")]
653 public string RequestId;
654 [XmlAttribute("action")]
655 public string Action;
656 public string RenderDeviceSpecifier;
657 public string CaptureDeviceSpecifier;
658 public string Duration;
659 public string Level;
660 public string ClientName;
661 public string AccountManagementServer;
662 public string MinimumPort;
663 public string MaximumPort;
664 public VoiceLoggingSettings Logging;
665 public string ConnectorHandle;
666 public string Value;
667 public string AccountName;
668 public string AccountPassword;
669 public string AudioSessionAnswerMode;
670 public string AccountURI;
671 public string ParticipantPropertyFrequency;
672 public string EnableBuddiesAndPresence;
673 public string URI;
674 public string Name;
675 public string Password;
676 public string JoinAudio;
677 public string JoinText;
678 public string PasswordHashAlgorithm;
679 public string SoundFilePath;
680 public string Loop;
681 public string SessionHandle;
682 public string OrientationType;
683 public VoicePosition SpeakerPosition;
684 public VoicePosition ListenerPosition;
685 public string ParticipantURI;
686 public string Volume;
687 }
688  
689 #endregion XML Serialization Classes
690 }
691  
692 public class VoicePosition
693 {
694 /// <summary>Positional vector of the users position</summary>
695 public Vector3d Position;
696 /// <summary>Velocity vector of the position</summary>
697 public Vector3d Velocity;
698 /// <summary>At Orientation (X axis) of the position</summary>
699 public Vector3d AtOrientation;
700 /// <summary>Up Orientation (Y axis) of the position</summary>
701 public Vector3d UpOrientation;
702 /// <summary>Left Orientation (Z axis) of the position</summary>
703 public Vector3d LeftOrientation;
704 }
705  
706 }