![]() |
Halyri - Mobiili
0.9
|
Class for managing audio and picture transmission from XNA Microphone and AudioVideoCaptureDevice. Media is captured using PreviewImageCapturer and WavAudioSampleCapturer classes. Capture configuration is taken from MediaConfigurationDto published by the server and available on NetworkConnection's MediaConfigurationUpdatedEvent. Network operations are performed by NetworkConnection class. More...
Public Member Functions | |
delegate void | CaptureConfigurationUpdated (object sender, EventArgs e, MediaConfigurationDto config) |
AudioVideoTransmitManager (Connection networkConnection) | |
Instantializes a AudioVideoTransmitManager that uses the provided NetworkConnection. The NetworkConnection has to be connected to a server with a valid session. More... | |
void | MediaConfigurationUpdateHandler (object sender, EventArgs e, MediaConfigurationDto config) |
Handles media uploading configurations received by NetworkConnection from server. This method only disbles audio and picture transmission if they are currently active and the new configuration suggests that they should be disabled. It also handles configuration changes to active audio and picture capturer classes. More... | |
void | StopAllCaptureTransmit () |
Disables media capture and transmission from any device. More... | |
void | ResetThrottlingState () |
Resets the ECF transfer channel throttling state of this instance. If packet transmissiong has been stalled due to throttling, packet transmission will resume. More... | |
void | ExternalSourceDeviceConfigurationChanged (AudioVideoCaptureDevice videoCaptureDevice, Microphone audioCaptureDevice, MediaConfigurationDto mediaConfiguration) |
Handles changes to external media source devices. This method should be called with a valid source device(s) when the media uploading configuration has transitioned from disabled to enabled state for either of the media types. More... | |
delegate void | CaptureConfigurationUpdated (object sender, EventArgs e, MediaConfigurationDto config) |
AudioVideoTransmitManager (Connection networkConnection) | |
Instantializes a AudioVideoTransmitManager that uses the provided NetworkConnection. The NetworkConnection has to be connected to a server with a valid session. More... | |
void | MediaConfigurationUpdateHandler (object sender, EventArgs e, MediaConfigurationDto config) |
Handles media uploading configurations received by NetworkConnection from server. This method only disbles audio and picture transmission if they are currently active and the new configuration suggests that they should be disabled. It also handles configuration changes to active audio and picture capturer classes. More... | |
void | StopAllCaptureTransmit () |
Disables media capture and transmission from any device. More... | |
void | ResetThrottlingState () |
Resets the ECF transfer channel throttling state of this instance. If packet transmissiong has been stalled due to throttling, packet transmission will resume. More... | |
void | ExternalSourceDeviceConfigurationChanged (AudioVideoCaptureDevice videoCaptureDevice, Microphone audioCaptureDevice, MediaConfigurationDto mediaConfiguration) |
Handles changes to external media source devices. This method should be called with a valid source device(s) when the media uploading configuration has transitioned from disabled to enabled state for either of the media types. More... | |
Public Attributes | |
CaptureConfigurationUpdated | CaptureConfigurationUpdatedEvent |
PacketThrottlingStarted | PacketThrottlingStartedEvent |
PacketSendStalled | PacketSendStalledEvent |
Properties | |
bool | PacketThrottlingEnabled [get] |
bool | AudioEnabled [get] |
bool | PictureEnabled [get] |
bool | UseUdp [get, set] |
Private Member Functions | |
void | AudioSampleEventHandler (object sender, EventArgs e, byte[] audioFrame) |
Handles new wave audio fragments. Sends the audio fragments to server if throttling does not prevent this action. More... | |
void | PcmSampleEventHandler (object sender, EventArgs e, byte[] audioFrame) |
Compresses the received PCM segment into speex format and transmit it over the UDP data channel if UseUdp = true. Otherwise returns immediately. More... | |
void | ImageCaptureEventHandler (object sender, EventArgs e, byte[] jpgData) |
Handles new jpeg images captured from the camera. Sends the pictures to server over WCF transfer channel if throttling does not prevent this action. More... | |
void | MediaSendFinishedHandler (object sender, AsyncCompletedEventArgs e) |
Handles async media send over WCF data channel finished events. Performs the throttling action by calculating the time used for sending the packet over the WCF data channel. More... | |
void | disableAudio () |
Disables the active WavAudioSampleCapturer instance and unregisters audio sample event receivers. More... | |
void | disablePicture () |
Disables the active PreviewImageCapturer instance and unregisters picture sample event receiver. More... | |
void | ConfigurePictureCapturerFromConfigurationInstance (PreviewImageCapturer capturer, MediaConfigurationDto configuration) |
Updates the quality parameters on the specified PreviewImageCapturer. New quality parameters are taken from provided MediaConfigurationDto. More... | |
void | AudioSampleEventHandler (object sender, EventArgs e, byte[] audioFrame) |
Handles new wave audio fragments. Sends the audio fragments to server if throttling does not prevent this action. More... | |
void | PcmSampleEventHandler (object sender, EventArgs e, byte[] audioFrame) |
Compresses the received PCM segment into speex format and transmit it over the UDP data channel if UseUdp = true. Otherwise returns immediately. More... | |
void | ImageCaptureEventHandler (object sender, EventArgs e, byte[] jpgData) |
Handles new jpeg images captured from the camera. Sends the pictures to server over WCF transfer channel if throttling does not prevent this action. More... | |
void | MediaSendFinishedHandler (object sender, AsyncCompletedEventArgs e) |
Handles async media send over WCF data channel finished events. Performs the throttling action by calculating the time used for sending the packet over the WCF data channel. More... | |
void | disableAudio () |
Disables the active WavAudioSampleCapturer instance and unregisters audio sample event receivers. More... | |
void | disablePicture () |
Disables the active PreviewImageCapturer instance and unregisters picture sample event receiver. More... | |
void | ConfigurePictureCapturerFromConfigurationInstance (PreviewImageCapturer capturer, MediaConfigurationDto configuration) |
Updates the quality parameters on the specified PreviewImageCapturer. New quality parameters are taken from provided MediaConfigurationDto. More... | |
Static Private Member Functions | |
static | AudioVideoTransmitManager () |
static | AudioVideoTransmitManager () |
Private Attributes | |
Object | ThrottlingParameterLock = new Object() |
int | overdueLimitMilliseconds = 9050 |
int | overduePacketCount = 0 |
int | overduePacketLimitSkipPictures = 4 |
int | overduePacketLimitDisablePictures = 8 |
int | overduePacketLimitDisableAll = 12 |
int | successiveSuccesfullPacketCount = 0 |
int | throttlingDecreaseFactor = 2 |
int | pictureSkipFactor = 1 |
int | pictureSkipCounter = 0 |
bool | packetThrotting = false |
MediaConfigurationDto | latestMediaConfiguration |
Connection | connection |
PreviewImageCapturer | pictureCapturer |
AudioVideoCaptureDevice | videoDevice |
WavAudioSampleCapturer | audioCapturer |
Microphone | audioDevice |
SpeexEncoder | speexEncoder |
bool | audioEnabled = false |
bool | pictureEnabled = false |
bool | useUdp = true |
Static Private Attributes | |
static int[] | imageWidthMapping |
static MediaInformationDto | outgoingJpgInformation |
static MediaInformationDto | outgoingWaveInformation |
static MediaInformation | udpOutgoingJpgInformation |
static MediaInformation | udpOutgoingWaveInformation |
static MediaInformation | udpOutgoingSpeexInformation |
Class for managing audio and picture transmission from XNA Microphone and AudioVideoCaptureDevice. Media is captured using PreviewImageCapturer and WavAudioSampleCapturer classes. Capture configuration is taken from MediaConfigurationDto published by the server and available on NetworkConnection's MediaConfigurationUpdatedEvent. Network operations are performed by NetworkConnection class.
<author>Veli-Mikko Puupponen</author> Implements a simple packet level throttling when using WCF connection by measuring packet transmission time and comparing it to a set threshold. For every packet whose time exceeds the threshold, a counter is incremented. Once the counter meets overdue packet threshold level, set ratio of picture data packets are dropped. If the overdue counter keeps increasing, picture packets are dropped completely. If the counter still increases, all packets are dropped and the PacketSendStalledEvent is fired.
If UseUdp = true, uses UDP transfer protocol and no packet throttling is performed by this class.
After this AudioVideoTransmitManager instance has been stalled, it has to be manually reset by a call to the ResetThrottlingState method.
|
staticprivate |
Halyri.AudioVideoTransmitManager.AudioVideoTransmitManager | ( | Connection | networkConnection | ) |
Instantializes a AudioVideoTransmitManager that uses the provided NetworkConnection. The NetworkConnection has to be connected to a server with a valid session.
networkConnection | NetworkConnection to be used to send pictures and audio |
|
staticprivate |
Halyri.AudioVideoTransmitManager.AudioVideoTransmitManager | ( | Connection | networkConnection | ) |
Instantializes a AudioVideoTransmitManager that uses the provided NetworkConnection. The NetworkConnection has to be connected to a server with a valid session.
networkConnection | NetworkConnection to be used to send pictures and audio |
|
private |
Handles new wave audio fragments. Sends the audio fragments to server if throttling does not prevent this action.
Wave fragments are only send over the WCF transfer channel. They are only sent provided that UseUdp = false.
sender | Sending object |
e | EventArgs for the event |
audioFrame | Wave file bytes |
|
private |
Handles new wave audio fragments. Sends the audio fragments to server if throttling does not prevent this action.
Wave fragments are only send over the WCF transfer channel. They are only sent provided that UseUdp = false.
sender | Sending object |
e | EventArgs for the event |
audioFrame | Wave file bytes |
delegate void Halyri.AudioVideoTransmitManager.CaptureConfigurationUpdated | ( | object | sender, |
EventArgs | e, | ||
MediaConfigurationDto | config | ||
) |
delegate void Halyri.AudioVideoTransmitManager.CaptureConfigurationUpdated | ( | object | sender, |
EventArgs | e, | ||
MediaConfigurationDto | config | ||
) |
|
private |
Updates the quality parameters on the specified PreviewImageCapturer. New quality parameters are taken from provided MediaConfigurationDto.
capturer | The PreviewImageCapturer whose configuration is updated |
configuration | The MediaConfigurationDto providing the configuration |
|
private |
Updates the quality parameters on the specified PreviewImageCapturer. New quality parameters are taken from provided MediaConfigurationDto.
capturer | The PreviewImageCapturer whose configuration is updated |
configuration | The MediaConfigurationDto providing the configuration |
|
private |
Disables the active WavAudioSampleCapturer instance and unregisters audio sample event receivers.
|
private |
Disables the active WavAudioSampleCapturer instance and unregisters audio sample event receivers.
|
private |
Disables the active PreviewImageCapturer instance and unregisters picture sample event receiver.
|
private |
Disables the active PreviewImageCapturer instance and unregisters picture sample event receiver.
void Halyri.AudioVideoTransmitManager.ExternalSourceDeviceConfigurationChanged | ( | AudioVideoCaptureDevice | videoCaptureDevice, |
Microphone | audioCaptureDevice, | ||
MediaConfigurationDto | mediaConfiguration | ||
) |
Handles changes to external media source devices. This method should be called with a valid source device(s) when the media uploading configuration has transitioned from disabled to enabled state for either of the media types.
videoCaptureDevice | AudioVideoCaptureDevice opened for at least video if video is enabled in the configuration |
audioCaptureDevice | XNA Microphone instance for capturing audio |
mediaConfiguration | The media uploading configuration used to set the devices in the UI |
void Halyri.AudioVideoTransmitManager.ExternalSourceDeviceConfigurationChanged | ( | AudioVideoCaptureDevice | videoCaptureDevice, |
Microphone | audioCaptureDevice, | ||
MediaConfigurationDto | mediaConfiguration | ||
) |
Handles changes to external media source devices. This method should be called with a valid source device(s) when the media uploading configuration has transitioned from disabled to enabled state for either of the media types.
videoCaptureDevice | AudioVideoCaptureDevice opened for at least video if video is enabled in the configuration |
audioCaptureDevice | XNA Microphone instance for capturing audio |
mediaConfiguration | The media uploading configuration used to set the devices in the UI |
|
private |
Handles new jpeg images captured from the camera. Sends the pictures to server over WCF transfer channel if throttling does not prevent this action.
If UseUdp = true, uses UDP transfer channel and performs no throttling.
sender | Sender instance of the event, not used |
e | EventArgs for the event, not used |
jpgData | JPEG image byte data |
|
private |
Handles new jpeg images captured from the camera. Sends the pictures to server over WCF transfer channel if throttling does not prevent this action.
If UseUdp = true, uses UDP transfer channel and performs no throttling.
sender | Sender instance of the event, not used |
e | EventArgs for the event, not used |
jpgData | JPEG image byte data |
void Halyri.AudioVideoTransmitManager.MediaConfigurationUpdateHandler | ( | object | sender, |
EventArgs | e, | ||
MediaConfigurationDto | config | ||
) |
Handles media uploading configurations received by NetworkConnection from server. This method only disbles audio and picture transmission if they are currently active and the new configuration suggests that they should be disabled. It also handles configuration changes to active audio and picture capturer classes.
If picture or audio is changed from enabled to disabled or vice versa, the configuration event is propagated through CaptureConfigurationUpdatedEvent to to the UI managing the capture devices.
sender | Sending object |
e | Eventargs, not currently used |
config | New media uploading configuration |
void Halyri.AudioVideoTransmitManager.MediaConfigurationUpdateHandler | ( | object | sender, |
EventArgs | e, | ||
MediaConfigurationDto | config | ||
) |
Handles media uploading configurations received by NetworkConnection from server. This method only disbles audio and picture transmission if they are currently active and the new configuration suggests that they should be disabled. It also handles configuration changes to active audio and picture capturer classes.
If picture or audio is changed from enabled to disabled or vice versa, the configuration event is propagated through CaptureConfigurationUpdatedEvent to to the UI managing the capture devices.
sender | Sending object |
e | Eventargs, not currently used |
config | New media uploading configuration |
|
private |
Handles async media send over WCF data channel finished events. Performs the throttling action by calculating the time used for sending the packet over the WCF data channel.
Not used id UseUdp = true;
sender | Sender instance of the event, not used |
e | EventArgs that containt a UserState instance specifying the send time of the packet related to this event |
|
private |
Handles async media send over WCF data channel finished events. Performs the throttling action by calculating the time used for sending the packet over the WCF data channel.
Not used id UseUdp = true;
sender | Sender instance of the event, not used |
e | EventArgs that containt a UserState instance specifying the send time of the packet related to this event |
|
private |
Compresses the received PCM segment into speex format and transmit it over the UDP data channel if UseUdp = true. Otherwise returns immediately.
sender | Sender instance of the event, not used |
e | EventArgs for the event, not used |
audioFrame | Framgnet of PCM data frames |
|
private |
Compresses the received PCM segment into speex format and transmit it over the UDP data channel if UseUdp = true. Otherwise returns immediately.
sender | Sender instance of the event, not used |
e | EventArgs for the event, not used |
audioFrame | Framgnet of PCM data frames |
void Halyri.AudioVideoTransmitManager.ResetThrottlingState | ( | ) |
Resets the ECF transfer channel throttling state of this instance. If packet transmissiong has been stalled due to throttling, packet transmission will resume.
Has no effect if the UDP transfer channel is being used.
void Halyri.AudioVideoTransmitManager.ResetThrottlingState | ( | ) |
Resets the ECF transfer channel throttling state of this instance. If packet transmissiong has been stalled due to throttling, packet transmission will resume.
Has no effect if the UDP transfer channel is being used.
void Halyri.AudioVideoTransmitManager.StopAllCaptureTransmit | ( | ) |
Disables media capture and transmission from any device.
void Halyri.AudioVideoTransmitManager.StopAllCaptureTransmit | ( | ) |
Disables media capture and transmission from any device.
|
private |
|
private |
|
private |
CaptureConfigurationUpdated Halyri.AudioVideoTransmitManager.CaptureConfigurationUpdatedEvent |
|
private |
|
staticprivate |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
PacketSendStalled Halyri.AudioVideoTransmitManager.PacketSendStalledEvent |
|
private |
PacketThrottlingStarted Halyri.AudioVideoTransmitManager.PacketThrottlingStartedEvent |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
get |
|
get |
|
get |
|
getset |