[fpc-pascal] Pipe vs Memory buffer.
silvioprog
silvioprog at gmail.com
Fri Jan 27 04:35:02 CET 2017
On Thu, Jan 26, 2017 at 11:52 PM, fredvs <fiens at hotmail.com> wrote:
> Hello Silvio:
>
> Yes, we are on the good way.
>
Awesome. :-)
> Following your advice, here from https-url-opus the result of :
>
> var
> BufferURL: tbytes;
>
> setlength(BufferURL, PipeBufferSize);
> CreatePipeHandles(InHandle, OutHandle, PipeBufferSize);
> InPipe := TInputPipeStream.Create(InHandle);
> OutPipe := TOutputPipeStream.Create(OutHandle);
> httpget := TThreadHttpGetter.Create(url, OutPipe);
> InPipe.Read(BufferURL[0],PipeBufferSize);
>
> writeln(tencoding.utf8.getstring(BufferURL));
>
> ======>
>
> Lavf57.57.100 encoder=Lavc57.65.100 libopus title=Be Thankful%artist=For
> What You GotWilliam De Vau$album=Blaxploitation Vol.3 The Payba
> date=1997TRACKNUMBER=11OggS
[...]
Some streams requires you set its cursor to 0 before writing/reading
buffer, so you need to check it:
CreatePipeHandles(InHandle, OutHandle, PipeBufferSize);
InPipe := TInputPipeStream.Create(InHandle);
OutPipe := TOutputPipeStream.Create(OutHandle);
httpget := TThreadHttpGetter.Create(url, OutPipe);
OutPipe.Seek(0, soBeginning);
InPipe.Seek(0, soBeginning);
InPipe.Read(BufferURL[0],PipeBufferSize);
Notice tencoding was just for testing. :-)
--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170127/23097025/attachment.html>
More information about the fpc-pascal
mailing list