Hi I have successfully got Directshow outputing a video from C++ MFC using Sample Grabber, but I can not figure out how to play the audio with this. I have attached code snippet of what I have done currently, can anyone tell me what I need to do to get audio stream to work. I have added the sound renderer filter, just dont know how to connect it with the rest of the graph. Thanks HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); hr = pGraph->QueryInterface(IID_IMediaEventEx, (void **)&pEvent); hr = pGraph->QueryInterface(IID_IBasicAudio, reinterpret_cast<void**>(&m_pAudio)); hr = pGraph->QueryInterface(IID_IMediaSeeking, reinterpret_cast<void**>(&pSeeking)); hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pGrabberF); if (FAILED(hr)) { // Return an error. } hr = pGraph->AddFilter(pGrabberF, L"Sample Grabber"); CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pSoundRenderer); hr = pGraph->AddFilter(g_pSoundRenderer, NULL); // hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pGrabberF); // hr = pGraph->AddFilter( if (FAILED(hr) ) { // Return an error. } pGrabberF->QueryInterface(IID_ISampleGrabber, (void**)&pGrabber); //ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE)); mt.majortype = MEDIATYPE_Stream; //mt.subtype = GUID_NULL;//MEDIASUBTYPE_RGB24; hr = pGrabber->SetMediaType(&mt); hr = pGraph->AddSourceFilter(fileName.AllocSysString(), L"Source", &pSrc); if (FAILED(hr)) { // Return an error code. } hr = ConnectFilters(pGraph, pSrc, pGrabberF); // Create the NULL renderer and connect hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&m_pNullRenderer)); hr = pGraph->AddFilter(m_pNullRenderer, L"NullRenderer"); hr = ConnectFilters(pGraph, pGrabberF, m_pNullRenderer);
godspeed123
Posts
-
Directshow Audio Question -
Directshow questionHi I have set up a video and connected it to a sample grabber correctly, so that I can see the image, but I cant get sound out, I have tried to render sound, but dont know how to connect it up, any help would be greatly appreciated. I have attached the following code snippet that shows what I have. HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); hr = pGraph->QueryInterface(IID_IMediaEventEx, (void **)&pEvent); hr = pGraph->QueryInterface(IID_IBasicAudio, reinterpret_cast<void**>(&m_pAudio)); hr = pGraph->QueryInterface(IID_IMediaSeeking, reinterpret_cast<void**>(&pSeeking)); hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pGrabberF); if (FAILED(hr)) { // Return an error. } hr = pGraph->AddFilter(pGrabberF, L"Sample Grabber"); CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&g_pSoundRenderer); hr = pGraph->AddFilter(g_pSoundRenderer, NULL); // hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pGrabberF); // hr = pGraph->AddFilter( if (FAILED(hr) ) { // Return an error. } pGrabberF->QueryInterface(IID_ISampleGrabber, (void**)&pGrabber); //ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE)); mt.majortype = MEDIATYPE_Stream; //mt.subtype = GUID_NULL;//MEDIASUBTYPE_RGB24; hr = pGrabber->SetMediaType(&mt); hr = pGraph->AddSourceFilter(fileName.AllocSysString(), L"Source", &pSrc); if (FAILED(hr)) { // Return an error code. } hr = ConnectFilters(pGraph, pSrc, pGrabberF); // Create the NULL renderer and connect hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&m_pNullRenderer)); hr = pGraph->AddFilter(m_pNullRenderer, L"NullRenderer"); hr = ConnectFilters(pGraph, pGrabberF, m_pNullRenderer);
-
Question Regarding ScrollViewHi, Its about the SetScrollSize property that I dont understand, not the images. Sorry for the confusion.
-
Question Regarding ScrollViewHi, I have made an OpenGL view embedded into a scrollview. I am trying to use SetScrollSizes function to set a proper Window size, but I dont understand how the values are found, I have many rows of rectangles shown in OpenGL, and I want to adjust the length of the scrollbar to accomodate the number of rows. I have used the following code SetScrollSizes( MM_TEXT, CSize( 100, totalNumOfRow*60 ) ); where 60 is the length of one rectangle showing on the screen. Any help would be greatly appreciated.
-
OpenGL and CScrollViewHi, I have an application that I have embedded an OpenGL scene into a CScrollView, the problem I am having is when I move the scroll bar, the OpenGL Scene doesnt move with it. What am I missing to cause the scene to move with the scroll bar movements. I think I am missing an openGL call that links the windows scrollbar position to the OpenGL Position. Any help would be greatly appreciated. Thanks in advance!
-
Tab in a SDI View or MainFrameDo you by any chance have like a mock example? Thanks for the help
-
Tab in a SDI View or MainFrameHi Mark, I still want the splitters, but I want say 3 splitters in 1 tab and 2 splitters in another.
-
Tab in a SDI View or MainFrameHi, I have a SDI application that I wrote in .NET 2005 C++ and in unmanaged code, I have used the ST_SplitterWnd to split the windows, but now what I need to do is, I need to create tabs so that all the views are contained in one, so that I can make another instance of tabs when the next tab is clicked. Now I have no clue how to do this. Is there anyone else out there that knows how to do this? Thanks in advance
-
Line in PictureBoxHi, I have used the picture box to draw an image on the screen. Its loading perfectly, now I want to draw over some parts of the image, with rectangles and lines. I tried to draw on the picture box by doing the following but nothing shows up? How can I go about doing this. Graphics g = pictureBox1.CreateGraphics(); SolidBrush solidBrush = new SolidBrush(Color.Blue); g.FillRectangle(solidBrush, 0, 0, 100, 100); Any help would be greatly appreciated
-
SDI Application with a TabviewHi, I want to able to have tabs with different CView classes in each tab, how is this done? Is there any tutorials or sample code to do this? Thanks in advance!
-
Setup and Deployment QuestionThe issue that I am getting, is the following: When I run the setup program, I get the error: The windows installer service cannot update the system file C:\Windows\system32\msvcrt.dll because the file is protected by Windows.... What do I have to do in the setup program to stop thins error from coming up? Thanks for all the help
-
Setup and Deployment QuestionHi, I want to stop a dll from installing if it is already there, I have .NET 2005, do I have to do something in the conditions side. If so what do I need to put there to stop it, and how do I go about making a condition. Thanks in advance
-
Run-time error '430' - Class does not support Automation or does not support expected interfaceI actually didnt write this software, but it happens I think when it is creating a report, so it has something to do with a database, or something along the line of that.
-
Run-time error '430' - Class does not support Automation or does not support expected interfaceHi, I am having this error come up when I am running some software that was written in Visual C++ 6.0. I searched online and everyone says to install MDAC and the problem will dissappear, but I am still experiencing it. Does anyone know what else I need to do to fix this problem Thanks
-
Question regarding elliptical fit to raw data points x, yHi, I saw this from my searching online, but the problem is none of this makes sense to me. Is there a step by step procedure to solve this problem. Thanks
-
Question regarding elliptical fit to raw data points x, yHi, I need an algorithm that fits an ellipse to x, y points. I looked around online but there is nothing written in C++. Even a methodology to achieve a fit will be good enough and I will be able to write the code. I also have the center position and all the raw data points. I need a best fit ellipse to it. Any help would be greatly appreicated. Thanks
-
Question about Windows Control Libraries and Propertiesthe error I get is as follows: The following exception has occurred: InvalidCastException: Specified cast is not valid. Does that help? If not I can put up all the code
-
Question about Windows Control Libraries and PropertiesThanks for the response, so how does this work? The function that I am using has the following prototype
public override StandardValuesCollection GetStandardValues( ITypeDescriptorContext context ) { // daq is the array of string in the Usercontrol class return new StandardValuesCollection( ((UserControl1) context.Instance).daq ); }
This code crashes, so I am clearly doing it wrong. Whats the correct method. Thanks for all the help -
Question regarding Windows Control Library and PropertiesHi, I am developing a windows control library in C# and I have to display the serial number of some cards that are connected to the system. I have written the code in the windows control library class that retieves all the data. Now inorder to make it show properly in the properties box in Visual Studio when I am using the control I had to write another class that is a TypeConverter namely StringConverter. so how does one take the serialnumber array which is just a string array in the windos control library class and give it to the StringConverter class? Any help would be greatly appreciated Thanks in advance
-
Question about Windows Control Libraries and PropertiesThanks for the help, I have linked it all up and it works!! One more question is if I have an array with serial numbers in the Windows Control Library class, how do I send it over to the StringConverter class. So in:
public class UserControl1 : System.Windows.Forms.UserControl { ... public string daqSerial = new string[10]; private string testProperty; ... public void RetrieveSerials() { ... // find all the serials connected to comp } [DescriptionAttribute("Serial"), CategoryAttribute("Global Settings"), TypeConverter(typeof(testingPropertyConverter))] public string TestProp { get { return testProperty; } set { testProperty = value; } } } public class testingPropertyConverter : StringConverter { public override bool GetStandardValuesSupported( ITypeDescriptorContext context ) { return true; } public override StandardValuesCollection GetStandardValues( ITypeDescriptorContext context ) { return new StandardValuesCollection(new string[]{"test0", "test1", "test2"}); } }
So instead of putting those fixed values how do I show the daqSerial Array. Any help would be greatly appreciated