473,608 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

socket and direct show

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("lo calhost").Addre ssList[0];

TcpListener tcpServerListen er = new TcpListener(ipA ddress,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:

CoCreateInstanc e(CLSID_FilterG raph, NULL,
CLSCTX_INPROC_S ERVER,IID_IGrap hBuilder, (void **)&m_pGraph[m_nDevices]);

....

m_pGrabber[m_nDevices].CoCreateInstan ce( CLSID_SampleGra bber );

CComQIPtr< IBaseFilter, &IID_IBaseFilte r >
pGrabBase(m_pGr abber[m_nDevices]);

HRESULT hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );
//Force it to connect to video, 24 bit

CMediaType VideoType;

VideoType.SetTy pe( &MEDIATYPE_Vide o );

//VideoType.SetSu btype( &MEDIASUBTYPE_R GB24 );

VideoType.SetSu btype( &MEDIASUBTYPE_Y UY2 );

hr = m_pGrabber[m_nDevices]->SetMediaType ( &VideoType ); // shouldn't fail
hr = m_pGraph[m_nDevices]->QueryInterface (IID_IMediaSeek ing, (void
**)&m_pMediaSee king[m_nDevices]);

hr =m_pMediaSeekin g[m_nDevices]->SetTimeFormat( &TIME_FORMAT_FR AME);

// add the grabber to the graph

//hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );

hr = m_pGrabber[m_nDevices]->SetBufferSampl es( FALSE );

hr = m_pGrabber[m_nDevices]->SetOneShot( FALSE );

hr = m_pGrabber[m_nDevices]->SetCallback(&m CB[m_nDevices], 1 );

//LPCWSTR str1=(LPCWSTR)s tr;

hr = m_pGraph[m_nDevices]->RenderFile((LP CWSTR)lstr, NULL);

hr = m_pGraph[m_nDevices]->QueryInterface (IID_IMediaCont rol, (void
**)&m_pMediaCon trol[m_nDevices]);
LONGLONG lDuration,lPos, lPos1,llAmount= 0;

hr = m_pMediaSeeking[m_nDevices]->SetTimeFormat( &TIME_FORMAT_FR AME);

hr = m_pMediaSeeking[m_nDevices]->GetDuration(&l Duration);

hr = m_pMediaSeeking[m_nDevices]->GetCurrentPosi tion(&lPos);

hr = m_pMediaSeeking[m_nDevices]->GetStopPositio n(&lPos1);
IBasicVideo* pVideo;

hr = m_pGraph[m_nDevices]->QueryInterface (IID_IBasicVide o,(void **)&pVideo);

LONG lWidth, lHeight;

hr = pVideo->GetVideoSize(& lWidth,&lHeight );

REFTIME rtTime;

hr = pVideo->get_AvgTimePer Frame(&rtTime);

double dRate;

dRate = 1.0/rtTime;
llAmount=(LONGL ONG)(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]->GetConnectedMe diaType( &mt );

VIDEOINFOHEADER * vih = (VIDEOINFOHEADE R*) mt.pbFormat;

int h=(int)vih->bmiHeader.biHe ight;

int w=(int)vih->bmiHeader.biWi dth;

FreeMediaType( mt );
//mCB[m_nDevices].m_hWinHwd=g_hw nd;

// Specify the owner window.

m_pGraph[m_nDevices]->QueryInterface (IID_IVideoWind ow, (void
**)&m_pWindow[m_nDevices]);

m_pWindow[m_nDevices]->put_Owner((OAH WND)g_hwnd);

m_pWindow[m_nDevices]->put_WindowStyl e(WS_CHILD | WS_CLIPSIBLINGS );
RECT grc;

GetClientRect(g _hwnd, &grc);

//::ScreenToClien t(&grc);

