[fpc-pascal] Pipe vs Memory buffer.
fredvs
fiens at hotmail.com
Sat Jan 28 13:32:53 CET 2017
Hello.
Some other news from the front:
var
BufferURL, buffadd: tbytes;
...
setlength(BufferURL, PipeBufferSize);
setlength(buffadd, PipeBufferSize);
CreatePipeHandles(InHandle, OutHandle, PipeBufferSize);
InPipe := TInputPipeStream.Create(InHandle);
OutPipe := TOutputPipeStream.Create(OutHandle);
httpget := TThreadHttpGetter.Create(url, OutPipe);
PipeBufferSize := 1024;
len2 := 0;
len := 1;
while (len2 < PipeBufferSize) and (len > 0) do
begin
len := InPipe.Read(buffadd[0],PipeBufferSize);
if len > 0 then for i := 0 to len -1 do
BufferURL[i+len2] := buffadd[i] ;
len2 := len2 + len;
end;
HandleOP := op_test_memory(BufferURL[0],PipeBufferSize, Err);
if Err=0
then begin
Err := op_test_open(HandleOP);
....
==============================>
...
Try to connect to
https://sites.google.com/site/fredvsbinaries/guit_kungs.opus
error: op_test_open: 0
OK open
OpusTag.comments = 6
ALBUM=Summer 2016
ARTIST=Kungs
DATE=2016
DESCRIPTION=Loop Guitar.
GENRE=Dance
TITLE=guit_kungs.opus
op_bitrate = 2147483647
Data.Channels 2
===========>
Yep, yep, yep, connected and retrieving the tag + infos ok.
The trick was to do a loop with InPipe.Read and add buffadd to BufferURL.
So, good, there is one step more.
Sadly, op_read_float(HandleOP, at Buffer[0], Wantframesl) does not work.
I suspect that some read callback must be define for reading.
There is a method for opening steams with custom callback:
OP_WARN_UNUSED_RESULT OggOpusFile *op_test_callbacks(void *_source,
const OpusFileCallbacks *_cb,const unsigned char *_initial_data,
size_t _initial_bytes,int *_error) OP_ARG_NONNULL(2);
Translated with this:
op_test_callbacks: function(const source; const cb: TOpusFileCallbacks;
const initial_data; initial_bytes: cuint;
out error: cint): TOpusFile;
But sadly I do not understand what is source and not sure what is
initial_data.
Also I do not understand how to deal with cb and assign read (to InPipe.Read
?)
TOpusFileCallbacks = record
read: op_read_func;
seek: op_seek_func;
tell: op_tell_func;
close: op_close_func;
end;
This does not work:
HandleOP := op_test_callbacks(pointer(InPipe),op_callbacks, BufferURL[0],
PipeBufferSize, err);
Huh, once again, your advices will be extremely appreciated.
Thanks.
Fre;D
-----
Many thanks ;-)
--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Pipe-vs-Memory-buffer-tp5727435p5727476.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
More information about the fpc-pascal
mailing list