private static bool IsPluginEnabled(string name) { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { return xmlreader.GetValueAsBool("plugins", name, false); } }
public void Save() { SaveEncryptedPassword(); using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.MPSettings()) { xmlwriter.SetValueAsBool("radiotime", "mp3", Mp3); xmlwriter.SetValueAsBool("radiotime", "wma", Wma); xmlwriter.SetValueAsBool("radiotime", "real", Real); xmlwriter.SetValueAsBool("radiotime", "UseVideo", UseVideo); xmlwriter.SetValueAsBool("radiotime", "JumpNowPlaying", JumpNowPlaying); xmlwriter.SetValue("radiotime", "user", User); xmlwriter.SetValueAsBool("radiotime", "showpresets", ShowPresets); xmlwriter.SetValue("radiotime", "pluginname", PluginName); xmlwriter.SetValue("radiotime", "FolderId", FolderId); xmlwriter.SetValueAsBool("radiotime", "StartWithFastPreset", StartWithFastPreset); var s = ""; foreach (var history in SearchHistory) { s += history + "|"; } xmlwriter.SetValue("radiotime", "searchHistory", s); s = ""; foreach (var history in ArtistSearchHistory) { s += history + "|"; } xmlwriter.SetValue("radiotime", "artistSearchHistory", s); } }
static DaemonTools() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { _Enabled = xmlreader.GetValueAsBool("daemon", "enabled", false); _Path = xmlreader.GetValueAsString("daemon", "path", ""); _Drive = xmlreader.GetValueAsString("daemon", "drive", "E:"); _DriveNo = xmlreader.GetValueAsInt("daemon", "driveNo", 0); _DriveType = xmlreader.GetValueAsString("daemon", "driveType", ""); /* * DAEMON Tools supports the following image files: * cue/bin * iso * ccd (CloneCD) * bwt (Blindwrite) * mds (Media Descriptor File) * cdi (Discjuggler) * nrg (Nero) * pdi (Instant CD/DVD) * b5t (BlindWrite 5) */ string[] extensions = xmlreader.GetValueAsString("daemon", "extensions", Utils.ImageExtensionsDefault).Split(','); _supportedExtensions = new HashSet<string>(); // Can't use an AddRange, as we need to trim the blanks foreach (string ext in extensions) _supportedExtensions.Add(ext.Trim()); } }
public void PageLoad() { AllocResources(); //_keyboard.InitializeInstance(); _previousOverlayVisible = GUIGraphicsContext.Overlay; _keyboard.PressedEnter = false; GUIGraphicsContext.Overlay = false; GUIPropertyManager.SetProperty("#currentmodule", GUILocalizeStrings.Get(100000 + GetID)); InitializeBackground(); _keyboard.ResetLabelAsInitialText(); if (!_keyboard._useSearchLayout && !_keyboard._password) { using (MediaPortal.Profile.MPSettings xmlreader = new MediaPortal.Profile.MPSettings()) { _keyboard.SmsStyleText = xmlreader.GetValueAsBool("general", "smsstyleinput", true); } } GUIPropertyManager.SetProperty("#VirtualKeyboard.SMSStyleInput", _keyboard.SmsStyleText.ToString().ToLowerInvariant()); base.OnPageLoad(); Log.Debug("Window: {0} init", ToString()); }
static DaemonTools() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { _Enabled = xmlreader.GetValueAsBool("daemon", "enabled", false); _Path = xmlreader.GetValueAsString("daemon", "path", ""); _Drive = xmlreader.GetValueAsString("daemon", "drive", "E:"); _DriveNo = xmlreader.GetValueAsInt("daemon", "driveNo", 0); _DriveType = xmlreader.GetValueAsString("daemon", "driveType", ""); /* * DAEMON Tools supports the following image files: * cue/bin * iso * ccd (CloneCD) * bwt (Blindwrite) * mds (Media Descriptor File) * cdi (Discjuggler) * nrg (Nero) * pdi (Instant CD/DVD) * b5t (BlindWrite 5) */ string[] extensions = xmlreader.GetValueAsString("daemon", "extensions", Utils.ImageExtensionsDefault).Split(','); _supportedExtensions = new HashSet <string>(); // Can't use an AddRange, as we need to trim the blanks foreach (string ext in extensions) { _supportedExtensions.Add(ext.Trim()); } } }
protected override void LoadSettings() { base.LoadSettings(); using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { currentLayout = (Layout)xmlreader.GetValueAsInt(SerializeName, "layout", (int)Layout.List); m_bSortAscending = xmlreader.GetValueAsBool(SerializeName, "sortasc", true); } }
protected override void LoadSettings() { base.LoadSettings(); using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { currentLayout = (Layout)xmlreader.GetValueAsInt(SerializeName, "layout", (int)Layout.List); m_bSortAscending = xmlreader.GetValueAsBool(SerializeName, "sortasc", true); } }
protected override void SaveSettings() { base.SaveSettings(); using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.MPSettings()) { xmlwriter.SetValue(SerializeName, "layout", (int)currentLayout); xmlwriter.SetValueAsBool(SerializeName, "sortasc", m_bSortAscending); } }
public static void CheckInstalledVersions() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { fUseDvbSubtitles = xmlreader.GetValueAsBool("tvservice", "dvbbitmapsubtitles", false); } startFilterCheckThread(); }
public static void CheckInstalledVersions() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { fUseDvbSubtitles = xmlreader.GetValueAsBool("tvservice", "dvbbitmapsubtitles", false); } startFilterCheckThread(); }
private void SaveEncryptedPassword() { if (!string.IsNullOrEmpty(Password)) { using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.MPSettings()) { xmlwriter.SetValue("radiotime", "encryptedPassword", PasswordUtility.EncryptData(Password, DataProtectionScope.LocalMachine)); xmlwriter.RemoveEntry("radiotime", "password"); } } }
/// <summary> /// Constructor which initializes the osd controller /// </summary> private OSDController() { _fullscreenWindow = new FullscreenWindow(); _videoOSDWindow = new VideoOSDWindow(); _dialogWindow = new DialogWindow(); _osdForm = new OSDForm(); GUIGraphicsContext.form.SizeChanged += parent_SizeChanged; using (MediaPortal.Profile.Settings settings = new MediaPortal.Profile.MPSettings()) { _blankScreen = settings.GetValueAsBool("externalOSDLibrary", "blankScreen", false); } }
public static string SkinName() { try { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { return xmlreader.GetValueAsString("skin", "name", ""); } } catch (Exception) { return string.Empty; } }
public static void InitLogLevel() { using (var xmlreader = new MediaPortal.Profile.MPSettings()) { int logLevel = xmlreader.GetValueAsInt("general", "loglevel", 2); if (DBOption.GetOptions(DBOption.cSQLLoggingEnabled)) { selectedLogLevel = MPTVSeriesLog.LogLevel.DebugSQL; } else if (logLevel == 3) { selectedLogLevel = MPTVSeriesLog.LogLevel.Debug; } else { selectedLogLevel = MPTVSeriesLog.LogLevel.Normal; } } }
public MyVideos(int priority) { // check that we are running MediaPortal 1.3 or greater string libFilename = Path.Combine(Config.GetSubFolder(Config.Dir.Plugins, "Windows"), "WindowPlugins.dll"); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(libFilename); string version = fvi.ProductVersion; if (new Version(version) < new Version(1, 3, 0, 0)) { throw new FileLoadException("MediaPortal does not meet minimum requirements!"); } // get video watched percentage to count as scrobble using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { WatchedPercent = xmlreader.GetValueAsInt("movies", "playedpercentagewatched", 95); } Priority = priority; }
private Logger() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { var MPminLevel = (MediaPortal.Services.Level)Enum.Parse(typeof(MediaPortal.Services.Level), xmlreader.GetValueAsString("general", "loglevel", "2")); switch (MPminLevel) { case MediaPortal.Services.Level.Information: minLevel = log4net.Core.Level.Info; break; case MediaPortal.Services.Level.Warning: minLevel = log4net.Core.Level.Warn; break; case MediaPortal.Services.Level.Error: minLevel = log4net.Core.Level.Error; break; } } Hierarchy hierarchy = (Hierarchy)LogManager.CreateRepository("AirPlay"); PatternLayout patternLayout = new PatternLayout(); patternLayout.ConversionPattern = "[%date{MM-dd HH:mm:ss,fff}] [%-12thread] [%-5level] %message%newline"; patternLayout.ActivateOptions(); RollingFileAppender roller = new RollingFileAppender(); roller.Encoding = System.Text.UTF8Encoding.UTF8; roller.Layout = patternLayout; roller.LockingModel = new FileAppender.MinimalLock(); roller.AppendToFile = true; roller.RollingStyle = RollingFileAppender.RollingMode.Once; roller.PreserveLogFileNameExtension = true; roller.MaxSizeRollBackups = 1; roller.MaximumFileSize = "10MB"; roller.StaticLogFileName = true; roller.File = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, "AirPlay.log"); roller.ActivateOptions(); hierarchy.Root.AddAppender(roller); hierarchy.Root.Level = minLevel; hierarchy.Configured = true; logger = log4net.LogManager.GetLogger("AirPlay", "AirPlay"); }
public MyVideos(int priority) { // check that we are running MediaPortal 1.7 Pre-Release or greater string libFilename = Path.Combine(Config.GetSubFolder(Config.Dir.Plugins, "Windows"), "GUIVideos.dll"); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(libFilename); string version = fvi.ProductVersion; if (new Version(version) < new Version(1, 6, 100, 0)) { throw new FileLoadException("MediaPortal does not meet minimum requirements!"); } // get video watched percentage to count as scrobble using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { WatchedPercent = xmlreader.GetValueAsInt("movies", "playedpercentagewatched", 95); } Priority = priority; }
private Log() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { var MPminLevel = (MediaPortal.Services.Level)Enum.Parse(typeof(MediaPortal.Services.Level), xmlreader.GetValueAsString("general", "loglevel", "2")); switch(MPminLevel) { case MediaPortal.Services.Level.Information: minLevel = log4net.Core.Level.Info; break; case MediaPortal.Services.Level.Warning: minLevel = log4net.Core.Level.Warn; break; case MediaPortal.Services.Level.Error: minLevel = log4net.Core.Level.Error; break; } } Hierarchy hierarchy = (Hierarchy)LogManager.CreateRepository("OnlineVideos"); PatternLayout patternLayout = new PatternLayout(); patternLayout.ConversionPattern = "[%date{MM-dd HH:mm:ss,fff}] [%-12thread] [%-5level] %message%newline"; patternLayout.ActivateOptions(); RollingFileAppender roller = new RollingFileAppender(); roller.Encoding = System.Text.UTF8Encoding.UTF8; roller.Layout = patternLayout; roller.LockingModel = new FileAppender.MinimalLock(); roller.AppendToFile = true; roller.RollingStyle = RollingFileAppender.RollingMode.Once; roller.PreserveLogFileNameExtension = true; roller.MaxSizeRollBackups = 1; roller.MaximumFileSize = "10MB"; roller.StaticLogFileName = true; roller.File = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, "OnlineVideos.log"); roller.ActivateOptions(); hierarchy.Root.AddAppender(roller); hierarchy.Root.Level = minLevel; hierarchy.Configured = true; logger = log4net.LogManager.GetLogger("OnlineVideos", "OnlineVideos"); }
/// <summary> /// Save the current playlist /// </summary> private void saveSmartDJPlaylist() { string playlistFileName = string.Empty; if (GetKeyboard(ref playlistFileName)) { string playListPath = string.Empty; // Have we out own playlist folder configured if (!string.IsNullOrEmpty(mvCentralCore.Settings.PlayListFolder.Trim())) playListPath = mvCentralCore.Settings.PlayListFolder; else { // No, so use my videos location using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { playListPath = xmlreader.GetValueAsString("movies", "playlists", string.Empty); playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath); } playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath); } // check if Playlist folder exists, create it if not if (!Directory.Exists(playListPath)) { try { Directory.CreateDirectory(playListPath); } catch (Exception e) { logger.Info("Error: Unable to create Playlist path: " + e.Message); return; } } string fullPlayListPath = Path.GetFileNameWithoutExtension(playlistFileName); fullPlayListPath += ".mvplaylist"; if (playListPath.Length != 0) { fullPlayListPath = playListPath + @"\" + fullPlayListPath; } PlayList playlist = new PlayList(); for (int i = 0; i < facadeLayout.Count; ++i) { GUIListItem listItem = facadeLayout[i]; PlayListItem playListItem = new PlayListItem(); DBTrackInfo mv = (DBTrackInfo)listItem.MusicTag; playListItem.Track = mv; playlist.Add(playListItem); } PlayListIO saver = new PlayListIO(); saver.Save(playlist, fullPlayListPath); } }
public override bool Init() { bool bResult = Load(GUIGraphicsContext.GetThemedSkinFile(@"\videoFullScreen.xml")); GetID = (int)Window.WINDOW_FULLSCREEN_VIDEO; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { _immediateSeekIsRelative = xmlreader.GetValueAsBool("movieplayer", "immediateskipstepsisrelative", true); _immediateSeekValue = xmlreader.GetValueAsInt("movieplayer", "immediateskipstepsize", 10); } SettingsLoaded = false; g_Player.PlayBackEnded += new g_Player.EndedHandler(g_Player_PlayBackEnded); g_Player.PlayBackStopped += new g_Player.StoppedHandler(g_Player_PlayBackStopped); g_Player.PlayBackChanged += new g_Player.ChangedHandler(g_Player_PlayBackChanged); return bResult; }
public bool pluginEnabled(Plugins plugin) { PluginDetails pd = new PluginDetails(plugin); // check if plugin is enabled/disabled // if we dont find they entry then we assume enabled as we know it // is installed so most likley configuration has not yet been run // to write the entry to MediaPortal.xml string returnValue = null; try { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { returnValue = xmlreader.GetValueAsString("plugins", pd.name, ""); } } catch (Exception e) { //showError("Error reading MediaPortal.xml : " + e.Message, formStreamedMpEditor.errorCode.readError); } if (string.IsNullOrEmpty(returnValue)) { // error looking up in mediaportal.xml, check if file exists if (string.IsNullOrEmpty(pd.filename)) return false; else return File.Exists(pd.filename); } if (returnValue.ToLower() == "no") return false; else return true; }
public bool Transcode(TranscodeInfo info, VideoFormat format, Quality quality, Standard standard) { try { if (!Supports(format)) return false; string ext = System.IO.Path.GetExtension(info.file); if (ext.ToLower() != ".ts" && ext.ToLower() != ".mpg") { Log.Info("TSReader2WMV: wrong file format"); return false; } Log.Info("TSReader2WMV: create graph"); graphBuilder = (IGraphBuilder)new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); Log.Info("TSReader2WMV: add filesource"); TsReader reader = new TsReader(); tsreaderSource = (IBaseFilter)reader; //ITSReader ireader = (ITSReader)reader; //ireader.SetTsReaderCallback(this); //ireader.SetRequestAudioChangeCallback(this); IBaseFilter filter = (IBaseFilter)tsreaderSource; graphBuilder.AddFilter(filter, "TSReader Source"); IFileSourceFilter fileSource = (IFileSourceFilter)tsreaderSource; Log.Info("TSReader2WMV: load file:{0}", info.file); int hr = fileSource.Load(info.file, null); //add audio/video codecs string strVideoCodec = ""; string strH264VideoCodec = ""; string strAudioCodec = ""; string strAACAudioCodec = ""; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { strVideoCodec = xmlreader.GetValueAsString("mytv", "videocodec", ""); strAudioCodec = xmlreader.GetValueAsString("mytv", "audiocodec", ""); strAACAudioCodec = xmlreader.GetValueAsString("mytv", "aacaudiocodec", ""); strH264VideoCodec = xmlreader.GetValueAsString("mytv", "h264videocodec", ""); } //Find the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2WMV: find tsreader compatible audio/video decoders"); IPin pinOut0, pinOut1; IPin pinIn0, pinIn1; pinOut0 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 0); //audio pinOut1 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 1); //video if (pinOut0 == null || pinOut1 == null) { Log.Error("TSReader2WMV: FAILED: unable to get output pins of tsreader"); Cleanup(); return false; } bool usingAAC = false; IEnumMediaTypes enumMediaTypes; hr = pinOut0.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) break; if (mediaTypes[0].majorType == MediaType.Audio && mediaTypes[0].subType == MediaSubType.LATMAAC) { Log.Info("TSReader2WMV: found LATM AAC audio out pin on tsreader"); usingAAC = true; } } bool usingH264 = false; hr = pinOut1.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) break; if (mediaTypes[0].majorType == MediaType.Video && mediaTypes[0].subType == AVC1) { Log.Info("TSReader2WMV: found H.264 video out pin on tsreader"); usingH264 = true; } } //Add the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2WMV: add audio/video decoders to graph"); if (usingH264 == false) { Log.Info("TSReader2WMV: add mpeg2 video decoder:{0}", strVideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strVideoCodec); if (VideoCodec == null) { Log.Error("TSReader2WMV: unable to add mpeg2 video decoder"); Cleanup(); return false; } } else { Log.Info("TSReader2WMV: add h264 video codec:{0}", strH264VideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strH264VideoCodec); if (VideoCodec == null) { Log.Error("TSReader2WMV: FAILED:unable to add h264 video codec"); Cleanup(); return false; } } if (usingAAC == false) { Log.Info("TSReader2WMV: add mpeg2 audio codec:{0}", strAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2WMV: FAILED:unable to add mpeg2 audio codec"); Cleanup(); return false; } } else { Log.Info("TSReader2WMV: add aac audio codec:{0}", strAACAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAACAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2WMV: FAILED:unable to add aac audio codec"); Cleanup(); return false; } } Log.Info("TSReader2WMV: connect tsreader->audio/video decoders"); //connect output #0 (audio) of tsreader->audio decoder input pin 0 //connect output #1 (video) of tsreader->video decoder input pin 0 pinIn0 = DsFindPin.ByDirection(AudioCodec, PinDirection.Input, 0); //audio pinIn1 = DsFindPin.ByDirection(VideoCodec, PinDirection.Input, 0); //video if (pinIn0 == null || pinIn1 == null) { Log.Error("TSReader2WMV: FAILED: unable to get pins of video/audio codecs"); Cleanup(); return false; } hr = graphBuilder.Connect(pinOut0, pinIn0); if (hr != 0) { Log.Error("TSReader2WMV: FAILED: unable to connect audio pins :0x{0:X}", hr); Cleanup(); return false; } hr = graphBuilder.Connect(pinOut1, pinIn1); if (hr != 0) { Log.Error("TSReader2WMV: FAILED: unable to connect video pins :0x{0:X}", hr); Cleanup(); return false; } string outputFilename = System.IO.Path.ChangeExtension(info.file, ".wmv"); if (!AddWmAsfWriter(outputFilename, quality, standard)) return false; Log.Info("TSReader2WMV: start pre-run"); mediaControl = graphBuilder as IMediaControl; mediaSeeking = tsreaderSource as IMediaSeeking; mediaEvt = graphBuilder as IMediaEventEx; mediaPos = graphBuilder as IMediaPosition; //get file duration long lTime = 5 * 60 * 60; lTime *= 10000000; long pStop = 0; hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); if (hr == 0) { long lStreamPos; mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position m_dDuration = lStreamPos; lTime = 0; mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); } double duration = m_dDuration / 10000000d; Log.Info("TSReader2WMV: movie duration:{0}", Util.Utils.SecondsToHMSString((int)duration)); hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2WMV: FAILED: unable to start graph :0x{0:X}", hr); Cleanup(); return false; } int maxCount = 20; while (true) { long lCurrent; mediaSeeking.GetCurrentPosition(out lCurrent); double dpos = (double)lCurrent; dpos /= 10000000d; System.Threading.Thread.Sleep(100); if (dpos >= 2.0d) break; maxCount--; if (maxCount <= 0) break; } Log.Info("TSReader2WMV: pre-run done"); Log.Info("TSReader2WMV: Get duration of movie"); mediaControl.Stop(); FilterState state; mediaControl.GetState(500, out state); GC.Collect(); GC.Collect(); GC.Collect(); GC.WaitForPendingFinalizers(); Log.Info("TSReader2WMV: reconnect mpeg2 video codec->ASF WM Writer"); graphBuilder.RemoveFilter(fileWriterbase); if (!AddWmAsfWriter(outputFilename, quality, standard)) return false; Log.Info("TSReader2WMV: Start transcoding"); hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2WMV:FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return false; } } catch (Exception e) { // TODO: Handle exceptions. Log.Error("unable to transcode file:{0} message:{1}", info.file, e.Message); return false; } return true; }
/// <summary> /// Show saved playlists /// </summary> /// <param name="_directory"></param> protected void OnShowSavedPlaylists(string _directory) { VirtualDirectory _virtualDirectory = new VirtualDirectory(); _virtualDirectory.AddExtension(".mvplaylist"); List<GUIListItem> itemlist = _virtualDirectory.GetDirectoryExt(_directory); string playListPath = string.Empty; if (!string.IsNullOrEmpty(mvCentralCore.Settings.PlayListFolder.Trim())) playListPath = mvCentralCore.Settings.PlayListFolder; else { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { playListPath = xmlreader.GetValueAsString("movies", "playlists", string.Empty); playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath); } } if (_directory == playListPath) itemlist.RemoveAt(0); // If no playlists found, show a Message to user and then exit if (itemlist.Count == 0) { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOK.SetHeading(983); dlgOK.SetLine(1, Localization.NoPlaylistsFound); dlgOK.SetLine(2, _directory); dlgOK.DoModal(GUIWindowManager.ActiveWindow); return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) return; dlg.Reset(); dlg.SetHeading(983); // Saved Playlists foreach (GUIListItem item in itemlist) { MediaPortal.Util.Utils.SetDefaultIcons(item); dlg.Add(item); } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) return; GUIListItem selectItem = itemlist[dlg.SelectedLabel]; if (selectItem.IsFolder) { OnShowSavedPlaylists(selectItem.Path); return; } GUIWaitCursor.Show(); LoadPlayList(selectItem.Path); GUIWaitCursor.Hide(); }
public void PageLoad() { AllocResources(); //_keyboard.InitializeInstance(); _previousOverlayVisible = GUIGraphicsContext.Overlay; _keyboard.PressedEnter = false; GUIGraphicsContext.Overlay = false; GUIPropertyManager.SetProperty("#currentmodule", GUILocalizeStrings.Get(100000 + GetID)); InitializeBackground(); _keyboard.ResetLabelAsInitialText(); if (!_keyboard._useSearchLayout && !_keyboard._password) { using (MediaPortal.Profile.MPSettings xmlreader = new MediaPortal.Profile.MPSettings()) { _keyboard.SmsStyleText = xmlreader.GetValueAsBool("general", "smsstyleinput", true); } } GUIPropertyManager.SetProperty("#VirtualKeyboard.SMSStyleInput", _keyboard.SmsStyleText.ToString().ToLowerInvariant()); base.OnPageLoad(); Log.Debug("Window: {0} init", ToString()); }
public bool Transcode(TranscodeInfo info, VideoFormat format, Quality quality, Standard standard) { try { if (!Supports(format)) { return(false); } string ext = System.IO.Path.GetExtension(info.file); if (ext.ToLowerInvariant() != ".ts" && ext.ToLowerInvariant() != ".mpg") { Log.Info("TSReader2WMV: wrong file format"); return(false); } Log.Info("TSReader2WMV: create graph"); graphBuilder = (IGraphBuilder) new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); Log.Info("TSReader2WMV: add filesource"); TsReader reader = new TsReader(); tsreaderSource = (IBaseFilter)reader; //ITSReader ireader = (ITSReader)reader; //ireader.SetTsReaderCallback(this); //ireader.SetRequestAudioChangeCallback(this); IBaseFilter filter = (IBaseFilter)tsreaderSource; graphBuilder.AddFilter(filter, "TSReader Source"); IFileSourceFilter fileSource = (IFileSourceFilter)tsreaderSource; Log.Info("TSReader2WMV: load file:{0}", info.file); int hr = fileSource.Load(info.file, null); //add audio/video codecs string strVideoCodec = ""; string strH264VideoCodec = ""; string strAudioCodec = ""; string strAACAudioCodec = ""; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { strVideoCodec = xmlreader.GetValueAsString("mytv", "videocodec", ""); strAudioCodec = xmlreader.GetValueAsString("mytv", "audiocodec", ""); strAACAudioCodec = xmlreader.GetValueAsString("mytv", "aacaudiocodec", ""); strH264VideoCodec = xmlreader.GetValueAsString("mytv", "h264videocodec", ""); } //Find the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2WMV: find tsreader compatible audio/video decoders"); IPin pinOut0, pinOut1; IPin pinIn0, pinIn1; pinOut0 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 0); //audio pinOut1 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 1); //video if (pinOut0 == null || pinOut1 == null) { Log.Error("TSReader2WMV: FAILED: unable to get output pins of tsreader"); Cleanup(); return(false); } bool usingAAC = false; IEnumMediaTypes enumMediaTypes; hr = pinOut0.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) { break; } if (mediaTypes[0].majorType == MediaType.Audio && mediaTypes[0].subType == MediaSubType.LATMAAC) { Log.Info("TSReader2WMV: found LATM AAC audio out pin on tsreader"); usingAAC = true; } } bool usingH264 = false; hr = pinOut1.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) { break; } if (mediaTypes[0].majorType == MediaType.Video && mediaTypes[0].subType == AVC1) { Log.Info("TSReader2WMV: found H.264 video out pin on tsreader"); usingH264 = true; } } //Add the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2WMV: add audio/video decoders to graph"); if (usingH264 == false) { Log.Info("TSReader2WMV: add mpeg2 video decoder:{0}", strVideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strVideoCodec); if (VideoCodec == null) { Log.Error("TSReader2WMV: unable to add mpeg2 video decoder"); Cleanup(); return(false); } } else { Log.Info("TSReader2WMV: add h264 video codec:{0}", strH264VideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strH264VideoCodec); if (VideoCodec == null) { Log.Error("TSReader2WMV: FAILED:unable to add h264 video codec"); Cleanup(); return(false); } } if (usingAAC == false) { Log.Info("TSReader2WMV: add mpeg2 audio codec:{0}", strAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2WMV: FAILED:unable to add mpeg2 audio codec"); Cleanup(); return(false); } } else { Log.Info("TSReader2WMV: add aac audio codec:{0}", strAACAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAACAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2WMV: FAILED:unable to add aac audio codec"); Cleanup(); return(false); } } Log.Info("TSReader2WMV: connect tsreader->audio/video decoders"); //connect output #0 (audio) of tsreader->audio decoder input pin 0 //connect output #1 (video) of tsreader->video decoder input pin 0 pinIn0 = DsFindPin.ByDirection(AudioCodec, PinDirection.Input, 0); //audio pinIn1 = DsFindPin.ByDirection(VideoCodec, PinDirection.Input, 0); //video if (pinIn0 == null || pinIn1 == null) { Log.Error("TSReader2WMV: FAILED: unable to get pins of video/audio codecs"); Cleanup(); return(false); } hr = graphBuilder.Connect(pinOut0, pinIn0); if (hr != 0) { Log.Error("TSReader2WMV: FAILED: unable to connect audio pins :0x{0:X}", hr); Cleanup(); return(false); } hr = graphBuilder.Connect(pinOut1, pinIn1); if (hr != 0) { Log.Error("TSReader2WMV: FAILED: unable to connect video pins :0x{0:X}", hr); Cleanup(); return(false); } string outputFilename = System.IO.Path.ChangeExtension(info.file, ".wmv"); if (!AddWmAsfWriter(outputFilename, quality, standard)) { return(false); } Log.Info("TSReader2WMV: start pre-run"); mediaControl = graphBuilder as IMediaControl; mediaSeeking = tsreaderSource as IMediaSeeking; mediaEvt = graphBuilder as IMediaEventEx; mediaPos = graphBuilder as IMediaPosition; //get file duration long lTime = 5 * 60 * 60; lTime *= 10000000; long pStop = 0; hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); if (hr == 0) { long lStreamPos; mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position m_dDuration = lStreamPos; lTime = 0; mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); } double duration = m_dDuration / 10000000d; Log.Info("TSReader2WMV: movie duration:{0}", Util.Utils.SecondsToHMSString((int)duration)); hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2WMV: FAILED: unable to start graph :0x{0:X}", hr); Cleanup(); return(false); } int maxCount = 20; while (true) { long lCurrent; mediaSeeking.GetCurrentPosition(out lCurrent); double dpos = (double)lCurrent; dpos /= 10000000d; System.Threading.Thread.Sleep(100); if (dpos >= 2.0d) { break; } maxCount--; if (maxCount <= 0) { break; } } Log.Info("TSReader2WMV: pre-run done"); Log.Info("TSReader2WMV: Get duration of movie"); mediaControl.Stop(); FilterState state; mediaControl.GetState(500, out state); GC.Collect(); GC.Collect(); GC.Collect(); GC.WaitForPendingFinalizers(); Log.Info("TSReader2WMV: reconnect mpeg2 video codec->ASF WM Writer"); graphBuilder.RemoveFilter(fileWriterbase); if (!AddWmAsfWriter(outputFilename, quality, standard)) { return(false); } Log.Info("TSReader2WMV: Start transcoding"); hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2WMV:FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return(false); } } catch (Exception e) { // TODO: Handle exceptions. Log.Error("unable to transcode file:{0} message:{1}", info.file, e.Message); return(false); } return(true); }
public static void InitLogLevel() { using (var xmlreader = new MediaPortal.Profile.MPSettings()) { int logLevel = xmlreader.GetValueAsInt("general", "loglevel", 2); if (DBOption.GetOptions(DBOption.cSQLLoggingEnabled)) selectedLogLevel = MPTVSeriesLog.LogLevel.DebugSQL; else if (logLevel == 3) selectedLogLevel = MPTVSeriesLog.LogLevel.Debug; else selectedLogLevel = MPTVSeriesLog.LogLevel.Normal; } }
/// <summary> /// Handle control clicked event /// </summary> /// <param name="controlId"></param> /// <param name="control"></param> /// <param name="actionType"></param> protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == btnLayouts) { mvCentralCore.Settings.DefaultPlaylistView = ((int)CurrentLayout).ToString(); } else if (control == btnShuffle) { OnShufflePlayList(); } else if (control == btnSave) { OnSavePlayList(); } else if (control == btnClear) { OnClearPlayList(); } else if (control == btnPlay || control == this.facadeLayout) { if ((control == this.facadeLayout && actionType != Action.ActionType.ACTION_SELECT_ITEM) || (facadeLayout.SelectedListItemIndex == -1)) return; // some other events raised onClicked too for some reason? playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; playlistPlayer.Reset(); playlistPlayer.Play(facadeLayout.SelectedListItemIndex); UpdateButtonStates(); } else if (control == btnNext) { playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; playlistPlayer.PlayNext(); } else if (control == btnPrevious) { playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; playlistPlayer.PlayPrevious(); } else if ((btnRepeat != null) && (control == btnRepeat)) { playlistPlayer.RepeatPlaylist = btnRepeat.Selected; } else if (control == btnLoad) { string playListPath; if (!string.IsNullOrEmpty(mvCentralCore.Settings.PlayListFolder.Trim())) playListPath = mvCentralCore.Settings.PlayListFolder; else { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { playListPath = xmlreader.GetValueAsString("movies", "playlists", string.Empty); playListPath = MediaPortal.Util.Utils.RemoveTrailingSlash(playListPath); } } OnShowSavedPlaylists(playListPath); } else if (control == btnAutoPlay) { playlistPlayer.PlaylistAutoPlay = btnAutoPlay.Selected; } }
public bool Transcode(TranscodeInfo info, MediaPortal.Core.Transcoding.VideoFormat format, MediaPortal.Core.Transcoding.Quality quality, Standard standard) { if (!Supports(format)) { return(false); } string ext = System.IO.Path.GetExtension(info.file); if (ext.ToLower() != ".ts" && ext.ToLower() != ".mpg") { Log.Info("TSReader2MP4: wrong file format"); return(false); } try { graphBuilder = (IGraphBuilder) new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); Log.Info("TSReader2MP4: add filesource"); TsReader reader = new TsReader(); tsreaderSource = (IBaseFilter)reader; IBaseFilter filter = (IBaseFilter)tsreaderSource; graphBuilder.AddFilter(filter, "TSReader Source"); IFileSourceFilter fileSource = (IFileSourceFilter)tsreaderSource; Log.Info("TSReader2MP4: load file:{0}", info.file); int hr = fileSource.Load(info.file, null); //add audio/video codecs string strVideoCodec = ""; string strH264VideoCodec = ""; string strAudioCodec = ""; string strAACAudioCodec = ""; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { strVideoCodec = xmlreader.GetValueAsString("mytv", "videocodec", ""); strAudioCodec = xmlreader.GetValueAsString("mytv", "audiocodec", ""); strAACAudioCodec = xmlreader.GetValueAsString("mytv", "aacaudiocodec", ""); strH264VideoCodec = xmlreader.GetValueAsString("mytv", "h264videocodec", ""); } //Find the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2MP4: find tsreader compatible audio/video decoders"); IPin pinOut0, pinOut1; IPin pinIn0, pinIn1; pinOut0 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 0); //audio pinOut1 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 1); //video if (pinOut0 == null || pinOut1 == null) { Log.Error("TSReader2MP4: FAILED: unable to get output pins of tsreader"); Cleanup(); return(false); } bool usingAAC = false; IEnumMediaTypes enumMediaTypes; hr = pinOut0.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) { break; } if (mediaTypes[0].majorType == MediaType.Audio && mediaTypes[0].subType == MediaSubType.LATMAAC) { Log.Info("TSReader2MP4: found LATM AAC audio out pin on tsreader"); usingAAC = true; } } bool usingH264 = false; hr = pinOut1.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) { break; } if (mediaTypes[0].majorType == MediaType.Video && mediaTypes[0].subType == AVC1) { Log.Info("TSReader2MP4: found H.264 video out pin on tsreader"); usingH264 = true; } } //Add the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2MP4: add audio/video decoders to graph"); if (usingH264 == false) { Log.Info("TSReader2MP4: add mpeg2 video decoder:{0}", strVideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strVideoCodec); if (VideoCodec == null) { Log.Error("TSReader2MP4: unable to add mpeg2 video decoder"); Cleanup(); return(false); } } else { Log.Info("TSReader2MP4: add h264 video codec:{0}", strH264VideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strH264VideoCodec); if (VideoCodec == null) { Log.Error("TSReader2MP4: FAILED:unable to add h264 video codec"); Cleanup(); return(false); } } if (usingAAC == false) { Log.Info("TSReader2MP4: add mpeg2 audio codec:{0}", strAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2MP4: FAILED:unable to add mpeg2 audio codec"); Cleanup(); return(false); } } else { Log.Info("TSReader2MP4: add aac audio codec:{0}", strAACAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAACAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2MP4: FAILED:unable to add aac audio codec"); Cleanup(); return(false); } } Log.Info("TSReader2MP4: connect tsreader->audio/video decoders"); //connect output #0 (audio) of tsreader->audio decoder input pin 0 //connect output #1 (video) of tsreader->video decoder input pin 0 pinIn0 = DsFindPin.ByDirection(AudioCodec, PinDirection.Input, 0); //audio pinIn1 = DsFindPin.ByDirection(VideoCodec, PinDirection.Input, 0); //video if (pinIn0 == null || pinIn1 == null) { Log.Error("TSReader2MP4: FAILED: unable to get pins of video/audio codecs"); Cleanup(); return(false); } hr = graphBuilder.Connect(pinOut0, pinIn0); if (hr != 0) { Log.Error("TSReader2MP4: FAILED: unable to connect audio pins :0x{0:X}", hr); Cleanup(); return(false); } hr = graphBuilder.Connect(pinOut1, pinIn1); if (hr != 0) { Log.Error("TSReader2MP4: FAILED: unable to connect video pins :0x{0:X}", hr); Cleanup(); return(false); } //add encoders, muxer & filewriter if (!AddCodecs(graphBuilder, info)) { return(false); } //setup graph controls mediaControl = graphBuilder as IMediaControl; mediaSeeking = tsreaderSource as IMediaSeeking; mediaEvt = graphBuilder as IMediaEventEx; mediaPos = graphBuilder as IMediaPosition; //get file duration Log.Info("TSReader2MP4: Get duration of recording"); long lTime = 5 * 60 * 60; lTime *= 10000000; long pStop = 0; hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); if (hr == 0) { long lStreamPos; mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position m_dDuration = lStreamPos; lTime = 0; mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); } double duration = m_dDuration / 10000000d; Log.Info("TSReader2MP4: recording duration: {0}", MediaPortal.Util.Utils.SecondsToHMSString((int)duration)); //run the graph to initialize the filters to be sure hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2MP4: FAILED: unable to start graph :0x{0:X}", hr); Cleanup(); return(false); } int maxCount = 20; while (true) { long lCurrent; mediaSeeking.GetCurrentPosition(out lCurrent); double dpos = (double)lCurrent; dpos /= 10000000d; System.Threading.Thread.Sleep(100); if (dpos >= 2.0d) { break; } maxCount--; if (maxCount <= 0) { break; } } mediaControl.Stop(); FilterState state; mediaControl.GetState(500, out state); GC.Collect(); GC.Collect(); GC.Collect(); GC.WaitForPendingFinalizers(); graphBuilder.RemoveFilter(mp4Muxer); graphBuilder.RemoveFilter(h264Encoder); graphBuilder.RemoveFilter(aacEncoder); graphBuilder.RemoveFilter((IBaseFilter)fileWriterFilter); if (!AddCodecs(graphBuilder, info)) { return(false); } //Set Encoder quality & Muxer settings if (!EncoderSet(graphBuilder, info)) { return(false); } //start transcoding - run the graph Log.Info("TSReader2MP4: start transcoding"); //setup flow control //need to leverage CBAsePin, CPullPin & IAsyncReader methods. IAsyncReader synchVideo = null; mediaSample = VideoCodec as IMediaSample; hr = synchVideo.SyncReadAligned(mediaSample); //So we only parse decoder output whent the encoders are ready. hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2MP4: FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return(false); } } catch (Exception ex) { Log.Error("TSReader2MP4: Unable create graph: {0}", ex.Message); Cleanup(); return(false); } return(true); }
public Logos() { // BackgroundWorker bgLogos = new System.ComponentModel.BackgroundWorker(); // string activeLogoConfigFile = Config.GetFile(Config.Dir.Config, "MyFilmsLogos_" + Configuration.CurrentConfig + ".xml"); // Default config customized logofile //string activeLogoConfig = "MyFilmsLogos_" + Configuration.CurrentConfig; string logoConfigPathSkin; string skinLogoPath; string activeLogoConfigFile = String.Empty; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { skinLogoPath = Config.GetDirectoryInfo(Config.Dir.Skin) + @"\" + xmlreader.GetValueAsString("skin", "name", "DefaultWide") + @"\Media\Logos"; // Get current path to logos in skindirectory logoConfigPathSkin = Config.GetDirectoryInfo(Config.Dir.Skin) + @"\" + xmlreader.GetValueAsString("skin", "name", "DefaultWide"); // Get current path to active skin directory } if (File.Exists(logoConfigPathSkin + @"\MyFilmsLogos.xml")) { try { activeLogoConfigFile = logoConfigPathSkin + @"\MyFilmsLogos.xml"; LogoConfigOverride = "O"; LogMyFilms.Debug("Using Skin specific logo config file: '" + activeLogoConfigFile + "'"); //wfile = wfile.Substring(wfile.LastIndexOf("\\") + 1) + "_" + Configuration.CurrentConfig; } catch { LogMyFilms.Debug("Error copying config specific file from skin override file !"); } } else { activeLogoConfigFile = Config.GetDirectoryInfo(Config.Dir.Config) + @"\MyFilmsLogos.xml"; LogoConfigOverride = ""; LogMyFilms.Debug("Using MyFilms default logo config file: '" + activeLogoConfigFile + "'"); } using (XmlSettings xmlConfig = new XmlSettings(activeLogoConfigFile)) { // First check, if Config specific LogoConfig exists, if not create it from default file! LogosPath = xmlConfig.ReadXmlConfig(activeLogoConfigFile, "ID0000", "LogosPath", ""); //Recreate the path to make it OS independant... if (LogosPath.Length < 1) // Fall back to default skin logos ! { LogosPath = skinLogoPath; } else { if (LogosPath.ToLower().Contains(@"Team Mediaportal\Mediaportal".ToLower())) { int pos = LogosPath.ToLower().LastIndexOf(@"Team Mediaportal\Mediaportal".ToLower()); LogosPath = LogosPath.Substring(pos + @"Team Mediaportal\Mediaportal".Length); LogosPath = Config.GetDirectoryInfo(Config.Dir.Config) + LogosPath; } } if (LogosPath.LastIndexOf("\\", StringComparison.Ordinal) != LogosPath.Length - 1) LogosPath = LogosPath + "\\"; Spacer = xmlConfig.ReadXmlConfig(activeLogoConfigFile, "ID0000", "Spacing", 1); Country = xmlConfig.ReadXmlConfig(activeLogoConfigFile, "ID0000", "Country", string.Empty); // use Country setting of Logos if available if (Country.Length > 0) { UseCountryLogos = true; //if (Directory.Exists(LogosPath + Country) || LogoFileList.Any(x => x.IndexOf("\\" + Country + "\\", StringComparison.OrdinalIgnoreCase) >= 0)) //{ //} } else { // fallback to use MP language, if directory exists and no specific country setting in logo manager if (Directory.Exists(LogosPath + MyFilmsSettings.MPLanguage) || LogoFileList.Any(x => x.IndexOf("\\" + MyFilmsSettings.MPLanguage + "\\", StringComparison.OrdinalIgnoreCase) >= 0)) { Country = MyFilmsSettings.MPLanguage; UseCountryLogos = true; } } if (UseCountryLogos) MyFilmsDetail.setGUIProperty("config.country", Country, true); LogMyFilms.Debug("Logo path for reading logos : '" + LogosPath + "'"); LogMyFilms.Debug("Logo path for storing cached logos : '" + LogosPathThumbs + "' with spacing = '" + Spacer + "'"); LogMyFilms.Debug("Logo Country : '" + Country + "', MP language = '" + MyFilmsSettings.MPLanguage + "', UseCountryLogos = '" + UseCountryLogos + "'"); #region read logo rules int i = 0; ID2001Logos.Clear(); ID2002Logos.Clear(); ID2003Logos.Clear(); ID2012Logos.Clear(); do { string wline = xmlConfig.ReadXmlConfig(activeLogoConfigFile, "ID2001", "ID2001_" + i, null); if (wline == null) break; ID2001Logos.Add(wline); i++; } while (true); i = 0; do { string wline = xmlConfig.ReadXmlConfig(activeLogoConfigFile, "ID2002", "ID2002_" + i, null); if (wline == null) break; ID2002Logos.Add(wline); i++; } while (true); i = 0; do { string wline = xmlConfig.ReadXmlConfig(activeLogoConfigFile, "ID2003", "ID2003_" + i, null); if (wline == null) break; ID2003Logos.Add(wline); i++; } while (true); #endregion } }
/// <summary> /// Constructor which initializes the osd controller /// </summary> private OSDController() { _fullscreenWindow = new FullscreenWindow(); _videoOSDWindow = new VideoOSDWindow(); _dialogWindow = new DialogWindow(); _osdForm = new OSDForm(); GUIGraphicsContext.form.SizeChanged += parent_SizeChanged; using (MediaPortal.Profile.Settings settings = new MediaPortal.Profile.MPSettings()) { _blankScreen = settings.GetValueAsBool("externalOSDLibrary", "blankScreen", false); } }
public void Load() { var passwordNeedsUpdate = false; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { Mp3 = xmlreader.GetValueAsBool("radiotime", "mp3", true); Wma = xmlreader.GetValueAsBool("radiotime", "wma", true); Real = xmlreader.GetValueAsBool("radiotime", "real", false); ShowPresets = xmlreader.GetValueAsBool("radiotime", "showpresets", false); UseVideo = xmlreader.GetValueAsBool("radiotime", "UseVideo", false); JumpNowPlaying = xmlreader.GetValueAsBool("radiotime", "JumpNowPlaying", false); User = xmlreader.GetValueAsString("radiotime", "user", string.Empty); var encryptedPassword = xmlreader.GetValueAsString("radiotime", "encryptedPassword", string.Empty); if (!string.IsNullOrEmpty(encryptedPassword)) { { Password = PasswordUtility.DecryptData(encryptedPassword, DataProtectionScope.LocalMachine); if (string.IsNullOrEmpty(Password)) { Password = string.Empty; } } } else { Password = xmlreader.GetValueAsString("radiotime", "password", string.Empty); passwordNeedsUpdate = true; } FolderId = xmlreader.GetValueAsString("radiotime", "FolderId", string.Empty); PluginName = xmlreader.GetValueAsString("radiotime", "pluginname", "RadioTime"); StartWithFastPreset = xmlreader.GetValueAsBool("radiotime", "StartWithFastPreset", false); SearchHistory.Clear(); ArtistSearchHistory.Clear(); var searchs = xmlreader.GetValueAsString("radiotime", "searchHistory", ""); if (!string.IsNullOrEmpty(searchs)) { var array = searchs.Split('|'); for (var i = 0; i < array.Length && i < 25; i++) { if (!string.IsNullOrEmpty(array[i])) { SearchHistory.Add(array[i]); } } } searchs = xmlreader.GetValueAsString("radiotime", "artistSearchHistory", ""); if (!string.IsNullOrEmpty(searchs)) { var array = searchs.Split('|'); for (var i = 0; i < array.Length && i < 25; i++) { if (!string.IsNullOrEmpty(array[i])) { ArtistSearchHistory.Add(array[i]); } } } PartnerId = "41"; } if (passwordNeedsUpdate) { SaveEncryptedPassword(); } }
public static bool IsPluginEnabled(string name) { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { return(xmlreader.GetValueAsBool("plugins", name, false)); } }
protected override void SaveSettings() { base.SaveSettings(); using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.MPSettings()) { xmlwriter.SetValue(SerializeName, "layout", (int)currentLayout); xmlwriter.SetValueAsBool(SerializeName, "sortasc", m_bSortAscending); xmlwriter.SetValue(SerializeName, "sortmethod", (int)currentSortMethod); } }
public bool Transcode(TranscodeInfo info, VideoFormat format, Quality quality, Standard standard) { try { if (!Supports(format)) return false; string ext = System.IO.Path.GetExtension(info.file); if (ext.ToLowerInvariant() != ".dvr-ms" && ext.ToLowerInvariant() != ".sbe") { Log.Info("DVRMS2WMV: wrong file format"); return false; } Log.Info("DVRMS2WMV: create graph"); graphBuilder = (IGraphBuilder)new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); Log.Info("DVRMS2WMV: add streambuffersource"); bufferSource = (IStreamBufferSource)new StreamBufferSource(); IBaseFilter filter = (IBaseFilter)bufferSource; graphBuilder.AddFilter(filter, "SBE SOURCE"); Log.Info("DVRMS2WMV: load file:{0}", info.file); IFileSourceFilter fileSource = (IFileSourceFilter)bufferSource; int hr = fileSource.Load(info.file, null); //add mpeg2 audio/video codecs string strVideoCodec = ""; string strAudioCodec = ""; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { strVideoCodec = xmlreader.GetValueAsString("mytv", "videocodec", "MPC - MPEG-2 Video Decoder (Gabest)"); strAudioCodec = xmlreader.GetValueAsString("mytv", "audiocodec", "MPC - MPA Decoder Filter"); } Log.Info("DVRMS2WMV: add mpeg2 video codec:{0}", strVideoCodec); Mpeg2VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strVideoCodec); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:Add mpeg2 video to filtergraph :0x{0:X}", hr); Cleanup(); return false; } Log.Info("DVRMS2WMV: add mpeg2 audio codec:{0}", strAudioCodec); Mpeg2AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAudioCodec); if (Mpeg2AudioCodec == null) { Log.Error("DVRMS2WMV:FAILED:unable to add mpeg2 audio codec"); Cleanup(); return false; } Log.Info("DVRMS2WMV: connect streambufer source->mpeg audio/video decoders"); //connect output #0 of streambuffer source->mpeg2 audio codec pin 1 //connect output #1 of streambuffer source->mpeg2 video codec pin 1 IPin pinOut0, pinOut1; IPin pinIn0, pinIn1; pinOut0 = DsFindPin.ByDirection((IBaseFilter)bufferSource, PinDirection.Output, 0); //audio pinOut1 = DsFindPin.ByDirection((IBaseFilter)bufferSource, PinDirection.Output, 1); //video if (pinOut0 == null || pinOut1 == null) { Log.Error("DVRMS2WMV:FAILED:unable to get pins of source"); Cleanup(); return false; } pinIn0 = DsFindPin.ByDirection(Mpeg2VideoCodec, PinDirection.Input, 0); //video pinIn1 = DsFindPin.ByDirection(Mpeg2AudioCodec, PinDirection.Input, 0); //audio if (pinIn0 == null || pinIn1 == null) { Log.Error("DVRMS2WMV:FAILED:unable to get pins of mpeg2 video/audio codec"); Cleanup(); return false; } hr = graphBuilder.Connect(pinOut0, pinIn1); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to connect audio pins :0x{0:X}", hr); Cleanup(); return false; } hr = graphBuilder.Connect(pinOut1, pinIn0); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to connect video pins :0x{0:X}", hr); Cleanup(); return false; } string outputFilename = System.IO.Path.ChangeExtension(info.file, ".wmv"); if (!AddWmAsfWriter(outputFilename, quality, standard)) return false; Log.Info("DVRMS2WMV: start pre-run"); mediaControl = graphBuilder as IMediaControl; mediaSeeking = bufferSource as IStreamBufferMediaSeeking; mediaEvt = graphBuilder as IMediaEventEx; mediaPos = graphBuilder as IMediaPosition; //get file duration long lTime = 5 * 60 * 60; lTime *= 10000000; long pStop = 0; hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); if (hr == 0) { long lStreamPos; mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position m_dDuration = lStreamPos; lTime = 0; mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); } double duration = m_dDuration / 10000000d; Log.Info("DVRMS2WMV: movie duration:{0}", Util.Utils.SecondsToHMSString((int)duration)); hr = mediaControl.Run(); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return false; } int maxCount = 20; while (true) { long lCurrent; mediaSeeking.GetCurrentPosition(out lCurrent); double dpos = (double)lCurrent; dpos /= 10000000d; System.Threading.Thread.Sleep(100); if (dpos >= 2.0d) break; maxCount--; if (maxCount <= 0) break; } Log.Info("DVRMS2WMV: pre-run done"); Log.Info("DVRMS2WMV: Get duration of movie"); mediaControl.Stop(); FilterState state; mediaControl.GetState(500, out state); GC.Collect(); GC.Collect(); GC.Collect(); GC.WaitForPendingFinalizers(); Log.Info("DVRMS2WMV: reconnect mpeg2 video codec->ASF WM Writer"); graphBuilder.RemoveFilter(fileWriterbase); if (!AddWmAsfWriter(outputFilename, quality, standard)) return false; Log.Info("DVRMS2WMV: Start transcoding"); hr = mediaControl.Run(); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return false; } } catch (Exception e) { // TODO: Handle exceptions. Log.Error("unable to transcode file:{0} message:{1}", info.file, e.Message); return false; } return true; }
public bool Transcode(TranscodeInfo info, MediaPortal.Core.Transcoding.VideoFormat format, MediaPortal.Core.Transcoding.Quality quality, Standard standard) { if (!Supports(format)) return false; string ext = System.IO.Path.GetExtension(info.file); if (ext.ToLowerInvariant() != ".ts" && ext.ToLowerInvariant() != ".mpg") { Log.Info("TSReader2MP4: wrong file format"); return false; } try { graphBuilder = (IGraphBuilder)new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); Log.Info("TSReader2MP4: add filesource"); TsReader reader = new TsReader(); tsreaderSource = (IBaseFilter)reader; IBaseFilter filter = (IBaseFilter)tsreaderSource; graphBuilder.AddFilter(filter, "TSReader Source"); IFileSourceFilter fileSource = (IFileSourceFilter)tsreaderSource; Log.Info("TSReader2MP4: load file:{0}", info.file); int hr = fileSource.Load(info.file, null); //add audio/video codecs string strVideoCodec = ""; string strH264VideoCodec = ""; string strAudioCodec = ""; string strAACAudioCodec = ""; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { strVideoCodec = xmlreader.GetValueAsString("mytv", "videocodec", ""); strAudioCodec = xmlreader.GetValueAsString("mytv", "audiocodec", ""); strAACAudioCodec = xmlreader.GetValueAsString("mytv", "aacaudiocodec", ""); strH264VideoCodec = xmlreader.GetValueAsString("mytv", "h264videocodec", ""); } //Find the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2MP4: find tsreader compatible audio/video decoders"); IPin pinOut0, pinOut1; IPin pinIn0, pinIn1; pinOut0 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 0); //audio pinOut1 = DsFindPin.ByDirection((IBaseFilter)tsreaderSource, PinDirection.Output, 1); //video if (pinOut0 == null || pinOut1 == null) { Log.Error("TSReader2MP4: FAILED: unable to get output pins of tsreader"); Cleanup(); return false; } bool usingAAC = false; IEnumMediaTypes enumMediaTypes; hr = pinOut0.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) break; if (mediaTypes[0].majorType == MediaType.Audio && mediaTypes[0].subType == MediaSubType.LATMAAC) { Log.Info("TSReader2MP4: found LATM AAC audio out pin on tsreader"); usingAAC = true; } } bool usingH264 = false; hr = pinOut1.EnumMediaTypes(out enumMediaTypes); while (true) { AMMediaType[] mediaTypes = new AMMediaType[1]; int typesFetched; hr = enumMediaTypes.Next(1, mediaTypes, out typesFetched); if (hr != 0 || typesFetched == 0) break; if (mediaTypes[0].majorType == MediaType.Video && mediaTypes[0].subType == AVC1) { Log.Info("TSReader2MP4: found H.264 video out pin on tsreader"); usingH264 = true; } } //Add the type of decoder required for the output video & audio pins on TSReader. Log.Info("TSReader2MP4: add audio/video decoders to graph"); if (usingH264 == false) { Log.Info("TSReader2MP4: add mpeg2 video decoder:{0}", strVideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strVideoCodec); if (VideoCodec == null) { Log.Error("TSReader2MP4: unable to add mpeg2 video decoder"); Cleanup(); return false; } } else { Log.Info("TSReader2MP4: add h264 video codec:{0}", strH264VideoCodec); VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strH264VideoCodec); if (VideoCodec == null) { Log.Error("TSReader2MP4: FAILED:unable to add h264 video codec"); Cleanup(); return false; } } if (usingAAC == false) { Log.Info("TSReader2MP4: add mpeg2 audio codec:{0}", strAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2MP4: FAILED:unable to add mpeg2 audio codec"); Cleanup(); return false; } } else { Log.Info("TSReader2MP4: add aac audio codec:{0}", strAACAudioCodec); AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAACAudioCodec); if (AudioCodec == null) { Log.Error("TSReader2MP4: FAILED:unable to add aac audio codec"); Cleanup(); return false; } } Log.Info("TSReader2MP4: connect tsreader->audio/video decoders"); //connect output #0 (audio) of tsreader->audio decoder input pin 0 //connect output #1 (video) of tsreader->video decoder input pin 0 pinIn0 = DsFindPin.ByDirection(AudioCodec, PinDirection.Input, 0); //audio pinIn1 = DsFindPin.ByDirection(VideoCodec, PinDirection.Input, 0); //video if (pinIn0 == null || pinIn1 == null) { Log.Error("TSReader2MP4: FAILED: unable to get pins of video/audio codecs"); Cleanup(); return false; } hr = graphBuilder.Connect(pinOut0, pinIn0); if (hr != 0) { Log.Error("TSReader2MP4: FAILED: unable to connect audio pins :0x{0:X}", hr); Cleanup(); return false; } hr = graphBuilder.Connect(pinOut1, pinIn1); if (hr != 0) { Log.Error("TSReader2MP4: FAILED: unable to connect video pins :0x{0:X}", hr); Cleanup(); return false; } //add encoders, muxer & filewriter if (!AddCodecs(graphBuilder, info)) return false; //setup graph controls mediaControl = graphBuilder as IMediaControl; mediaSeeking = tsreaderSource as IMediaSeeking; mediaEvt = graphBuilder as IMediaEventEx; mediaPos = graphBuilder as IMediaPosition; //get file duration Log.Info("TSReader2MP4: Get duration of recording"); long lTime = 5 * 60 * 60; lTime *= 10000000; long pStop = 0; hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); if (hr == 0) { long lStreamPos; mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position m_dDuration = lStreamPos; lTime = 0; mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); } double duration = m_dDuration / 10000000d; Log.Info("TSReader2MP4: recording duration: {0}", MediaPortal.Util.Utils.SecondsToHMSString((int)duration)); //run the graph to initialize the filters to be sure hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2MP4: FAILED: unable to start graph :0x{0:X}", hr); Cleanup(); return false; } int maxCount = 20; while (true) { long lCurrent; mediaSeeking.GetCurrentPosition(out lCurrent); double dpos = (double)lCurrent; dpos /= 10000000d; System.Threading.Thread.Sleep(100); if (dpos >= 2.0d) break; maxCount--; if (maxCount <= 0) break; } mediaControl.Stop(); FilterState state; mediaControl.GetState(500, out state); GC.Collect(); GC.Collect(); GC.Collect(); GC.WaitForPendingFinalizers(); graphBuilder.RemoveFilter(mp4Muxer); graphBuilder.RemoveFilter(h264Encoder); graphBuilder.RemoveFilter(aacEncoder); graphBuilder.RemoveFilter((IBaseFilter)fileWriterFilter); if (!AddCodecs(graphBuilder, info)) return false; //Set Encoder quality & Muxer settings if (!EncoderSet(graphBuilder, info)) return false; //start transcoding - run the graph Log.Info("TSReader2MP4: start transcoding"); //setup flow control //need to leverage CBAsePin, CPullPin & IAsyncReader methods. IAsyncReader synchVideo = null; mediaSample = VideoCodec as IMediaSample; hr = synchVideo.SyncReadAligned(mediaSample); //So we only parse decoder output whent the encoders are ready. hr = mediaControl.Run(); if (hr != 0) { Log.Error("TSReader2MP4: FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return false; } } catch (Exception ex) { Log.Error("TSReader2MP4: Unable create graph: {0}", ex.Message); Cleanup(); return false; } return true; }
public static void InitLogger() { LoggingConfiguration config = LogManager.Configuration ?? new LoggingConfiguration(); try { FileInfo logFile = new FileInfo(Config.GetFile(Config.Dir.Log, LogFileName)); if (logFile.Exists) { if (File.Exists(Config.GetFile(Config.Dir.Log, OldLogFileName))) { File.Delete(Config.GetFile(Config.Dir.Log, OldLogFileName)); } logFile.CopyTo(Config.GetFile(Config.Dir.Log, OldLogFileName)); logFile.Delete(); } } catch (Exception) { } FileTarget fileTarget = new FileTarget(); fileTarget.FileName = Config.GetFile(Config.Dir.Log, LogFileName); fileTarget.Encoding = "utf-8"; fileTarget.Layout = "${date:format=dd-MMM-yyyy HH\\:mm\\:ss} " + "${level:fixedLength=true:padding=5} " + "[${logger:fixedLength=true:padding=20:shortName=true}]: ${message} " + "${exception:format=tostring}"; config.AddTarget("myvideo-importer", fileTarget); // Get current Log Level from MediaPortal LogLevel logLevel = LogLevel.Debug; string threadPriority = "Normal"; int intLogLevel = 3; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { threadPriority = xmlreader.GetValueAsString("general", "ThreadPriority", threadPriority); intLogLevel = xmlreader.GetValueAsInt("general", "loglevel", intLogLevel); } switch (intLogLevel) { case 0: logLevel = LogLevel.Error; break; case 1: logLevel = LogLevel.Warn; break; case 2: logLevel = LogLevel.Info; break; default: logLevel = LogLevel.Debug; break; } #if DEBUG logLevel = LogLevel.Debug; #endif Priority = string.IsNullOrEmpty(threadPriority) || !threadPriority.Equals("Normal", StringComparison.CurrentCulture) ? (string.IsNullOrEmpty(threadPriority) || !threadPriority.Equals("BelowNormal", StringComparison.CurrentCulture) ? ePriority.BelowNormal : ePriority.Lowest) : ePriority.Lowest; LoggingRule rule = new LoggingRule("MyVideoImporter.*", logLevel, fileTarget); config.LoggingRules.Add(rule); LogManager.Configuration = config; }
public bool Transcode(TranscodeInfo info, VideoFormat format, Quality quality, Standard standard) { try { if (!Supports(format)) { return(false); } string ext = System.IO.Path.GetExtension(info.file); if (ext.ToLower() != ".dvr-ms" && ext.ToLower() != ".sbe") { Log.Info("DVRMS2WMV: wrong file format"); return(false); } Log.Info("DVRMS2WMV: create graph"); graphBuilder = (IGraphBuilder) new FilterGraph(); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); Log.Info("DVRMS2WMV: add streambuffersource"); bufferSource = (IStreamBufferSource) new StreamBufferSource(); IBaseFilter filter = (IBaseFilter)bufferSource; graphBuilder.AddFilter(filter, "SBE SOURCE"); Log.Info("DVRMS2WMV: load file:{0}", info.file); IFileSourceFilter fileSource = (IFileSourceFilter)bufferSource; int hr = fileSource.Load(info.file, null); //add mpeg2 audio/video codecs string strVideoCodec = ""; string strAudioCodec = ""; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { strVideoCodec = xmlreader.GetValueAsString("mytv", "videocodec", "MPC - MPEG-2 Video Decoder (Gabest)"); strAudioCodec = xmlreader.GetValueAsString("mytv", "audiocodec", "MPC - MPA Decoder Filter"); } Log.Info("DVRMS2WMV: add mpeg2 video codec:{0}", strVideoCodec); Mpeg2VideoCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strVideoCodec); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:Add mpeg2 video to filtergraph :0x{0:X}", hr); Cleanup(); return(false); } Log.Info("DVRMS2WMV: add mpeg2 audio codec:{0}", strAudioCodec); Mpeg2AudioCodec = DirectShowUtil.AddFilterToGraph(graphBuilder, strAudioCodec); if (Mpeg2AudioCodec == null) { Log.Error("DVRMS2WMV:FAILED:unable to add mpeg2 audio codec"); Cleanup(); return(false); } Log.Info("DVRMS2WMV: connect streambufer source->mpeg audio/video decoders"); //connect output #0 of streambuffer source->mpeg2 audio codec pin 1 //connect output #1 of streambuffer source->mpeg2 video codec pin 1 IPin pinOut0, pinOut1; IPin pinIn0, pinIn1; pinOut0 = DsFindPin.ByDirection((IBaseFilter)bufferSource, PinDirection.Output, 0); //audio pinOut1 = DsFindPin.ByDirection((IBaseFilter)bufferSource, PinDirection.Output, 1); //video if (pinOut0 == null || pinOut1 == null) { Log.Error("DVRMS2WMV:FAILED:unable to get pins of source"); Cleanup(); return(false); } pinIn0 = DsFindPin.ByDirection(Mpeg2VideoCodec, PinDirection.Input, 0); //video pinIn1 = DsFindPin.ByDirection(Mpeg2AudioCodec, PinDirection.Input, 0); //audio if (pinIn0 == null || pinIn1 == null) { Log.Error("DVRMS2WMV:FAILED:unable to get pins of mpeg2 video/audio codec"); Cleanup(); return(false); } hr = graphBuilder.Connect(pinOut0, pinIn1); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to connect audio pins :0x{0:X}", hr); Cleanup(); return(false); } hr = graphBuilder.Connect(pinOut1, pinIn0); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to connect video pins :0x{0:X}", hr); Cleanup(); return(false); } string outputFilename = System.IO.Path.ChangeExtension(info.file, ".wmv"); if (!AddWmAsfWriter(outputFilename, quality, standard)) { return(false); } Log.Info("DVRMS2WMV: start pre-run"); mediaControl = graphBuilder as IMediaControl; mediaSeeking = bufferSource as IStreamBufferMediaSeeking; mediaEvt = graphBuilder as IMediaEventEx; mediaPos = graphBuilder as IMediaPosition; //get file duration long lTime = 5 * 60 * 60; lTime *= 10000000; long pStop = 0; hr = mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); if (hr == 0) { long lStreamPos; mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position m_dDuration = lStreamPos; lTime = 0; mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); } double duration = m_dDuration / 10000000d; Log.Info("DVRMS2WMV: movie duration:{0}", Util.Utils.SecondsToHMSString((int)duration)); hr = mediaControl.Run(); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return(false); } int maxCount = 20; while (true) { long lCurrent; mediaSeeking.GetCurrentPosition(out lCurrent); double dpos = (double)lCurrent; dpos /= 10000000d; System.Threading.Thread.Sleep(100); if (dpos >= 2.0d) { break; } maxCount--; if (maxCount <= 0) { break; } } Log.Info("DVRMS2WMV: pre-run done"); Log.Info("DVRMS2WMV: Get duration of movie"); mediaControl.Stop(); FilterState state; mediaControl.GetState(500, out state); GC.Collect(); GC.Collect(); GC.Collect(); GC.WaitForPendingFinalizers(); Log.Info("DVRMS2WMV: reconnect mpeg2 video codec->ASF WM Writer"); graphBuilder.RemoveFilter(fileWriterbase); if (!AddWmAsfWriter(outputFilename, quality, standard)) { return(false); } Log.Info("DVRMS2WMV: Start transcoding"); hr = mediaControl.Run(); if (hr != 0) { Log.Error("DVRMS2WMV:FAILED:unable to start graph :0x{0:X}", hr); Cleanup(); return(false); } } catch (Exception e) { // TODO: Handle exceptions. Log.Error("unable to transcode file:{0} message:{1}", info.file, e.Message); return(false); } return(true); }
private void Initialize() { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { ReceiveEnabled = xmlreader.GetValueAsBool("USBUIRT", "internal", false); TransmitEnabled = xmlreader.GetValueAsBool("USBUIRT", "external", false); Is3Digit = xmlreader.GetValueAsBool("USBUIRT", "is3digit", false); tunerNeedsEnter = xmlreader.GetValueAsBool("USBUIRT", "needsenter", false); CommandRepeatCount = xmlreader.GetValueAsInt("USBUIRT", "repeatcount", 2); InterCommandDelay = xmlreader.GetValueAsInt("USBUIRT", "commanddelay", 100); } if (!LoadValues()) { Log.Info("USBUIRT:unable to load values from:{0}", remotefile); } if (!LoadTunerValues()) { Log.Info("USBUIRT:unable to load tunervalues from:{0}", tunerfile); } }