Beispiel #1
0
        public IEnumerable <ITrack> GetTracks()
        {
            using (RipperToken ripper = new RipperToken())
            {
                List <ITrack> trackList = new List <ITrack>();

                int errorCode = SharpRipLib.CDRipLib.CDRipLib.CR_ReadToc();

                if (errorCode != ErrorCodes.CDEX_OK)
                {
                    throw new CDRipLibException(errorCode, string.Empty);
                }

                int trackCount = SharpRipLib.CDRipLib.CDRipLib.CR_GetNumTocEntries();

                for (int i = 0; i < trackCount; i++)
                {
                    TOCENTRY currentTocEntry = ripper.GetTocEntry(i);
                    TOCENTRY nextTocEntry    = ripper.GetTocEntry(i + 1);

                    Track track = new Track(
                        currentTocEntry.btTrackNumber,
                        currentTocEntry.dwStartSector,
                        nextTocEntry.dwStartSector - 1,
                        _TrackTypeConverter.FromFlag(currentTocEntry.btFlag));

                    trackList.Add(track);
                }

                return(trackList);
            }
        }
Beispiel #2
0
        public void RippTrack()
        {
            SharpRipLib.CDRipLib.CDRipLib.CR_ReadToc();

            TOCENTRY toc1 = SharpRipLib.CDRipLib.CDRipLib.CR_GetTocEntry(1);
            TOCENTRY toc2 = SharpRipLib.CDRipLib.CDRipLib.CR_GetTocEntry(2);

            int bufferSize = -1;
            int success    = SharpRipLib.CDRipLib.CDRipLib.CR_OpenRipper(out bufferSize, (int)toc1.dwStartSector, (int)toc2.dwStartSector);

            Console.WriteLine("Open ripper success: {0}", success);

            bool abort;
            int  numberOfBytesRead = -1;

            if (success == 0)
            {
                try
                {
                    while (numberOfBytesRead != 0)
                    {
                        IntPtr pbtStream = Marshal.AllocHGlobal(bufferSize * Marshal.SizeOf(typeof(byte)));
                        SharpRipLib.CDRipLib.CDRipLib.CR_RipChunk(pbtStream, out numberOfBytesRead, out abort);

                        if (numberOfBytesRead != 0)
                        {
                            byte[] byteArray = new byte[numberOfBytesRead];
                            Marshal.Copy(pbtStream, byteArray, 0, numberOfBytesRead);

                            if (OnDataRipped != null)
                            {
                                OnDataRipped(this, new DataRippedEventArgs(byteArray));
                            }
                        }
                        else
                        {
                            if (OnRippingFinished != null)
                            {
                                OnRippingFinished(this, null);
                            }
                        }
                    }
                }
                finally
                {
                    SharpRipLib.CDRipLib.CDRipLib.CR_CloseRipper();
                }
            }
        }
Beispiel #3
0
        private static void Test01()
        {
            SharpRipLib.CDRipLib.CDRipLib.CR_Init(1);

            try
            {
                Console.WriteLine("Version: {0}", SharpRipLib.CDRipLib.CDRipLib.CR_GetCDRipVersion());

                int result = SharpRipLib.CDRipLib.CDRipLib.CR_ReadToc();
                Console.WriteLine("Result: {0}", result);

                TOCENTRY toc1 = SharpRipLib.CDRipLib.CDRipLib.CR_GetTocEntry(0);
                Console.WriteLine("Track: {0}", toc1.btTrackNumber);

                TOCENTRY toc2 = SharpRipLib.CDRipLib.CDRipLib.CR_GetTocEntry(1);
                Console.WriteLine("Track: {0}", toc2.btTrackNumber);
            }
            finally
            {
                SharpRipLib.CDRipLib.CDRipLib.CR_DeInit();
            }
        }