Jump to content

Plugin SDK and Visual C++


Recommended Posts

Hello:

I'm playing with the plugin SDK using Visual C++, finding the experience so frustrating. After fighting with the SDK, finally I got a "working" plugin. That is, the plugin loads, the SetAppHandle works, the SetMenuHandle works and the Execute (plugin) works, but in the TTuner and TPluginPids I obtain this:

 

------Cambio de canal -------------------------------------

Fecha y hora del cambio: 07/18/06 09:42:24

Contens of struct TTuner:

Frequency: 794000 (0xC1D90)

Symbol rate: 6875 (0x1ADB)

LNB: 16842752 (0x1010000)

ECM: 229 (0xE5)

FEC: 3 (0x3)

Polarity: 0 (0x0)

LNB selection: 3 (0x3)

DiSEqC: 282 (0x11A)

Audio PID: 26214681 (0x1900119)

Tele PID: 18415896 (0x1190118)

Service ID: 1650543383 (0x62614B17)

Lista de PIDs: (contens of array TPluginPids)

PID[0]=8191 (0x1FFF)

PID[1]=0 (0x0)

PID[2]=-1606352896 (0xA0410000)

PID[3]=0 (0x0)

PID[4]=0 (0x0)

PID[5]=1244784 (0x12FE70)

PID[6]=4808858 (0x49609A)

PID[7]=2089949425 (0x7C9218F1)

PID[8]=15848156 (0xF1D2DC)

PID[9]=16387936 (0xFA0F60)

PID[10]=15338304 (0xEA0B40)

 

The settings for this frecueny are (I taked them from the channellist):

Frecuency=794000 (0xC1D90)

Symbol rate: 6875 (0x1ADB)

Video PID=781 (0x0119)

Audio PID=282 (0x011A)

SID=280 (0x0118)

PMT PID=257 (0x0101)

PCR PID=281 (0x0119)

 

As you can see, contens of TTuner seems to be mixed (audio PID in DiSEqC, PMT PID in LNB, etc) and the PID array have nothing I can recognize. I use cable, not satellite (technisat cablestar 2 PCI).

 

I defined the struct and the array this way in a header file:

 

#define DllExport extern "C"

typedef struct ElTuner {

char TunerType;

DWORD Frequency;

DWORD SymbolRate;

DWORD LNB;

UINT ECM;

char Unused;

char AC3;

DWORD FEC;

DWORD Polarity; //| Modulation |GuardInterval

DWORD LNBSelection;

DWORD DiSEqC;

DWORD AudioPid;

DWORD VideoPid;

DWORD TelePid;

DWORD ServiceID;

} TTuner;

 

typedef void (__stdcall* TRebuildFunc)(TTuner *);

typedef int TPluginPids[11];

 

And have this code in a .cpp file:

 

DllExport bool __stdcall Execute(TTuner *PTuner, TPluginPids *PPluginPids){

FILE *archivo;

char fecha[11];

char hora[11];

int x;

 

archivo=fopen("volcado.txt","a"); //abre para añadir. si no hay archivo, lo crea

fprintf(archivo,"\n------Cambio de canal -------------------------------------\n");

fprintf(archivo,"Fecha y hora del cambio: %s %s\n", _strdate(fecha), _strtime(hora));

fprintf(archivo,"Frequency: %lu (%lX)\n",PTuner->Frequency, PTuner->Frequency);

fprintf(archivo,"Symbol rate: %lu (%lX)\n",PTuner->SymbolRate, PTuner->SymbolRate);

fprintf(archivo,"LNB: %lu (%lX)\n",PTuner->LNB,PTuner->LNB );

fprintf(archivo,"ECM: %lu (%lX)\n",PTuner->ECM,PTuner->ECM );

fprintf(archivo,"FEC: %lu (%lX)\n",PTuner->FEC,PTuner->FEC );

fprintf(archivo,"Polarity: %lu (%lX)\n",PTuner->Polarity,PTuner->Polarity );

fprintf(archivo,"LNB selection: %lu (%lX)\n",PTuner->LNBSelection,PTuner->LNBSelection );

fprintf(archivo,"DiSEqC: %lu (%lX)\n",PTuner->DiSEqC,PTuner->DiSEqC );

fprintf(archivo,"Audio PID: %lu (%lX)\n",PTuner->AudioPid,PTuner->AudioPid );

fprintf(archivo,"Tele PID: %lu (%lX)\n",PTuner->TelePid,PTuner->TelePid );

fprintf(archivo,"Service ID: %lu (%lX)\n",PTuner->ServiceID,PTuner->ServiceID );

fprintf(archivo,"Lista de PIDs:\n");

for(x=0;x<11;x++){

fprintf(archivo,"PID[%i]=%i (%X)\n",x,*(PPluginPids[x]),*(PPluginPids[x]));

}

 

fclose(archivo);

return false;

}

 

