From c957294142c1967efe95d43f19d1ca696b238e02 Mon Sep 17 00:00:00 2001 From: Marcel Groothuis Date: Sat, 18 Feb 2012 19:08:03 +0100 Subject: [PATCH] Return also the tsbuffer pos and file id after a channel switch --- TVServerXBMC/Changelog.txt | 4 ++++ TVServerXBMC/Commands/TimeshiftChannel.cs | 10 +++++++--- TVServerXBMC/Properties/AssemblyInfo.cs | 4 ++-- TVServerXBMC/TV/ServerInterface.cs | 17 ++++++++--------- TVServerXBMC/TVServerConnection.cs | 4 ++-- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/TVServerXBMC/Changelog.txt b/TVServerXBMC/Changelog.txt index 2f508e7..d672bb7 100644 --- a/TVServerXBMC/Changelog.txt +++ b/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 diff --git a/TVServerXBMC/Commands/TimeshiftChannel.cs b/TVServerXBMC/Commands/TimeshiftChannel.cs index 7d49ed2..e2b2868 100644 --- a/TVServerXBMC/Commands/TimeshiftChannel.cs +++ b/TVServerXBMC/Commands/TimeshiftChannel.cs @@ -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) { @@ -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) @@ -59,7 +61,9 @@ 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); @@ -67,7 +71,7 @@ public override void handleCommand(string command, string[] arguments, ref TvCon 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); } diff --git a/TVServerXBMC/Properties/AssemblyInfo.cs b/TVServerXBMC/Properties/AssemblyInfo.cs index 38af058..1d7d102 100644 --- a/TVServerXBMC/Properties/AssemblyInfo.cs +++ b/TVServerXBMC/Properties/AssemblyInfo.cs @@ -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")] diff --git a/TVServerXBMC/TV/ServerInterface.cs b/TVServerXBMC/TV/ServerInterface.cs index 061d5af..b33a288 100644 --- a/TVServerXBMC/TV/ServerInterface.cs +++ b/TVServerXBMC/TV/ServerInterface.cs @@ -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; @@ -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? diff --git a/TVServerXBMC/TVServerConnection.cs b/TVServerXBMC/TVServerConnection.cs index 3ba2521..a7ae70d 100644 --- a/TVServerXBMC/TVServerConnection.cs +++ b/TVServerXBMC/TVServerConnection.cs @@ -179,7 +179,7 @@ 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 = ""; @@ -187,7 +187,7 @@ public static String playChannel(int chanId, bool resolveHostnames, ref string O //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) {