History

Move find_info_tag to lavu and add av_ prefix to it

Anton Khirnov committed 15 years ago

Commit 1b981071 parent 9c9912b10 files · +85 −62Browse files

Unified · Split

10 files
  1. ffserver.c +3 −3
  2. libavformat/avformat.h +4 −5
  3. libavformat/rtpproto.c +8 −7
  4. libavformat/sapenc.c +5 −4
  5. libavformat/sdp.c +2 −1
  6. libavformat/udp.c +8 −7
  7. libavformat/utils.c +5 −35
  8. libavformat/version.h +3 −0
  9. libavutil/parseutils.c +39 −0
  10. libavutil/parseutils.h +8 −0
ffserver.c+3−3
@@ -2135,10 +2135,10 @@ static int open_input_stream(HTTPContext *c, const char *info) · 2134 unmodified lines
2135 strcpy(input_filename, c->stream->feed->feed_filename);2135 strcpy(input_filename, c->stream->feed->feed_filename);
2136 buf_size = FFM_PACKET_SIZE;2136 buf_size = FFM_PACKET_SIZE;
2137 /* compute position (absolute time) */2137 /* compute position (absolute time) */
2138 if (find_info_tag(buf, sizeof(buf), "date", info)) {2138 if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
2139 if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0)2139 if ((ret = av_parse_time(&stream_pos, buf, 0)) < 0)
2140 return ret;2140 return ret;
2141 } else if (find_info_tag(buf, sizeof(buf), "buffer", info)) {2141 } else if (av_find_info_tag(buf, sizeof(buf), "buffer", info)) {
2142 int prebuffer = strtol(buf, 0, 10);2142 int prebuffer = strtol(buf, 0, 10);
2143 stream_pos = av_gettime() - prebuffer * (int64_t)1000000;2143 stream_pos = av_gettime() - prebuffer * (int64_t)1000000;
2144 } else2144 } else
@@ -2147,7 +2147,7 @@ static int open_input_stream(HTTPContext *c, const char *info) · 2 unmodified lines
2147 strcpy(input_filename, c->stream->feed_filename);2147 strcpy(input_filename, c->stream->feed_filename);
2148 buf_size = 0;2148 buf_size = 0;
2149 /* compute position (relative time) */2149 /* compute position (relative time) */
2150 if (find_info_tag(buf, sizeof(buf), "date", info)) {2150 if (av_find_info_tag(buf, sizeof(buf), "date", info)) {
2151 if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0)2151 if ((ret = av_parse_time(&stream_pos, buf, 1)) < 0)
2152 return ret;2152 return ret;
2153 } else2153 } else
libavformat/avformat.h+4−5
@@ -1501,13 +1501,12 @@ int64_t ffm_read_write_index(int fd); · 1500 unmodified lines
1501int ffm_write_write_index(int fd, int64_t pos);1501int ffm_write_write_index(int fd, int64_t pos);
1502void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);1502void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
1503 1503
1504#if FF_API_FIND_INFO_TAG
1504/**1505/**
1505 * Attempt to find a specific tag in a URL.1506 * @deprecated use av_find_info_tag in libavutil instead.
1506 *
1507 * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
1508 * Return 1 if found.
1509 */1507 */
1510int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);1508attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
1509#endif
1511 1510
1512/**1511/**
1513 * Return in 'buf' the path with '%d' replaced by a number.1512 * Return in 'buf' the path with '%d' replaced by a number.
libavformat/rtpproto.c+8−7
@@ -24,6 +24,7 @@ · 23 unmodified lines
24 * RTP protocol24 * RTP protocol
25 */25 */
26 26
27#include "libavutil/parseutils.h"
27#include "libavutil/avstring.h"28#include "libavutil/avstring.h"
28#include "avformat.h"29#include "avformat.h"
29#include "rtpdec.h"30#include "rtpdec.h"
@@ -161,25 +162,25 @@ static int rtp_open(URLContext *h, const char *uri, int flags) · 131 unmodified lines
161 162
162 p = strchr(uri, '?');163 p = strchr(uri, '?');
163 if (p) {164 if (p) {
164 if (find_info_tag(buf, sizeof(buf), "ttl", p)) {165 if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
165 ttl = strtol(buf, NULL, 10);166 ttl = strtol(buf, NULL, 10);
166 }167 }
167 if (find_info_tag(buf, sizeof(buf), "rtcpport", p)) {168 if (av_find_info_tag(buf, sizeof(buf), "rtcpport", p)) {
168 rtcp_port = strtol(buf, NULL, 10);169 rtcp_port = strtol(buf, NULL, 10);
169 }170 }
170 if (find_info_tag(buf, sizeof(buf), "localport", p)) {171 if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
171 local_rtp_port = strtol(buf, NULL, 10);172 local_rtp_port = strtol(buf, NULL, 10);
172 }173 }
173 if (find_info_tag(buf, sizeof(buf), "localrtpport", p)) {174 if (av_find_info_tag(buf, sizeof(buf), "localrtpport", p)) {
174 local_rtp_port = strtol(buf, NULL, 10);175 local_rtp_port = strtol(buf, NULL, 10);
175 }176 }
176 if (find_info_tag(buf, sizeof(buf), "localrtcpport", p)) {177 if (av_find_info_tag(buf, sizeof(buf), "localrtcpport", p)) {
177 local_rtcp_port = strtol(buf, NULL, 10);178 local_rtcp_port = strtol(buf, NULL, 10);
178 }179 }
179 if (find_info_tag(buf, sizeof(buf), "pkt_size", p)) {180 if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
180 max_packet_size = strtol(buf, NULL, 10);181 max_packet_size = strtol(buf, NULL, 10);
181 }182 }
182 if (find_info_tag(buf, sizeof(buf), "connect", p)) {183 if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
183 connect = strtol(buf, NULL, 10);184 connect = strtol(buf, NULL, 10);
184 }185 }
185 }186 }
libavformat/sapenc.c+5−4
@@ -20,6 +20,7 @@ · 19 unmodified lines
20 */20 */
21 21
22#include "avformat.h"22#include "avformat.h"
23#include "libavutil/parseutils.h"
23#include "libavutil/random_seed.h"24#include "libavutil/random_seed.h"
24#include "libavutil/avstring.h"25#include "libavutil/avstring.h"
25#include "libavutil/intreadwrite.h"26#include "libavutil/intreadwrite.h"
@@ -87,16 +88,16 @@ static int sap_write_header(AVFormatContext *s) · 61 unmodified lines
87 option_list = strrchr(path, '?');88 option_list = strrchr(path, '?');
88 if (option_list) {89 if (option_list) {
89 char buf[50];90 char buf[50];
90 if (find_info_tag(buf, sizeof(buf), "announce_port", option_list)) {91 if (av_find_info_tag(buf, sizeof(buf), "announce_port", option_list)) {
91 port = strtol(buf, NULL, 10);92 port = strtol(buf, NULL, 10);
92 }93 }
93 if (find_info_tag(buf, sizeof(buf), "same_port", option_list)) {94 if (av_find_info_tag(buf, sizeof(buf), "same_port", option_list)) {
94 same_port = strtol(buf, NULL, 10);95 same_port = strtol(buf, NULL, 10);
95 }96 }
96 if (find_info_tag(buf, sizeof(buf), "ttl", option_list)) {97 if (av_find_info_tag(buf, sizeof(buf), "ttl", option_list)) {
97 ttl = strtol(buf, NULL, 10);98 ttl = strtol(buf, NULL, 10);
98 }99 }
99 if (find_info_tag(buf, sizeof(buf), "announce_addr", option_list)) {100 if (av_find_info_tag(buf, sizeof(buf), "announce_addr", option_list)) {
100 av_strlcpy(announce_addr, buf, sizeof(announce_addr));101 av_strlcpy(announce_addr, buf, sizeof(announce_addr));
101 }102 }
102 }103 }
libavformat/sdp.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#include <string.h>21#include <string.h>
22#include "libavutil/avstring.h"22#include "libavutil/avstring.h"
23#include "libavutil/base64.h"23#include "libavutil/base64.h"
24#include "libavutil/parseutils.h"
24#include "libavcodec/xiph.h"25#include "libavcodec/xiph.h"
25#include "avformat.h"26#include "avformat.h"
26#include "internal.h"27#include "internal.h"
@@ -136,7 +137,7 @@ static int sdp_get_address(char *dest_addr, int size, int *ttl, const char *url) · 109 unmodified lines
136 if (p) {137 if (p) {
137 char buff[64];138 char buff[64];
138 139
139 if (find_info_tag(buff, sizeof(buff), "ttl", p)) {140 if (av_find_info_tag(buff, sizeof(buff), "ttl", p)) {
140 *ttl = strtol(buff, NULL, 10);141 *ttl = strtol(buff, NULL, 10);
141 } else {142 } else {
142 *ttl = 5;143 *ttl = 5;
libavformat/udp.c+8−7
@@ -27,6 +27,7 @@ · 26 unmodified lines
27#define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */27#define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */
28#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */28#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
29#include "avformat.h"29#include "avformat.h"
30#include "libavutil/parseutils.h"
30#include <unistd.h>31#include <unistd.h>
31#include "internal.h"32#include "internal.h"
32#include "network.h"33#include "network.h"
@@ -259,7 +260,7 @@ int udp_set_remote_url(URLContext *h, const char *uri) · 226 unmodified lines
259 s->is_multicast = ff_is_multicast_address((struct sockaddr*) &s->dest_addr);260 s->is_multicast = ff_is_multicast_address((struct sockaddr*) &s->dest_addr);
260 p = strchr(uri, '?');261 p = strchr(uri, '?');
261 if (p) {262 if (p) {
262 if (find_info_tag(buf, sizeof(buf), "connect", p)) {263 if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
263 int was_connected = s->is_connected;264 int was_connected = s->is_connected;
264 s->is_connected = strtol(buf, NULL, 10);265 s->is_connected = strtol(buf, NULL, 10);
265 if (s->is_connected && !was_connected) {266 if (s->is_connected && !was_connected) {
@@ -330,7 +331,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) · 64 unmodified lines
330 331
331 p = strchr(uri, '?');332 p = strchr(uri, '?');
332 if (p) {333 if (p) {
333 if (find_info_tag(buf, sizeof(buf), "reuse", p)) {334 if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
334 const char *endptr=NULL;335 const char *endptr=NULL;
335 s->reuse_socket = strtol(buf, &endptr, 10);336 s->reuse_socket = strtol(buf, &endptr, 10);
336 /* assume if no digits were found it is a request to enable it */337 /* assume if no digits were found it is a request to enable it */
@@ -338,19 +339,19 @@ static int udp_open(URLContext *h, const char *uri, int flags) · 1 unmodified line
338 s->reuse_socket = 1;339 s->reuse_socket = 1;
339 reuse_specified = 1;340 reuse_specified = 1;
340 }341 }
341 if (find_info_tag(buf, sizeof(buf), "ttl", p)) {342 if (av_find_info_tag(buf, sizeof(buf), "ttl", p)) {
342 s->ttl = strtol(buf, NULL, 10);343 s->ttl = strtol(buf, NULL, 10);
343 }344 }
344 if (find_info_tag(buf, sizeof(buf), "localport", p)) {345 if (av_find_info_tag(buf, sizeof(buf), "localport", p)) {
345 s->local_port = strtol(buf, NULL, 10);346 s->local_port = strtol(buf, NULL, 10);
346 }347 }
347 if (find_info_tag(buf, sizeof(buf), "pkt_size", p)) {348 if (av_find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
348 h->max_packet_size = strtol(buf, NULL, 10);349 h->max_packet_size = strtol(buf, NULL, 10);
349 }350 }
350 if (find_info_tag(buf, sizeof(buf), "buffer_size", p)) {351 if (av_find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
351 s->buffer_size = strtol(buf, NULL, 10);352 s->buffer_size = strtol(buf, NULL, 10);
352 }353 }
353 if (find_info_tag(buf, sizeof(buf), "connect", p)) {354 if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
354 s->is_connected = strtol(buf, NULL, 10);355 s->is_connected = strtol(buf, NULL, 10);
355 }356 }
356 }357 }
libavformat/utils.c+5−35
@@ -3391,44 +3391,14 @@ int64_t parse_date(const char *timestr, int duration) · 3390 unmodified lines
3391}3391}
3392#endif3392#endif
3393 3393
3394#if FF_API_FIND_INFO_TAG
3395#include "libavutil/parseutils.h"
3396
3394int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)3397int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
3395{3398{
3396 const char *p;3399 return av_find_info_tag(arg, arg_size, tag1, info);
3397 char tag[128], *q;
3398
3399 p = info;
3400 if (*p == '?')
3401 p++;
3402 for(;;) {
3403 q = tag;
3404 while (*p != '\0' && *p != '=' && *p != '&') {
3405 if ((q - tag) < sizeof(tag) - 1)
3406 *q++ = *p;
3407 p++;
3408 }
3409 *q = '\0';
3410 q = arg;
3411 if (*p == '=') {
3412 p++;
3413 while (*p != '&' && *p != '\0') {
3414 if ((q - arg) < arg_size - 1) {
3415 if (*p == '+')
3416 *q++ = ' ';
3417 else
3418 *q++ = *p;
3419 }
3420 p++;
3421 }
3422 }
3423 *q = '\0';
3424 if (!strcmp(tag, tag1))
3425 return 1;
3426 if (*p != '&')
3427 break;
3428 p++;
3429 }
3430 return 0;
3431}3400}
3401#endif
3432 3402
3433int av_get_frame_filename(char *buf, int buf_size,3403int av_get_frame_filename(char *buf, int buf_size,
3434 const char *path, int number)3404 const char *path, int number)
libavformat/version.h+3−0
@@ -98,5 +98,8 @@ · 97 unmodified lines
98#ifndef FF_API_PARSE_DATE98#ifndef FF_API_PARSE_DATE
99#define FF_API_PARSE_DATE (LIBAVFORMAT_VERSION_MAJOR < 54)99#define FF_API_PARSE_DATE (LIBAVFORMAT_VERSION_MAJOR < 54)
100#endif100#endif
101#ifndef FF_API_FIND_INFO_TAG
102#define FF_API_FIND_INFO_TAG (LIBAVFORMAT_VERSION_MAJOR < 54)
103#endif
101 104
102#endif //AVFORMAT_VERSION_H105#endif //AVFORMAT_VERSION_H
libavutil/parseutils.c+39−0
@@ -608,6 +608,45 @@ int av_parse_time(int64_t *timeval, const char *datestr, int duration) · 607 unmodified lines
608 return 0;608 return 0;
609}609}
610 610
611int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
612{
613 const char *p;
614 char tag[128], *q;
615
616 p = info;
617 if (*p == '?')
618 p++;
619 for(;;) {
620 q = tag;
621 while (*p != '\0' && *p != '=' && *p != '&') {
622 if ((q - tag) < sizeof(tag) - 1)
623 *q++ = *p;
624 p++;
625 }
626 *q = '\0';
627 q = arg;
628 if (*p == '=') {
629 p++;
630 while (*p != '&' && *p != '\0') {
631 if ((q - arg) < arg_size - 1) {
632 if (*p == '+')
633 *q++ = ' ';
634 else
635 *q++ = *p;
636 }
637 p++;
638 }
639 }
640 *q = '\0';
641 if (!strcmp(tag, tag1))
642 return 1;
643 if (*p != '&')
644 break;
645 p++;
646 }
647 return 0;
648}
649
611#ifdef TEST650#ifdef TEST
612 651
613#undef printf652#undef printf
libavutil/parseutils.h+8−0
@@ -106,4 +106,12 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, · 105 unmodified lines
106 */106 */
107int av_parse_time(int64_t *timeval, const char *timestr, int duration);107int av_parse_time(int64_t *timeval, const char *timestr, int duration);
108 108
109/**
110 * Attempt to find a specific tag in a URL.
111 *
112 * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
113 * Return 1 if found.
114 */
115int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
116
109#endif /* AVUTIL_PARSEUTILS_H */117#endif /* AVUTIL_PARSEUTILS_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t