29.03.2013, 12:30
|
|
|
: 04.02.2011
:
: 148
Delphi: 7
: 133
|
|
, , WinSock API ... : Exception class EJPEG with message "JPEG error #53" , ...
:
procedure TForm1.Button1Click(Sender: TObject);
Const
C_WORD:Cardinal = 65536;
var
sock: TSocket;
buf: array [0..65535] of Char;
tmp,S: String;
RcvLen: Integer;
host: PHostEnt;
addr: sockaddr_in;
ip: pInteger;
d: WSAData;
Start,Finish:Cardinal;
Jpg:TJpegImage;
f:boolean;
mem:tmemorystream;
z:cardinal;
sX:Cardinal;
begin
mem:=tmemorystream.Create; //nicaa?i iioie
jpg:=tjpegimage.create; //nicaa?i eaa?
f:=false; // Aiiieieoaeuiue oeaa
z:=100;//High(Z);
WSAStartup($0101, d);
//
sock := socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
//
host := gethostbyname('192.168.0.90');
ip := pInteger(host.h_addr_list^);
//
addr.sin_family := AF_INET;
addr.sin_port := htons(80);
addr.sin_addr.S_addr := ip^;
//
connect(sock, addr, sizeof(addr));
//
tmp := 'GET /mjpg/video.mjpg HTTP/1.1'+#13+#10+'Authorization: Basic ' + encodestring('admin:admin')+#13+#10+#13+#10;
send(sock, tmp[1], length(tmp), 0);
tmp := '';
//
ZeroMemory(@buf, C_WORD);
RcvLen := recv(Sock, buf, C_WORD, 0);
while RcvLen > 0 do begin
//
Tmp := Tmp + Copy(buf, 0, RcvLen);
RcvLen := recv(sock, buf, C_WORD, 0);
s:='';
start:=pos('',tmp);//FFD8
if start>0 then
begin
if start>1 then delete(tmp,1,start-1);
finish:=pos('--myboundary',tmp);
if finish>0 then
begin
s:=Copy(tmp,1,finish-1);
delete(tmp,1,finish+5);
//if length(s)<5 then s:='';
end;
end;
if s<>'' then
begin
mem.Clear;
mem.Write(s[1],length(s));
mem.Position := 0;
jpg.LoadFromStream(mem);
Image.Canvas.Lock;
try
application.processmessages;
Image.Picture.Bitmap.assign(JPG);
finally
Image.Canvas.Unlock;
end;
end;
dec(z);
if z=0 then break;
end;
Memo1.Text := Tmp;
WSACleanup();
mem.Free;
jpg.Free;
end;
:
:
HTTP/1.0 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Connection: close
Content-Type: multipart/x-mixed-replace; boundary=--myboundary
--myboundary
Content-Type: image/jpeg
Content-Length: 36001
ʓ:8D{SH
qHW#IUy*VO4X.ESJz
k^3Hdd{PGCNGo~lO
ҡ\ɩnXhoݐI%vf4B*h42\>v \Rz=$[8fՖHQuB'Wˉ3ۤd>}*&9s?_Α?--myboundary
Content-Type: image/jpeg
Content-Length: 35944
t#$v(PH UD*/2>50Ң(^~F--myboundary
Content-Type: image/jpeg
Content-Length: 35951
!A间#sSwQO /?#?jr--myboundary
Content-Type: image/jpeg
Content-Length: 35997
*jgu?xGJC#rk3LiA;21jK Kɣ
$S$2L2>5?~@`?--myboundary
Content-Type: image/jpeg
Content-Length: 35958
N{%rVЌ?(POjv>d*)tˏA--myboundary
Content-Type: image/jpeg
Content-Length: 35997
jw 5#rk3LiVsw%ec9jRJ:F8̌cp?/jeT-y?Ar3/+9 䃃u2}ͷ(jqۊfiAsZ#7;nc tjaګw--myboundary
Content-Type: image/jpeg
Content-Length: 35965
4W
UncPN丌}j)-.t#4c)}j!@V嗴?MߧE>SdL?\KmFm>m =,ǰx)8+:?cɡfF#j^ m,i)%L2$L7O*/!VOB0ET*3dfM'>}}je--myboundary
Content-Type: image/jpeg
Content-Length: 36015
ޓh9Er6*iqV֧6ǒ<Rp&4ƞX-j ޗacPRZ\F}J)Hd )t2Mߦ;TSJ?sS'דLڝj`|--myboundary
Content-Type: image/jpeg
Content-Length: 35807
Ai;w';"M#bZ5?*7G
uT--myboundary
Content-Type: image/jpeg
Content-Length: 35935
$t4d rGҢ(_0jr--myboundary
Content-Type: image/jpeg
Content-Length: 35968
W
n#PN丌9-IZB3F8.H>d )tˏAQO/--myboundary
Content-Type: image/jpeg
Content-Length: 35944
*Y(6\?N:lA!qN ,}Of|:Ry8Atr>8)GHMi*} ?U=koEt2--myboundary
Content-Type: image/jpeg
Content-Length: 35871
">8&9--myboundary
Content-Type: image/jpeg
Content-Length: 35910
sScJ|F~FN@?S3~j[(ٸ1{_0o>8&9Q7AW6i4˔4~<nۯ]^B>CRzćEU/&O4}utqN2Jxi=?1Q*ExѼ?/*R~S=JqPW2mR2~ªr3VX jfMHq--myboundary
Content-Type: image/jpeg
Content-Length: 36009
@4m*P48kSUș1&:G&4ƞH[?.#(ơ\Ќ1҅━VI
L sSc?g`?9>78LjX76n _0o>*,r(P̯;~t2V+{){--myboundary
Content-Type: image/jpeg
Content-Length: 35943
ޗacPФt#F:P*JG֬$.{H3v$ufP\}_4q,R!),,pѸ=+W &rƟ$,L2/$L75iͥ!=ЌU('HwF\YdW1ǧLP ?*q&>=it hFSF?yKCR^1xn?ʪr)(<??TT(`w7--myboundary
Content-Type: image/jpeg
Content-Length: 35892
S7--myboundary
Content-Type: image/jpeg
Content-Length: 35920
GLTSK?Nrkx6XF14n:;V^m$i)iKr"Dp5iե!= U('Dti4^Lh--myboundary
Content-Type: image/jpeg
Content-Length: 35972
H[?.#(ơ\t#4cBRYH6\--myboundary
Content-Type: image/jpeg
Content-Length: 35954
qF5Z΄ftA=iHՒB.8g--myboundary
Content-Type: image/jpeg
Content-Length: 35985
**\Tdƹ
954W
n#PN9jRZ\Fh>d*)t2?569銊|*IyXgsS$>n=J`|X7mݨ wcyN 9Q--myboundary
Content-Type: image/jpeg
Content-Length: 36015
pqO#mza܍r*gUmjslw 0ZG\(f?\+A;21jUt#4c
N"]2d}j|s@0sS'qNW_*v;2V ;{)ٵ{--myboundary
Content-Type: image/jpeg
Content-Length: 35989
8Uͪ~<RԴQɬ1VswecڡRVЌQ.H K_g--myboundary
Content-Type: image/jpeg
Content-Length: 35990
H'r\FQ=KKBE.Y$H6]2gɏ=8Yb[Qa+ܟzۆ;}M{
I݉?I*J+:eT;&7AWzi&LM_OK L2/$L7liե!=ԌU('HzdfM'>z{uS0#p#Bؖ*2??Hm1R=CWrc6 '2mR2<)5WQr6瞑1ǵ#+#<--myboundary
Content-Type: image/jpeg
Content-Length: 35975
O<JC$?{e[?.#(ơR*s?P"G֬.@AQO( }i?n:qN--myboundary
Content-Type: image/jpeg
Content-Length: 35982
Td
954W
ʷ'r\FQ=G2KKɣ(PHJG֬$.A--myboundary
Content-Type: image/jpeg
Content-Length: 35944
djaӵE>P$?# 47t֨\*.#uT;&7AW6i4˔ ~<n9ǽv~iyd9B0ET}bC4T/&O5~}S--cbaPBZ]1LdTxcO?+<$
^z(یT@OH[\*.Q>ƬzDƚ
--myboundary
Content-Type: image/jpeg
Content-Length: 35993
$?{!n#PN{dRZ\FNzsF:P#J@$K_q@ A!S=qLZ<
6nɑ{_0o>*r>p(y9=Οm."ڍ=_S{Qzl? nL{ǁB|+:?E*1IcPGjkͥ˔ ?iE䉞7ϮjS=ЌbPOX"*y2y[}S--N"aPBZObTe1R+?)hsCWr*6 <TLA
H$bxǟcSzDƑǔ0x;--myboundary
Content-Type: image/jpeg
Content-Length: 35970
954W
BF*qF5J--.t#&trE) ˦_g_՝>m2!q,E{¾m= ,ǰx)8Q+:avM4n:;V^m$i)i%--myboundary
Content-Type: image/jpeg
Content-Length: 36029
JL/Tc<,+
8P)p@=M&}hF*iqZ**Nm$y1ip&4ƸVqwec9kVVЌю('֔⬒$.q3̤6p %;(٦Z
*vwUW?:e+Esj--myboundary
Content-Type: image/jpeg
Content-Length: 35988
gUmjsjwLRԙpYcOup5K?0DZr$ *s*(PH֬.Yq3--myboundary
Content-Type: image/jpeg
Content-Length: 35965
cOup?.#(ơ[:1҅zHle?uQO (q?jrΟm6"ڍ=L+}zۆ;}M{
H,ރ
u+?*.#a&7Aj+ͤ˔$ *DpmVpO#UJ ѤEU/&O5~}S--8nj-+h@ъaLtyL~_<TГCW}vn3L[tvU\.BA<T_qk}X>7V*G0zI9!_ GKēp" 7iTo?)M0p!8>F9'ښ~YypT lt9F<Jd:9="a_H~oc`?36j*Lsjn:Q`*&= M+0}*Nr)u$~c@\!Sߥ2"Z,7N
X#zT/8+*{R#'zS?QH@--myboundary
Content-Type: image/jpeg
Content-Length: 35934
-JKK(J)H$K^?5>9QO/?# OLCqN^)*KSٻcn(yyJ˜(R--myboundary
Content-Type: image/jpeg
Content-Length: 36039
JAEJG
.)zM**E@**NmSJC-$?{`'z\FQ=C*s(\ҜWVA
LjaҢ)_N@'דLC
pҙw-xlO?۽J/n>;f9)6fh4_ W_*vӷL%hvmb c`^:Ǟsڬib-.a
'Cd@4?I*Q\+:?E"B
*իכI4ej|ܰ0H3895iե!=ЎET }bC#5RX<Ozn=S0AWObZOb?{Te*Exo )ʔ9ߡR^1Fg|
F *3|--myboundary
Content-Type: image/jpeg
Content-Length: 36026
|
|