Click here to Skip to main content
16,018,973 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVista problem with HtmlView Pin
john563226-Nov-07 2:41
john563226-Nov-07 2:41 
Question_snprintf_s in Windows Embedded XP Pin
janadhana26-Nov-07 2:13
janadhana26-Nov-07 2:13 
AnswerRe: _snprintf_s in Windows Embedded XP Pin
JudyL_MD26-Nov-07 2:35
JudyL_MD26-Nov-07 2:35 
QuestionVC++ Codec (h264) Pin
renoreballos26-Nov-07 2:02
renoreballos26-Nov-07 2:02 
AnswerRe: VC++ Codec (h264) Pin
Mark Salsbery26-Nov-07 6:02
Mark Salsbery26-Nov-07 6:02 
GeneralRe: VC++ Codec (h264) Pin
renoreballos26-Nov-07 16:42
renoreballos26-Nov-07 16:42 
GeneralRe: VC++ Codec (h264) Pin
Mark Salsbery27-Nov-07 7:21
Mark Salsbery27-Nov-07 7:21 
GeneralRe: VC++ Codec (h264) Pin
renoreballos27-Nov-07 14:40
renoreballos27-Nov-07 14:40 
Mark,

So you're using DirectShow, right?
- yes, i am

If so, is your h264 codec already in a directshow filter or do you need to
somehow get video frames from a DirectShow stream into the codec?
- yes, i ned to get video frames from directshow stream into my codec, in the outcome my directshow diagram would be like this:

-->Analog Video in Capture>------>XvidMPEG4 CODEC>--->XvidMPEG4 decoder>----->Renderer
preview>------>Renderer 0001

(hope u can picture out the directshow graph i cannot copy and paste the diagram...or even attach it here...)

and the code for this is:
<code>
//Don't forget to change project settings:
//1. C++: add include path to DirectShow include folder (such as c:\dxsdk\include)
//2. Link: add link path to DirectShow lib folder (such as c:\dxsdk\lib).
//3. Link: add strmiids.lib and quartz.lib

#include "stdafx.h"
#include <DShow.h>
#include <atlbase.h>
#include <initguid.h>

BOOL hrcheck(HRESULT hr, TCHAR* errtext)
{
if (hr >= S_OK)
return FALSE;
TCHAR szErr[MAX_ERROR_TEXT_LEN];
DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
if (res)
printf("Error %x: %s\n%s\n",hr, errtext,szErr);
else
printf("Error %x: %s\n", hr, errtext);
return TRUE;
}

//change this macro to fit your style of error handling
#define CHECK_HR(hr, msg) if (hrcheck(hr, msg)) return hr;

CComPtr<IBaseFilter> CreateFilter(WCHAR* displayName)
{
IBindCtx *pBindCtx;
HRESULT hr = CreateBindCtx(0, &pBindCtx);
if (hrcheck(hr, "Can't create bind context"))
return NULL;

ULONG chEaten = 0;
IMoniker *pMoniker = 0;
hr = MkParseDisplayName(pBindCtx, displayName, &chEaten, &pMoniker);
pBindCtx->Release();
if (hrcheck(hr, "Can't create parse display name of the filter"))
return NULL;

IBaseFilter *pFilter = NULL;
if (SUCCEEDED(hr))
{
hr = pMoniker->BindToObject(pBindCtx, NULL, IID_IBaseFilter, (void**)&pFilter);
pMoniker->Release();
if (hrcheck(hr, "Can't bind moniker to filter object"))
return NULL;
}
return CComPtr<IBaseFilter>(pFilter);
}

// {B87BEB7B-8D29-423F-AE4D-6582C10175AC}
DEFINE_GUID(CLSID_VideoRenderer,
0xB87BEB7B, 0x8D29, 0x423F, 0xAE, 0x4D, 0x65, 0x82, 0xC1, 0x01, 0x75, 0xAC); //quartz.dll

// {17CCA71B-ECD7-11D0-B908-00A0C9223196}
DEFINE_GUID(CLSID_Conexant2388xVideoCapture,
0x17CCA71B, 0xECD7, 0x11D0, 0xB9, 0x08, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96); //ksproxy.ax

