|
Hi,
I just got a project about mutimedia network.
So ask some question about...
How to transfer a realtime video or audio.
What protocol support ?
And the best Encode method fo Audio & Video?
|
|
|
|
|
this doesnt have much to do with coding in c++ does it? maybe you should try a search engine, im sure you will find more information on statistics involved with audio/video compression somewhere else.
-dz
|
|
|
|
|
Try to take a look the site:
http://www.banasoft.net/AVPhone.htm
|
|
|
|
|
I am using a template class and everyithing works fine until I try to break my code into multiple files. Here is a minimal test case that demonstrates my problem. I am using Visual C++ 6 SP 5 Window XP.
******Solved*************
Visual C++ 6 requires that the implementation and declaration of a template reside in the same file. I can either put everything in the .cpp file or the .h but it has to be in one file.
//Onefile.cpp
#include <vector>
#include <iostream>
using namespace std;
template
class Test
{
public:
// constructors
Test(int size);
~Test() {};
// opertors
T & operator[](int offset) { return itsVector[offset];}
Show();
vector itsVector;
int itsLength;
};
template
Test::Test(int size)
: itsLength(size), itsVector(size)
{
for (int i = 1; i itsVector = i;
}
template
Test::Show()
{
for (int i = 1; i < itsLength; i++)
cout << itsVector[i] << ((i == itsLength-1) ? ('\n') : (','));
}
int main()
{
Test v(4);
v.Show();
v[1] = 9;
v.Show();
return 0;
}
This compiles links and executes just fine. Here is the problem.
//Test.h
#include <vector>
#include <iostream>
using namespace std;
template
class Test
{
public:
// constructors
Test(int size);
~Test() {};
// opertors
T & operator[](int offset) { return itsVector[offset];}
Show();
vector itsVector;
int itsLength;
};
//test.cpp
#include "Test.h"
template
Test::Test(int size)
: itsLength(size), itsVector(size)
{
for (int i = 1; i itsVector[i] = i;
}
template
Test::Show()
{
for (int i = 1; i < itsLength; i++)
cout << itsVector[i] << ((i == itsLength-1) ? ('\n') : (','));
}
//main.cpp
#include <iostream>
#include "Test.h"
using namespace std;
int main()
{
Test v(4);
v.Show();
v[1] = 9;
v.Show();
return 0;
}
When I try to build I get the following linking error.
main.obj : error LNK2001: unresolved external symbol "public: int __thiscall Test::Show(void)" (?Show@?$Test@H@@QAEHXZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall Test::Test(int)" (??0?$Test@H@@QAE@H@Z)
Debug/TestTemplate.exe : fatal error LNK1120: 2 unresolved externals
All the errors disapear if quit using templates.
Does anyone know what I am doing wrong?
|
|
|
|
|
Well, your syntax for using templates is wrong. The template declaration is as follows:
template<class mytype, ...>
class MyClass
{
...
This allows you to use a type called mytype or whatever. The class' member functions should be declared as follows:
template<class mytype, ...>
MyClass<mytype, ...>::MemberFunction
Finally, declare instances of the template class like this:
myClass<type (int, class, CString, whatever)> myVar;
This is the worst explanation of template syntax ever. You should read the MSDN documentation of templates. I'm surprised the code got through the compiler.
|
|
|
|
|
it's because everything between a pair of tags, <>, is interpreted as an html tag and therefore remove cause he forgot to turn off html interpretation.
|
|
|
|
|
|
First, you probably should send the source again with the "Display this message as-is (no HTML)" checked, so that it can be read.
Second, you need to have the template code available when you are compiling main.cpp - if you just have the template code in test.cpp but no actual code using it for a specific type, nothing gets expanded. Typically, you would put your template code in the test.h include file. You should not have a test.cpp file for this template class. Any source file that needs to use the templated class can then include test.h, and the templated functions will be expanded as needed.
Best regards,
John
|
|
|
|
|
Sorry this is my first post and I did not notice the <> disapearing. I found the answer to my problem at another forum. Thanks for the help.
|
|
|
|
|
If you post your answer, then other people can learn from this post as well.
What was your solution?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
That isn't specific to VC6. I don't even know of a compiler that supports templates where the definition isn't fully known to the module in question.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
The solution is to put the implementation in the .h file. I tried putting it in a .cpp and VC++ added it to the project resulting in multiple definitions. I even tried inclusion guards (#ifndef). So itstead I left it in the .h, .txt workes as well (I really don't like putting the implementation in a header file).
|
|
|
|
|
hi ...
i ve got yet another problem hope u guys could solve it...
ive copied an image in an array i.e ive copied the colours of that image in an array..
now i want to recopy dat image from the array in a separte file .. but ive failed so far..
hope u guys culd hlp me out
looking forward from all the gurus of code
|
|
|
|
|
pata hay kia ker....pehlay tiberain sun ki CD day kay ja phir bataon ga.;P
|
|
|
|
|
I have a program that I wrote that works like s webserver, or I want it to anyway. Clients will connect to a socket do something, then disconnect. Currently, I'm seeing weird behavior, but everythign is weird because this is new to me.
First, I'm using a socket wrapper from PJ Naughter's W3Mfc project.
I am under the impression that with web servers you connect to a well-known socket. Then the server 'bounces' you to a new socket so it can accept the next connection. The bounced connection is handled by a thread.
In my code, I have a basic server that Bind()s, Accept()s and allows for 5 connections.
In one function (and thread) I:
setup the server socket,
enter a while loop,
wait for an accept(),
do my stuff over the socket,
then close it.
Should I be firing off a new thread after I accept()?
Originally the code was written to handle a few connections a minute, but it looks like it may do several dozen now. I'm seeing the first 6 connections get accepted.. then the next few fail, then it's spotty. Would firing off a new thread fix this? How do I Accept() and start a thread safely (how do I pass the connected socket to the new thread?)
Thank you for your time.
|
|
|
|
|
What u said about ur impression that ure "bounced" to another socket is true.
And yes multithreading is a solution, but u should keep track of ur connected sockets in a linked list or stuff.
In order to pass the connected socket to the working thread, u can do it when launching the thread and that by doing:
AfxBeginThread ( WorkerThread , yourConnectedSocket ) ;
and in the worker thread u should do a cast on the type of the socket.
UINT WorkerThread ( LPVOID param )
{
if(!param)
return;
CSocket sock = (CSocket) param; // supposing ur socket is a CSocket
....
}
Papa
Murex Co.
|
|
|
|
|
you are corect, the concept is known as "completion ports"....search MSDN for this term, there was a good article in MSDN Mag last year on this.....Win2K Server has API support built in for allocating blocks of ports for this...
good luck
1. The Lord loves a workin' man.
2. See a doctor and get rid of it.
3. Don't trust whitey.
|
|
|
|
|
Hi, I have a problem, ... I need to close an application correctly (send a Message WM_CLOSE) but I kwown only the name of this application. This I get HANDLE with EnumProcessModules function, but i don't known how to send a message.
Thanks a lot
|
|
|
|
|
Ok then u have to FindWindow() it, then post this window a WM_CLOSE message.
Papa
Murex Co.
|
|
|
|
|
Thanks a lot, but my application hasn't Windows, it's only a Process on Memory, can I use FindWindow() to send the message WM_CLOSE ?
|
|
|
|
|
Hello, does anyone have experience using MySql and its C++Interface?
my problem is:
every time I try to fill a database using MySql++ the MySql-Server shuts down after a while. What is it due to ?
The Connection-Pointers are destroyed after Filling a record, so there should not be a "Too Many Connections"-Problem.
Versions:
MySql 3.23.42-nt,
mysql++-1.7.1-1-win32-vc++
|
|
|
|
|
Hi, all,
I want to print a snapshot of the activated window, I'v written some codes.
It works well if the printer is directly connected the computer, but if it
outputs to a network printer, it doesn't work, a paper is exported from the
printer, but nothing on it.
here is the code:
void CBaseTabSheet::OnFilePrint()
{
// TODO: Add your command handler code here
CRect rectWindow;
CWnd *pWnd;
CDC memDC;
if (GetParent()->IsZoomed()) {
pWnd = AfxGetMainWnd();
AfxGetMainWnd()->GetWindowRect(rectWindow);
} else {
pWnd = GetParent();
GetParent()->GetWindowRect(rectWindow);
}
CWindowDC dc(pWnd);
int nX = rectWindow.Size().cx;
int nY = rectWindow.Size().cy;
memDC.CreateCompatibleDC(&dc);
CBitmap *pBitmap = new CBitmap();
pBitmap->CreateCompatibleBitmap(&dc, nX, nY);
CBitmap * pOldBitmap = (CBitmap *)memDC.SelectObject(pBitmap);
memDC.BitBlt(0, 0, nX, nY, &dc, 0, 0, SRCCOPY);
CDC prtDC;
CPrintInfo printInfo;
DOCINFO di;
if (AfxGetApp()->GetPrinterDeviceDefaults(&printInfo.m_pPD->m_pd)) {
HDC hDC = printInfo.m_pPD->m_pd.hDC;
if (hDC == NULL) {
hDC = printInfo.m_pPD->CreatePrinterDC();
}
if (hDC != NULL) {
CString strTitle;
strTitle.LoadString(AFX_IDS_APP_TITLE);
prtDC.Attach(hDC);
memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = strTitle;
prtDC.m_bPrinting = TRUE;
if (prtDC.StartDoc(&di) != -1) {
prtDC.StartPage();
int X = prtDC.GetDeviceCaps(LOGPIXELSX);
prtDC.StretchBlt(0, 0, nX * X / 96, nY * X / 96,
&memDC, 0, 0, nX, nY, SRCCOPY);
prtDC.EndPage();
prtDC.EndDoc();
}
prtDC.Detach();
prtDC.DeleteDC();
}
}
memDC.SelectObject(pOldBitmap);
delete pBitmap;
memDC.DeleteDC();
}
Any suggestion? Thanks in advance
Vincent
|
|
|
|
|
You need to use the OpenPrinter function and then to use the StartDocPrinter and StartPagePrinter, WritePrinter functions...
Best Regards
Carlos Antollini.
www.wanakostudios.com
Sonork ID 100.10529 cantollini
|
|
|
|
|
Its probably because the printer driver does not support the BitBlt function. Convert your bitmap to a DIB and use StretchDIBBits.
You should then find it will work every time.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Hi, Roger Allen,
Thank you for your reply.
Could you tell me more details about how to conver the bitmap to DIB? As you can see my codes, I created a CBitmap object and selected it to a device, and copied the screen image to it. How can I conver this CBitmap object to DIB.
Thank you very much.
Vincent
|
|
|
|