public bool AddStreamingConnection(string remoteAddress, Socket socket) { if (discoveredSsdpDevice.DescriptionLocation.Host.Equals(remoteAddress)) { streamingConnection = DependencyFactory.Container.Resolve <StreamingConnection>(); streamingConnection.SetSocket(socket); streamingConnection.SendStartStreamingResponse(); return(true); } return(false); }
public void OnRecordingDataAvailable(byte[] dataToSend, WaveFormat format, int reduceLagThreshold) { if (streamingConnection != null) { if (streamingConnection.IsConnected()) { if (deviceState != DeviceState.Paused) { streamingConnection.SendData(dataToSend, format, reduceLagThreshold); } } else { Console.WriteLine(string.Format("Connection closed from {0}", streamingConnection.GetRemoteEndPoint())); streamingConnection = null; } } }
/// <summary> /// Stream the recorded data to the device. /// </summary> /// <param name="dataToSend">tha audio data</param> /// <param name="format">the wav format</param> /// <param name="reduceLagThreshold">lag value</param> /// <param name="streamFormat">the stream format</param> public void OnRecordingDataAvailable(byte[] dataToSend, WaveFormat format, int reduceLagThreshold, SupportedStreamFormat streamFormat) { if (streamingConnection == null || dataToSend == null || dataToSend.Length == 0) { return; } if (streamingConnection.IsConnected()) { if (GetDeviceState() != DeviceState.NotConnected && GetDeviceState() != DeviceState.Paused) // When you keep streaming to a device when it is paused, the application stops streaming after a while (local buffers full?) { streamingConnection.SendData(dataToSend, format, reduceLagThreshold, streamFormat); } } else { logger.Log($"Connection closed from {streamingConnection.GetRemoteEndPoint()}"); streamingConnection = null; } }
/// <summary> /// Add the streaming connection if it's for this device. /// </summary> /// <param name="remoteAddress">remote IP address of the streaming connection</param> /// <param name="socket">socket of the streaming connection</param> /// <returns></returns> public bool AddStreamingConnection(string remoteAddress, Socket socket) { if (discoveredDevice == null) { return(false); } //TODO: Is this right for device groups? if ((GetDeviceState() == DeviceState.LoadingMedia || GetDeviceState() == DeviceState.Buffering || GetDeviceState() == DeviceState.Idle) && discoveredDevice.IPAddress == remoteAddress) { streamingConnection = DependencyFactory.Container.Resolve <StreamingConnection>(); streamingConnection.SetDependencies(socket, this, logger); streamingConnection.SendStartStreamingResponse(); return(true); } return(false); }
/// <summary> /// Creates a new parser for the specified stream. /// </summary> /// <param name="userStream"> The stream. </param> /// <param name="context"> The context this stream is associated with </param> /// <returns> The created parser. </returns> public static StreamParser Create(IStreamingConnection userStream, IContextEntry context) { return(new StreamParser(userStream, context)); }
/// <summary> /// Initializes a new instance of the <see cref="StreamParser" /> class. /// </summary> /// <param name="stream"> The user stream. </param> /// <param name="context"> The context this stream is associated with </param> private StreamParser(IStreamingConnection stream, IContextEntry context) { AssociatedContext = context; Connections = new List <IStreaming>(); Stream = stream; }
/// <summary> /// Creates a new parser for the specified stream. /// </summary> /// <param name="userStream">The stream.</param> /// <returns>The created parser.</returns> public static StreamParser Create(IStreamingConnection userStream) { return(new StreamParser(userStream)); }
/// <summary> /// Initializes a new instance of the <see cref="StreamParser" /> class. /// </summary> /// <param name="stream">The user stream.</param> private StreamParser(IStreamingConnection stream) { Connections = new List <IStreaming>(); Stream = stream; }