473,503 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Direct show-Playing file

Hi,
I am writing a c# application that using a directshow to play file and
display it on my C# gui, its work just fine but when i try to open another
thread in my c# application the file stop playing and i get black image!!!
Why?
What i should considre when i open a new thread in c# application??

Thanks
Nov 17 '05 #1
2 4459
Dave,

Can you post the relevant sections of code, or better yet, a complete
example of what is causing the error? It's nearly impossible to determine
the error without seeing any of what you are doing.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <be******@netvision.net.il> wrote in message
news:OZ*************@TK2MSFTNGP10.phx.gbl...
Hi,
I am writing a c# application that using a directshow to play file and
display it on my C# gui, its work just fine but when i try to open another
thread in my c# application the file stop playing and i get black image!!!
Why?
What i should considre when i open a new thread in c# application??

Thanks

Nov 17 '05 #2
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 creat socket member and
not by openning a thread, we 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!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OE**************@TK2MSFTNGP09.phx.gbl...
Dave,

Again, without seeing what you are trying to do, it is impossible to
help you. There is no such thing as "regular direct show code" or
"regular code" for that matter. Everyone codes different, and not
everyone codes the same way (and that's assuming they are doing the right
thing).

Are you trying to run the filter graph from another thread? If so, is
that thread initialized to use com? Also, are you trying to update the UI
from that thread? Obviously, there are many questions which are more
easily answered with a complete example, since there is so much that can
go wrong.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <be******@netvision.net.il> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
Hi,
The code for playing the file is regular direct show code that use the
SampleGrabber to get the frames from the file, i wrote it inside a c++
managed dll that i connect it from the c# gui application,
I dont getting any error when i am creating new thread but i just get
black
image from the file and it seems the it is not calling to the
ISampleBuffer!
Thanks,

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:#y*************@TK2MSFTNGP15.phx.gbl...
Dave,

Can you post the relevant sections of code, or better yet, a
complete

dong
example of what is causing the error? It's nearly impossible to
determine
the error without seeing any of what you are doing.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <be******@netvision.net.il> wrote in message
news:OZ*************@TK2MSFTNGP10.phx.gbl...
> Hi,
> I am writing a c# application that using a directshow to play file and
> display it on my C# gui, its work just fine but when i try to open

another
> thread in my c# application the file stop playing and i get black

image!!!
> Why?
> What i should considre when i open a new thread in c# application??
>
> Thanks
>
>



Nov 17 '05 #3

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

Similar topics

7
2312
by: Randell D. | last post by:
Folks, I have a Javascript performance question that I might have problems explaining... In PHP, better performance can be obtained dealing directly with a variable, as opposed to an element...
10
4627
by: Alex Greem | last post by:
Dear all, Our database (DB2 Workgroup 7.2 FP12) is constantly under heavy load. Most time CPU usage (1 Pentium3 1Ghz) is more 50% busy. We have 3GB RAM memory Our normal workload is 200-300...
4
2647
by: kerb | last post by:
Hello can you help I am trying to access direct address in ufs filesystem what I am trying to do is for example I have inode 12930123912 and I want to know where on which CHS (cylinder,head...
0
1190
by: perl | last post by:
How can i change the resolution of the video from my webcam when i'm using direct show? best regards
1
2260
by: cmk128 | last post by:
Hi Any c# direct x book? I can't find any, please recommend thanks from Peter
3
1459
by: john.enevoldson | last post by:
Hi, When running a job that inserts data into a particular table we are seeing a significant number of direct writes against the tablespace containing the table. This is the only table in the...
5
3776
by: Remco van Engelen | last post by:
Hello, I have a question regarding the ISO C grammar. The syntax of a direct-declarator reads (section A.2.2, page 413 in my copy; the (R1) is just to 'name' the rule for later reference): ...
0
1328
by: Ken Fine | last post by:
Short version: I want to know how in ASP.NET I could bar direct http access to some files in a directory that match a pattern, but not others. An alternate solution would be to bar all direct http...
5
9372
by: Rahul B | last post by:
Hi, I am having the following issues while trying to restrict the current user from creating any objects. Below is the privileges for the user and response when i try to create a table in that...
0
7203
marktang
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,...
0
7087
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...
0
7334
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...
1
6993
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...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
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...
0
4675
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...
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
383
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...

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.