-
Notifications
You must be signed in to change notification settings - Fork 17
/
TimeshiftChannel.cs
89 lines (77 loc) · 2.99 KB
/
TimeshiftChannel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
namespace TVServerXBMC.Commands
{
class TimeshiftChannel : CommandHandler
{
public TimeshiftChannel(ConnectionHandler connection)
: base(connection)
{
}
/*
* Expect arguments: ChannelID
*/
public override void handleCommand(string command, string[] arguments, ref TvControl.IUser me)
{
if (arguments == null || arguments.Length < 1)
{
getConnection().WriteLine("[ERROR]: Usage: " + getCommandToHandle() + ":ChannelId[|ResolveIPs=False][|StopTimeshift=True]");
return;
}
try {
int chanId = int.Parse(arguments[0]);
bool resolveToIP = true;
bool stoptimeshift = true;
string originalURL = "";
string result;
string timeShiftFileName = "";
Int64 timeShiftBufPos = 0;
long timeShiftBufNr = 0;
if (arguments.Length >= 2)
{
resolveToIP = Boolean.Parse(arguments[1]);
if (arguments.Length >= 3)
{
stoptimeshift = Boolean.Parse(arguments[2]);
}
if (stoptimeshift)
{
TVServerConnection.StopTimeshift(ref me);
}
result = TVServerConnection.playChannel(chanId, resolveToIP, ref originalURL, ref me, ref timeShiftFileName, ref timeShiftBufPos, ref timeShiftBufNr);
if ( !result.StartsWith("[ERROR]") )
{
if (resolveToIP == true)
{
result += "|" + originalURL;
}
else
{
result += "|";
}
result += "|" + timeShiftFileName +
"|" + me.CardId.ToString() +
"|" + timeShiftBufPos.ToString() +
"|" + timeShiftBufNr.ToString();
}
writer.write(result);
}
else
{ //backward compatibility
TVServerConnection.StopTimeshift(ref me);
result = TVServerConnection.playChannel(chanId, resolveToIP, ref originalURL, ref me, ref timeShiftFileName, ref timeShiftBufPos, ref timeShiftBufNr);
writer.write(result);
}
} catch {
getConnection().WriteLine("[ERROR]: Usage: " + getCommandToHandle() + ":ChannelId[|ResolveIPs][|StopTimeshift]");
}
}
public override string getCommandToHandle()
{
return "TimeshiftChannel";
}
}
}