aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspMethod.cs88
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspRequest.cs141
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspResponse.cs150
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspStatusCode.cs251
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs1
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj4
6 files changed, 634 insertions, 1 deletions
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspMethod.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspMethod.cs
new file mode 100644
index 000000000..fae7c4bfc
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspMethod.cs
@@ -0,0 +1,88 @@
+/*
+ Copyright (C) <2007-2016> <Kay Diefenthal>
+
+ SatIp.RtspSample is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ SatIp.RtspSample is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with SatIp.RtspSample. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using System.Collections.Generic;
+
+namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.SatIp
+{
+ /// <summary>
+ /// Standard RTSP request methods.
+ /// </summary>
+ public sealed class RtspMethod
+ {
+ public override int GetHashCode()
+ {
+ return (_name != null ? _name.GetHashCode() : 0);
+ }
+
+ private readonly string _name;
+ private static readonly IDictionary<string, RtspMethod> _values = new Dictionary<string, RtspMethod>();
+
+ public static readonly RtspMethod Describe = new RtspMethod("DESCRIBE");
+ public static readonly RtspMethod Announce = new RtspMethod("ANNOUNCE");
+ public static readonly RtspMethod GetParameter = new RtspMethod("GET_PARAMETER");
+ public static readonly RtspMethod Options = new RtspMethod("OPTIONS");
+ public static readonly RtspMethod Pause = new RtspMethod("PAUSE");
+ public static readonly RtspMethod Play = new RtspMethod("PLAY");
+ public static readonly RtspMethod Record = new RtspMethod("RECORD");
+ public static readonly RtspMethod Redirect = new RtspMethod("REDIRECT");
+ public static readonly RtspMethod Setup = new RtspMethod("SETUP");
+ public static readonly RtspMethod SetParameter = new RtspMethod("SET_PARAMETER");
+ public static readonly RtspMethod Teardown = new RtspMethod("TEARDOWN");
+
+ private RtspMethod(string name)
+ {
+ _name = name;
+ _values.Add(name, this);
+ }
+
+ public override string ToString()
+ {
+ return _name;
+ }
+
+ public override bool Equals(object obj)
+ {
+ var method = obj as RtspMethod;
+ if (method != null && this == method)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static ICollection<RtspMethod> Values
+ {
+ get { return _values.Values; }
+ }
+
+ public static explicit operator RtspMethod(string name)
+ {
+ RtspMethod value;
+ if (!_values.TryGetValue(name, out value))
+ {
+ return null;
+ }
+ return value;
+ }
+
+ public static implicit operator string(RtspMethod method)
+ {
+ return method._name;
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspRequest.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspRequest.cs
new file mode 100644
index 000000000..d8462b223
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspRequest.cs
@@ -0,0 +1,141 @@
+/*
+ Copyright (C) <2007-2016> <Kay Diefenthal>
+
+ SatIp.RtspSample is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ SatIp.RtspSample is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with SatIp.RtspSample. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using System.Collections.Generic;
+using System.Text;
+
+
+namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.SatIp
+{
+ /// <summary>
+ /// A simple class that can be used to serialise RTSP requests.
+ /// </summary>
+ public class RtspRequest
+ {
+ private readonly RtspMethod _method;
+ private readonly string _uri;
+ private readonly int _majorVersion;
+ private readonly int _minorVersion;
+ private IDictionary<string, string> _headers = new Dictionary<string, string>();
+ private string _body = string.Empty;
+
+ /// <summary>
+ /// Initialise a new instance of the <see cref="RtspRequest"/> class.
+ /// </summary>
+ /// <param name="method">The request method.</param>
+ /// <param name="uri">The request URI</param>
+ /// <param name="majorVersion">The major version number.</param>
+ /// <param name="minorVersion">The minor version number.</param>
+ public RtspRequest(RtspMethod method, string uri, int majorVersion, int minorVersion)
+ {
+ _method = method;
+ _uri = uri;
+ _majorVersion = majorVersion;
+ _minorVersion = minorVersion;
+ }
+
+ /// <summary>
+ /// Get the request method.
+ /// </summary>
+ public RtspMethod Method
+ {
+ get
+ {
+ return _method;
+ }
+ }
+
+ /// <summary>
+ /// Get the request URI.
+ /// </summary>
+ public string Uri
+ {
+ get
+ {
+ return _uri;
+ }
+ }
+
+ /// <summary>
+ /// Get the request major version number.
+ /// </summary>
+ public int MajorVersion
+ {
+ get
+ {
+ return _majorVersion;
+ }
+ }
+
+ /// <summary>
+ /// Get the request minor version number.
+ /// </summary>
+ public int MinorVersion
+ {
+ get
+ {
+ return _minorVersion;
+ }
+ }
+
+ /// <summary>
+ /// Get or set the request headers.
+ /// </summary>
+ public IDictionary<string, string> Headers
+ {
+ get
+ {
+ return _headers;
+ }
+ set
+ {
+ _headers = value;
+ }
+ }
+
+ /// <summary>
+ /// Get or set the request body.
+ /// </summary>
+ public string Body
+ {
+ get
+ {
+ return _body;
+ }
+ set
+ {
+ _body = value;
+ }
+ }
+
+ /// <summary>
+ /// Serialise this request.
+ /// </summary>
+ /// <returns>raw request bytes</returns>
+ public byte[] Serialise()
+ {
+ var request = new StringBuilder();
+ request.AppendFormat("{0} {1} RTSP/{2}.{3}\r\n", _method, _uri, _majorVersion, _minorVersion);
+ foreach (var header in _headers)
+ {
+ request.AppendFormat("{0}: {1}\r\n", header.Key, header.Value);
+ }
+ request.AppendFormat("\r\n{0}", _body);
+ return Encoding.UTF8.GetBytes(request.ToString());
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspResponse.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspResponse.cs
new file mode 100644
index 000000000..0bf80012d
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspResponse.cs
@@ -0,0 +1,150 @@
+/*
+ Copyright (C) <2007-2016> <Kay Diefenthal>
+
+ SatIp.RtspSample is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ SatIp.RtspSample is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with SatIp.RtspSample. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+
+
+namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.SatIp
+{
+ /// <summary>
+ /// A simple class that can be used to deserialise RTSP responses.
+ /// </summary>
+ public class RtspResponse
+ {
+ private static readonly Regex RegexStatusLine = new Regex(@"RTSP/(\d+)\.(\d+)\s+(\d+)\s+([^.]+?)\r\n(.*)", RegexOptions.Singleline);
+
+ private int _majorVersion = 1;
+ private int _minorVersion;
+ private RtspStatusCode _statusCode;
+ private string _reasonPhrase;
+ private IDictionary<string, string> _headers;
+ private string _body;
+
+ /// <summary>
+ /// Initialise a new instance of the <see cref="RtspResponse"/> class.
+ /// </summary>
+ private RtspResponse()
+ {
+ }
+
+ /// <summary>
+ /// Get the response major version number.
+ /// </summary>
+ public int MajorVersion
+ {
+ get
+ {
+ return _majorVersion;
+ }
+ }
+
+ /// <summary>
+ /// Get the response minor version number.
+ /// </summary>
+ public int MinorVersion
+ {
+ get
+ {
+ return _minorVersion;
+ }
+ }
+
+ /// <summary>
+ /// Get the response status code.
+ /// </summary>
+ public RtspStatusCode StatusCode
+ {
+ get
+ {
+ return _statusCode;
+ }
+ }
+
+ /// <summary>
+ /// Get the response reason phrase.
+ /// </summary>
+ public string ReasonPhrase
+ {
+ get
+ {
+ return _reasonPhrase;
+ }
+ }
+
+ /// <summary>
+ /// Get the response headers.
+ /// </summary>
+ public IDictionary<string, string> Headers
+ {
+ get
+ {
+ return _headers;
+ }
+ }
+
+ /// <summary>
+ /// Get the response body.
+ /// </summary>
+ public string Body
+ {
+ get
+ {
+ return _body;
+ }
+ set
+ {
+ _body = value;
+ }
+ }
+
+ /// <summary>
+ /// Deserialise/parse an RTSP response.
+ /// </summary>
+ /// <param name="responseBytes">The raw response bytes.</param>
+ /// <param name="responseByteCount">The number of valid bytes in the response.</param>
+ /// <returns>a response object</returns>
+ public static RtspResponse Deserialise(byte[] responseBytes, int responseByteCount)
+ {
+ var response = new RtspResponse();
+ var responseString = Encoding.UTF8.GetString(responseBytes, 0, responseByteCount);
+
+ var m = RegexStatusLine.Match(responseString);
+ if (m.Success)
+ {
+ response._majorVersion = int.Parse(m.Groups[1].Captures[0].Value);
+ response._minorVersion = int.Parse(m.Groups[2].Captures[0].Value);
+ response._statusCode = (RtspStatusCode)int.Parse(m.Groups[3].Captures[0].Value);
+ response._reasonPhrase = m.Groups[4].Captures[0].Value;
+ responseString = m.Groups[5].Captures[0].Value;
+ }
+
+ var sections = responseString.Split(new[] { "\r\n\r\n" }, StringSplitOptions.None);
+ response._body = sections[1];
+ var headers = sections[0].Split(new[] { "\r\n" }, StringSplitOptions.None);
+ response._headers = new Dictionary<string, string>();
+ foreach (var headerInfo in headers.Select(header => header.Split(':')))
+ {
+ response._headers.Add(headerInfo[0], headerInfo[1].Trim());
+ }
+ return response;
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspStatusCode.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspStatusCode.cs
new file mode 100644
index 000000000..8786314ed
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspStatusCode.cs
@@ -0,0 +1,251 @@
+/*
+ Copyright (C) <2007-2016> <Kay Diefenthal>
+
+ SatIp.RtspSample is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ SatIp.RtspSample is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with SatIp.RtspSample. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+using System.ComponentModel;
+
+namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.SatIp
+{
+ /// <summary>
+ /// Standard RTSP status codes.
+ /// </summary>
+ public enum RtspStatusCode
+ {
+ /// <summary>
+ /// 100 continue
+ /// </summary>
+ Continue = 100,
+
+ /// <summary>
+ /// 200 OK
+ /// </summary>
+ [Description("Okay")]
+ Ok = 200,
+ /// <summary>
+ /// 201 created
+ /// </summary>
+ Created = 201,
+
+ /// <summary>
+ /// 250 low on storage space
+ /// </summary>
+ [Description("Low On Storage Space")]
+ LowOnStorageSpace = 250,
+
+ /// <summary>
+ /// 300 multiple choices
+ /// </summary>
+ [Description("Multiple Choices")]
+ MultipleChoices = 300,
+ /// <summary>
+ /// 301 moved permanently
+ /// </summary>
+ [Description("Moved Permanently")]
+ MovedPermanently = 301,
+ /// <summary>
+ /// 302 moved temporarily
+ /// </summary>
+ [Description("Moved Temporarily")]
+ MovedTemporarily = 302,
+ /// <summary>
+ /// 303 see other
+ /// </summary>
+ [Description("See Other")]
+ SeeOther = 303,
+ /// <summary>
+ /// 304 not modified
+ /// </summary>
+ [Description("Not Modified")]
+ NotModified = 304,
+ /// <summary>
+ /// 305 use proxy
+ /// </summary>
+ [Description("Use Proxy")]
+ UseProxy = 305,
+
+ /// <summary>
+ /// 400 bad request
+ /// </summary>
+ [Description("Bad Request")]
+ BadRequest = 400,
+ /// <summary>
+ /// 401 unauthorised
+ /// </summary>
+ Unauthorised = 401,
+ /// <summary>
+ /// 402 payment required
+ /// </summary>
+ [Description("Payment Required")]
+ PaymentRequired = 402,
+ /// <summary>
+ /// 403 forbidden
+ /// </summary>
+ Forbidden = 403,
+ /// <summary>
+ /// 404 not found
+ /// </summary>
+ [Description("Not Found")]
+ NotFound = 404,
+ /// <summary>
+ /// 405 method not allowed
+ /// </summary>
+ [Description("Method Not Allowed")]
+ MethodNotAllowed = 405,
+ /// <summary>
+ /// 406 not acceptable
+ /// </summary>
+ [Description("Not Acceptable")]
+ NotAcceptable = 406,
+ /// <summary>
+ /// 407 proxy authentication required
+ /// </summary>
+ [Description("Proxy Authentication Required")]
+ ProxyAuthenticationRequred = 407,
+ /// <summary>
+ /// 408 request time-out
+ /// </summary>
+ [Description("Request Time-Out")]
+ RequestTimeOut = 408,
+
+ /// <summary>
+ /// 410 gone
+ /// </summary>
+ Gone = 410,
+ /// <summary>
+ /// 411 length required
+ /// </summary>
+ [Description("Length Required")]
+ LengthRequired = 411,
+ /// <summary>
+ /// 412 precondition failed
+ /// </summary>
+ [Description("Precondition Failed")]
+ PreconditionFailed = 412,
+ /// <summary>
+ /// 413 request entity too large
+ /// </summary>
+ [Description("Request Entity Too Large")]
+ RequestEntityTooLarge = 413,
+ /// <summary>
+ /// 414 request URI too large
+ /// </summary>
+ [Description("Request URI Too Large")]
+ RequestUriTooLarge = 414,
+ /// <summary>
+ /// 415 unsupported media type
+ /// </summary>
+ [Description("Unsupported Media Type")]
+ UnsupportedMediaType = 415,
+
+ /// <summary>
+ /// 451 parameter not understood
+ /// </summary>
+ [Description("Parameter Not Understood")]
+ ParameterNotUnderstood = 451,
+ /// <summary>
+ /// 452 conference not found
+ /// </summary>
+ [Description("Conference Not Found")]
+ ConferenceNotFound = 452,
+ /// <summary>
+ /// 453 not enough bandwidth
+ /// </summary>
+ [Description("Not Enough Bandwidth")]
+ NotEnoughBandwidth = 453,
+ /// <summary>
+ /// 454 session not found
+ /// </summary>
+ [Description("Session Not Found")]
+ SessionNotFound = 454,
+ /// <summary>
+ /// 455 method not valid in this state
+ /// </summary>
+ [Description("Method Not Valid In This State")]
+ MethodNotValidInThisState = 455,
+ /// <summary>
+ /// 456 header field not valid for this resource
+ /// </summary>
+ [Description("Header Field Not Valid For This Resource")]
+ HeaderFieldNotValidForThisResource = 456,
+ /// <summary>
+ /// 457 invalid range
+ /// </summary>
+ [Description("Invalid Range")]
+ InvalidRange = 457,
+ /// <summary>
+ /// 458 parameter is read-only
+ /// </summary>
+ [Description("Parameter Is Read-Only")]
+ ParameterIsReadOnly = 458,
+ /// <summary>
+ /// 459 aggregate operation not allowed
+ /// </summary>
+ [Description("Aggregate Operation Not Allowed")]
+ AggregateOperationNotAllowed = 459,
+ /// <summary>
+ /// 460 only aggregate operation allowed
+ /// </summary>
+ [Description("Only Aggregate Operation Allowed")]
+ OnlyAggregateOperationAllowed = 460,
+ /// <summary>
+ /// 461 unsupported transport
+ /// </summary>
+ [Description("Unsupported Transport")]
+ UnsupportedTransport = 461,
+ /// <summary>
+ /// 462 destination unreachable
+ /// </summary>
+ [Description("Destination Unreachable")]
+ DestinationUnreachable = 462,
+
+ /// <summary>
+ /// 500 internal server error
+ /// </summary>
+ [Description("Internal Server Error")]
+ InternalServerError = 500,
+ /// <summary>
+ /// 501 not implemented
+ /// </summary>
+ [Description("Not Implemented")]
+ NotImplemented = 501,
+ /// <summary>
+ /// 502 bad gateway
+ /// </summary>
+ [Description("Bad Gateway")]
+ BadGateway = 502,
+ /// <summary>
+ /// 503 service unavailable
+ /// </summary>
+ [Description("Service Unavailable")]
+ ServiceUnavailable = 503,
+ /// <summary>
+ /// 504 gateway time-out
+ /// </summary>
+ [Description("Gateway Time-Out")]
+ GatewayTimeOut = 504,
+ /// <summary>
+ /// 505 RTSP version not supported
+ /// </summary>
+ [Description("RTSP Version Not Supported")]
+ RtspVersionNotSupported = 505,
+
+ /// <summary>
+ /// 551 option not supported
+ /// </summary>
+ [Description("Option Not Supported")]
+ OptionNotSupported = 551
+ }
+}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs
index 413ce4549..d0a55966f 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs
@@ -235,7 +235,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
}
}
-
var result = new SatIpTunerHostInfo
{
Url = url,
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index b5ec4649e..02f7596e0 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -248,6 +248,10 @@
<Compile Include="LiveTv\RecordingImageProvider.cs" />
<Compile Include="LiveTv\RefreshChannelsScheduledTask.cs" />
<Compile Include="LiveTv\TunerHosts\SatIp\ChannelScan.cs" />
+ <Compile Include="LiveTv\TunerHosts\SatIp\Rtsp\RtspMethod.cs" />
+ <Compile Include="LiveTv\TunerHosts\SatIp\Rtsp\RtspRequest.cs" />
+ <Compile Include="LiveTv\TunerHosts\SatIp\Rtsp\RtspResponse.cs" />
+ <Compile Include="LiveTv\TunerHosts\SatIp\Rtsp\RtspStatusCode.cs" />
<Compile Include="LiveTv\TunerHosts\SatIp\SatIpHost.cs" />
<Compile Include="LiveTv\TunerHosts\SatIp\SatIpDiscovery.cs" />
<Compile Include="Localization\LocalizationManager.cs" />