|
No, I already answered your question: it will be called every 10 msec because you have only one single thread. A timer only post a message to your application message queue, which is handled in your main thread. It means that if your main thread is stuck 10 seconds in a specific function, no messages will be processed from the queue (even your timer message). So, your function will be called every 10 seconds only. There's no magic: if there's only one thread, you can only have one piece of code executed at a given time.
|
|
|
|
|
Ok.. I got it..
It is now clear.
Thanks
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
NiceNaidu wrote: Suppose If I have timer that gets fired every 1000 ms.
and the timer is calling a Sleep() for 10000 ms.
How this is going to behave ?
Why not write a program and find it out?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
How can I change the text of a menu item run-time if I have a CMenu* pointer?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
UINT id = m.GetMenuItemID(0);
m.ModifyMenu(ID_FILE_NEW32771, MF_BYCOMMAND, ID_FILE_NEW32771, _T("Hello"));
|
|
|
|
|
Thanks
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
You're welcome.
|
|
|
|
|
Hi @ all,
i´m trying to send an RTP Packet to a Server. My Packet Structure looks like this:
struct rtppacket
{
unsigned int version:2;
unsigned int padding:1;
unsigned int extension:1;
unsigned int csrcccount:4;
unsigned int marker:1;
unsigned int payloadtype:7;
unsigned int sequencenumber:16;
u_int32_t timestamp;
u_int32_t ssrc;
u_int32_t csrc[1];
void* datap;
int datalen;
};
that´s my way to fill and send the structure:
m_rtpPack.version = 2;
m_rtpPack.sequencenumber = 1;
m_rtpPack.csrc[0] = 0;
m_rtpPack.csrcccount = 0;
m_rtpPack.extension = 0;
m_rtpPack.marker = 1;
m_rtpPack.payloadtype = 0;
m_rtpPack.padding = 0;
m_rtpPack.ssrc = 0;
m_rtpPack.timestamp = GetTickCount();
...
...
m_rtpPack.datap = szBuffer;
m_rtpPack.datalen = sizeof(szBuffer);
nSend = sendto(m_Socket, (char*)&m_rtpPack, sizeof(m_rtpPack), 0, (SOCKADDR*)&m_saRemote, sizeof(SOCKADDR));
That doesn´t work. If I take a look of the RTP flow with packetyzer it can read the header information of rtp and the server can´t do something with incoming.
The structure padding compiler option is Zp1. What I do false?
Greetzs
Crazydogg
|
|
|
|
|
The problem is that you will send the pointer to the data (datap) and not the data itself. A pointer is 4 bytes (depending on the platform) that points to the data. Thus, when you send your structure, you will send the header correctly but for the data, you will send only the 4 bytes of the pointer. Same problem with calculating the size of the structure: it is always the same, no matter how large the buffer is (its not in the structure, it is only pointed by a member of your struct).
To fix the problem, you need to send it separateley: first the structure, as you already did (don't care about the data pointer yet), then the data buffer. On the receiver side, when you receive the data, you create a new buffer (in datap) and copy the data in it.
|
|
|
|
|
Ok I understand the problem, but I can´t influence the server side. It´s an extern Asterisk server. Because of that I have to send header and data together.
|
|
|
|
|
Is the buffer a fixed size buffer (e.g. always 1024 bytes) ?
If yes, then simply declare the buffer inside the structure:
struct MyStruct
{
...
...
unsigned char datap[1024];
...
};
|
|
|
|
|
The buffer is smaller in most cases but maximum is 1024.
I will try it so. Thank you
|
|
|
|
|
It also depends of what the serve epxects. But as the datasize field is after the data, it probably means that the server always expects 1024 bytes because it is impossible for it to know where the data field stops and where the datasize field starts.
|
|
|
|
|
So i´ve tried it as talk about. It doesn´t work too.
Is there yet another way to create this packet with header information and data?
|
|
|
|
|
CrazyDogg wrote: So i´ve tried it as talk about. It doesn´t work too.
What do you mean by doesn't work ?
|
|
|
|
|
I mean it´s the same problem as before.
|
|
|
|
|
What is the server expecting exactly ?
Post also some code of what you are doing now.
|
|
|
|
|
The Server expect a RTP Packet with RTP header information and data of payload type 0 also audio sample in uLaw Format.
All what I do now is that i´ve changed in structure from void* pData to char pData[1024]. Nothing else like before.
|
|
|
|
|
You can't just change the structure size and expect
it to work, especially if you can't alter the server code.
The server is expecting a certain number of bytes.
Also, RTP integer fields are supposed to be in network byte order
AFAIK, unless you're using your own version of RTP.
Besides fixing the pointer problem already discussed,
you need to fix your code so it implements the protocol
the server is expecting.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
you´re right with the network byte order. The server expect in BIG ENDIAN and my was for LITTLE ENDIAN.
Now it works correctly. Thanks a lot.
|
|
|
|
|
|
did you put file.c in another directory than the one having your own sources ?
this error message is typical of when the compiler doesn't find the implementation of something (function, class, macro, ...) used elsewhere.
|
|
|
|
|
|
Chesnokov Yuriy wrote: You can not use C functions in non static MFC application functions
nowhere in the original question was mentionned that the C function was static !
|
|
|
|
|
As far as I know (I'm not a C expert), if you declare a C function static, its scope will be limited to the file in which it has been defined. So, you can't use it from another file.
Why do you need to have it static ?
Chesnokov Yuriy wrote: static BOOL CSomeDlg::OnInitDialog() //can not be static
{
//...
}
You can't declare OnInitDialog as static: it is implemented from the base CDlg class. A static member function means that the function doesn't not belong to a particular instance of the class (so you can access it using the :: operator: CSomeDlg::MyFunction() ).
|
|
|
|