public override void UpdateMetadata(FileFieldTemplate template, Media.File fileObject, Stream stream, Uri blobUri, bool forceClear = false) { base.UpdateMetadata(template, fileObject, stream, blobUri, forceClear); if (template.TemplateType != FileTemplateType.Image) { return; } _queue.Enqueue(new ImageQueue() { SystemId = fileObject.SystemId, BlobUri = blobUri, FileName = fileObject.Name, }); if (_analyzing) { return; } if (_timer == null) { lock (_lock) { if (_timer == null) { _timer = new Timer(10000); _timer.Elapsed += _timer_Elapsed; _timer.AutoReset = false; } } } if (_timer.Enabled) { _timer.Stop(); } if (!_timer.Enabled) { lock (_lock) { if (!_timer.Enabled) { _timer.Start(); } } } }
public ChannelStreamer(Protocol protocol, Media.File file, byte[] key, MusicStream output) { if (key.Length != (128 / 8)) { output.AllAvailable = true; throw new InvalidDataException("Encryption key for channel must be 128-bit."); } _cipher.BlockSize = 128; _cipher.KeySize = 128; _key = key; _cipher.Mode = CipherMode.ECB; //CTR not available _cipher.Padding = PaddingMode.None; _output = output; _file = file; _protocol = protocol; _channelLength = 160 * 1024 * 5 / 8; /* 160 kbit * 5 seconds. */ /* Send first substream request. */ string hash = this._cache.Hash(this._file, this._channelOffset, this._channelLength); if (this._cache != null && this._cache.Contains("substream", hash)) { this._cache.Load("substream", hash, this); } else { try { this._protocol.SendSubstreamRequest(this, this._file, this._channelOffset, this._channelLength); } catch (ProtocolException) { return; } } }
public string Hash(Media.File file, int offset, int length) { return(file.Id + "/" + offset + "-" + length); }