|
13 | 13 | int sdp_h264(uint8_t *data, int bytes, const char* proto, unsigned short port, int payload, int frequence, const void* extra, int extra_size) |
14 | 14 | { |
15 | 15 | static const char* pattern = |
16 | | - "m=video %hu %s %d\n" |
17 | | - "a=rtpmap:%d H264/90000\n" |
| 16 | + "m=video %hu %s %d\r\n" |
| 17 | + "a=rtpmap:%d H264/90000\r\n" |
18 | 18 | "a=fmtp:%d packetization-mode=1;profile-level-id=%02X%02X%02X;sprop-parameter-sets="; |
19 | 19 |
|
20 | 20 | int r, n; |
@@ -47,8 +47,12 @@ int sdp_h264(uint8_t *data, int bytes, const char* proto, unsigned short port, i |
47 | 47 | n += (int)base64_encode((char*)data + n, avc.pps[i].data, avc.pps[i].bytes); |
48 | 48 | } |
49 | 49 |
|
50 | | - if (n < bytes) |
51 | | - data[n++] = '\n'; |
| 50 | + if (n + 2 > bytes) |
| 51 | + return -ENOMEM; // don't have enough memory |
| 52 | + |
| 53 | + data[n++] = '\r'; |
| 54 | + data[n++] = '\n'; |
| 55 | + |
52 | 56 | return n; |
53 | 57 | } |
54 | 58 |
|
@@ -81,7 +85,7 @@ int sdp_h264_load(uint8_t* data, int bytes, const char* config) |
81 | 85 | #if defined(_DEBUG) || defined(DEBUG) |
82 | 86 | void sdp_h264_test(void) |
83 | 87 | { |
84 | | - const char* sdp = "m=video 0 RTP/AVP 96\na=rtpmap:96 H264/90000\na=fmtp:96 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z2QAH6zZQFAFumoCGgKAAAADAIAAAB5HjBjL,aO+8sA==\n"; |
| 88 | + const char* sdp = "m=video 0 RTP/AVP 96\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1;profile-level-id=64001F;sprop-parameter-sets=Z2QAH6zZQFAFumoCGgKAAAADAIAAAB5HjBjL,aO+8sA==\r\n"; |
85 | 89 | const char* config = "Z2QAH6zZQFAFumoCGgKAAAADAIAAAB5HjBjL,aO+8sA=="; |
86 | 90 | static const uint8_t extra[] = { 0x01, 0x64, 0x00, 0x1f, 0xff, 0xe1, 0x00, 0x1b, 0x67, 0x64, 0x00, 0x1f, 0xac, 0xd9, 0x40, 0x50, 0x05, 0xba, 0x6a, 0x02, 0x1a, 0x02, 0x80, 0x00, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x1e, 0x47, 0x8c, 0x18, 0xcb, 0x01, 0x00, 0x04, 0x68, 0xef, 0xbc, 0xb0 }; |
87 | 91 | static const uint8_t ps[] = { 0x00, 0x00, 0x00, 0x1, 0x67, 0x64, 0x00, 0x1f, 0xac, 0xd9, 0x40, 0x50, 0x05, 0xba, 0x6a, 0x02, 0x1a, 0x02, 0x80, 0x00, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x1e, 0x47, 0x8c, 0x18, 0xcb, 0x00, 0x00, 0x00, 0x1, 0x68, 0xef, 0xbc, 0xb0 }; |
|
0 commit comments