Пример #1
0
        /// <summary>
        /// Checks if the HandbrakeEncoder is available to immediately start
        /// encoding the next file. If it is not, nothing is done until the
        /// encoder is no longer busy.
        /// </summary>
        private void CheckAndQueueEncoderTask()
        {
            UpdateEncodeQueueList();

            if (_encoderWorker.IsBusy || encodeQueueFiles.Count == 0)
            {
                return;
            }

            // Start encoding the next file in the queue
            var sourceFile      = encodeQueueFiles[0];
            var destinationFile = Path.Combine(Settings.Default.OutputFolder,
                                               Path.GetFileNameWithoutExtension(sourceFile));

            destinationFile = Path.ChangeExtension(destinationFile, Settings.Default.OutputFileExtension);

            var settings = new EncoderSettings
            {
                SourceFilename      = sourceFile,
                DestinationFilename = destinationFile
            };

            //_encoder.SourceFilename = sourceFile;
            //_encoder.DestinationFilename = destinationFile;
            _encoderWorker.RunWorkerAsync(settings);

            //UpdateEncodeQueueList();

            //_encodeQueueFiles.RemoveAt(0);
        }
        /// <summary>
        /// Updates the user interface of this form.
        /// </summary>
        private void UpdateUI()
        {
            if (EncoderSettings.Equals(PngEncoderSettings.BestSpeed))
            {
                bestSpeedRadioButton.Checked = true;
            }
            else if (EncoderSettings.Equals(PngEncoderSettings.Fast))
            {
                fastRadioButton.Checked = true;
            }
            else if (EncoderSettings.Equals(PngEncoderSettings.Normal))
            {
                normalRadioButton.Checked = true;
            }
            else if (EncoderSettings.Equals(PngEncoderSettings.BestCompression))
            {
                bestCompressionRadioButton.Checked = true;
            }
            else
            {
                customRadioButton.Checked = true;
            }

            customGroupBox.Enabled                = customRadioButton.Checked;
            filterMethodComboBox.SelectedItem     = EncoderSettings.FilterMethod;
            compressionLevelComboBox.SelectedItem = EncoderSettings.CompressionLevel;

            adam7InterlacingCheckBox.Checked = EncoderSettings.InterlaceMethod == PngInterlaceMethod.Adam7;

            if (EditAnnotationSettings)
            {
                annotationsBinaryCheckBox.Checked = (EncoderSettings.AnnotationsFormat | AnnotationsFormat.VintasoftBinary) != 0;
            }
        }
Пример #3
0
        public byte[] BuildTx(string[] command, out string msg)
        {
            if (command.Length == 0)
            {
                msg = "Expecting a creditcoin command";
                return(null);
            }

            var map = CBORObject.NewMap();

            map.Add("v", command[0]);         // verb

            map.Add("i", DateTime.Now.Ticks); // id

            for (int i = 1; i < command.Length; ++i)
            {
                map.Add("p" + i.ToString(), command[i]); // params
            }

            var pubKeyHexStr = mSigner.GetPublicKey().ToHexString();
            var settings     = new EncoderSettings()
            {
                BatcherPublicKey = pubKeyHexStr,
                SignerPublickey  = pubKeyHexStr,
                FamilyName       = CREDITCOIN,
                FamilyVersion    = version
            };

            settings.Inputs.Add(prefix);
            settings.Outputs.Add(prefix);
            var encoder = new Encoder(settings, mSigner.GetPrivateKey());

            msg = null;
            return(encoder.EncodeSingleTransaction(map.EncodeToBytes()));
        }
Пример #4
0
        static void Main(string[] args)
        {
            if (args != null && (args.Count() < 2 || args.Count() > 3))
            {
                Console.WriteLine("Name and Verb arguments must be set.", Color.Red);
                Console.WriteLine("Usage: dotnet run [keyname] [verb] [optional value]");
                Console.WriteLine(" dotnet run intkey set 42\t- sets initial value");
                Console.WriteLine(" dotnet run intkey inc\t- increases existing value");
                Console.WriteLine(" dotnet run intkey dec\t- decreases existing value");
                return;
            }

            var name = args[0];
            var verb = args[1];

            var obj = CBORObject.NewMap()
                      .Add("Name", name)
                      .Add("Verb", verb);

            if (args.Count() == 3)
            {
                obj.Add("Value", Int32.Parse(args[2]));
            }

            var prefix = "intkey".ToByteArray().ToSha512().ToHexString().Substring(0, 6);
            var signer = new Signer();

            var settings = new EncoderSettings()
            {
                BatcherPublicKey = signer.GetPublicKey().ToHexString(),
                SignerPublickey  = signer.GetPublicKey().ToHexString(),
                FamilyName       = "intkey",
                FamilyVersion    = "1.0"
            };

            settings.Inputs.Add(prefix);
            settings.Outputs.Add(prefix);
            var encoder = new Encoder(settings, signer.GetPrivateKey());

            var payload = encoder.EncodeSingleTransaction(obj.EncodeToBytes());

            var content = new ByteArrayContent(payload);

            content.Headers.Add("Content-Type", "application/octet-stream");

            var httpClient = new HttpClient();

            var response = httpClient.PostAsync("http://localhost:8008/batches", content).Result;

            Console.WriteLine(response.Content.ReadAsStringAsync().Result);
        }
