| Index: source/patched-ffmpeg-mt/libavformat/sdp.c
|
| ===================================================================
|
| --- source/patched-ffmpeg-mt/libavformat/sdp.c (revision 59334)
|
| +++ source/patched-ffmpeg-mt/libavformat/sdp.c (working copy)
|
| @@ -44,17 +44,22 @@
|
| int ttl; /**< TTL, in case of multicast stream */
|
| const char *user; /**< username of the session's creator */
|
| const char *src_addr; /**< IP address of the machine from which the session was created */
|
| + const char *src_type; /**< address type of src_addr */
|
| const char *dst_addr; /**< destination IP address (can be multicast) */
|
| + const char *dst_type; /**< destination IP address type */
|
| const char *name; /**< session name (can be an empty string) */
|
| };
|
|
|
| -static void sdp_write_address(char *buff, int size, const char *dest_addr, int ttl)
|
| +static void sdp_write_address(char *buff, int size, const char *dest_addr,
|
| + const char *dest_type, int ttl)
|
| {
|
| if (dest_addr) {
|
| + if (!dest_type)
|
| + dest_type = "IP4";
|
| if (ttl > 0) {
|
| - av_strlcatf(buff, size, "c=IN IP4 %s/%d\r\n", dest_addr, ttl);
|
| + av_strlcatf(buff, size, "c=IN %s %s/%d\r\n", dest_type, dest_addr, ttl);
|
| } else {
|
| - av_strlcatf(buff, size, "c=IN IP4 %s\r\n", dest_addr);
|
| + av_strlcatf(buff, size, "c=IN %s %s\r\n", dest_type, dest_addr);
|
| }
|
| }
|
| }
|
| @@ -62,22 +67,24 @@
|
| static void sdp_write_header(char *buff, int size, struct sdp_session_level *s)
|
| {
|
| av_strlcatf(buff, size, "v=%d\r\n"
|
| - "o=- %d %d IN IP4 %s\r\n"
|
| + "o=- %d %d IN %s %s\r\n"
|
| "s=%s\r\n",
|
| s->sdp_version,
|
| - s->id, s->version, s->src_addr,
|
| + s->id, s->version, s->src_type, s->src_addr,
|
| s->name);
|
| - sdp_write_address(buff, size, s->dst_addr, s->ttl);
|
| + sdp_write_address(buff, size, s->dst_addr, s->dst_type, s->ttl);
|
| av_strlcatf(buff, size, "t=%d %d\r\n"
|
| "a=tool:libavformat " AV_STRINGIFY(LIBAVFORMAT_VERSION) "\r\n",
|
| s->start_time, s->end_time);
|
| }
|
|
|
| #if CONFIG_NETWORK
|
| -static void resolve_destination(char *dest_addr, int size)
|
| +static void resolve_destination(char *dest_addr, int size, char *type,
|
| + int type_size)
|
| {
|
| - struct addrinfo hints, *ai, *cur;
|
| + struct addrinfo hints, *ai;
|
|
|
| + av_strlcpy(type, "IP4", type_size);
|
| if (!dest_addr[0])
|
| return;
|
|
|
| @@ -85,21 +92,17 @@
|
| * as a numeric IP address in the SDP. */
|
|
|
| memset(&hints, 0, sizeof(hints));
|
| - /* We only support IPv4 addresses in the SDP at the moment. */
|
| - hints.ai_family = AF_INET;
|
| if (getaddrinfo(dest_addr, NULL, &hints, &ai))
|
| return;
|
| - for (cur = ai; cur; cur = cur->ai_next) {
|
| - if (cur->ai_family == AF_INET) {
|
| - getnameinfo(cur->ai_addr, cur->ai_addrlen, dest_addr, size,
|
| - NULL, 0, NI_NUMERICHOST);
|
| - break;
|
| - }
|
| - }
|
| + getnameinfo(ai->ai_addr, ai->ai_addrlen, dest_addr, size,
|
| + NULL, 0, NI_NUMERICHOST);
|
| + if (ai->ai_family == AF_INET6)
|
| + av_strlcpy(type, "IP6", type_size);
|
| freeaddrinfo(ai);
|
| }
|
| #else
|
| -static void resolve_destination(char *dest_addr, int size)
|
| +static void resolve_destination(char *dest_addr, int size, char *type,
|
| + int type_size)
|
| {
|
| }
|
| #endif
|
| @@ -267,9 +270,9 @@
|
|
|
| config[0] = config[1] = config[2] = 0;
|
| config[3] = 1;
|
| - config[4] = 0xfe; // ident must match the one in rtpenc_xiph.c
|
| - config[5] = 0xcd;
|
| - config[6] = 0xba;
|
| + config[4] = (RTP_XIPH_IDENT >> 16) & 0xff;
|
| + config[5] = (RTP_XIPH_IDENT >> 8) & 0xff;
|
| + config[6] = (RTP_XIPH_IDENT ) & 0xff;
|
| config[7] = (headers_len >> 8) & 0xff;
|
| config[8] = headers_len & 0xff;
|
| config[9] = 2;
|
| @@ -412,6 +415,10 @@
|
| c->width, c->height, pix_fmt, config);
|
| break;
|
| }
|
| + case CODEC_ID_VP8:
|
| + av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n",
|
| + payload_type);
|
| + break;
|
| default:
|
| /* Nothing special to do here... */
|
| break;
|
| @@ -422,7 +429,7 @@
|
| return buff;
|
| }
|
|
|
| -void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, int port, int ttl)
|
| +void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, const char *dest_type, int port, int ttl)
|
| {
|
| const char *type;
|
| int payload_type;
|
| @@ -440,7 +447,7 @@
|
| }
|
|
|
| av_strlcatf(buff, size, "m=%s %d RTP/AVP %d\r\n", type, port, payload_type);
|
| - sdp_write_address(buff, size, dest_addr, ttl);
|
| + sdp_write_address(buff, size, dest_addr, dest_type, ttl);
|
| if (c->bit_rate) {
|
| av_strlcatf(buff, size, "b=AS:%d\r\n", c->bit_rate / 1000);
|
| }
|
| @@ -453,22 +460,28 @@
|
| AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0);
|
| struct sdp_session_level s;
|
| int i, j, port, ttl;
|
| - char dst[32];
|
| + char dst[32], dst_type[5];
|
|
|
| memset(buff, 0, size);
|
| memset(&s, 0, sizeof(struct sdp_session_level));
|
| s.user = "-";
|
| s.src_addr = "127.0.0.1"; /* FIXME: Properly set this */
|
| + s.src_type = "IP4";
|
| s.name = title ? title->value : "No Name";
|
|
|
| port = 0;
|
| ttl = 0;
|
| if (n_files == 1) {
|
| port = sdp_get_address(dst, sizeof(dst), &ttl, ac[0]->filename);
|
| - resolve_destination(dst, sizeof(dst));
|
| + resolve_destination(dst, sizeof(dst), dst_type, sizeof(dst_type));
|
| if (dst[0]) {
|
| s.dst_addr = dst;
|
| + s.dst_type = dst_type;
|
| s.ttl = ttl;
|
| + if (!strcmp(dst_type, "IP6")) {
|
| + s.src_addr = "::1";
|
| + s.src_type = "IP6";
|
| + }
|
| }
|
| }
|
| sdp_write_header(buff, size, &s);
|
| @@ -477,12 +490,12 @@
|
| for (i = 0; i < n_files; i++) {
|
| if (n_files != 1) {
|
| port = sdp_get_address(dst, sizeof(dst), &ttl, ac[i]->filename);
|
| - resolve_destination(dst, sizeof(dst));
|
| + resolve_destination(dst, sizeof(dst), dst_type, sizeof(dst_type));
|
| }
|
| for (j = 0; j < ac[i]->nb_streams; j++) {
|
| ff_sdp_write_media(buff, size,
|
| ac[i]->streams[j]->codec, dst[0] ? dst : NULL,
|
| - (port > 0) ? port + j * 2 : 0, ttl);
|
| + dst_type, (port > 0) ? port + j * 2 : 0, ttl);
|
| if (port <= 0) {
|
| av_strlcatf(buff, size,
|
| "a=control:streamid=%d\r\n", i + j);
|
| @@ -498,8 +511,7 @@
|
| return AVERROR(ENOSYS);
|
| }
|
|
|
| -void ff_sdp_write_media(char *buff, int size, AVCodecContext *c,
|
| - const char *dest_addr, int port, int ttl)
|
| +void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *dest_addr, const char *dest_type, int port, int ttl)
|
| {
|
| }
|
| #endif
|
|
|