I managed to send messages to DVBViewer via SendMessage, grabbing the DVBViewer handle with SetAppHandle.

so, what's wrong?

 

thanks for your attention.

Link to comment
Do you mean the /Zp (Struct Member Alignment) compiler option? Is set as "Default". I haven't change any of the project options.

 

I don't know the Visual C compiler options. I'm using Borland C.

But you should check, that the alignment setting meets the requirements of the plugin interface (or maybe Delphi ?). I don't know.

 

You can wait for one of the programmers to answer the questions (they are not very busy her in the moment :) ) or you can look in hex mode into the structures memory area (with the debugger) and try to find out by yourself. :bye:

 

The default setting for Borland C++ Builder 4 ist 32bit alignment - but maybe it depents on the target machine setting.

 

Sorry, no facts. Only a lot of presumptions ;)

 

But if you find out, please tell me. I will run into the same problems in a few weeks.

 

dgdg

Edited by dgdg
Link to comment

Thanks Griga. I never thought it was an alignment trouble.

 

Another question but related: if I call TRebuildFunc in the same Execute function, the channel list gets, well, not "corrupted", but the name of the channel and the EPG info goes to another channel. Could this be caused by the bad alignment of the TTuner struct? Now I think so.

 

And the last one: Where can I find a list of PIDs to use instead of TPluginPIDs?

 

Thanks for the help.

Link to comment

@Griga

 

To make shure I've got it right, I have to ask again.

 

In the thread you mentioned I found this confusing statement:

 

- The Delphi Compiler does a 4-bytes-alignment for all DWord values. So if a value that occupies only one byte is followed by a DWord or Integer, there will be up to three unused bytes in between (e.g. after the first member "Tunertype", an enumerated type, that is coded as a byte, and the subsequent DWord Frequency).

 

Word values are aligned at 2-byte-boundaries respectively.

 

I think the last statement is not right. It's always 4-byte alignment independent from the type of the record variable !?

 

dgdg

Edited by dgdg
Link to comment

I did the same, but reading the memory positions of the struct TTuner. Also, I redefine the struct, considering all the members of the struct as DWORD. I obtained this:

 

Contens of the memory positions starting in TTuner first address

(and walking byte per byte):

 

TunerType :00 00 00 00

Frequency :10 5C 0C 00

SymbolRate :DB 1A 00 00

LNB :00 00 28 00

ECM :55 04 00 00

Unused :06 00 00 18

AC3 :03 00 00 00

FEC :00 00 00 00

Polarity :03 00 00 00

LNB Selection:4E 04 00 00

DiSEqC :4D 04 F4 01

AudioPid :00 00 41 A0

VideoPid :4C 04 4D 04

TelePid :17 4B 61 62

ServiceID :65 6C 20 28

 

Contens of struct TTuner when all its members are defined as type DWORD:

(struct alignment as default, doesn't matter due to using all DWORD)

 

Tuner type : 0 (0x00000000)

Frequency : 810000 (0x000C5C10) -> OK

Symbol rate : 6875 (0x00001ADB) -> OK

LNB : 2621440 (0x00280000) -> 0x0028=PMT PID

ECM : 1109 (0x00000455) -> OK

Unused : 402653190 (0x18000006)

AC3 : 3 (0x00000003)

FEC : 0 (0x00000000)

Polarity : 3 (0x00000003)

LNB selection: 1102 (0x0000044E) -> 0x044E=Audio PID

DiSEqC : 32769101 (0x01F4044D) -> 0x044D=Video PID or PCR; 0x01F4=????

Audio PID : 2688614400 (0xA0410000) -> 0xA041=????

Video PID : 72156236 (0x044D044C) -> 0x044D= Video PID or PCR; 0x044C=SID

Tele PID : 1650543383 (0x62614B17) -> ????

Service ID : 673213541 (0x28206C65) -> ????

 

Teletext PID for this channel: don't have teletext.

Video PID and PCR are the same for this channel.

EMM PID: 0x004B (grabbed with TSReader)

 

So, if there are no problems with the alignment, the information is still mixed. Whats now? I'm so confused.

 

Help will be appreciated.

Edited by hal90000
Link to comment

Hi,

 

this information is not so helpful because the associated DVBViewer data is missing.

 

I can only see, what the values actually look like and not what it should look like. In your first posting you told us different values.

 

Best you write the expected values directly beside the current value (all values, not only the wrong ones).

Than you can see if the structures actually match.

 

dgdg

Edited by dgdg
Link to comment

Here's what the delphi 4 bytes alignment does:

 

type
 MyRec = record
b1: Byte;  //-> offset 0
//1 byte unused
w: Word;  //-> offset 2
b2: Byte;  //-> offset 4
b3: Byte; //-> Offset 5
//2 bytes unused
dw: DWord; //-> offset 8
 end;

 

DWord values are located at offsets that are divisible by 4

Word values are located at offsets that are divisible by 2

Byte values and char strings can be located at any offset.

 

@hal90000: What do you want to achieve?

Link to comment
DWord values are located at offsets that are divisible by 4

Word values are located at offsets that are divisible by 2

Byte values and char strings can be located at any offset.

 

:);):D:D:wacko::wacko::wacko::wacko::wacko::wacko:

 

