Mercurial > mplayer.hg
annotate libmpdemux/rtp.c @ 15255:e9b4eeb31768
synced with 1.73
author | gabrov |
---|---|
date | Sun, 24 Apr 2005 22:16:09 +0000 |
parents | 8dd7a656eaf8 |
children | 281d155fb37f |
rev | line source |
---|---|
15178
8dd7a656eaf8
Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12799
diff
changeset
|
1 /* Imported from the dvbstream-0.2 project |
8dd7a656eaf8
Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12799
diff
changeset
|
2 * |
8dd7a656eaf8
Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12799
diff
changeset
|
3 * Modified for use with MPlayer, for details see the CVS changelog at |
8dd7a656eaf8
Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12799
diff
changeset
|
4 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
8dd7a656eaf8
Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12799
diff
changeset
|
5 * $Id$ |
8dd7a656eaf8
Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12799
diff
changeset
|
6 */ |
8dd7a656eaf8
Mark modified imported files as such to comply more closely with GPL ¡ø2a.
diego
parents:
12799
diff
changeset
|
7 |
3686 | 8 #include <stdlib.h> |
9 #include <string.h> | |
3716 | 10 #include <unistd.h> |
3686 | 11 #include <stdlib.h> |
12 #include <stdio.h> | |
13 #include <sys/types.h> | |
10281 | 14 #include "config.h" |
15 #ifndef HAVE_WINSOCK2 | |
16 #include <netinet/in.h> | |
3686 | 17 #include <sys/socket.h> |
18 #include <arpa/inet.h> | |
10281 | 19 #else |
20 #include <winsock2.h> | |
21 #include <ws2tcpip.h> | |
22 #endif | |
3686 | 23 |
24 /* MPEG-2 TS RTP stack */ | |
25 | |
26 #define DEBUG 1 | |
27 #include "rtp.h" | |
28 | |
29 | |
30 int getrtp2(int fd, struct rtpheader *rh, char** data, int* lengthData) { | |
31 static char buf[1600]; | |
32 unsigned int intP; | |
33 char* charP = (char*) &intP; | |
34 int headerSize; | |
35 int lengthPacket; | |
36 lengthPacket=recv(fd,buf,1590,0); | |
37 if (lengthPacket==0) | |
38 exit(1); | |
39 if (lengthPacket<0) { | |
40 fprintf(stderr,"socket read error\n"); | |
41 exit(2); | |
42 } | |
43 if (lengthPacket<12) { | |
44 fprintf(stderr,"packet too small (%d) to be an rtp frame (>12bytes)\n", lengthPacket); | |
45 exit(3); | |
46 } | |
47 rh->b.v = (unsigned int) ((buf[0]>>6)&0x03); | |
48 rh->b.p = (unsigned int) ((buf[0]>>5)&0x01); | |
49 rh->b.x = (unsigned int) ((buf[0]>>4)&0x01); | |
50 rh->b.cc = (unsigned int) ((buf[0]>>0)&0x0f); | |
51 rh->b.m = (unsigned int) ((buf[1]>>7)&0x01); | |
52 rh->b.pt = (unsigned int) ((buf[1]>>0)&0x7f); | |
53 intP = 0; | |
54 memcpy(charP+2,&buf[2],2); | |
55 rh->b.sequence = ntohl(intP); | |
56 intP = 0; | |
57 memcpy(charP,&buf[4],4); | |
58 rh->timestamp = ntohl(intP); | |
59 | |
60 headerSize = 12 + 4*rh->b.cc; /* in bytes */ | |
61 | |
62 *lengthData = lengthPacket - headerSize; | |
63 *data = (char*) buf + headerSize; | |
64 | |
65 // fprintf(stderr,"Reading rtp: v=%x p=%x x=%x cc=%x m=%x pt=%x seq=%x ts=%x lgth=%d\n",rh->b.v,rh->b.p,rh->b.x,rh->b.cc,rh->b.m,rh->b.pt,rh->b.sequence,rh->timestamp,lengthPacket); | |
66 | |
67 return(0); | |
68 } | |
69 | |
70 |