Paste the code First,
#define WIFI_W 640
#define WIFI_H 480
structctx{Uchar*frame;};classcconnectwifi{ Public: Cconnectwifi (void); voidInit (HWND hwnd); libvlc_instance_t*M_vlcinst; libvlc_media_player_t*M_vlcmplay; libvlc_media_t*M_vlcmedia; structCTX Context; ~cconnectwifi (void);}; Cconnectwifi::cconnectwifi (void) {M_vlcinst=NULL; M_vlcmplay=NULL; M_vlcmedia=NULL; Context.frame=NewUchar[wifi_w * Wifi_h *3]; memset (Context.frame,0, wifi_w*wifi_h*3); M_vlcinst= Libvlc_new (0, NULL); }cconnectwifi::~cconnectwifi (void){ if(M_vlcmplay) {libvlc_media_player_release (m_vlcmplay); M_vlcmplay=NULL; } if(m_vlcinst) {libvlc_release (m_vlcinst); M_vlcinst=NULL; } if(context.frame) {delete []context.frame; Context.frame=NULL; }}void*Lock(void* Data,void**p_pixels) { structctx* CTX = (structctx*) data; *p_pixels = ctx->frame; returnNULL;}voidUnlockvoid* Data,void* ID,void*Const*p_pixels) {Uchar* pixels = (uchar*) *P_pixels; Imageprocesscallback (pixels, Wifi_w, wifi_h);}voidDisplayvoid*data,void*ID) { //(void) data; //ASSERT (id = = NULL);}voidCconnectwifi::init (HWND hwnd) {M_vlcmedia= Libvlc_media_new_location (M_vlcinst,"http://10.10.1.1:8196"); Libvlc_media_add_option (M_vlcmedia,": network-caching=10"); M_vlcmplay=Libvlc_media_player_new_from_media (M_vlcmedia); Libvlc_media_player_set_hwnd (M_vlcmplay, HWND); Libvlc_media_release (M_vlcmedia); Libvlc_video_set_callbacks (M_vlcmplay,Lock, unlock, display, &context); Libvlc_video_set_format (M_vlcmplay,"RV24", Wifi_w, Wifi_h, Wifi_w *3); intres =Libvlc_media_player_play (M_vlcmplay);}
The above code is a piece of code to access the WiFi image device, and also the first contact with VLC, many places are not very clear.
where Libvlc_media_add_option (M_vlcmedia, ": network-caching=10") is to solve the problem of delay in buffer time too long, if too big delay serious, too small is very card, Set according to the situation. Another problem does not understand, after the connection is normal, suddenly interrupt the network, unexpectedly can also call the callback function Imageprocesscallback, and a call, but all the same frame data. Is it the so-called "pull" mode? How to solve this problem, have done the trouble please leave a message below, thank you!