Edit stream with DDMODAPI_SET_STREAM_CB

Module API help / support section for programmers.

Moderators: Dreamer, FredB, X05

xosef1234
Just popping in
Posts: 5
Joined: Sat Nov 30, 2013 1:23 pm

Edit stream with DDMODAPI_SET_STREAM_CB

Postby xosef1234 » Sat Nov 30, 2013 1:31 pm

Hi,

I want to edit a non-dvb conform stream, but I cannot even get the stream from the tuner. Is there any example for DDMODAPI_SET_STREAM_CB? I succeeded in programming what I want using filter (DDMODAPI_START_FILTER) and writing to a file, but I want to have this in "real-time".

Furthermore, is it still true that the edited stream packet shall be 188 bytes or can it be e.g. less?

Thanks for any help

User avatar
rel
relocation
Posts: 2051
Joined: Fri Jun 16, 2006 9:50 am

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby rel » Sun Dec 01, 2013 12:29 pm

currently should be 188 bytes, but tell me your device type/model and I'll try to help work around 188 byte limitation

In module SDK, check "how to modify whole TS stream for DD input .txt" file
under DreamSDK\Doc folder
DVB Dream - because I have to dream about having time to code it
xosef1234
Just popping in
Posts: 5
Joined: Sat Nov 30, 2013 1:23 pm

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby xosef1234 » Sun Dec 01, 2013 1:29 pm

I cannot find the file "how to modify whole TS stream for DD input .txt" in the DreamSDK
can you advice where to find it or maybe upload?

I am using a TeVii S660 BDA DVB-S2
User avatar
rel
relocation
Posts: 2051
Joined: Fri Jun 16, 2006 9:50 am

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby rel » Tue Dec 03, 2013 10:20 am

how to modify whole TS stream for DD input :

Code: Select all

Now with DVB Dream version 1.5g beta 2 , there is a new Module API function "DDMODAPI_SET_STREAM_CB".
This function will allow the modules modify the incoming stream.
This feature can allow you to develop modules which can convert other standards to DVB standard. or for some advanced descrambling


EXAMPLE (in object pascal):

const
DDMODAPI_SET_STREAM_CB = $0010006C; // sets stream callback to modify the steam
DDMODAPI_FREE_STREAM_CB = $0010006D; // frees stream callback to modify the steam

// This function gets TS packets and send them back to the DD
function StreamCallback(InBuf: Pointer; InLen: Integer; pOutBuf: PPointer; pOutLen: PInteger): BOOL;
stdcall;
begin
copymemory(buf, InBuf, InLen); // possible to modify stream here instead of copying as is.
pOutBuf^ := buf;

// pOutBuf^ := InBuf; // use this when there is no need to do any change on the TS packets
pOutLen^ := InLen;
end;



// Initialize the buffer and set up the callback
// should be done during module initialization
var
buf: pbytearray = nil;
begin
getmem(buf, 188);
SendMessage(DDWindowHandle, WM_MODULE_MSG, DDMODAPI_SET_STREAM_CB, Integer(@StreamCallback));
end;









EXAMPLE (in C):

// I am not sure this one will work, only tested the object pascal version above. please refer
// to that code piece, if you get any compile error
// Last two parameters of the callback function are a pointer to pointer and pointer to int.

#define DDMODAPI_SET_STREAM_CB 0x0010006c // sets stream callback to modify the steam
#define DDMODAPI_FREE_STREAM_CB 0x0010006d // frees stream callback to modify the steam

// This function gets TS packets and send them back to the DD
BOOL StreamCallback(unsigned char *InBuf, int InLen, void *pOutBuf, int *pOutLen): BOOL;
stdcall;
begin
copymemory(buf, InBuf, InLen); // possible to modify stream here instead of copying as is.
(unsigned char *)*pOutBuf := buf;

// (unsigned char *)*pOutBuf := InBuf; // use this when there is no need to do any change on the TS packets
*pOutLen := InLen;
end;


// Initialize the buffer and set up the callback
// should be done during module initialization