// {64697678-0000-0010-8000-00AA00389B71}
DEFINE_GUID(CLSID_XvidMPEG4VideoDecoder,
0x64697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); //xvid.ax



HRESULT BuildGraph(IGraphBuilder *pGraph)
{
HRESULT hr = S_OK;

//graph builder
CComPtr<ICaptureGraphBuilder2> pBuilder;
hr = pBuilder.CoCreateInstance(CLSID_CaptureGraphBuilder2);
CHECK_HR(hr, "Can't create Capture Graph Builder");
hr = pBuilder->SetFiltergraph(pGraph);
CHECK_HR(hr, "Can't SetFiltergraph");

//add Video Renderer
CComPtr<IBaseFilter> pVideoRenderer;
hr = pVideoRenderer.CoCreateInstance(CLSID_VideoRenderer);
CHECK_HR(hr, "Can't create Video Renderer");
hr = pGraph->AddFilter(pVideoRenderer, L"Video Renderer");
CHECK_HR(hr, "Can't add Video Renderer to graph");


//add Conexant 2388x Video Capture
CComPtr<IBaseFilter> pConexant2388xVideoCapture;
hr = pConexant2388xVideoCapture.CoCreateInstance(CLSID_Conexant2388xVideoCapture);
CHECK_HR(hr, "Can't create Conexant 2388x Video Capture");
hr = pGraph->AddFilter(pConexant2388xVideoCapture, L"Conexant 2388x Video Capture");
CHECK_HR(hr, "Can't add Conexant 2388x Video Capture to graph");


//add Xvid MPEG-4 Video Decoder
CComPtr<IBaseFilter> pXvidMPEG4VideoDecoder;
hr = pXvidMPEG4VideoDecoder.CoCreateInstance(CLSID_XvidMPEG4VideoDecoder);
CHECK_HR(hr, "Can't create Xvid MPEG-4 Video Decoder");
hr = pGraph->AddFilter(pXvidMPEG4VideoDecoder, L"Xvid MPEG-4 Video Decoder");
CHECK_HR(hr, "Can't add Xvid MPEG-4 Video Decoder to graph");


//add Xvid MPEG-4 Codec
CComPtr<IBaseFilter> pXvidMPEG4Codec = CreateFilter(L"@device:cm:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\\xvid");
hr = pGraph->AddFilter(pXvidMPEG4Codec, L"Xvid MPEG-4 Codec");
CHECK_HR(hr, "Can't add Xvid MPEG-4 Codec to graph");

//add Video Renderer
CComPtr<IBaseFilter> pVideoRenderer2;
hr = pVideoRenderer2.CoCreateInstance(CLSID_VideoRenderer);
CHECK_HR(hr, "Can't create Video Renderer");
hr = pGraph->AddFilter(pVideoRenderer2, L"Video Renderer");
CHECK_HR(hr, "Can't add Video Renderer to graph");


//connect Conexant 2388x Video Capture and Xvid MPEG-4 Video Decoder
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pConexant2388xVideoCapture, NULL, pXvidMPEG4VideoDecoder);
CHECK_HR(hr, "Can't connect Conexant 2388x Video Capture and Xvid MPEG-4 Video Decoder");

//connect Conexant 2388x Video Capture and Xvid MPEG-4 Codec
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pConexant2388xVideoCapture, NULL, pXvidMPEG4Codec);
CHECK_HR(hr, "Can't connect Conexant 2388x Video Capture and Xvid MPEG-4 Codec");

//connect Xvid MPEG-4 Video Decoder and Video Renderer
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pXvidMPEG4VideoDecoder, NULL, pVideoRenderer);
CHECK_HR(hr, "Can't connect Xvid MPEG-4 Video Decoder and Video Renderer");

//connect Conexant 2388x Video Capture and Video Renderer
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pConexant2388xVideoCapture, NULL, pVideoRenderer2);
CHECK_HR(hr, "Can't connect Conexant 2388x Video Capture and Video Renderer");

//connect Xvid MPEG-4 Codec and Xvid MPEG-4 Video Decoder
hr = pBuilder->RenderStream(NULL, &MEDIATYPE_Video, pXvidMPEG4Codec, NULL, pXvidMPEG4VideoDecoder);
CHECK_HR(hr, "Can't connect Xvid MPEG-4 Codec and Xvid MPEG-4 Video Decoder");

