/// <summary> /// Does the video job. /// </summary> private void DoWorkerJob(System.Net.Sockets.UdpClient socket, int data_port) { Profiler.BeginThreadProfiling("RTSP", $"UDPSocket.DoWorkerJob port {data_port}"); IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, data_port); try { // loop until we get an exception eg the socket closed while (true) { byte[] frame = socket.Receive(ref ipEndPoint); Profiler.BeginSample("OnDataReceived"); // We have an RTP frame. // Fire the DataReceived event with 'frame' Console.WriteLine("Received RTP data on port " + data_port); Messages.RtspChunk currentMessage = new Messages.RtspData(); // aMessage.SourcePort = ?? currentMessage.Data = frame; ((Messages.RtspData)currentMessage).Channel = data_port; OnDataReceived(new RtspChunkEventArgs(currentMessage)); Profiler.EndSample(); } } catch (ObjectDisposedException) { } catch (SocketException) { } }
/// <summary> /// Clones this instance. /// <remarks>Listner is not cloned</remarks> /// </summary> /// <returns>a clone of this instance</returns> public override object Clone() { RtspData result = new RtspData(); result.Channel = this.Channel; if (this.Data != null) { result.Data = this.Data.Clone() as byte[]; } result.SourcePort = this.SourcePort; return(result); }