unsigned char *buf = NULL;
buf = (unsigned char *) malloc(188);
SendMessage((DDWindowHandle, WM_MODULE_MSG, DDMODAPI_SET_STREAM_CB, &StreamCallback);




tell me which device you run ? bda.dev or tevii.dev ? (which one is selected in devices dialog ? main menu->options->devices)
For DVB Dream, the output of the function above should be 188 bytes, so if input stream less than 188 bytes, it should be modified and should be compatible with DVB. Tevii device currently tries to sync to 0x47 sync byte of TS. and assumes all data 188 bytes packets. So if you think , you can receive any other size packets, let me know. we will need to modify tevii device (or BDA device) interface.
Attachments
how to modify whole TS stream for DD input .txt
(2.33 KiB) Downloaded 493 times
DVB Dream - because I have to dream about having time to code it
xosef1234
Just popping in
Posts: 5
Joined: Sat Nov 30, 2013 1:23 pm

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby xosef1234 » Tue Dec 03, 2013 3:29 pm

thank you for uploading

however, it doesn't work; I do not get any TS package, no sync byte is even present
the bytearrays I receive are almost constant, even the length of the input data (InLen) is strange

I am not sure where the error is (maybe it is me? :oops: )

with BDA 3.0.84
InLen = 5857632 (but only 376 bytes can be recorded/accessed)
InBuf =
1st 188Bytes of 1st callback call
e0 85 b2 06 04 fe da 06 f3 71 d3 6d e0 85 b2 06 bc 00 00 00 30 56 5e 02 a8 fa 6f 01 14 fe da 06 a9 13 d3 6d 00 e0 05 00 00 00 00 00 24 fe da 06 66 49 d3 6d e0 85 b2 06 00 e0 05 00 40 fe da 06 40 49 d3 6d 00 00 00 00 00 00 00 00 e0 85 b2 06 00 e0 05 00 00 00 00 00 88 fe da 06 78 5d e8 67 48 e4 d3 6d 00 00 00 00 00 00 00 00 e0 85 b2 06 00 e0 05 00 00 00 00 00 a8 fc 6f 01 30 56 5e 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 96 98 00 00 00 00 00 00 e0 05 00 9c fe da 06 54 04 ec 67 e0 85 b2 06 00 00 00 00 68 91 6f 01 b8 fe da 06 e1 c7 c0
1st 188Bytes of 2nd callback call
fa 3b 5a 00 04 fe da 06 f3 71 d3 6d fa 3b 5a 00 bc 00 00 00 30 56 5e 02 a8 fa 6f 01 14 fe da 06 a9 13 d3 6d 00 e0 05 00 00 00 00 00 24 fe da 06 66 49 d3 6d e0 85 b2 06 00 e0 05 00 40 fe da 06 40 49 d3 6d 00 00 00 00 00 00 00 00 e0 85 b2 06 00 e0 05 00 00 00 00 00 88 fe da 06 78 5d e8 67 48 e4 d3 6d 00 00 00 00 00 00 00 00 e0 85 b2 06 00 e0 05 00 00 00 00 00 a8 fc 6f 01 30 56 5e 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 96 98 00 00 00 00 00 00 e0 05 00 9c fe da 06 54 04 ec 67 e0 85 b2 06 00 00 00 00 68 91 6f 01 b8 fe da 06 e1 c7 c0

with tevii 1.0.0
InLen = 385024 = 2048*188 ?! (I tried accessing up to 18800 bytes -> possible)
InBuf =
1st 564 Bytes of 1st callback call
68 a4 e3 06 44 fe 11 07 17 19 7b 03 68 a4 e3 06 bc 00 00 00 5c fe 11 07 da 19 7b 03 68 a4 e3 06 10 2f 53 06 c8 2e 53 06 10 bb 32 00 6c fe 11 07 50 13 7b 03 68 a4 e3 06 00 e0 05 00 b8 fe 11 07 1f 35 c0 6d 00 00 00 00 68 a4 e3 06 00 e0 05 00 6b 90 4d e5 00 00 00 00 58 0a 5d 02 10 bb 32 00 10 2f 53 06 c4 ff 11 07 48 5b c1 6d 00 00 00 00 e1 c7 8a 6d 68 a4 e3 06 10 bb 32 00 58 0a 5d 02 68 0b 5d 02 10 bb 32 00 d0 fe 11 07 5c c7 8a 6d 10 bb 32 00 48 c6 32 00 f8 0e 61 02 38 c6 32 00 4c ff 11 07 f1 ef 8b 6d 68 0b 5d 02 10 bb 32 00 00 00 00 00 70 b0 32 00 e0 91 32 00
ac bd 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3c 03 00 00 60 03 00 00 5c 03 00 00 7c 03 00 00 8f 06 90 77 94 06 90 77 a4 38 ef 70 00 00 00 00 a0 bc 32 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c4 ff 11 07 64 ff 11 07 b3 d2 8a 6d 84 17 5d 02 01 00 00 00 03 00 00 00 a0 bc 32 00 88 ff 11 07 21 31 8b 6d 00 00 00 00 e0 91 32 00 00 00 00 00 00 00 00 00 a0 bc 32 00 00 00 00 00 00 00 00 00 94 ff 11 07 e9 d2 bb 76 a0 bc 32 01 d4 ff 11 07 03 16 90 77 a0 bc 32 00 3c 38 ef 70 00 00 00 00
00 00 00 00 a0 bc 32 00 00 00 00 00 00 00 00 00 00 00 00 00 a0 ff 11 07 00 00 00 00 ff ff ff ff a2 9a 8c 77 c0 8e 6f 00 00 00 00 00 ec ff 11 07 d6 15 90 77 8a 2f 8b 6d a0 bc 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8a 2f 8b 6d a0 bc 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
rest of bytes are 00
1st 564 Bytes of 2nd callback call
f0 c2 dd 06 44 fe 11 07 17 19 7b 03 f0 c2 dd 06 bc 00 00 00 5c fe 11 07 da 19 7b 03 f0 c2 dd 06 10 2f 53 06 c8 2e 53 06 c0 ba 32 00 6c fe 11 07 50 13 7b 03 f0 c2 dd 06 00 e0 05 00 b8 fe 11 07 1f 35 c0 6d 00 00 00 00 f0 c2 dd 06 00 e0 05 00 6b 90 4d e5 00 00 00 00 58 0a 5d 02 c0 ba 32 00 10 2f 53 06 c4 ff 11 07 48 5b c1 6d 00 00 00 00 e1 c7 8a 6d f0 c2 dd 06 c0 ba 32 00 58 0a 5d 02 68 0b 5d 02 c0 ba 32 00 d0 fe 11 07 5c c7 8a 6d c0 ba 32 00 80 c7 32 00 30 0f 61 02 70 c7 32 00 4c ff 11 07 f1 ef 8b 6d 68 0b 5d 02 c0 ba 32 00 00 00 00 00 80 b0 32 00 00 92 32 00 ac
bd 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3c 03 00 00 60 03 00 00 5c 03 00 00 78 03 00 00 8f 06 90 77 94 06 90 77 a4 38 ef 70 00 00 00 00 a0 bc 32 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c4 ff 11 07 64 ff 11 07 b3 d2 8a 6d 84 17 5d 02 01 00 00 00 03 00 00 00 a0 bc 32 00 88 ff 11 07 21 31 8b 6d 00 00 00 00 00 92 32 00 00 00 00 00 00 00 00 00 a0 bc 32 00 00 00 00 00 00 00 00 00 94 ff 11 07 e9 d2 bb 76 a0 bc 32 01 d4 ff 11 07 03 16 90 77 a0 bc 32 00 3c 38 ef 70 00 00 00 00 00
00 00 00 a0 bc 32 00 00 00 00 00 00 00 00 00 00 00 00 00 a0 ff 11 07 00 00 00 00 ff ff ff ff a2 9a 8c 77 c0 8e 6f 00 00 00 00 00 ec ff 11 07 d6 15 90 77 8a 2f 8b 6d a0 bc 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8a 2f 8b 6d a0 bc 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
rest of bytes are 00
User avatar
rel
relocation
Posts: 2051
Joined: Fri Jun 16, 2006 9:50 am

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby rel » Thu Dec 05, 2013 2:12 pm

you try to access stream from inside a module, right? (DD mod file) and not from a standalone application / exe file ?
DVB Dream - because I have to dream about having time to code it
xosef1234
Just popping in
Posts: 5
Joined: Sat Nov 30, 2013 1:23 pm

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby xosef1234 » Thu Dec 05, 2013 2:49 pm

yes, of course, from inside a module
I just took your example....
the streamcallback function is executed without errors and the code inside is executed (for the beginning I am just writing the Inlen and Inbuf either to a file or to a richedit field)

as I said, before I made it with DDMODAPI_START_FILTER and there it works perfectly, but of course I can only write to a file or stream to vlc

I attach the mod-file as well as the source code - maybe you can have a look ?
Attachments
streamcallbacktest-20131205.rar
(235.48 KiB) Downloaded 499 times
User avatar
rel
relocation
Posts: 2051
Joined: Fri Jun 16, 2006 9:50 am

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby rel » Thu Dec 05, 2013 4:27 pm

You forgot stdcall; for your callback definition. Add this to function definition

function StreamCallback(InBuf: Pointer; InLen: Integer; pOutBuf: PPointer; pOutLen: PInteger): BOOL; stdcall;

InLen should work fine.


Will you use Tevii.dev or BDA.dev for your further tests?
Tell me what you are trying to do. If you have a specific purpose. Is it DSS or ATSC related ?
DVB Dream - because I have to dream about having time to code it
xosef1234
Just popping in
Posts: 5
Joined: Sat Nov 30, 2013 1:23 pm

Re: Edit stream with DDMODAPI_SET_STREAM_CB

Postby xosef1234 » Fri Dec 06, 2013 3:46 pm

:oops:
you are right; with stdcall it works perfectly, sorry for that

at the moment I am still using BDA.dev - to be honest, up to now I couldn't see any difference
since I do not know whether further information can be provided publicly, I send you a pm

Return to “Module / Plugin Programming”

Who is online

Users browsing this forum: No registered users and 1 guest