|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
i didnt get any usefull answer ..plzz i will appreciate any helppp !;)
|
|
|
|
|
Sorry I didn't see that you asked a question
Can't you use a StreamReader to read the lines? You can use the System.Convert class to
convert the strings back into the appropriate types.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Please don't cross post, choose a forum and stick to it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have an IP camera hooked up to my laptop - locally I can see video. How do I re-broadcast the video out my 2 network connection so it can be seen from the web, or at least another computer.
What I need is a netmeeting type project that can use an IP camera instead of a capture card.
tks
xlthim
|
|
|
|
|
Try hunting for IP camera Sony, www.axis.com might be a good sample.. alternatively, you can use your webcam to capture video and stream it over HTTP.. is you are looking for ready product for that.. LEADTOOLS might be of help.. if you have looking for sample code and want to learn the how-to of it, then you already are at codeproject.. so what are you waiting for buddy...
|
|
|
|
|
I've done that for some cameras that contain a web server in them (usually IP cameras do). All you have to do is implement the browser side. In my case a simple GET or POST is enough for the camera to start outputing JPEG sequences which you can forward as you like.
I've also encoutered other more complex servers that require the browser to install ActiveX controlls or something like that. I didn't want to go to all that trouble, so I just sniffed the packets with Ethereal, then saved them so that I can use them in my application. I don't know how they work (because I didn't bother looking at their contents), but they do.
Rilhas
|
|
|
|
|
Hi,
I'm looking for a plugin that allows to open Corel CMX files. I know this is a rather unusual request, but any help would be greatly appreciated.
Thanks in advance.
|
|
|
|
|
I need to create audio peaks for the audio stream from an AVI. For this I intend to use DirectShow by using SampleGrabber. I adapted some of the samples from the SDK.
There is only one problem here: I receive the audio samples in real-time (i.e. the same as I would be playing the file), but I need this process to be much faster. I was advised to set the graph SyncSource to NULL and by this the samples will be processed as quickly as possible. Unfortunatelly I get no effect by doing this.
I'm attaching here the code I'm using, perhaps I'm doing something wrong and somebody can help me out
Thanks alot !
#include <windows.h>
#include <streams.h>
#include <stdio.h>
#include <atlbase.h>
#include <qedit.h>
int GrabBitmaps(TCHAR * szFile);
HRESULT GetPin(IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin);
IPin * GetInPin ( IBaseFilter *pFilter, int Num );
IPin * GetOutPin( IBaseFilter *pFilter, int Num );
class CSampleGrabberCB : public ISampleGrabberCB {
public:
STDMETHODIMP_(ULONG) AddRef() { return 2; }
STDMETHODIMP_(ULONG) Release() { return 1; }
STDMETHODIMP QueryInterface(REFIID riid, void ** ppv) {
CheckPointer(ppv,E_POINTER);
if( riid == IID_ISampleGrabberCB || riid == IID_IUnknown ) {
*ppv = (void *) static_cast<ISampleGrabberCB*> ( this );
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP SampleCB( double SampleTime, IMediaSample * pSample ) {return 0;}
STDMETHODIMP BufferCB( double SampleTime, BYTE * pBuffer, long BufferSize ) {
_tprintf(TEXT("Found a sample at %f s\t[%ld]\r\n"), SampleTime , BufferSize );
return 0;
}
}
int _tmain(int argc, TCHAR* argv[]) {
if( argc != 2 || !argv || !argv[1] ) {
_tprintf( TEXT("GrabBitmaps: You must specify a media filename!\r\n") );
_tprintf( TEXT("Usage: GrabBitmaps Filename\r\n"));
return 0;
}
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
TCHAR szFile[MAX_PATH];
_tcsncpy(szFile, argv[1], MAX_PATH-1);
szFile[MAX_PATH-1] = 0;
int nSuccess = GrabBitmaps(szFile);
CoUninitialize();
return nSuccess;
}
int GrabBitmaps(TCHAR * szFile ) {
USES_CONVERSION;
CComPtr< ISampleGrabber > pGrabber;
CComPtr< IBaseFilter > pSource;
CComPtr< IGraphBuilder > pGraph;
CComPtr< IVideoWindow > pVideoWindow;
HRESULT hr;
if (!szFile) return -1;
_tprintf(TEXT("Grabbing bitmaps from %s.\r\n"), szFile);
pGrabber.CoCreateInstance( CLSID_SampleGrabber );
if( !pGrabber ) {
_tprintf( TEXT("Could not create CLSID_SampleGrabber\r\n") );
return -1;
}
CComQIPtr<IBaseFilter, &IID_IBaseFilter> pGrabberBase(pGrabber);
pSource.CoCreateInstance(CLSID_AsyncReader);
if (!pSource) {
_tprintf( TEXT("Could not create source filter\r\n") );
return -1;
}
pGraph.CoCreateInstance(CLSID_FilterGraph);
if( !pGraph ) {
_tprintf( TEXT("Could not not create the graph\r\n") );
return -1;
}
hr = pGraph->AddFilter( pSource, L"Source" );
hr = pGraph->AddFilter( pGrabberBase, L"Grabber" );
CComQIPtr<IFileSourceFilter, &IID_IFileSourceFilter> pLoad(pSource);
hr = pLoad->Load( T2W( szFile ), NULL );
if (FAILED(hr)) {
_tprintf( TEXT("Could not load the media file\r\n") );
return -1;
}
CMediaType GrabType;
GrabType.SetType(&MEDIATYPE_Audio);
GrabType.SetSubtype(&MEDIASUBTYPE_PCM);
GrabType.SetFormatType(&FORMAT_WaveFormatEx);
hr = pGrabber->SetMediaType(&GrabType);
CComPtr< IPin > pSourcePin;
CComPtr< IPin > pGrabPin;
pSourcePin = GetOutPin( pSource, 0 );
pGrabPin = GetInPin( pGrabberBase, 0 );
hr = pGraph->Connect( pSourcePin, pGrabPin );
if( FAILED( hr ) ) {
_tprintf( TEXT("Could not connect source filter to grabber\r\n") );
return -1;
}
CComPtr <IPin> pGrabOutPin = GetOutPin( pGrabberBase, 0 );
hr = pGraph->Render( pGrabOutPin );
if( FAILED( hr ) ) {
_tprintf( TEXT("Could not render grabber output pin\r\n") );
return -1;
}
hr = pGrabber->SetBufferSamples( FALSE );
hr = pGrabber->SetOneShot(FALSE);
CSampleGrabberCB CB;
hr = pGrabber->SetCallback(&CB, 1);
CComQIPtr<IMediaFilter, &IID_IMediaFilter> pFilter(pGraph);
hr = pFilter->SetSyncSource(NULL);
if (FAILED(hr)) printf("SetNoClock: Failed to set sync source! hr=0x%x\n", hr);
CComQIPtr<IVideoWindow, &IID_IVideoWindow> pWindow(pGraph);
if (pWindow) hr = pWindow->put_AutoShow(OAFALSE);
CComQIPtr< IMediaControl, &IID_IMediaControl > pControl( pGraph );
hr = pControl->Run( );
CComQIPtr< IMediaEvent, &IID_IMediaEvent > pEvent( pGraph );
long EvCode = 0;
hr = pEvent->WaitForCompletion( INFINITE, &EvCode );
_tprintf(TEXT("Sample grabbing complete.\r\n"));
return 0;
}
HRESULT GetPin( IBaseFilter * pFilter, PIN_DIRECTION dirrequired, int iNum, IPin **ppPin) {
CComPtr< IEnumPins > pEnum;
*ppPin = NULL;
HRESULT hr = pFilter->EnumPins(&pEnum);
if(FAILED(hr)) return hr;
ULONG ulFound;
IPin *pPin;
hr = E_FAIL;
while (S_OK == pEnum->Next(1, &pPin, &ulFound)) {
PIN_DIRECTION pindir = (PIN_DIRECTION)3;
pPin->QueryDirection(&pindir);
if (pindir == dirrequired) {
if (iNum == 0) {
*ppPin = pPin;
hr = S_OK;
break;
}
iNum--;
}
pPin->Release();
}
return hr;
}
IPin * GetInPin( IBaseFilter * pFilter, int nPin ) {
CComPtr<IPin> pComPin=0;
GetPin(pFilter, PINDIR_INPUT, nPin, &pComPin);
return pComPin;
}
IPin * GetOutPin( IBaseFilter * pFilter, int nPin ) {
CComPtr<IPin> pComPin=0;
GetPin(pFilter, PINDIR_OUTPUT, nPin, &pComPin);
return pComPin;
}
|
|
|
|
|
What do you need to do with the output - does it need to be rendered? Is there a video stream
as well as the audio stream?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I don't need to render the output, I just need to analyze it and write the results to another file. Yes, the input media file contains video as well as audio.
Claudiu
|
|
|
|
|
By using pGraph->Render(), you're getting the default renderers, right? In your current code,
does the audio play when you run the graph?
I'm thinking if you use the NULL Renderer filter on the outputs of the grabber and the AVI
Splitter (instead of the default renderers) then maybe the graph will run as fast as possible
with the sync source set to NULL.
I thought the audio renderer was determining the flow rate of samples through the graph, which is
why setting the sync source to NULL has no effect. If the AVI splitter is pushing samples at the
real-time rate, then you'd probably need a custom grabber filter.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Exactly, the audio gets played when I run the graph.
Can you please show me where to insert those filters in the graph? To make a test and see if it's working ?
Claudiu
|
|
|
|
|
After you connect the source filter to the grabber filter, there will be some splitter filter(s)
inserted in between by the graph builder. To get an idea of exactly which filter(s) are inserted
use GRAPHEDIT.EXE - Add a file source (async) filter, set it's input filename in the dialog,
add a grabber filter, and connect the output of the source to the input of the grabber. You'll
then see the inserted filter(s).
So after you connect the source filter to the grabber filter, You can traverse the partial graph
(as described here[^]) starting from the grabber's input pin. Unless an intermediate decoder filter
was needed for the audio stream, the next filter upstream should be a splitter filter (it may
be AVI, MPEG-1, or other depending on the file format). It should be the first filter you find
that has unconnected output pins (see Find an Unconnected Pin on a Filter[^]). For each of the
unconnected output pins, create a NULL renderer filter and connect its input pin to the
unconnected output pin.
Create another NULL Renderer filter and connect it to the grabber filter's output pin.
The graph should be complete at this point. You don't need to call pGraph->Render().
You'll still want to call SetSyncSource on the graph builder's IMediaFilter interface to set
the sync source to NULL.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I managed to create the NULL Renderer and insert it into the graph and it works !
The samples are received as I would expected.
Here's the modifications I made:
CComPtr<IBaseFilter> nullRenderer;
hr = nullRenderer.CoCreateInstance(CLSID_NullRenderer);
hr = pGraph->AddFilter(nullRenderer, L"NULL renderer");
CComPtr <IPin> nullGrabInPin = GetInPin(nullRenderer, 0);
CComPtr <IPin> pGrabOutPin = GetOutPin(pGrabberBase, 0);
pGraph->Connect(pGrabOutPin, nullGrabInPin);
Thanks so much for your help !
Now I have to find somewhere the format of the data received on BufferCB for audio PCM and I'm all done.
Claudiu
|
|
|
|
|
Claudiu Bucur wrote: Now I have to find somewhere the format of the data received on BufferCB for audio PCM
Maybe pGrabPin->ConnectionMediaType()
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
helloo guys..okie iam creating acode that can draw different shapes(lines, squar,..etc)thats done then save their info in text file ..(like the start point ,end point,..etc)..thats cool too ; BUTT the problem is its writting the last thing i draw ..(if i draw line then squar ..it writes squar twice)
// save the file
string str_Line;
System.IO.FileStream fs = new System.IO.FileStream("c:\\graphics.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
StreamWriter streamWriter=new StreamWriter(fs);
if(drawwhat==1)
{
for(int j=0;j less than arraylist_points.Count;j++)
streamWriter.WriteLine("Line");
start=(Point)arraylist_points[j];
end=(Point)arraylist_points[j+1];
str_Line=start.ToString()+end.ToString();
streamWriter.WriteLine(str_Line);
j++;
}
}
else if(drawwhat==2)
{
for(int j=0;j {
streamWriter.WriteLine("squar");
start=(Point)arraylist_points[j];
end=(Point)arraylist_points[j+1];
str_Line=start.ToString()+end.ToString();
streamWriter.WriteLine(str_Line);
j++;
}
}
streamWriter.Flush();
streamWriter.Close();
fs.Close();
}
//plzz brothers iam stuck !
|
|
|
|
|
I can't see where anything would be written twice, unless you have something in your
arraylist_points array twice..
How do you separate the start and end points when you read them in since they've been
concatenated?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
heloo my friend..okie my for loop like that :
for (int j=0; j < arraylist_points.Count; j++){...}
so lets say i draw squar then line ..it will be saved in text file as..:
Line
{X=83,Y=58}{X=257,Y=172}
Line
{X=165,Y=55}{X=71,Y=251}
its should write squar then line..not line twice..!!
|
|
|
|
|
Cool but the code you posted doesn't show anything except looping through an existing array.
If DrawWhat==1 it writes a bunch of lines (in a loop)
If DrawWhat==2 it writes a bunch of squares (in a loop)
If you want them written in a different order than that you'll need to code it that way
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
mr jets wrote: for(int j=0;j {
Check 'Ignore HTML tags in this message' to make your code render properly.
Have you stepped through the code ? Have you made sure the last item isn't actually in the list twice ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
mr jets wrote: BUTT the problem is its writting the last thing i draw
As I tell my team. When faced with a bug/issue you cannot explain, start verifying your assumptions. Step through the code with a debugger, generate a smaller sample to easily step through. If the bug is consistant, then you can reduce it to 2 or 3 shapes and still get the extra item, so single step through inspecting values. Debugging isn't magic, its just research into how the computer is dealing with your code, and finding where what you told it is inconsistant with what it is doing.
If you don't have a debugger, message boxes, print displays and other items have been an age-old custom to watching computer activity as it happens.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi, i am writing a small app which renders OpenGL to a frame inside a window. I want it to be rendered every time an event occurs such as creating a new file (which would reset the view). However, i also want to render in frames per second when it is enabled. In this case, a timer causes an event every, say, 100ms. Now, that event causes a render function to be called which copies the OpenGL screen to a texture, warps it, and renders it back. Every time any other event occurs, all that needs to be done is to draw the warped image.
So, how do i use SwapBuffers(HDC) twice, once in each render function, but so that the image does not flicker.
Download here[^] and get my WMP visualization here[^]. Run the program before you try to compile, because if Dev-Cpp can't compile it will delete the exe.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
don't copy the buffer, render straight to texture so that you can warp it to your heart's content.
http://www.paulsprojects.net/opengl/rtotex/rtotex.html[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I'm not sure if you know what i mean. Did you download my files? Look at the effect in my Visualization, that is the kind of effect i want.
Here is a pic: http://img519.imageshack.us/my.php?image=viz1kx4.png
Do you mean for me to render directly to a texture, then display that? How exactly would i do that?
btw, your link is broken
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|