This is incompatible to Borland C++ Builder (Visual C++ I don't know). With Borland C++ it's Packed or Fixed Alignment (same for all types). So now chance to pass records directly from DVBViewer to Borland C++.

 

dgdg

Edited by dgdg
Link to comment

Hello:

Well, let's go step by step:

dgdg: Now, the contens of the memory positions, read byte to byte from the start of TTuner to the end, shows the same thing than in the struct:

 

Tuner type : 0 (0x00000000): I don't know if this is correct or not. Mine is a cable tuner.

Frequency : 810000 (0x000C5C10) -> OK. That's right. This is the frequency I tuned.

Symbol rate : 6875 (0x00001ADB) -> OK. That's right. My provider has this symbol rate.

LNB : 2621440 (0x00280000) -> Here appears the PMT PID of the channel tuned (0x0028). The PMT PID must be 0x0028, but appear 0x00280000. Don't know why. Anyway, mine is a cable tuner, so this must be zero.

ECM : 1109 (0x00000455) -> OK. The ECM of the channel tuned.

Unused : 402653190 (0x18000006)

AC3 : 3 (0x00000003) the stream goes in MPEG2. I don't know how to interpret this value, but I know somewhere in the forum explain how to interpret it.

FEC : 0 (0x00000000) Did I mention I use cable?

Polarity : 3 (0x00000003) See below

LNB selection: 1102 (0x0000044E) -> This is the Audio PID of the channel tuned (0x044E). See below

DiSEqC : 32769101 (0x01F4044D) -> Here appears the Video PID or the PCR PID. I don't know, this channel has the same Video PID and PCR PID. The other number, 0x01F4, don't know what is. Anyway, must be zero.

Audio PID : 2688614400 (0xA0410000) This number must be 0x044E instead of 0xA0410000

Video PID : 72156236 (0x044D044C) -> The first 4 bytes shows the Video PID or the PCR (0x044D); The next 4 bytes shows the SID of the channel tuned (0x044C). Must be 0x044D.

Tele PID : 1650543383 (0x62614B17) -> ????. The channel has no teletext. Must be zero.

Service ID : 673213541 (0x28206C65) -> ????. This must be 0x044C.

 

Griga: in Visual C++ the alignment (as Microsoft says) complete each variable in the struct with zero bytes. So, if I have this struct with 4 byte alignment:

struct example{

char a; //1 byte for the char followed by 3 bytes wasted

int b; //4 bytes for the int followed by 0 bytes wasted

WORD c; //2 bytes for the WORD followed by 2 bytes wasted

};

and the size of the struct example is 12 bytes.

 

What do I want to achieve? I want to make a plugin that, when I change channel, re-tune the channel another time. I don't know why, but when I change channel, I need to change again to the same channel to see it. This must be something concerning to my TV provider: the same occurs using other DVB viewers like MyTheatre or ProgDVB. That will be my second step.

My first step is understand the plugin API. I find this subject very interesting, and have two or three ideas for the future.

Link to comment

@hal90000

 

ok, I try to get this all together and come to this interpretetion:

 

TunerType:	00 00 00 00 (SET)
Frequency:	10 5C 0C 00 (DWORD)
SymbolRate:   DB 1A 00 00 (DWORD)
LNB:		  00 00 28 00 (DWORD)
ECM:		  55 04 (UINT)
Unused:	   00 (CHAR)
AC3:		  00 (CHAR)
FEC:		  06 00 00 18 (DWORD) 
Polarity:	 03 00 00 00 (DWORD)
LNBSelection: 00 00 00 00 (DWORD)
DiSEqC:	   03 00 00 00 (DWORD)
AudioPid:	 4E 04 00 00 (DWORD)
VideoPid:	 4D 04 F4 01 (DWORD)
TelePid:	  00 00 41 A0 (DWORD)
ServiceID:	4C 04 4D 04 (DWORD)

 

Hopefully without error, because it was not easy to gather this information from you different posts. ;)

 

