Пример #1
0
        public bool Start()
        {
            DataOutputStream = pipeClient;

            injectionTask = Task.Factory.StartNew(delegate()
            {
                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);
            injectionTask.LogOnException();
            return true;
        }