Exemplo n.º 1
0
        public void DeleteTrack(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                return;
            }

            var trackReference = track.TrackReference;

            SubFingerprintDao.DeleteSubFingerprintsByTrackReference(trackReference);
            TrackDao.DeleteTrack(trackReference);
        }
Exemplo n.º 2
0
        public TrackInfo ReadTrackById(string trackId)
        {
            var trackData = TrackDao.ReadTrackById(trackId);

            if (trackData == null)
            {
                return(null);
            }

            var metaFields = CopyMetaFields(trackData.MetaFields);

            metaFields.Add("TrackLength", $"{trackData.Length: 0.000}");
            return(new TrackInfo(trackData.Id, trackData.Title, trackData.Artist, metaFields, trackData.MediaType));
        }
Exemplo n.º 3
0
        public AVHashes ReadHashesByTrackId(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                return(AVHashes.Empty);
            }

            var fingerprints = SubFingerprintDao
                               .ReadHashedFingerprintsByTrackReference(track.TrackReference)
                               .Select(subFingerprint => new HashedFingerprint(subFingerprint.Hashes, subFingerprint.SequenceNumber, subFingerprint.SequenceAt, subFingerprint.OriginalPoint));

            return(new AVHashes(new Hashes(fingerprints, track.Length, MediaType.Audio), Hashes.GetEmpty(MediaType.Video)));
        }
Exemplo n.º 4
0
        public void Insert(TrackInfo trackInfo, AVHashes hashes)
        {
            if (trackInfo.MediaType.HasFlag(MediaType.Video) || hashes.Audio is null)
            {
                throw new NotSupportedException(VIDEO_NOT_SUPPORTED_MESSAGE);
            }

            var audioHashes  = hashes.Audio;
            var fingerprints = audioHashes.ToList();

            if (fingerprints.Count == 0)
            {
                return;
            }

            var trackData = TrackDao.InsertTrack(trackInfo, audioHashes.DurationInSeconds);

            SubFingerprintDao.InsertHashDataForTrack(audioHashes, trackData.TrackReference);
        }
Exemplo n.º 5
0
        public void UpdateTrack(TrackInfo trackInfo)
        {
            if (trackInfo.MediaType.HasFlag(MediaType.Video))
            {
                throw new NotSupportedException(VIDEO_NOT_SUPPORTED_MESSAGE);
            }

            var track = TrackDao.ReadTrackById(trackInfo.Id);

            if (track == null)
            {
                throw new ArgumentException($"Could not find track {trackInfo.Id} to update", nameof(trackInfo.Id));
            }

            var subFingerprints = SubFingerprintDao.ReadHashedFingerprintsByTrackReference(track.TrackReference);
            var hashes          = new Hashes(subFingerprints.Select(subFingerprint => new HashedFingerprint(subFingerprint.Hashes, subFingerprint.SequenceNumber, subFingerprint.SequenceAt, subFingerprint.OriginalPoint)), track.Length, track.MediaType);

            DeleteTrack(trackInfo.Id);
            Insert(trackInfo, new AVHashes(hashes, null));
        }
Exemplo n.º 6
0
 public LMDBModelService(string pathToDatabase, LMDBConfiguration configuration = null)
 {
     databaseContext   = new DatabaseContext(pathToDatabase, configuration ?? new LMDBConfiguration());
     TrackDao          = new TrackDao(databaseContext);
     SubFingerprintDao = new SubFingerprintDao(databaseContext);
 }
Exemplo n.º 7
0
 public IEnumerable <string> GetTrackIds()
 {
     return(TrackDao.GetTrackIds());
 }
Exemplo n.º 8
0
 public IEnumerable <TrackData> ReadTracksByReferences(IEnumerable <IModelReference> references)
 {
     return(TrackDao.ReadTracksByReferences(references));
 }