public bool Start() { injectionTask = Task.Factory.StartNew(delegate() { DataOutputStream = pipeClient; byte[] bytes = new byte[1000]; int result = InputStream.Read(bytes, 0, 1000); string bytesToFile = ByteArrayToString(bytes); string onMetaData = bytesToFile.Substring(27, 10); // if "onMetaData" exists then proceed to read the attributes if (onMetaData == "onMetaData") { int indexDuration = bytesToFile.IndexOf("duration"); double durationOld = GetNextDouble(bytes, indexDuration + 9, 8); double durationNew = ((double)this.context.MediaInfo.Duration) / 1000; byte[] newDur = DoubleToByteArray(durationNew, true); for (int i = 0; i < 8; i++) { bytes[indexDuration + 9 + i] = newDur[i]; } } String bytesToFileNew = ByteArrayToString(bytes); pipeServer.Write(bytes, 0, result); StreamCopy.AsyncStreamCopy(InputStream, pipeServer); }, TaskCreationOptions.LongRunning); return(true); }
public bool Start() { // wait for the input pipe to be ready if (transcoderInputStream is NamedPipe) { ((NamedPipe)transcoderInputStream).WaitTillReady(); } // copy the inputStream to the transcoderInputStream if (doInputCopy) { Log.Info("Encoding: Copy stream of type {0} into transcoder input stream of type {1}", InputStream.ToString(), transcoderInputStream.ToString()); StreamCopy.AsyncStreamCopy(InputStream, transcoderInputStream, "transinput"); } // delay start of next unit till our output stream is ready if (DataOutputStream is NamedPipe && (outputMethod == TransportMethod.NamedPipe || outputMethod == TransportMethod.StandardOut)) { Log.Trace("Transcoder running: {0}", !transcoderApplication.HasExited); Log.Info("Encoding: Waiting till output named pipe is ready"); ((NamedPipe)DataOutputStream).WaitTillReady(); } return(true); }
public bool Start() { // setup input if (inputMethod == InputMethod.NamedPipe) { ((NamedPipe)transcoderInputStream).WaitTillReady(); Log.Info("VLCManagedEncoder: Copy stream of type {0} into transcoder input pipe", InputStream.ToString()); StreamCopy.AsyncStreamCopy(InputStream, transcoderInputStream, "transinput"); } // delay start of next unit till our output stream is ready Log.Info("VLCManagedEncoder: Waiting till output named pipe is ready"); ((NamedPipe)DataOutputStream).WaitTillReady(); // TODO: wait for state machine // setup data thread infoReader = ThreadManager.Start("VLCInfoThread", InfoThread, context.StartPosition); return(true); }
public bool Start() { // setup input if (inputMethod == InputMethod.NamedPipe) { ((NamedPipe)transcoderInputStream).WaitTillReady(); StreamLog.Info(context.Identifier, "VLCManagedEncoder: Copy stream of type {0} into transcoder input pipe", InputStream.ToString()); StreamCopy.AsyncStreamCopy(InputStream, transcoderInputStream, "transinput"); } // delay start of next unit till our output stream is ready StreamLog.Info(context.Identifier, "VLCManagedEncoder: Waiting till output named pipe is ready"); ((NamedPipe)DataOutputStream).WaitTillReady(); // TODO: wait for state machine // setup the data reading infoReference = new Reference <WebTranscodingInfo>(() => context.TranscodingInfo, x => { context.TranscodingInfo = x; }); if (context.MediaInfo.Duration > 0) { StreamLog.Trace(context.Identifier, "VLCManagedInfo: duration known; is {0}", context.MediaInfo.Duration); calculator = new TranscodingInfoCalculator(context.StartPosition, 25, POLL_DATA_TIME, context.MediaInfo.Duration); } else { StreamLog.Trace(context.Identifier, "VLCManagedInfo: duration unknown"); calculator = new TranscodingInfoCalculator(context.StartPosition, 25, POLL_DATA_TIME); } // and setup the timer inputTimer = new Timer() { AutoReset = true, Interval = POLL_DATA_TIME }; inputTimer.Elapsed += InfoTimerTick; inputTimer.Start(); return(true); }
public bool Start() { // wait for the input pipe to be ready if (transcoderInputStream is NamedPipe) { ((NamedPipe)transcoderInputStream).WaitTillReady(); } // copy the inputStream to the transcoderInputStream if (doInputCopy) { Log.Info("Encoding: Copy stream of type {0} into transcoder input stream of type {1}", InputStream.ToString(), transcoderInputStream.ToString()); StreamCopy.AsyncStreamCopy(InputStream, transcoderInputStream, "transinput"); } // delay start of next unit till our output stream is ready if (DataOutputStream is NamedPipe && (outputMethod == TransportMethod.NamedPipe || outputMethod == TransportMethod.StandardOut)) { Log.Trace("Transcoder running: {0}", !transcoderApplication.HasExited); Log.Info("Encoding: Waiting till output named pipe is ready"); var pipe = (NamedPipe)DataOutputStream; var checkFailed = context != null && context.TranscodingInfo != null; while (!pipe.IsReady && !(checkFailed && context.TranscodingInfo.Failed)) { System.Threading.Thread.Sleep(100); } if (checkFailed && context.TranscodingInfo.Failed) { Log.Warn("Encoding: Aborting wait because transcoder application failed and will never setup output named pipe."); return(false); } } return(true); }
/// <summary> /// Reads characters from the streams and advances the position within each stream to the end. /// </summary> /// <param name="streams">The stream collection to read.</param> /// <param name="encoding">The encoding to read text.</param> /// <param name="closeStream">true if need close stream automatically after read; otherwise, false.</param> /// <returns>Bytes from the stream collection.</returns> /// <exception cref="NotSupportedException">The stream does not support reading.</exception> /// <exception cref="ObjectDisposedException">The stream has disposed.</exception> public static IEnumerable <char> ReadChars(StreamPagingResolver streams, Encoding encoding = null, bool closeStream = false) => ReadChars(StreamCopy.ToStreamCollection(streams), encoding, closeStream);
public bool Start() { StreamCopy.AsyncStreamCopy(InputStream, DataOutputStream, logIdentifier); return(true); }
public bool Start() { StreamCopy.AsyncStreamCopy(InputStream, segmenterApplication.StandardInput.BaseStream); return(true); }