Some problems and solutions of network stream encountered by Windows using LIBVLC

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.