17.06.2013 Views

pvbrowser manual - Flussi liberi informatici

pvbrowser manual - Flussi liberi informatici

pvbrowser manual - Flussi liberi informatici

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.13. WEBCAM 83<br />

5.13 Webcam<br />

Le Webcams con flusso Motion JPEG su http possono essere utilizzate grazie alla classe rlWebcam.<br />

Se non si conosce sotto quale URL la WebCam rende disponibile il flusso video M-JPEG si può capirlo con<br />

tcpdump.<br />

Utilizzare tcpdump<br />

tcpdump -X -i eth0 -t -q -s 0 "host 192.168.1.200 && port 80" | grep -A 10 GET<br />

IP myhost.46727 > 192.168.1.200.http: tcp 97<br />

0x0000: 4500 0089 edb6 4000 4006 c891 c0a8 010e E.....@.@.......<br />

0x0010: c0a8 01c8 b687 0050 d99f 8b7d 0003 d5b2 .......P...}....<br />

0x0020: 5018 16d0 2460 0000 4745 5420 2f63 6769 P...‘..GET./cgi<br />

0x0030: 2d62 696e 2f53 7472 6561 6d3f 5669 6465 -bin/Stream?Vide<br />

0x0040: 6f20 4175 7468 6f72 697a 6174 696f 6e3a o.Authorization:<br />

0x0050: 2042 6173 6963 2059 5752 7461 5734 3663 .Basic.YWRtaW46c<br />

0x0060: 4746 7a63 3364 7663 6d51 3d3f 7765 6263 GFzc3dvcmQ=?webc<br />

0x0070: 616d 5057 443d 526f 6f74 436f 6f6b 6965 amPWD=RootCookie<br />

0x0080: 3030 3030 300d 0a0d 0a 00000....<br />

Integrazione di una Webcam in pvserver<br />

include "rlwebcam.h"<br />

typedef struct // (todo: define your data structure here)<br />

{<br />

rlWebcam webcamBig;<br />

}<br />

DATA;<br />

static int slotInit(PARAM *p, DATA *d)<br />

{<br />

if(p == NULL || d == NULL) return -1;<br />

p->sleep = 20;<br />

p->force_null_event = 0;<br />

d->webcamBig.debug = 0;<br />

d->webcamBig.filename.printf("%swebcam.jpg", p->file_prefix);<br />

d->webcamBig.setUrl("http://192.168.1.200/cgi-bin/Stream?Video Authorization: Basic<br />

YWRtaW46cGFzc3dvcmQ=?webcamPWD=RootCookie00000");<br />

return 0;<br />

}<br />

static int slotNullEvent(PARAM *p, DATA *d)<br />

{<br />

if(p == NULL || d == NULL) return -1;<br />

if(const char *fname = d->webcamBig.getFrame()) // OR if(const char *fname = d->webcamBig.<br />

getSnapshot())<br />

{<br />

pvDownloadFileAs(p,fname,"webcam.jpg");<br />

pvSetImage(p,WebcamBig,"webcam.jpg"); // WebcamBig is a pvQImage object that accepts jpeg images<br />

}<br />

return 0;<br />

}<br />

5.14 Cookies<br />

I cookie sono brevi informazioni che vengono memorizzate sul computer client se il client <strong>pvbrowser</strong> è configurato<br />

per accettare i cookie.<br />

Esempio di cookies<br />

pvPrintf(p,ID_COOKIE,"%s=%s","cookie_name","cookie_values"); // setting cookie "cookie_name"<br />

// snip<br />

pvPrintf(p,ID_COOKIE,"cookie_name"); // requesting cookie "cookie_name"<br />

// As result you will receive a text event under<br />

// ID_COOKIE

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!