mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-17 15:53:42 +01:00
make dlna project portable
This commit is contained in:
26
MediaBrowser.Model/Net/ISocketFactory.cs
Normal file
26
MediaBrowser.Model/Net/ISocketFactory.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
namespace MediaBrowser.Model.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// Implemented by components that can create a platform specific UDP socket implementation, and wrap it in the cross platform <see cref="IUdpSocket"/> interface.
|
||||
/// </summary>
|
||||
public interface ISocketFactory
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Createa a new unicast socket using the specified local port number.
|
||||
/// </summary>
|
||||
/// <param name="localPort">The local port to bind to.</param>
|
||||
/// <returns>A <see cref="IUdpSocket"/> implementation.</returns>
|
||||
IUdpSocket CreateUdpSocket(int localPort);
|
||||
|
||||
/// <summary>
|
||||
/// Createa a new multicast socket using the specified multicast IP address, multicast time to live and local port.
|
||||
/// </summary>
|
||||
/// <param name="ipAddress">The multicast IP address to bind to.</param>
|
||||
/// <param name="multicastTimeToLive">The multicast time to live value. Actually a maximum number of network hops for UDP packets.</param>
|
||||
/// <param name="localPort">The local port to bind to.</param>
|
||||
/// <returns>A <see cref="IUdpSocket"/> implementation.</returns>
|
||||
IUdpSocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort);
|
||||
}
|
||||
}
|
||||
27
MediaBrowser.Model/Net/IUdpSocket.cs
Normal file
27
MediaBrowser.Model/Net/IUdpSocket.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Model.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a common interface across platforms for UDP sockets used by this SSDP implementation.
|
||||
/// </summary>
|
||||
public interface IUdpSocket : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Waits for and returns the next UDP message sent to this socket (uni or multicast).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<ReceivedUdpData> ReceiveAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Sends a UDP message to a particular end point (uni or multicast).
|
||||
/// </summary>
|
||||
/// <param name="messageData">The data to send.</param>
|
||||
/// <param name="endPoint">The <see cref="IpEndPointInfo"/> providing the address and port to send to.</param>
|
||||
Task SendTo(byte[] messageData, IpEndPointInfo endPoint);
|
||||
}
|
||||
}
|
||||
18
MediaBrowser.Model/Net/IpEndPointInfo.cs
Normal file
18
MediaBrowser.Model/Net/IpEndPointInfo.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Net
|
||||
{
|
||||
public class IpEndPointInfo
|
||||
{
|
||||
public IpAddressInfo IpAddress { get; set; }
|
||||
|
||||
public int Port { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var ipAddresString = IpAddress == null ? string.Empty : IpAddress.ToString();
|
||||
|
||||
return ipAddresString + ":" + this.Port.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
24
MediaBrowser.Model/Net/ReceivedUdpData.cs
Normal file
24
MediaBrowser.Model/Net/ReceivedUdpData.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
namespace MediaBrowser.Model.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the sockets wrapper to hold raw data received from a UDP socket.
|
||||
/// </summary>
|
||||
public sealed class ReceivedUdpData
|
||||
{
|
||||
/// <summary>
|
||||
/// The buffer to place received data into.
|
||||
/// </summary>
|
||||
public byte[] Buffer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of bytes received.
|
||||
/// </summary>
|
||||
public int ReceivedBytes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IpEndPointInfo"/> the data was received from.
|
||||
/// </summary>
|
||||
public IpEndPointInfo ReceivedFrom { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user