473,548 Members | 2,604 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 4464
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.co m

"Dave" <be******@netvi sion.net.il> wrote in message
news:OZ******** *****@TK2MSFTNG P10.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("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!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:OE******** ******@TK2MSFTN GP09.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.co m

"Dave" <be******@netvi sion.net.il> wrote in message
news:uq******** ******@tk2msftn gp13.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.c om> wrote
in
message news:#y******** *****@TK2MSFTNG P15.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.co m

"Dave" <be******@netvi sion.net.il> wrote in message
news:OZ******** *****@TK2MSFTNG P10.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
2317
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 in an array... Thus, if I have a programming routine that utilises $a several times, it is better to write the value contained in $a to something...
10
4633
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 dyn.sql/s. The action question is there way to eliminate direct I/O? By definition direct I/O is I/O that bypass bufferpools and used for LONG...
4
2656
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 sector) that inode starts and where it ends. Thank you.
0
1193
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
2263
by: cmk128 | last post by:
Hi Any c# direct x book? I can't find any, please recommend thanks from Peter
3
1462
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 tablespace and there are no other jobs running against the table at the same time. The table contains no lobs or long varchar columns so we cannot...
5
3781
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): (R1) direct-declarator: identifier "(" declarator ")"
0
1331
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 access to files and require that any access of the files be mediated by my web application. In other words, direct access via...
5
9387
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 user. Can anybody tell what is the difference between DIRECT SYSADM and Indirect SYSADM and why is Indirect SYSADM is assigned to user by default.
0
7512
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7707
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. ...
0
7951
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...
0
7803
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6036
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
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...
0
5082
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...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1926
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 we have to send another system

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.