thank you very much
I am waitting you.
my main code is in following:
// vlc2Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "vlc2Dlg.h"
#include <string.h>
//#include "dshow.h"
#include <stdio.h>
#include "malloc.h"
#include "vlc.h"
#include "libvlc.h"
#include <windows.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// Cvlc2Dlg dialog
Cvlc2Dlg::Cvlc2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(Cvlc2Dlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void Cvlc2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Cvlc2Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, &Cvlc2Dlg::OnBnClickedOk)
ON_BN_CLICKED(IDC_BUTTON1, &Cvlc2Dlg::OnBnClickedButton1)
ON_BN_CLICKED(IDCANCEL, &Cvlc2Dlg::OnBnClickedCancel)
END_MESSAGE_MAP()
// Cvlc2Dlg message handlers
BOOL Cvlc2Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void Cvlc2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void Cvlc2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR Cvlc2Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
/**********************************************************************
* loadLibrary: Carga la librería VLC
**********************************************************************/
int loadLibrary ( LPWSTR libreria) { //
LPCWSTR lib = L"\\libvlc.dll";
DWORD tamano = GetCurrentDirectoryW(0, NULL);
int liblen = lstrlenW(lib);
printf("Tamano: %d, %d\n", tamano, liblen);
LPWSTR buffer = new WCHAR[tamano + liblen];
tamano = GetCurrentDirectoryW(tamano, buffer);
//buffer[tamano] = 0;
lstrcatW(buffer, lib);
printf("Buffer: %S\n", buffer);
if (libvlc == NULL) {
libvlc = LoadLibraryW(libreria);
delete buffer;
}
if (libvlc != NULL) {
return EXITO;
delete buffer;
} else {
printf("Libreria libvlc.dll no encontrada, %d\n", GetLastError());
return NO_LIB;
delete buffer;
}
}
/**********************************************************************
* freeLibrary: Libera la librería VLC
**********************************************************************/
bool freeLibrary() {
BOOL libera = false;
if (libvlc != NULL) {
printf("Liberando libreria libvlc.dll\n");
libera = FreeLibrary(libvlc);
if (!libera) {
printf("Error al liberar\n");
}
}
return (libera == VLC_TRUE);
}
/**********************************************************************
* funcionFalla: Muestra un mensaje si una función no puede ser
* obtenida desde la DLL
**********************************************************************/
inline int funcionFalla(const char * msg) {
printf("La funcion %s no pudo inicializarse\n", msg);
freeLibrary();
return FUNCION_FALLA;
}
/**********************************************************************
* initLib: Carga todas las funciones desde la librería
**********************************************************************/
int initLib(LPWSTR libreria) {
if (libvlc == NULL) {
if (loadLibrary(libreria) != EXITO) {
return NO_LIB;
}
}
if ((VLC_AddIntf = (_VLC_ADDINTF) GetProcAddress(libvlc, "VLC_AddIntf")) == NULL)
return funcionFalla("VLC_AddIntf");
if ((VLC_AddTarget = (_VLC_ADDTARGET) GetProcAddress(libvlc, "VLC_AddTarget")) == NULL)
return funcionFalla("VLC_AddTarget");
if ((VLC_CleanUp = (_VLC_CLEANUP) GetProcAddress(libvlc, "VLC_CleanUp")) == NULL)
return funcionFalla("VLC_CleanUp");
if ((VLC_Create = (_VLC_CREATE) GetProcAddress(libvlc, "VLC_Create")) == NULL)
return funcionFalla("VLC_Create");
if ((VLC_Destroy = (_VLC_DESTROY) GetProcAddress(libvlc, "VLC_Destroy")) == NULL)
return funcionFalla("VLC_Destroy");
if ((VLC_Die = (_VLC_DIE) GetProcAddress(libvlc, "VLC_Die")) == NULL)
return funcionFalla("VLC_Die");
if ((VLC_Error = (_VLC_ERROR) GetProcAddress(libvlc, "VLC_Error")) == NULL)
return funcionFalla("VLC_Error");
if ((VLC_FullScreen = (_VLC_FULLSCREEN) GetProcAddress(libvlc, "VLC_FullScreen")) == NULL)
return funcionFalla("VLC_FullScreen");
if ((VLC_Init = (_VLC_INIT) GetProcAddress(libvlc, "VLC_Init")) == NULL)
return funcionFalla("VLC_Init");
if ((VLC_IsPlaying = (_VLC_ISPLAYING) GetProcAddress(libvlc, "VLC_IsPlaying")) == NULL)
return funcionFalla("VLC_IsPlaying");
if ((VLC_LengthGet = (_VLC_LENGTHGET) GetProcAddress(libvlc, "VLC_LengthGet")) == NULL)
return funcionFalla("VLC_LengthGet");
if ((VLC_Pause = (_VLC_PAUSE) GetProcAddress(libvlc, "VLC_Pause")) == NULL)
return funcionFalla("VLC_Pause");
if ((VLC_Play = (_VLC_PLAY) GetProcAddress(libvlc, "VLC_Play")) == NULL)
return funcionFalla("VLC_Play");
if ((VLC_PlaylistClear = (_VLC_PLAYLISTCLEAR) GetProcAddress(libvlc, "VLC_PlaylistClear")) == NULL)
return funcionFalla("VLC_PlaylistClear");
if ((VLC_PlaylistIndex = (_VLC_PLAYLISTINDEX) GetProcAddress(libvlc, "VLC_PlaylistIndex")) == NULL)
return funcionFalla("VLC_PlaylistIndex");
if ((VLC_PlaylistNext = (_VLC_PLAYLISTNEXT) GetProcAddress(libvlc, "VLC_PlaylistNext")) == NULL)
return funcionFalla("VLC_PlaylistNext");
if ((VLC_PlaylistNumberOfItems = (_VLC_PLAYLISTNUMBEROFITEMS) GetProcAddress(libvlc, "VLC_PlaylistNumberOfItems")) == NULL)
return funcionFalla("VLC_PlaylistNumberOfItems");
if ((VLC_PlaylistPrev = (_VLC_PLAYLISTPREV) GetProcAddress(libvlc, "VLC_PlaylistPrev")) == NULL)
return funcionFalla("VLC_PlaylistPrev");
if ((VLC_PositionGet = (_VLC_POSITIONGET) GetProcAddress(libvlc, "VLC_PositionGet")) == NULL)
return funcionFalla("VLC_PositionGet");
if ((VLC_PositionSet = (_VLC_POSITIONSET) GetProcAddress(libvlc, "VLC_PositionSet")) == NULL)
return funcionFalla("VLC_PositionSet");
if ((VLC_SpeedFaster = (_VLC_SPEEDFASTER) GetProcAddress(libvlc, "VLC_SpeedFaster")) == NULL)
return funcionFalla("VLC_SpeedFaster");
if ((VLC_SpeedSlower = (_VLC_SPEEDSLOWER) GetProcAddress(libvlc, "VLC_SpeedSlower")) == NULL)
return funcionFalla("VLC_SpeedSlower");
if ((VLC_Stop = (_VLC_STOP) GetProcAddress(libvlc, "VLC_Stop")) == NULL)
return funcionFalla("VLC_Stop");
if ((VLC_TimeGet = (_VLC_TIMEGET) GetProcAddress(libvlc, "VLC_TimeGet")) == NULL)
return funcionFalla("VLC_TimeGet");
if ((VLC_TimeSet = (_VLC_TIMESET) GetProcAddress(libvlc, "VLC_TimeSet")) == NULL)
return funcionFalla("VLC_TimeSet");
if ((VLC_VariableGet = (_VLC_VARIABLEGET) GetProcAddress(libvlc, "VLC_VariableGet")) == NULL)
return funcionFalla("VLC_VariableGet");
if ((VLC_VariableSet = (_VLC_VARIABLESET) GetProcAddress(libvlc, "VLC_VariableSet")) == NULL)
return funcionFalla("VLC_VariableSet");
if ((VLC_VariableType = (_VLC_VARIABLETYPE) GetProcAddress(libvlc, "VLC_VariableType")) == NULL)
return funcionFalla("VLC_VariableType");
if ((VLC_Version = (_VLC_VERSION) GetProcAddress(libvlc, "VLC_Version")) == NULL)
return funcionFalla("VLC_Version");
if ((VLC_VolumeGet = (_VLC_VOLUMEGET) GetProcAddress(libvlc, "VLC_VolumeGet")) == NULL)
return funcionFalla("VLC_VolumeGet");
if ((VLC_VolumeMute = (_VLC_VOLUMEMUTE) GetProcAddress(libvlc, "VLC_VolumeMute")) == NULL)
return funcionFalla("VLC_VolumeMute");
if ((VLC_VolumeSet = (_VLC_VOLUMESET) GetProcAddress(libvlc, "VLC_VolumeSet")) == NULL)
return funcionFalla("VLC_VolumeSet");
return EXITO;
}
/**********************************************************************
* verError: Muestra un mensaje de error
**********************************************************************/
void getError(int error) {
fprintf(stderr, "Error: %s\n", (VLC_Error)(error));
}
// Main
int main(int argc, char * argv[]) {
if (initLib(L"libvlc.dll") != EXITO) {
printf("No se pudo cargar la libreria\n");
return -1;
}
int id = -1;
// It creates the VLC instance
int i_ret = (VLC_Create)();
if( i_ret < 0 ) {
getError(i_ret);
return i_ret;
}
id = i_ret;
// Inits the instance
printf("%d\n", id);
char ** commands = new char*[6];
commands[0] = "testvlcconsole.exe";
commands[1] = "dshow://";
commands[2] = ":dshow-vdev=Logitech QuickCam Pro 3000 (08B0)";
commands[3] = ":dshow-adev=";
commands[4] = ":dshow-size=176x144";
commands[5] = ":sout=#transcode{vcodec=h264,vb=1024,scale=1}:duplicate{dst=rtp{mux=ts,dst=192.168.0.155,port=1234}}";
i_ret = (VLC_Init)(id, 6, commands );
printf("%d\n", i_ret);
if( i_ret < 0 ) {
getError(i_ret);
(VLC_Destroy)( id );
return -1;
}
// Start playing
i_ret = (VLC_Play)(id);
if( i_ret < 0 ) {
getError(i_ret);
return false;
}
getchar();
while((VLC_IsPlaying)(id));
(VLC_Die)(id);
(VLC_CleanUp)(id);
(VLC_Destroy)(id);
freeLibrary();
return 0;
}
void Cvlc2Dlg::OnBnClickedButton1()
{
loadLibrary((LPWSTR)"c:\\libvlc.dll");
}
static void quit_on_exception (libvlc_exception_t *excp) {
if (libvlc_exception_raised (excp)) {
fprintf(stderr, "error: %s\n", libvlc_exception_get_message(excp));
exit(-1);
}
}
void Cvlc2Dlg::OnBnClickedOk()
{
libvlc_exception_t excp;
libvlc_instance_t *inst;
int item;
char *myarg0 = "-I"; char *myarg1 = "dummy";
char *myarg2 = "--plugin-path=c:\\program files\\videolan\\vlc\\plugins";
char *myargs[4] = {myarg0, myarg1, myarg2, NULL};
char *filename = "c:\\sample.mpeg";
////////////////////////////////////////from here the errors are acciured that same as your reported errors
libvlc_exception_init (&excp);
inst = libvlc_new (3, myargs, &excp);
quit_on_exception (&excp);
item = libvlc_playlist_add (inst, filename, NULL, &excp);
quit_on_exception (&excp);
libvlc_playlist_play (inst, item, 0, NULL, &excp);
quit_on_exception (&excp);
Sleep (10000);
libvlc_destroy (inst);
OnOK();
}
void Cvlc2Dlg::OnBnClickedCancel()
{
OnCancel();
}