return S_OK;
}

int main(int argc, char* argv[])
{
CoInitialize(NULL);
CComPtr<IGraphBuilder> graph;
graph.CoCreateInstance(CLSID_FilterGraph);

printf("Building graph...\n");
HRESULT hr = BuildGraph(graph);
if (hr==S_OK) {
printf("Running");
CComQIPtr<IMediaControl, &IID_IMediaControl> mediaControl(graph);
hr = mediaControl->Run();
CHECK_HR(hr, "Can't run the graph");
CComQIPtr<IMediaEvent, &IID_IMediaEvent> mediaEvent(graph);
BOOL stop = FALSE;
while(!stop)
{
long ev=0, p1=0, p2=0;
Sleep(500);
printf(".");
if (mediaEvent->GetEvent(&ev, &p1, &p2, 0)==S_OK)
{
if (ev == EC_COMPLETE || ev == EC_USERABORT)
{
printf("Done!\n");
stop = TRUE;
}
else
if (ev == EC_ERRORABORT)
{
printf("An error occured: HRESULT=%x\n", p1);
mediaControl->Stop();
stop = TRUE;
}
mediaEvent->FreeEventParams(ev, p1, p2);
}
}
}
CoUninitialize();
return 0;
}
</code>


now, my problem is how am i going to put this into my code in order that this will make sense, even just display this two video on my screen before transmitting this to the medium. i try this already but it didnt display, isnt it that i didnt envoke the Release(); function call? or etc....?

please suggest me or help me on how toget through with this....
thank you...

reno
QuestionHow to change the client wnd dynamically in SDI(no doc-view) Pin
followait26-Nov-07 1:51
followait26-Nov-07 1:51 
QuestionImage Skew(angle) Pin
sujtha26-Nov-07 0:33
sujtha26-Nov-07 0:33 
QuestionRe: Image Skew(angle) Pin
Nelek26-Nov-07 0:58
protectorNelek26-Nov-07 0:58 
JokeRe: Image Skew(angle) Pin
CPallini26-Nov-07 2:07
mveCPallini26-Nov-07 2:07 
GeneralRe: Image Skew(angle) Pin
Chris Losinger26-Nov-07 2:17
professionalChris Losinger26-Nov-07 2:17 
GeneralRe: Image Skew(angle) Pin
CPallini26-Nov-07 3:26
mveCPallini26-Nov-07 3:26 
GeneralRe: Image Skew(angle) Pin
Chris Losinger26-Nov-07 3:31
professionalChris Losinger26-Nov-07 3:31 
GeneralRe: Image Skew(angle) Pin
Luc3426-Aug-10 4:22
Luc3426-Aug-10 4:22 
AnswerRe: Image Skew(angle) Pin
Chris Losinger26-Nov-07 2:14
professionalChris Losinger26-Nov-07 2:14 
QuestionHow to convert initialize an unsigned char* Pin
prithaa25-Nov-07 23:45
prithaa25-Nov-07 23:45 
AnswerRe: How to convert initialize an unsigned char* Pin
Cedric Moonen25-Nov-07 23:58
Cedric Moonen25-Nov-07 23:58 
GeneralRe: How to convert initialize an unsigned char* Pin
prithaa26-Nov-07 1:28
prithaa26-Nov-07 1:28 
GeneralRe: How to convert initialize an unsigned char* Pin
Cedric Moonen26-Nov-07 1:39
Cedric Moonen26-Nov-07 1:39 
JokeRe: How to convert initialize an unsigned char* Pin
Rajesh R Subramanian26-Nov-07 2:28
professionalRajesh R Subramanian26-Nov-07 2:28 
QuestionVirtual Destructor Pin
Andy Rama25-Nov-07 23:35
Andy Rama25-Nov-07 23:35 
AnswerRe: Virtual Destructor Pin
CPallini25-Nov-07 23:54
mveCPallini25-Nov-07 23:54 
GeneralRe: Virtual Destructor Pin
Matthew Faithfull26-Nov-07 0:15
Matthew Faithfull26-Nov-07 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.