Exemplo n.º 1
0
        public TimeSpan Duration()
        {
            TitleTime tt = new TitleTime();
            TimeSpan duration = TimeSpan.Zero;
            List<SimpleCell> SortedCells = new List<SimpleCell>();

            int pgc_num = ifoGetNumPGCI(Handle);
            for (int i = 0; i < pgc_num; i++)
            {
                int num_cells = ifoGetPGCIInfo(Handle, i, ref tt);
                IntPtr ptr_cells = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(t_vs_vobcellid)) * num_cells);
                if (ptr_cells != IntPtr.Zero)
                {
                    try
                    {
                        if (ifoGetPGCICells(Handle, i, ptr_cells))
                        {
                            IntPtr ptr_cell = ptr_cells;
                            for (int k = 0; k < num_cells; k++)
                            {
                                t_vs_vobcellid cell = (t_vs_vobcellid)Marshal.PtrToStructure(ptr_cell, typeof(t_vs_vobcellid));
                                ptr_cell = new IntPtr(ptr_cell.ToInt64() + Marshal.SizeOf(typeof(t_vs_vobcellid))); //ptr += offset

                                //Сохраняем инфу от cell, если у нас такой еще нет (берутся только start\end_lba и time)
                                SimpleCell obj = new SimpleCell() { start = cell.start_lba, end = cell.end_lba, time = cell.time };
                                if (!SortedCells.Contains(obj))
                                    SortedCells.Add(obj);
                            }
                        }
                    }
                    finally
                    {
                        Marshal.FreeHGlobal(ptr_cells);
                    }
                }
            }

            foreach (SimpleCell cell in SortedCells)
            {
                #region frames bits
                /*
                1 0 0 1 0 0 1 0  (73)
                1 0 0 1 0 0 0 0  (9, & 0x3f) 25fps
                0 0 0 0 0 0 1 0  (64, & ~0x3f) 25fps

                0 1 0 1 0 0 0 0  (10, & 0x3f) 29fps
                0 0 0 0 0 0 1 1  (192, & ~0x3f) 29fps
                */
                #endregion

                duration += TimeSpan.FromHours(cell.time.hours) +
                    TimeSpan.FromMinutes(cell.time.minutes) +
                    TimeSpan.FromSeconds(cell.time.seconds) +
                    TimeSpan.FromMilliseconds((cell.time.frames & 0x3f) * //Перевод кадров в ms
                    (((cell.time.frames & (1 << 7)) != 0) ? 1000.0 / (30000.0 / 1001.0) : 40.0));
            }

            return duration;
        }
Exemplo n.º 2
0
        public TimeSpan Duration()
        {
            TitleTime tt = new TitleTime();
            TimeSpan duration = TimeSpan.Zero;
            TimeSpan c_duration = TimeSpan.Zero;

            for (int i = 0; i < ifoGetNumPGCI(Handle); i++)
            {
                ifoGetPGCIInfo(Handle, i, ref tt);
                c_duration = TimeSpan.FromHours(tt.s1) +
                TimeSpan.FromMinutes(tt.s2) +
                TimeSpan.FromSeconds(tt.s3) +
                TimeSpan.FromMilliseconds(tt.s4);

                //Отбрасываем мусор
                if (c_duration.TotalMinutes > 1)
                    duration += c_duration;
            }

            return duration;
        }
Exemplo n.º 3
0
 private static extern int ifoGetPGCIInfo(IntPtr v_IFO_handle, int v_Ptr, ref TitleTime v_len);
Exemplo n.º 4
0
 private static extern int ifoGetPGCIInfo(IntPtr v_IFO_handle, int v_Ptr, ref TitleTime v_len);
Exemplo n.º 5
0
        public TimeSpan Duration()
        {
            TitleTime         tt          = new TitleTime();
            TimeSpan          duration    = TimeSpan.Zero;
            List <SimpleCell> SortedCells = new List <SimpleCell>();

            int pgc_num = ifoGetNumPGCI(Handle);

            for (int i = 0; i < pgc_num; i++)
            {
                int    num_cells = ifoGetPGCIInfo(Handle, i, ref tt);
                IntPtr ptr_cells = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(t_vs_vobcellid)) * num_cells);
                if (ptr_cells != IntPtr.Zero)
                {
                    try
                    {
                        if (ifoGetPGCICells(Handle, i, ptr_cells))
                        {
                            IntPtr ptr_cell = ptr_cells;
                            for (int k = 0; k < num_cells; k++)
                            {
                                t_vs_vobcellid cell = (t_vs_vobcellid)Marshal.PtrToStructure(ptr_cell, typeof(t_vs_vobcellid));
                                ptr_cell = new IntPtr(ptr_cell.ToInt64() + Marshal.SizeOf(typeof(t_vs_vobcellid))); //ptr += offset

                                //Сохраняем инфу от cell, если у нас такой еще нет (берутся только start\end_lba и time)
                                SimpleCell obj = new SimpleCell()
                                {
                                    start = cell.start_lba, end = cell.end_lba, time = cell.time
                                };
                                if (!SortedCells.Contains(obj))
                                {
                                    SortedCells.Add(obj);
                                }
                            }
                        }
                    }
                    finally
                    {
                        Marshal.FreeHGlobal(ptr_cells);
                    }
                }
            }

            foreach (SimpleCell cell in SortedCells)
            {
                #region frames bits

                /*
                 * 1 0 0 1 0 0 1 0  (73)
                 * 1 0 0 1 0 0 0 0  (9, & 0x3f) 25fps
                 * 0 0 0 0 0 0 1 0  (64, & ~0x3f) 25fps
                 *
                 * 0 1 0 1 0 0 0 0  (10, & 0x3f) 29fps
                 * 0 0 0 0 0 0 1 1  (192, & ~0x3f) 29fps
                 */
                #endregion

                duration += TimeSpan.FromHours(cell.time.hours) +
                            TimeSpan.FromMinutes(cell.time.minutes) +
                            TimeSpan.FromSeconds(cell.time.seconds) +
                            TimeSpan.FromMilliseconds((cell.time.frames & 0x3f) * //Перевод кадров в ms
                                                      (((cell.time.frames & (1 << 7)) != 0) ? 1000.0 / (30000.0 / 1001.0) : 40.0));
            }

            return(duration);
        }