-int ff_url_join(char *str, int size, const char *proto,
- const char *authorization, const char *hostname,
- int port, const char *fmt, ...)
-{
-#if CONFIG_NETWORK
- struct addrinfo hints = { 0 }, *ai;
-#endif
-
- str[0] = '\0';
- if (proto)
- av_strlcatf(str, size, "%s://", proto);
- if (authorization && authorization[0])
- av_strlcatf(str, size, "%s@", authorization);
-#if CONFIG_NETWORK && defined(AF_INET6)
- /* Determine if hostname is a numerical IPv6 address,
- * properly escape it within [] in that case. */
- hints.ai_flags = AI_NUMERICHOST;
- if (!getaddrinfo(hostname, NULL, &hints, &ai)) {
- if (ai->ai_family == AF_INET6) {
- av_strlcat(str, "[", size);
- av_strlcat(str, hostname, size);
- av_strlcat(str, "]", size);
- } else {
- av_strlcat(str, hostname, size);
- }
- freeaddrinfo(ai);
- } else
-#endif
- /* Not an IPv6 address, just output the plain string. */
- av_strlcat(str, hostname, size);
-
- if (port >= 0)
- av_strlcatf(str, size, ":%d", port);
- if (fmt) {
- va_list vl;
- int len = strlen(str);
-
- va_start(vl, fmt);
- vsnprintf(str + len, size > len ? size - len : 0, fmt, vl);
- va_end(vl);
- }
- return strlen(str);
-}
-
-int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
- AVFormatContext *src)
-{
- AVPacket local_pkt;
-
- local_pkt = *pkt;
- local_pkt.stream_index = dst_stream;
- if (pkt->pts != AV_NOPTS_VALUE)
- local_pkt.pts = av_rescale_q(pkt->pts,
- src->streams[pkt->stream_index]->time_base,
- dst->streams[dst_stream]->time_base);
- if (pkt->dts != AV_NOPTS_VALUE)
- local_pkt.dts = av_rescale_q(pkt->dts,
- src->streams[pkt->stream_index]->time_base,
- dst->streams[dst_stream]->time_base);
- return av_write_frame(dst, &local_pkt);
-}
-