It appears to be that depending on the data type only the first byte or the first to bytes are valid (except Frequency).

 

So all you have do to is to define you C++ structure as an packed structure and define the TunerType as DWORD. Then it should work.

 

The C structure given in the Plugin SDK manual is wrong. There is missing one important advice in the documentation: All informations are subject to change at any time without notice. :)

 

dgdg

Edited by dgdg
Link to comment

Hello again:

 

I'd been making a little research and those are my conclusions:

 

The description of the struct TTuner is bad. As you say, dgdg, all informations are subject to change, and this is one of them. It is not a problem with packet/alignment, or could be, but I don't want to fight against it. I decided to use this struct definition:

 

DWORD TunerType :00 00 00 00

DWORD Frequency :10 5C 0C 00

DWORD SymbolRate :DB 1A 00 00

WORD LNB :00 00

WORD PMT :28 00

WORD UNUSED1 (ecm pid) :55 04

BYTE UNUSED 2 :00

BYTE AC3 :00

WORD FEC :06 00

WORD UNUSED 3 :00 18

WORD POLARITY :03 00

WORD UNUSED 4 :00 00

WORD LNBSELECTION :00 00

WORD UNUSED 5 :00 00

WORD DISEQC :03 00

WORD UNUSED 6 :00 00

WORD AUDIOPID :4E 04

WORD UNUSED 7 :00 00

WORD VIDEOPID :4D 04

WORD TRANSPORT STREAMID:F4 01

WORD TELEPID :00 00

WORD NETWORK ID :41 A0

WORD SID :4C 04

WORD PCRPID :4D 04

 

I've found this information elsewhere in the forum, and is completely valid for me. Now everything is in its place and I don't have to change the struct alignment. And if this doesn't work, I can access the memory positions I need.

 

Anyway, this thing has never been a trouble for me. Visual C++ has many ways to access info located in memory. But is like an itch: things doesn't goes as they supposed to. Like the definition of the function SetAppHandle in the SDK: if you try to use it as described in the SDK, you get nuts!. Must be this way for Visual C++:

 

typedef void (__stdcall* TRebuildFunc)(TTuner *);// and no void __stdcall TRebuildFunc (PTuner Tuner)

 

extern "C" void __stdcall SetAppHandle(HWND, TRebuildFunc);// and no void __stdcall SetAppHandle(int Handle;TRebuildFunc RebuildFunc);

 

extern "C" void __stdcall SetAppHandle(HWND Handle, TRebuildFunc RebuildFunc){

// your stuff here

}

 

 

For Griga: if you mean Settings->Options->TV + Radio->Automatic channel data update, no way. I'm trying RebuildFunc inside Execute, trying to force a tune prior to the normal way of tuning:

 

extern "C" bool __stdcall Execute(TTuner *PTuner, TPluginPids *PPluginPids){

RebuildFunc(Ptuner);

}

 

Is this acceptable? I'm going to try again with the new TTuner definition.

 

Thanks.

Link to comment
Settings->Options->TV + Radio->Automatic channel data update

Not that one.

 

see options -> hardware

Which DVBViewer version do you use? It would be helpful to know.

Link to comment

Hello:

 

DVBViewer V3.2.6.80. Hey!, there is a new version! I didn't nottice.

Anyway, I'm going to install the new version and try this option.

 

A question: I can schedule and record programs with the DVBscheduler, and with this option set:

 

(from the ReadMe-DVBScheduler)

•Restart DVBViewer Without Tuning Last Channel:If this option is switched on, the DVB Task Scheduler generates tasks that launch the DVBViewer with the command line parameter -c, which sets the DVBViewer to its own standby mode. In this case no TV/radio will be played back, unless the scheduled recording actually starts.

 

I think this standby mode is my solution. Could you tell me how to put DVBViewer in this mode through the SDK plugin? If I put DVBViewer in this mode before I switch a channel, my problem will finish.

 

Thanks.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...