GetAbsolutePath() public static method

public static GetAbsolutePath ( string filePath ) : string
filePath string
return string
コード例 #1
0
        //private Image ResizeImage(Image image, int newWidth, int newHeight, bool highQuality)
        //{
        //    System.Drawing.Image result = new Bitmap(newWidth, newHeight);
        //    System.Drawing.Graphics graphic = Graphics.FromImage(result);

        //    // Set the quality options
        //    if (highQuality)
        //    {
        //        graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        //        graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        //        graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
        //        graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
        //    }

        //    // Constraint the sizes
        //    double originalRatio = (double)image.Width / image.Height;
        //    double standardRatio = (double)newWidth / newHeight;
        //    int offsetX = 0, offsetY = 0;
        //    if (originalRatio > standardRatio)
        //    {
        //        newHeight = (int)(image.Height * newWidth / image.Width);
        //        offsetY = (newWidth - newHeight) >> 1;
        //    }
        //    else
        //    {
        //        newWidth = (int)(image.Width * newHeight / image.Height);
        //        offsetX = (newHeight - newWidth) >> 1;
        //    }

        //    // Draw the image with the resized dimensions
        //    graphic.DrawImage(image, offsetX, offsetY, newWidth, newHeight);

        //    return result;
        //}

        internal void AdjustTVLogo(Channel channel)
        {
            if (channel.Tag != null)
            {
                TreeNode treeNode = channel.Tag as TreeNode;

                if (channel is ChannelFolder)
                {
                    treeNode.ImageKey = treeNode.SelectedImageKey = "FolderClosed";
                    return;
                }
                else if (channel is ChannelTV)
                {
                    string logo = (channel as ChannelTV).Logo;
                    if (logo != null && logo.Length > 0)
                    {
                        if (MainForm.imageListLogoTV.Images.ContainsKey(logo))
                        {
                            treeNode.ImageKey = treeNode.SelectedImageKey = logo;
                            return;
                        }
                        else
                        {
                            try
                            {
                                string path = FileUtils.GetAbsolutePath(logo);
                                if (File.Exists(path))
                                {
                                    Bitmap bitmap = new Bitmap(path);
                                    //if (!Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
                                    //    bitmap.MakeTransparent(Color.White);
                                    //Image thumbnail = ResizeImage(bitmap, 16, 16, false);
                                    Image thumbnail = Utils.ResizeImage(bitmap, 16, 16, false);
                                    MainForm.imageListLogoTV.Images.Add(logo, thumbnail);
                                    treeNode.ImageKey = treeNode.SelectedImageKey = logo;
                                    thumbnail.Dispose();
                                    bitmap.Dispose();
                                    return;
                                }
                            }
                            catch (ArgumentException) { }
                        }
                    }
                }

                treeNode.ImageKey = treeNode.SelectedImageKey = "LogoTVDefault";
            }
        }
コード例 #2
0
        private void ConnectStreamBufferSinkToSource()
        {
            if (!Directory.Exists(Settings.VideosFolder))
            {
                Directory.CreateDirectory(Settings.VideosFolder);
            }

            string currentSBEProfile         = Settings.VideosFolder + "\\CurrentRecording.sbe-stub";
            string currentSBEProfileFilename = FileUtils.GetAbsolutePath(currentSBEProfile as string);

            IStreamBufferSink sink = this.streamBufferSink as IStreamBufferSink;
            int hr = sink.LockProfile(currentSBEProfile); //currentSBEProfileFilename); //currentSBEProfile);

            DsError.ThrowExceptionForHR(hr);

            IStreamBufferSource source = this.streamBufferSource as IStreamBufferSource;

            hr = source.SetStreamSink(sink);                                  // This line does not seem to be compatible with SBE2Sink.
            //So, I commented out the generation of exception   DsError.ThrowExceptionForHR(hr);
            hr = (source as IFileSourceFilter).Load(currentSBEProfile, null); //currentSBEProfileFilename, null); //currentSBEProfile, null);
            DsError.ThrowExceptionForHR(hr);
        }
