ReadHashedFingerprintsByTrackReference() public method

public ReadHashedFingerprintsByTrackReference ( IModelReference trackReference ) : IList
trackReference IModelReference
return IList
示例#1
0
        public AVHashes ReadHashesByTrackId(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

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

            var fingerprints = SubFingerprintDao
                               .ReadHashedFingerprintsByTrackReference(track.TrackReference)
                               .Select(ToHashedFingerprint);

            return(new AVHashes(new Hashes(fingerprints, track.Length, MediaType.Audio), Hashes.GetEmpty(MediaType.Video)));
        }
        /// <inheritdoc cref="IModelService.UpdateTrack"/>
        public void UpdateTrack(TrackInfo trackInfo)
        {
            var track = TrackDao.ReadTrackById(trackInfo.Id);

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

            if (trackInfo.MediaType != track.MediaType)
            {
                throw new ArgumentException($"Can't update media type from {trackInfo.MediaType} to {track.MediaType}. Delete {track.Id} and reinsert with new media type.");
            }

            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, hashes);
        }