Пример #5
0
 public AudioEncoder(EncoderSettings settings, string path, Stream output = null)
 {
     m_path             = path;
     m_stream           = output;
     m_settings         = settings;
     m_streamGiven      = output != null;
     m_initialized      = false;
     m_finalSampleCount = 0;
     m_samplesWritten   = 0;
     m_blockOutput      = BlockOutputCallback;
     if (m_settings.PCM.BitsPerSample < 16 || m_settings.PCM.BitsPerSample > 24)
     {
         throw new Exception("bits per sample must be 16..24");
     }
 }
Пример #6
0
        public async Task <bool> SwatoothKeyStore(EncoderSettings settings, CBORObject obj)
        {
            if (obj != null && settings != null)
            {
                var res = await _key.InsertOneAsync(new KeyMaintainer()
                {
                    certficate  = Convert.ToBase64String(obj.EncodeToBytes()),
                    keysettings = Newtonsoft.Json.JsonConvert.SerializeObject(settings),
                    uname       = obj["Name"].AsString(),
                    CreatedAt   = DateTime.Now
                });

                return(res);
            }
            return(false);
        }
Пример #7
0
        public resData postMedicalRecord(string userId, string verb, string value)
        {
            var obj = CBORObject.NewMap()
                      .Add("Name", userId)
                      .Add("Verb", verb)
                      .Add("Value", value);
            var prefix = "intkey".ToByteArray().ToSha512().ToHexString().Substring(0, 6);
            var signer = new Signer();

            var settings = new EncoderSettings()
            {
                BatcherPublicKey = signer.GetPublicKey().ToHexString(),
                SignerPublickey  = signer.GetPublicKey().ToHexString(),
                FamilyName       = "intkey",
                FamilyVersion    = "1.0"
            };

            settings.Inputs.Add(prefix);
            settings.Outputs.Add(prefix);
            var encoder = new Sawtooth.Sdk.Client.Encoder(settings, signer.GetPrivateKey());

            var payload = encoder.EncodeSingleTransaction(obj.EncodeToBytes());
            //var payload = obj.EncodeToBytes();

            var content = new ByteArrayContent(payload);

            content.Headers.Add("Content-Type", "application/octet-stream");

            var httpClient = new HttpClient();

            var response = httpClient.PostAsync("http://localhost:8008/batches", content).Result;

            return(new resData()
            {
                response = response, encoderSettings = settings, obj = obj
            });
        }
Пример #8
0
        public void DoTranscoding(EncoderSettings encoderSettings, string inputFile)
        {
            _grabber = CdRipper.CreateGrabber(OutputFormat);
            if (_grabber == null)
            {
                throw new NotSupportedException(string.Format("TXT_UNSUPPORTED_OUTPUT_FORMAT: {0}", InputFormat));
            }

            switch (InputFormat)
            {
            case AudioMediaFormatType.WAV:
                switch (OutputFormat)
                {
                case AudioMediaFormatType.MP3:
                {
                    // Transcode WAV => MP3 i.o.w encode the wav
                    WaveFormatEx wfex    = WaveFormatEx.Cdda;
                    byte[]       buff    = WaveFile.ReadWaveData(inputFile, ref wfex);
                    GrabberToMP3 grabber = (_grabber as GrabberToMP3);
                    grabber.Options = (encoderSettings as Mp3EncoderSettings).Options;


                    // Resample is not supported at this time.
                    // Specify the same settings as the input WAV file, otherwise we'll be failing.
                    grabber.Options.WaveFormat = wfex;

                    grabber.EncodeBuffer(buff,
                                         Path.ChangeExtension(inputFile, "MP3"),
                                         false, null);

                    return;
                }
                }
                break;

            case AudioMediaFormatType.MP3:
                switch (OutputFormat)
                {
                case AudioMediaFormatType.WAV:
                    // Transcode MP3 => WAV i.o.w decode the MP3
                    string outputFile = Path.ChangeExtension(inputFile, "WAV");
                    if (DecodeMP3ToWAV(inputFile, outputFile) == false)
                    {
                        throw new Exception("TXT_FAILED_CONVERSION_MP3_WAV");
                    }

                    return;

                case AudioMediaFormatType.MP3:
                {
                    // Transcode MP3 => MP3 i.o.w adjust MP3 encoding
                    string tempWavFile = Path.GetTempFileName();
                    if (DecodeMP3ToWAV(inputFile, tempWavFile) == false)
                    {
                        throw new Exception("TXT_FAILED_CONVERSION_MP3_TEMP_WAV");
                    }

                    WaveFormatEx wfex = WaveFormatEx.Cdda;
                    byte[]       buff = WaveFile.ReadWaveData(tempWavFile, ref wfex);

                    GrabberToMP3 grabber = (_grabber as GrabberToMP3);
                    grabber.Options = (encoderSettings as Mp3EncoderSettings).Options;

                    ID3FileInfoSlim ifiSlim =
                        new ID3FileInfoSlim(MediaFileInfo.FromPath(inputFile, false));

                    grabber.EncodeBuffer(buff,
                                         Path.ChangeExtension(inputFile, "REENC.MP3"),
                                         (encoderSettings as Mp3EncoderSettings).CopyInputFileMetadata,
                                         ifiSlim);

                    if (File.Exists(tempWavFile))
                    {
                        File.Delete(tempWavFile);
                    }

                    return;
                }
                }
                break;
            }

            throw new NotSupportedException(string.Format("TXT_UNSUPPORTED_TRANSCODING: {0}", this));
        }
Пример #9
0
 public IEncoder GetEncoder(EncoderSettings settings)
 {
     return(new HandbrakeEncoder());
 }