Skip to content

Commit

Permalink
Return also the tsbuffer pos and file id after a channel switch
Browse files Browse the repository at this point in the history
  • Loading branch information
margro committed Feb 18, 2012
1 parent 15d4a6c commit c957294
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
4 changes: 4 additions & 0 deletions TVServerXBMC/Changelog.txt
@@ -1,3 +1,7 @@
1.2.2.110:
- Send timeshift buffer position to XBMC on a channel switch
- Update binaries for MediaPortal TVServer 1.2.2

1.2.1.109:
- Send TvResult as integer to XBMC to be able to show a localized error message when timeshifting fails

Expand Down
10 changes: 7 additions & 3 deletions TVServerXBMC/Commands/TimeshiftChannel.cs
Expand Up @@ -33,6 +33,8 @@ public override void handleCommand(string command, string[] arguments, ref TvCon
string originalURL = "";
string result;
string timeShiftFileName = "";
Int64 timeShiftBufPos = 0;
long timeShiftBufNr = 0;

if (arguments.Length >= 2)
{
Expand All @@ -47,7 +49,7 @@ public override void handleCommand(string command, string[] arguments, ref TvCon
TVServerConnection.StopTimeshift(ref me);
}

result = TVServerConnection.playChannel(chanId, resolveToIP, ref originalURL, ref me, ref timeShiftFileName);
result = TVServerConnection.playChannel(chanId, resolveToIP, ref originalURL, ref me, ref timeShiftFileName, ref timeShiftBufPos, ref timeShiftBufNr);
if ( !result.StartsWith("[ERROR]") )
{
if (resolveToIP == true)
Expand All @@ -59,15 +61,17 @@ public override void handleCommand(string command, string[] arguments, ref TvCon
result += "|";
}
result += "|" + timeShiftFileName +
"|" + me.CardId.ToString();
"|" + 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);
result = TVServerConnection.playChannel(chanId, resolveToIP, ref originalURL, ref me, ref timeShiftFileName, ref timeShiftBufPos, ref timeShiftBufNr);
writer.write(result);
}

Expand Down
4 changes: 2 additions & 2 deletions TVServerXBMC/Properties/AssemblyInfo.cs
Expand Up @@ -30,8 +30,8 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.2.2.109")]
[assembly: AssemblyFileVersion("1.2.2.109")]
[assembly: AssemblyVersion("1.2.2.110")]
[assembly: AssemblyFileVersion("1.2.2.110")]

// Set usage and compatibility information
[assembly: CompatibleVersion("1.1.7.0", "1.1.6.27644")]
Expand Down
17 changes: 8 additions & 9 deletions TVServerXBMC/TV/ServerInterface.cs
Expand Up @@ -120,13 +120,15 @@ public void ResetConnection()
#endregion

#region Control functions
public TvResult StartTimeShifting(int idChannel, ref string rtspURL, ref string remoteserver, ref IUser user, ref string timeshiftfilename)
public TvResult StartTimeShifting(int idChannel, ref string rtspURL, ref string remoteserver, ref IUser user, ref string timeshiftfilename, ref Int64 timeShiftBufPos, ref long timeShiftBufNr)
{
VirtualCard vcard;
//int cardId = -1;
TvResult result;
remoteserver = "";

timeShiftBufNr = -1;
timeShiftBufPos = -1;

System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();

//cardId = user.CardId;
Expand Down Expand Up @@ -176,19 +178,16 @@ public TvResult StartTimeShifting(int idChannel, ref string rtspURL, ref string
//Fetch video stream information (takes approx 2-5 ms):
TvLibrary.Interfaces.IVideoStream videostream = vcard.GetCurrentVideoStream(TVServerController.userlist[user.Name]);
TvLibrary.Interfaces.VideoStreamType vidtype = videostream.StreamType;
Console.WriteLine("Video stream type=" + vidtype.ToString() + " Pid=" + videostream.Pid + " PcrPid=" + videostream.PcrPid);
Console.WriteLine("Video stream type=" + vidtype.ToString() + " Pid=" + videostream.Pid.ToString("X") + " PcrPid=" + videostream.PcrPid.ToString("X"));

TvLibrary.Interfaces.IAudioStream audiostream = vcard.AudioStream;
TvLibrary.Interfaces.AudioStreamType audiotype = audiostream.StreamType;
Console.WriteLine("Audio stream type=" + audiotype.ToString() + " Pid=" + audiostream.Pid + " Language=" + audiostream.Language);
Console.WriteLine("Audio stream type=" + audiotype.ToString() + " Pid=" + audiostream.Pid.ToString("X") + " Language=" + audiostream.Language);
}
catch { }

//long pos = 0;
//long bufferId = 0;

//controller.TimeShiftGetCurrentFilePosition(ref user, ref pos, ref bufferId);
//Console.WriteLine("TimeShift file pos=" + pos.ToString() + " buffer id=" + bufferId.ToString());
controller.TimeShiftGetCurrentFilePosition(ref user, ref timeShiftBufPos, ref timeShiftBufNr);
Console.WriteLine("TimeShift file pos=" + timeShiftBufPos.ToString() + " buffer id=" + timeShiftBufNr.ToString());
}
else if ((result == TvResult.NoTuningDetails) || (result== TvResult.UnknownError))
{ //Hmmz, maybe a webstream?
Expand Down
4 changes: 2 additions & 2 deletions TVServerXBMC/TVServerConnection.cs
Expand Up @@ -179,15 +179,15 @@ public static bool DeleteSchedule(int schedId)
* \param OriginalURL is the URL given to us by the TVServer
* \return value is the URL with resolved hostnames,
*/
public static String playChannel(int chanId, bool resolveHostnames, ref string OriginalURL, ref TvControl.IUser me, ref string timeShiftFileName)
public static String playChannel(int chanId, bool resolveHostnames, ref string OriginalURL, ref TvControl.IUser me, ref string timeShiftFileName, ref Int64 timeShiftBufPos, ref long timeShiftBufNr)
{
string rtspURL = "";
string remoteserver = "";

//serverIntf.StopTimeShifting(ref me);
timeshiftChannel.Remove(me.Name);

TvResult result = serverIntf.StartTimeShifting(chanId, ref rtspURL, ref remoteserver, ref me, ref timeShiftFileName);
TvResult result = serverIntf.StartTimeShifting(chanId, ref rtspURL, ref remoteserver, ref me, ref timeShiftFileName, ref timeShiftBufPos, ref timeShiftBufNr);

if (result != TvResult.Succeeded)
{
Expand Down

0 comments on commit c957294

Please sign in to comment.