Hi,
i am writing a c# application that use direct show to play mpg file but when
i declere a socket in my c# application i just cant play the file enymore,
It seems that the problem is because we are tring to write this lines:
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
TcpListener tcpServerListener = new TcpListener(ipAddress,5555);
And not the openning of thread!
When we just try to open or use win sock the file playin is hang like
someone blocking it!!!
The code that play the file is inside managed c++ class assembly the my c#
application link to it,
The c++ code for playing the file:
CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void **)&m_pGraph[m_nDevices]);
....
m_pGrabber[m_nDevices].CoCreateInstance( CLSID_SampleGrabber );
CComQIPtr< IBaseFilter, &IID_IBaseFilter >
pGrabBase(m_pGrabber[m_nDevices]);
HRESULT hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );
//Force it to connect to video, 24 bit
CMediaType VideoType;
VideoType.SetType( &MEDIATYPE_Video );
//VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 );
VideoType.SetSubtype( &MEDIASUBTYPE_YUY2 );
hr = m_pGrabber[m_nDevices]->SetMediaType( &VideoType ); // shouldn't fail
hr = m_pGraph[m_nDevices]->QueryInterface(IID_IMediaSeeking, (void
**)&m_pMediaSeeking[m_nDevices]);
hr =m_pMediaSeeking[m_nDevices]->SetTimeFormat(&TIME_FORMAT_FRAME);
// add the grabber to the graph
//hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );
hr = m_pGrabber[m_nDevices]->SetBufferSamples( FALSE );
hr = m_pGrabber[m_nDevices]->SetOneShot( FALSE );
hr = m_pGrabber[m_nDevices]->SetCallback(&mCB[m_nDevices], 1 );
//LPCWSTR str1=(LPCWSTR)str;
hr = m_pGraph[m_nDevices]->RenderFile((LPCWSTR)lstr, NULL);
hr = m_pGraph[m_nDevices]->QueryInterface(IID_IMediaControl, (void
**)&m_pMediaControl[m_nDevices]);
LONGLONG lDuration,lPos,lPos1,llAmount=0;
hr = m_pMediaSeeking[m_nDevices]->SetTimeFormat(&TIME_FORMAT_FRAME);
hr = m_pMediaSeeking[m_nDevices]->GetDuration(&lDuration);
hr = m_pMediaSeeking[m_nDevices]->GetCurrentPosition(&lPos);
hr = m_pMediaSeeking[m_nDevices]->GetStopPosition(&lPos1);
IBasicVideo* pVideo;
hr = m_pGraph[m_nDevices]->QueryInterface(IID_IBasicVideo,(void **)&pVideo);
LONG lWidth, lHeight;
hr = pVideo->GetVideoSize(&lWidth,&lHeight);
REFTIME rtTime;
hr = pVideo->get_AvgTimePerFrame(&rtTime);
double dRate;
dRate = 1.0/rtTime;
llAmount=(LONGLONG)(lPos1/dRate);
// ask for the connection media type so we know how big
// it is, so we can write out bitmaps
//
AM_MEDIA_TYPE mt;
ZeroMemory(&mt,sizeof(mt));
hr = m_pGrabber[m_nDevices]->GetConnectedMediaType( &mt );
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
int h=(int)vih->bmiHeader.biHeight;
int w=(int)vih->bmiHeader.biWidth;
FreeMediaType( mt );
//mCB[m_nDevices].m_hWinHwd=g_hwnd;
// Specify the owner window.
m_pGraph[m_nDevices]->QueryInterface(IID_IVideoWindow, (void
**)&m_pWindow[m_nDevices]);
m_pWindow[m_nDevices]->put_Owner((OAHWND)g_hwnd);
m_pWindow[m_nDevices]->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
RECT grc;
GetClientRect(g_hwnd, &grc);
//::ScreenToClient(&grc);
m_pWindow[m_nDevices]->SetWindowPosition(grc.left, grc.top,
(grc.right-grc.left), (grc.bottom-grc.top));
// Run the graph.
m_pMediaControl[m_nDevices]->Run();
Everything work fine and playing whell until I write the line above to
define the socket, Why???
I am using the
class CSampleGrabberCB : public ISampleGrabberCB
{
....
}
Class for grabing the file frame and when I use the socket it seems that the
callback function of this class or the thread that run this class is beeing
hang because of the declering of the socket!!!
I try every thing and I think that it is a microsoft bug!!!
Do you have any idea???
Thanks! 1 2950
did you try the computer name instead?
"Dave" wrote: Hi,
i am writing a c# application that use direct show to play mpg file but when i declere a socket in my c# application i just cant play the file enymore,
It seems that the problem is because we are tring to write this lines:
IPAddress ipAddress = Dns.Resolve("localhost").AddressList[0];
TcpListener tcpServerListener = new TcpListener(ipAddress,5555);
And not the openning of thread!
When we just try to open or use win sock the file playin is hang like someone blocking it!!!
The code that play the file is inside managed c++ class assembly the my c# application link to it,
The c++ code for playing the file:
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,IID_IGraphBuilder, (void **)&m_pGraph[m_nDevices]);
....
m_pGrabber[m_nDevices].CoCreateInstance( CLSID_SampleGrabber );
CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase(m_pGrabber[m_nDevices]);
HRESULT hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );
//Force it to connect to video, 24 bit
CMediaType VideoType;
VideoType.SetType( &MEDIATYPE_Video );
//VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 );
VideoType.SetSubtype( &MEDIASUBTYPE_YUY2 );
hr = m_pGrabber[m_nDevices]->SetMediaType( &VideoType ); // shouldn't fail
hr = m_pGraph[m_nDevices]->QueryInterface(IID_IMediaSeeking, (void **)&m_pMediaSeeking[m_nDevices]);
hr =m_pMediaSeeking[m_nDevices]->SetTimeFormat(&TIME_FORMAT_FRAME);
// add the grabber to the graph
//hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );
hr = m_pGrabber[m_nDevices]->SetBufferSamples( FALSE );
hr = m_pGrabber[m_nDevices]->SetOneShot( FALSE );
hr = m_pGrabber[m_nDevices]->SetCallback(&mCB[m_nDevices], 1 ); //LPCWSTR str1=(LPCWSTR)str;
hr = m_pGraph[m_nDevices]->RenderFile((LPCWSTR)lstr, NULL);
hr = m_pGraph[m_nDevices]->QueryInterface(IID_IMediaControl, (void **)&m_pMediaControl[m_nDevices]);
LONGLONG lDuration,lPos,lPos1,llAmount=0;
hr = m_pMediaSeeking[m_nDevices]->SetTimeFormat(&TIME_FORMAT_FRAME);
hr = m_pMediaSeeking[m_nDevices]->GetDuration(&lDuration);
hr = m_pMediaSeeking[m_nDevices]->GetCurrentPosition(&lPos);
hr = m_pMediaSeeking[m_nDevices]->GetStopPosition(&lPos1);
IBasicVideo* pVideo;
hr = m_pGraph[m_nDevices]->QueryInterface(IID_IBasicVideo,(void **)&pVideo);
LONG lWidth, lHeight;
hr = pVideo->GetVideoSize(&lWidth,&lHeight);
REFTIME rtTime;
hr = pVideo->get_AvgTimePerFrame(&rtTime);
double dRate;
dRate = 1.0/rtTime;
llAmount=(LONGLONG)(lPos1/dRate);
// ask for the connection media type so we know how big
// it is, so we can write out bitmaps
//
AM_MEDIA_TYPE mt;
ZeroMemory(&mt,sizeof(mt));
hr = m_pGrabber[m_nDevices]->GetConnectedMediaType( &mt );
VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
int h=(int)vih->bmiHeader.biHeight;
int w=(int)vih->bmiHeader.biWidth; FreeMediaType( mt );
//mCB[m_nDevices].m_hWinHwd=g_hwnd;
// Specify the owner window.
m_pGraph[m_nDevices]->QueryInterface(IID_IVideoWindow, (void **)&m_pWindow[m_nDevices]);
m_pWindow[m_nDevices]->put_Owner((OAHWND)g_hwnd);
m_pWindow[m_nDevices]->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
RECT grc;
GetClientRect(g_hwnd, &grc);
//::ScreenToClient(&grc);
m_pWindow[m_nDevices]->SetWindowPosition(grc.left, grc.top, (grc.right-grc.left), (grc.bottom-grc.top));
// Run the graph.
m_pMediaControl[m_nDevices]->Run();
Everything work fine and playing whell until I write the line above to define the socket, Why???
I am using the
class CSampleGrabberCB : public ISampleGrabberCB
{
....
}
Class for grabing the file frame and when I use the socket it seems that the callback function of this class or the thread that run this class is beeing hang because of the declering of the socket!!!
I try every thing and I think that it is a microsoft bug!!!
Do you have any idea???
Thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bryan Olson |
last post by:
Here's the problem: Suppose we use:
import socket
f = some_socket.makefile()
Then:
f.read() is efficient, but verbose, and incorrect (or at
least does not play will with others);
|
by: Morgan Leppink |
last post by:
Hi all -
We have been developing a complex TCP socket communication
app that is responsible for keeping numerous connections
open to clients on routable IPs. The app receives request
on a...
|
by: Vladimir Lushnikov |
last post by:
Hi,
I know there exist asynchronous socket methods for connecting,
receiving/sending data and disconnecting - but how do you know when the
socket has been terminated - can you assign an event...
|
by: rs |
last post by:
how I the client tell the server that the socket is closed? or this there an
even that informs the server that the clients socket is close?
Oh, I am using vb.net 2003
Thanks
|
by: Dave |
last post by:
Hi,
i am writing a c# application that use direct show to play mpg file but when
i declere a socket in my c# application i just cant play the file enymore,
It seems that the problem is because...
|
by: pawan |
last post by:
Hi
While performance/stress testing my application (a COM+ Server
component) we drive the transaction to the component via a Socket
Server app, listening to a port and passing the incomming...
|
by: atlaste |
last post by:
Hi,
In an attempt to create a full-blown webcrawler I've found myself
writing a wrapper around the Socket class in an attempt to make it
completely async, supporting timeouts and some scheduling...
|
by: John Nagle |
last post by:
Here are three network-related exceptions. These
were caught by "except" with no exception type, because
none of the more specific exceptions matched. This
is what a traceback produced:
1....
|
by: keksy |
last post by:
Hi every1,
I am writing a small client/server application and in it I want to
send an image asynchronous from the client to the server through a TCP
socket. I found an example code on the MSDN...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |