Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, November 28, 2007 7:59:18 AM(UTC)
Gr-system

Groups: Registered
Posts: 4


Help me, I did a small test application to the Sdk lead, but the pin of ILMNetSnk is not connecting,
See the code:
Obs: Disregard alguamas things I disorganized :$


//-------------Beginning interfaces
HRESULT GetInterfaces(void)
{
HRESULT hr;

// initialize COM library
hr = CoInitialize(NULL);
if(FAILED(hr))
{
return hr;
}



// Create the filter graph
hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **) &g_pGraph);
if (FAILED(hr))
return hr;

// Create the capture graph builder
hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void **) &g_pCapture);
if (FAILED(hr))
return hr;

// Obtain interfaces for media control and Video Window
hr = g_pGraph->QueryInterface(IID_IMediaControl,(LPVOID *) &g_pMC);
if (FAILED(hr))
return hr;

hr = g_pGraph->QueryInterface(IID_IVideoWindow, (LPVOID *) &g_pVW);
if (FAILED(hr))
return hr;

hr = g_pGraph->QueryInterface(IID_IMediaEvent, (LPVOID *) &g_pME);
if (FAILED(hr))
return hr;





//_____________________________________________LtmCapture capture___________________________________

try
{



hr = CoCreateInstance(CLSID_ltmmCapture, 0, CLSCTX_INPROC_SERVER, IID_IltmmCapture, (void**) &m_capture);
//iLmn1=m_capture;
//iLmn=iLmn1;
//hr = g_pGraph->AddFilter(iLmn, L"");

// set the target format:
m_capture->put_TargetFormat(ltmmCapture_TargetFormat_NET);
// Set the window handle used to process graph events
hr = g_pME->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0);

// set the server address as a target file
BSTR sServer;
sServer = SysAllocString(L"ltsf://192.168.0.6"); // Porta padrão, 27015
m_capture->put_TargetFile(sServer);
SysFreeString(sServer);
// call ReadyCapture to build the graph:
m_capture->ReadyCapture(ltmmCapture_Mode_VideoOrAudio);
// get the mux object and query for the interface
IUnknown* pUnk = NULL;
ILMNetMux* pMux1 = NULL;

m_capture->GetSubObject(ltmmCapture_Object_TargetFilter, &pUnk);
hr = CoCreateInstance(CLSID_LMNetMux, 0, CLSCTX_INPROC_SERVER,
IID_ILMNetMux,(void**)&pUnk);

pUnk->QueryInterface(IID_ILMNetMux, (void**) &pMux1);
iLmn1=pUnk;
iLmn=iLmn1;
hr = g_pGraph->AddFilter(iLmn, L"LMNetMux");
// this is a live source
pMux1->put_LiveSource(VARIANT_TRUE);

// Set the max queue duration
double dVal;
pMux1->get_MaxQueueDuration(&dVal);
if (dVal put_MaxQueueDuration(10);

// I can afford 128 kbps only
pMux1->put_BitRateLimit(128*1024);
m_capture->put_Preview(VARIANT_TRUE);
// start the server:
m_capture->StartCapture(ltmmCapture_Mode_VideoOrAudio);

//___________________________________--fim LTmCpture--____________________________________

///"""""""""""""""""""""""""""""""Ajute MPEG4"""""""""""""""""""""""""""

IUnknown* pUnk1 ;
m_capture->GetSubObject(ltmmCapture_Object_VideoCompressor, &pUnk1);
if(FAILED(hr))
return hr;



hr = CoCreateInstance(CLSID_LMMP4Encoder, 0, CLSCTX_INPROC_SERVER,
IID_ILMMP42Encoder,(void**)&pv);
pvBase =pv;
hr = g_pGraph->AddFilter(pvBase,L"MPE4-encoder");
// hr = pUnk1->QueryInterface(IID_ILMMP42Encoder, (void**) &pv);
//pUnk1->Release();
//if(FAILED(hr))
// return hr;


//||||||||||||||||||||||||||||||||||||||CONFIGURAÇÃO MPEG4________________|
m_capture->put_FrameRate(10.0);//_________________________________________|
m_capture->put_UseFrameRate(VARIANT_TRUE);//______________________________|
pv->put_OutputFrameRate(10.0);//__________________________________________|
pv->put_PFrames(10);//____________________________________________________|
pv->put_BFrames(0);//_____________________________________________________|
pv->put_SearchWidth(8);//_________________________________________________|
pv->put_SearchHeight(8);//________________________________________________|
pv->put_QFactor(9);//_____________________________________________________|
pv->put_QuantType(LMP4_QUANTTYPE_Linear);//_______________________________|
pv->put_MotionAlgorithm(LMP4_MOTIONALGORITHM_FastSearch);//_______________|
pv->put_MotionAccurancy(LMP4_MOTIONACCURACY_HalfPixel);//_________________|
pv->put_MotionVectorPerMacroblock(LMP4_MOTIONVECTOR_OnePerMacroblock);//__|
pv->put_OutputFormat(LMP4_OUTPUTFORMAT_mp4v);//___________________________|
pv->put_SuperCompression(VARIANT_FALSE);//________________________________|
pv->Release();//__________________________________________________________|

//""""""""""""""""""""""""""""""""""""FIM MPEG4""""""""""""""""""""""""""""""""


//___________________________________
hr = CoCreateInstance(CLSID_LMNetSnk, 0, CLSCTX_INPROC_SERVER,
IID_ILMNetSnk,(void**)&Sink);
if (FAILED(hr))
return hr;
pLNSk =Sink;
//hr = g_pGraph->AddFilter(pLNSk, L"LMNetSnk");

}
catch(TCHAR *Trata)
{
Msg(Trata);
}
return hr;

}

//-----------Connecting the pins

HRESULT Conectamux()
{
HRESULT hr;
// Conectar LMNetMux
IPin * pOut = GetOutPin( pSrcFilter, 0 );// ponteiro Video Capture
IPin * pIn = GetInPin( pvBase, 0 );// ponteiro LMNetMux
hr = g_pGraph->Connect( pOut, pIn);// conecta, os pinos

return hr;
}

HRESULT ConectaSink()
{

HRESULT hr;
// Conectar LMNetSnk
IPin *pOut = GetOutPin(pvBase, 0 );// ponteiro LMNetMux
IPin * pIn = GetInPin(iLmn, 0 );// ponteiro LMNetSnk
hr = g_pGraph->Connect( pOut, pIn);// conecta, os pinos
return hr;

}

//---------------THE FAILURE HAPPENS HERE :'(
HRESULT ConectaRtp()
{

HRESULT hr;
// Conectar LMNetSnk
IPin *pOut = GetOutPin(iLmn, 0 );// ponteiro LMNetMux
IPin * pIn = GetInPin( pLNSk, 0 );// ponteiro LMNetSnk
hr = g_pGraph->Connect( pOut, pIn);// conecta, os pinos
return hr;
}

//--------------Drawing connections
Conectamux();
ConectaSink();
ConectaRtp();

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, November 29, 2007 3:05:43 AM(UTC)

Qasem Lubani  
Guest

Groups: Guests
Posts: 3,034

Was thanked: 2 time(s) in 2 post(s)


I haven't tried your code, but
it seems you're using the MS DirectShow SDK and creating a Filter Graph and Graph
Builder objects, along with using our ltmmCapture control. Normally, you
shouldn't have to do that, because our control will construct the filter graph it needs.


If you must access the filter
graph used inside our Capture control, you can retrieve it using the IltmmCapture::GetSubObject function.


I recommend using the video conferencing sample code
from our help files, and demo projects shipped with our toolkit to see how to use our networking modules.

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.160 seconds.