Domanda

I have the Qt 5.2.1 project for viewing few IP cameras through internet and LAN. Some of them requires proxy, some of them don't. I use libVLC 2.1.4 for playing video.

So, the problem is: when i want to watch cameras through a proxy server i start my program, check QCheckButton "use proxy" (then set up proxy) and press "Start", then VLC instance is created with

vlcArgs << QString("--http-proxy=http://%1:%2/").arg(host).arg(port);
...
vlcInstance_ = libvlc_new(argsCounter, vlc_args); // vlc_args is vlcArgs with char* type

But if i open camera than shouldn't be viewed via proxy, camera doesn't show anything because VLC passes all network traffic via proxy.

I can't create two VLC instances because i use singleton class for it (for some reasons).

I start playing like this:

// libvlc_media_player_t *vlcPlayer_;
libvlc_media_t* media = libvlc_media_new_location( vlc()->instance(), videoUrl.toEncoded() );
libvlc_media_player_set_media(vlcPlayer_, media);
libvlc_media_player_play(vlcPlayer_);

Is there a way to pass proxy settings directly to vlc media or vlc media player? I've heard about libvlc_media_add_option but not sure it can work with proxy settings.

Sorry for my english.

È stato utile?

Soluzione

You can pass network proxy settings among other options to any libvlc_media_t. The only thing to notice here is that you should use colon symbol rather then double-dash as a delimiter:

libvlc_media_t* media = libvlc_media_new_location( vlc()->instance(), video_url);
libvlc_media_add_option(media, ":http-proxy=http://proxy-host:proxy-port/");
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top