m_pWindow[m_nDevices]->SetWindowPosit ion(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 CSampleGrabberC B : public ISampleGrabberC B

{

....

}

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!
Nov 2 '05 #1
1 2974
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("lo calhost").Addre ssList[0];

TcpListener tcpServerListen er = new TcpListener(ipA ddress,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:

CoCreateInstanc e(CLSID_FilterG raph, NULL,
CLSCTX_INPROC_S ERVER,IID_IGrap hBuilder, (void **)&m_pGraph[m_nDevices]);

....

m_pGrabber[m_nDevices].CoCreateInstan ce( CLSID_SampleGra bber );

CComQIPtr< IBaseFilter, &IID_IBaseFilte r >
pGrabBase(m_pGr abber[m_nDevices]);

HRESULT hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );
//Force it to connect to video, 24 bit

CMediaType VideoType;

VideoType.SetTy pe( &MEDIATYPE_Vide o );

//VideoType.SetSu btype( &MEDIASUBTYPE_R GB24 );

VideoType.SetSu btype( &MEDIASUBTYPE_Y UY2 );

hr = m_pGrabber[m_nDevices]->SetMediaType ( &VideoType ); // shouldn't fail
hr = m_pGraph[m_nDevices]->QueryInterface (IID_IMediaSeek ing, (void
**)&m_pMediaSee king[m_nDevices]);

hr =m_pMediaSeekin g[m_nDevices]->SetTimeFormat( &TIME_FORMAT_FR AME);

// add the grabber to the graph

//hr = m_pGraph[m_nDevices]->AddFilter( pGrabBase, L"Grabber" );

hr = m_pGrabber[m_nDevices]->SetBufferSampl es( FALSE );

hr = m_pGrabber[m_nDevices]->SetOneShot( FALSE );

hr = m_pGrabber[m_nDevices]->SetCallback(&m CB[m_nDevices], 1 );

//LPCWSTR str1=(LPCWSTR)s tr;

hr = m_pGraph[m_nDevices]->RenderFile((LP CWSTR)lstr, NULL);

hr = m_pGraph[m_nDevices]->QueryInterface (IID_IMediaCont rol, (void
**)&m_pMediaCon trol[m_nDevices]);
LONGLONG lDuration,lPos, lPos1,llAmount= 0;

hr = m_pMediaSeeking[m_nDevices]->SetTimeFormat( &TIME_FORMAT_FR AME);

hr = m_pMediaSeeking[m_nDevices]->GetDuration(&l Duration);

hr = m_pMediaSeeking[m_nDevices]->GetCurrentPosi tion(&lPos);

hr = m_pMediaSeeking[m_nDevices]->GetStopPositio n(&lPos1);
IBasicVideo* pVideo;

hr = m_pGraph[m_nDevices]->QueryInterface (IID_IBasicVide o,(void **)&pVideo);

LONG lWidth, lHeight;

hr = pVideo->GetVideoSize(& lWidth,&lHeight );

REFTIME rtTime;

hr = pVideo->get_AvgTimePer Frame(&rtTime);

double dRate;

dRate = 1.0/rtTime;
llAmount=(LONGL ONG)(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]->GetConnectedMe diaType( &mt );

VIDEOINFOHEADER * vih = (VIDEOINFOHEADE R*) mt.pbFormat;

int h=(int)vih->bmiHeader.biHe ight;

int w=(int)vih->bmiHeader.biWi dth;

FreeMediaType( mt );
//mCB[m_nDevices].m_hWinHwd=g_hw nd;

// Specify the owner window.

m_pGraph[m_nDevices]->QueryInterface (IID_IVideoWind ow, (void
**)&m_pWindow[m_nDevices]);

m_pWindow[m_nDevices]->put_Owner((OAH WND)g_hwnd);

m_pWindow[m_nDevices]->put_WindowStyl e(WS_CHILD | WS_CLIPSIBLINGS );
RECT grc;

GetClientRect(g _hwnd, &grc);

//::ScreenToClien t(&grc);

m_pWindow[m_nDevices]->SetWindowPosit ion(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 CSampleGrabberC B : public ISampleGrabberC B

{

....

}

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!

Nov 4 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
11748
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);
1
2152
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 non-routable listener socket that marshals communications between the non-routable netowrk and the clients out on the routable network. The app runs as a .NET service in Win2K Server. Async
2
2908
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 handler or a delegate as to when the socket is disconnected - either gracefully from remote or shut down by "brute force"? In short, something like this:
4
6717
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
1
272
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 we are tring to write this lines: IPAddress ipAddress = Dns.Resolve("localhost").AddressList; TcpListener tcpServerListener = new TcpListener(ipAddress,5555);
2
1222
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 transactions to the COM+ application. The Socket App then returns the response back over the opened socket to the client. For a 100 users scenario, 8 CPU box I am able to get 130 Transactions per seconds. How ever if I try to pass these...
11
8589
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 mechanisms. I use a non-blocking approach for this, using the call to 'poll' to support the async mechanism - rather than the 'begin' and 'end' functions. I already found that connecting doesn't set the "isconnected" variable correctly...
10
3563
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. File "D:\Python24\lib\socket.py", line 295, in read data = self._sock.recv(recv_size) timeout: timed out
1
7155
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 site, which is actually for sending strings. I tried to adapt this code so that the client sends an image instead of a string. However, there is something wrong on the server side (i guess)... The server starts listening, the client starts sending...
0
8003
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8498
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8478
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8152
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5476
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.