コード例 #3
0
ファイル: WizardForm.cs プロジェクト: friman/Digital-Signage
        private bool ScanProbeFrequency(ChannelTV currentChannelTV, bool needRebuild)
        {
            this.propertyGridChannel.SelectedObject = currentChannelTV;
            Application.DoEvents();

            MainForm.videoControl.BackColor = Color.Transparent;
            try
            {
                MainForm.TuneChannel(currentChannelTV, needRebuild);
                needRebuild            = false;
                textBoxScanStatus.Text = Properties.Resources.Scanning;
                if (currentChannelTV is ChannelDVB)
                {
                    textBoxScanFrequency.Text = string.Format(Properties.Resources.ScanningFrequency, (currentChannelTV as ChannelDVB).Frequency);
                }
                else if (currentChannelTV is ChannelAnalogic)
                {
                    textBoxScanFrequency.Text = string.Format(Properties.Resources.ScanningChannel, (currentChannelTV as ChannelAnalogic).Channel);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLineIf(MainForm.trace.TraceError, ex.ToString());
                textBoxScanStatus.Text          = Properties.Resources.Error + " " + ex.Message;
                textBoxScanFrequency.Text       = Properties.Resources.ScanningError;
                MainForm.videoControl.BackColor = MainForm.Settings.VideoBackgroundColor;
            }

            if (currentChannelTV is ChannelDVB)
            {
                if (MainForm.GraphBuilder is IBDA)
                {
                    IBDA graphBuilderBDA = MainForm.GraphBuilder as IBDA;
                    bool locked, present;
                    int  strength, quality;
                    System.Threading.Thread.Sleep(500);
                    if ((graphBuilderBDA as ITV).GetSignalStatistics(out locked, out present, out strength, out quality))
                    {
                        if (locked && present)
                        {
                            IMpeg2Data mpeg2Data = graphBuilderBDA.SectionsAndTables as IMpeg2Data;

                            short     originalNetworkId      = -1;
                            Hashtable serviceNameByServiceId = new Hashtable();
                            // Hervé Stalin : Ajout d'une hashtable pour le services_type d'un service
                            Hashtable    serviceTypeByServiceID = new Hashtable();
                            PSISection[] psiSdts = PSISection.GetPSITable((int)PIDS.SDT, (int)TABLE_IDS.SDT_ACTUAL, mpeg2Data);
                            for (int i = 0; i < psiSdts.Length; i++)
                            {
                                PSISection psiSdt = psiSdts[i];
                                if (psiSdt != null && psiSdt is PSISDT)
                                {
                                    PSISDT sdt = (PSISDT)psiSdt;
                                    Trace.WriteLineIf(MainForm.trace.TraceVerbose, "PSI Table " + i + "/" + psiSdts.Length + "\r\n");
                                    Trace.WriteLineIf(MainForm.trace.TraceVerbose, sdt.ToString());

                                    originalNetworkId = (short)sdt.OriginalNetworkId;
                                    foreach (PSISDT.Data service in sdt.Services)
                                    {
                                        serviceNameByServiceId[service.ServiceId] = service.GetServiceName();
                                        //Hervé Stalin : remplissage du hashtable du service_type
                                        serviceTypeByServiceID[service.ServiceId] = service.GetServiceType();
                                    }
                                }
                            }

                            //Hervé Stalin : Code pode pour créér un hashtable de lcn
                            Hashtable    logicalChannelNumberByServiceId = new Hashtable();
                            PSISection[] psiNits = PSISection.GetPSITable((int)PIDS.NIT, (int)TABLE_IDS.NIT_ACTUAL, mpeg2Data);
                            for (int i = 0; i < psiNits.Length; i++)
                            {
                                PSISection psinit = psiNits[i];
                                if (psinit != null && psinit is PSINIT)
                                {
                                    PSINIT nit = (PSINIT)psinit;
                                    Trace.WriteLineIf(MainForm.trace.TraceVerbose, "PSI Table " + i + "/" + psiNits.Length + "\r\n");
                                    Trace.WriteLineIf(MainForm.trace.TraceVerbose, nit.ToString());

                                    foreach (PSINIT.Data data in nit.Streams)
                                    {
                                        foreach (PSIDescriptor psiDescriptorData in data.Descriptors)
                                        {
                                            if (psiDescriptorData.DescriptorTag == DESCRIPTOR_TAGS.DESCR_LOGICAL_CHANNEL)
                                            {
                                                PSIDescriptorLogicalChannel psiDescriptorLogicalChannel = (PSIDescriptorLogicalChannel)psiDescriptorData;
                                                foreach (PSIDescriptorLogicalChannel.ChannelNumber f in psiDescriptorLogicalChannel.LogicalChannelNumbers)
                                                {
                                                    logicalChannelNumberByServiceId[f.ServiceID] = f.LogicalChannelNumber;
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            PSISection[] psis = PSISection.GetPSITable((int)PIDS.PAT, (int)TABLE_IDS.PAT, mpeg2Data);
                            for (int i = 0; i < psis.Length; i++)
                            {
                                PSISection psi = psis[i];
                                if (psi != null && psi is PSIPAT)
                                {
                                    PSIPAT pat = (PSIPAT)psi;
                                    Trace.WriteLineIf(MainForm.trace.TraceVerbose, "PSI Table " + i + "/" + psis.Length + "\r\n");
                                    Trace.WriteLineIf(MainForm.trace.TraceVerbose, pat.ToString());

                                    ChannelDVB newTemplateChannelDVB = (MainForm.GraphBuilder as ITV).CurrentChannel.MakeCopy() as ChannelDVB;
                                    newTemplateChannelDVB.ONID = originalNetworkId;
                                    newTemplateChannelDVB.TSID = pat.TransportStreamId;

                                    foreach (PSIPAT.Data program in pat.ProgramIds)
                                    {
                                        if (!program.IsNetworkPID)                                         // Hervé Stalin : est encore utile ?
                                        {
                                            //Hervé Stalin: discrimination par le service type
                                            SERVICE_TYPES st;
                                            try
                                            {
                                                st = (SERVICE_TYPES)serviceTypeByServiceID[program.ProgramNumber];
                                            }
                                            catch
                                            {
                                                st = SERVICE_TYPES.DIGITAL_TELEVISION_SERVICE;                                                  // bypass en cas de probleme de parsing (mauvaise réception dans mon cas)
                                            }

                                            if (st == SERVICE_TYPES.DIGITAL_TELEVISION_SERVICE ||                                                                   // TV SD MPEG2
                                                st == SERVICE_TYPES.ADVANCE_CODEC_HD_DIGITAL_SERVICE ||                                                             // TV HD H264
                                                st == SERVICE_TYPES.ADVANCE_CODEC_SD_DIGITAL_SERVICE ||                                                             // TV SD H264
                                                st == SERVICE_TYPES.MPEG2_HD_DIGITAL_TELEVISION_SERVICE ||                                                          // TV HD MPEG2
                                                st == SERVICE_TYPES.DIGITAL_RADIO_SOUND_SERVICE ||                                                                  // Radio MP2
                                                st == SERVICE_TYPES.ADVANCED_CODEC_DIGITAL_RADIO_SOUND_SERVICE ||                                                   // Radio AC3/E-AC3/AAC
                                                st == SERVICE_TYPES.MOSAIC_SERVICE ||                                                                               // Mosaic MPEG2
                                                st == SERVICE_TYPES.ADVANCED_CODEC_MOSAIC_SERVICE)                                                                  // Mosaic H264

                                            {
                                                ChannelDVB newChannelDVB = newTemplateChannelDVB.MakeCopy() as ChannelDVB;
                                                newChannelDVB.SID  = program.ProgramNumber;
                                                newChannelDVB.Name = (string)serviceNameByServiceId[program.ProgramNumber];
                                                //Hervé Stalin: ajout du LCN
                                                newChannelDVB.ChannelNumber = Convert.ToInt16(logicalChannelNumberByServiceId[program.ProgramNumber]);

                                                if (newChannelDVB.Name == null)
                                                {
                                                    newChannelDVB.Name = Properties.Resources.NoName;
                                                }

                                                UpdateDVBChannelPids(mpeg2Data, program.Pid, newChannelDVB);

                                                ListViewItem lvi = new ListViewItem(newChannelDVB.Name, "LogoTVDefault");
                                                lvi.SubItems.Add(newChannelDVB.Frequency.ToString());
                                                lvi.SubItems.Add(newChannelDVB.ChannelNumber.ToString());
                                                lvi.Tag = newChannelDVB;
                                                //this.listViewScanResult.SmallImageList = MainForm.imageListLogoTV;
                                                this.listViewScanResult.Items.Add(lvi);
                                                this.buttonScanClear.Enabled = true;

                                                try
                                                {
                                                    var extensions = new HashSet <string>(StringComparer.OrdinalIgnoreCase)
                                                    {
                                                        ".gif", ".png", ".jpg", ".jpeg", ".bmp"
                                                    };
                                                    //var files = Directory.EnumerateFiles(@".\Logos\", "*");
                                                    var files = Directory.GetFiles(@".\Logos\", "*");
                                                    foreach (var logo in files)
                                                    {
                                                        string extension = Path.GetExtension(logo).ToLowerInvariant();
                                                        if (extensions.Contains(extension))
                                                        {
                                                            string filename = Path.GetFileNameWithoutExtension(logo).ToLowerInvariant();
                                                            if (newChannelDVB.Name.ToLowerInvariant().IndexOf(filename) != -1)
                                                            {
                                                                newChannelDVB.Logo = logo;
                                                                //MainForm.panelChannel.AdjustTVLogo(newChannelDVB);
                                                                if (MainForm.imageListLogoTV.Images.ContainsKey(logo))
                                                                {
                                                                    lvi.ImageKey = logo;
                                                                }
                                                                else
                                                                {
                                                                    try
                                                                    {
                                                                        string path = FileUtils.GetAbsolutePath(logo);
                                                                        if (File.Exists(path))
                                                                        {
                                                                            Bitmap bitmap = new Bitmap(path);
                                                                            //if (!Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
                                                                            //    bitmap.MakeTransparent(Color.White);
                                                                            Image thumbnail = Utils.ResizeImage(bitmap, 16, 16, false);
                                                                            MainForm.imageListLogoTV.Images.Add(logo, thumbnail);
                                                                            lvi.ImageKey = logo;
                                                                            thumbnail.Dispose();
                                                                            bitmap.Dispose();
                                                                            break;
                                                                        }
                                                                    }
                                                                    catch (ArgumentException) { }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                catch (Exception)
                                                {
                                                }

                                                //PSISection[] psis2 = PSISection.GetPSITable(program.Pid, (int)TABLE_IDS.PMT, mpeg2Data);
                                                //for (int i2 = 0; i2 < psis2.Length; i2++)
                                                //{
                                                //    PSISection psi2 = psis2[i2];
                                                //    if (psi2 != null && psi2 is PSIPMT)
                                                //    {
                                                //        PSIPMT pmt = (PSIPMT)psi2;
                                                //        Trace.WriteLineIf(trace.TraceVerbose, "PSI Table " + i2 + "/" + psis2.Length + "\r\n");
                                                //        Trace.WriteLineIf(trace.TraceVerbose, pmt.ToString());
                                                //    }
                                                //}
                                            }
                                        }
                                    }

                                    Application.DoEvents();
                                }
                            }
                        }
                    }
                }
            }
            else if (currentChannelTV is ChannelAnalogic)
            {
                GraphBuilderWDM graphBuilderWDM = MainForm.GraphBuilder as GraphBuilderWDM;
                if (graphBuilderWDM.CurrentChannel != null)
                {
                    bool locked, present;
                    int  strength, quality;
                    if (graphBuilderWDM.GetSignalStatistics(out locked, out present, out strength, out quality))
                    {
                        if (locked && present)
                        {
                            ChannelAnalogic newChannel = graphBuilderWDM.CurrentChannel.MakeCopy() as ChannelAnalogic;
                            newChannel.Name = Properties.Resources.NewChannelName + " " + newChannel.Channel.ToString();

                            ListViewItem lvi = new ListViewItem(newChannel.Name, "LogoTVDefault");
                            lvi.SubItems.Add(newChannel.Channel.ToString());
                            lvi.Tag = newChannel;
                            this.listViewScanResult.Items.Add(lvi);
                            this.buttonScanClear.Enabled = true;
                        }
                    }
                }
            }
            return(needRebuild);
        }
コード例 #4
0
        protected void ConfigureTimeShiftingRegistry()
        {
            //http://msdn.microsoft.com/en-us/library/windows/desktop/dd694948%28v=vs.85%29.aspx

            UIntPtr HKEY_CURRENT_USER = (UIntPtr)0x80000001;
            //unchecked
            //{
            //    HKEY_CURRENT_USER = (UIntPtr)0x80000001;
            //}

            // Create the StreamBufferConfig object.
            StreamBufferConfig     streamBufferConfig    = new StreamBufferConfig();
            IStreamBufferConfigure streamBufferConfigure = streamBufferConfig as IStreamBufferConfigure;

            // Create a new registry key to hold our settings.
            streamBufferConfigHKey = IntPtr.Zero;
            IntPtr p = Marshal.AllocCoTaskMem(4);

            Marshal.WriteIntPtr(p, IntPtr.Zero);
            try
            {
                int lRes = RegCreateKey(HKEY_CURRENT_USER, MainForm.RegistryBaseKey + "\\SBE", p);
                streamBufferConfigHKey = Marshal.ReadIntPtr(p);
            }
            finally
            {
                Marshal.FreeCoTaskMem(p);
            }

            // Set the registry key.
            IStreamBufferInitialize streamBufferInitialize = streamBufferConfigure as IStreamBufferInitialize;
            int hr = streamBufferInitialize.SetHKEY(streamBufferConfigHKey);

            DsError.ThrowExceptionForHR(hr);

            //http://msdn.microsoft.com/en-us/library/windows/desktop/dd694977%28v=vs.85%29.aspx
            //For Windows Vista or later the IStreamBufferSink::LockProfile method requires administrator privileges,
            // unless you first call IStreamBufferConfigure3::SetNamespace with the value NULL.
            IStreamBufferConfigure3 streamBufferConfigure3 = streamBufferConfig as IStreamBufferConfigure3;

            if (streamBufferConfigure3 != null)
            {
                hr = streamBufferConfigure3.SetNamespace(null);
                DsError.ThrowExceptionForHR(hr);
            }

            // Set the TimeShifting configuration
            //hr = streamBufferConfigure.SetDirectory("C:\\MyDirectory");
            string directory     = Settings.VideosFolder;
            string directoryPath = FileUtils.GetAbsolutePath(directory as string);

            hr = streamBufferConfigure.SetDirectory(directoryPath);
            DsError.ThrowExceptionForHR(hr);


            hr = streamBufferConfigure.SetBackingFileDuration(600);             // Min 15 seconds
            //TODO not working anymore!!
            hr = streamBufferConfigure.SetBackingFileCount(
                Math.Min(100, Math.Max(4, Settings.TimeShiftingBufferLengthMin / 10)),  // 4-100
                Math.Min(102, Math.Max(6, Settings.TimeShiftingBufferLengthMax / 10))); // 6-102
        }