Exemplo n.º 1
0
        /// <summary>
        /// Pass the 'inStream' through exiftool and write the output to the 'outStream'.
        /// </summary>
        private void WriteTemporaryFile(Stream file, Stream input)
        {
            // get a buffer
            var buffer = BufferCache.Get();
            // read from the input stream
            int count = input.Read(buffer, 0, Global.BufferSizeLocal);

            // write the buffer to the file
            file.Write(buffer, 0, count);
            // reset the buffer
            BufferCache.Set(buffer);

            // is this the final buffer?
            if (count < Global.BufferSizeLocal)
            {
                // yes, dispose of the file stream
                file.Dispose();

                var process = _coordinator.Process.TakeItem();
                process.StandardInput.BaseStream.Write(_bytesRemoveMetadata, 0, _bytesRemoveMetadata.Length);
                byte[] pathBytes = System.Text.Encoding.ASCII.GetBytes(Path);
                process.StandardInput.BaseStream.Write(pathBytes, 0, pathBytes.Length);
                process.StandardInput.BaseStream.Write(_coordinator.BytesExecute, 0, _coordinator.BytesExecute.Length);
                process.StandardInput.BaseStream.Flush();
                _coordinator.Process.Release();

                // add this task to run with the coordinators process
                _coordinator.Add(this);
            }
            else
            {
                // continue writing the temporary file
                ManagerUpdate.Control.AddSingle(WriteTemporaryFile, file, input);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Remove metadata from the media found in the input stream.
        /// </summary>
        public MetaRetrieval(MediaCoordinator coordinator, string path, IAction <MetaRetrieval> onComplete, bool removeFile = true)
        {
            _coordinator    = coordinator;
            _removeTempFile = removeFile;

            // create a name for the media
            Path            = path;
            OnComplete      = onComplete;
            OnComplete.ArgA = this;

            var process = _coordinator.Process.TakeItem();

            process.StandardInput.BaseStream.Write(_bytesGetMetadata, 0, _bytesGetMetadata.Length);
            byte[] pathBytes = System.Text.Encoding.ASCII.GetBytes(Path);
            process.StandardInput.BaseStream.Write(pathBytes, 0, pathBytes.Length);
            process.StandardInput.BaseStream.Write(_coordinator.BytesExecute, 0, _coordinator.BytesExecute.Length);
            process.StandardInput.BaseStream.Flush();
            _coordinator.Process.Release();

            _coordinator.Add(this);
        }