History

Move av_gettime() to libavutil

Mans Rullgard committed 14 years ago

Commit ae0a3011 parent db7d8fb6 files · +70 −9Browse files

Unified · Split

6 files
  1. libavformat/avformat.h +2 −3
  2. libavformat/utils.c +4 −6
  3. libavformat/version.h +3 −0
  4. libavutil/Makefile +2 −0
  5. libavutil/time.c +30 −0
  6. libavutil/time.h +29 −0
libavformat/avformat.h+2−3
@@ -1635,10 +1635,9 @@ void av_dump_format(AVFormatContext *ic, · 1634 unmodified lines
16351635 const char *url,
16361636 int is_output);
16371637
1638−/**
1639− * Get the current time in microseconds.
1640− */
1638+#if FF_API_AV_GETTIME
16411639 int64_t av_gettime(void);
1640+#endif
16421641
16431642 /**
16441643 * Return in 'buf' the path with '%d' replaced by a number.
libavformat/utils.c+4−6
@@ -38,8 +38,6 @@ · 37 unmodified lines
3838 #include "riff.h"
3939 #include "audiointerleave.h"
4040 #include "url.h"
41−#include <sys/time.h>
42−#include <time.h>
4341 #include <stdarg.h>
4442 #if CONFIG_NETWORK
4543 #include "network.h"
@@ -3411,12 +3409,12 @@ void av_dump_format(AVFormatContext *ic, · 3365 unmodified lines
34113409 av_free(printed);
34123410 }
34133411
3414−int64_t av_gettime(void)
3412+#if FF_API_AV_GETTIME && CONFIG_SHARED && HAVE_SYMVER
3413+FF_SYMVER(int64_t, av_gettime, (void), "LIBAVFORMAT_54")
34153414 {
3416− struct timeval tv;
3417− gettimeofday(&tv,NULL);
3418− return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
3415+ return av_gettime();
34193416 }
3417+#endif
34203418
34213419 uint64_t ff_ntp_time(void)
34223420 {
libavformat/version.h+3−0
@@ -59,5 +59,8 @@ · 58 unmodified lines
5959 #ifndef FF_API_INTERLEAVE_PACKET
6060 #define FF_API_INTERLEAVE_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
6161 #endif
62+#ifndef FF_API_AV_GETTIME
63+#define FF_API_AV_GETTIME (LIBAVFORMAT_VERSION_MAJOR < 55)
64+#endif
6265
6366 #endif /* AVFORMAT_VERSION_H */
libavutil/Makefile+2−0
@@ -36,6 +36,7 @@ HEADERS = adler32.h \ · 35 unmodified lines
3636 rational.h \
3737 samplefmt.h \
3838 sha.h \
39+ time.h \
3940
4041 ARCH_HEADERS = bswap.h \
4142 intmath.h \
@@ -77,6 +78,7 @@ OBJS = adler32.o \ · 35 unmodified lines
7778 rc4.o \
7879 samplefmt.o \
7980 sha.o \
81+ time.o \
8082 tree.o \
8183 utils.o \
8284
libavutil/time.c+30−0
@@ -0,0 +1,30 @@
1+/*
2+ * This file is part of Libav.
3+ *
4+ * Libav is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * Libav is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with Libav; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+#include <stddef.h>
20+#include <stdint.h>
21+#include <sys/time.h>
22+
23+#include "libavutil/time.h"
24+
25+int64_t av_gettime(void)
26+{
27+ struct timeval tv;
28+ gettimeofday(&tv, NULL);
29+ return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
30+}
libavutil/time.h+29−0
@@ -0,0 +1,29 @@
1+/*
2+ * This file is part of Libav.
3+ *
4+ * Libav is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * Libav is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with Libav; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+#ifndef AVUTIL_TIME_H
20+#define AVUTIL_TIME_H
21+
22+#include <stdint.h>
23+
24+/**
25+ * Get the current time in microseconds.
26+ */
27+int64_t av_gettime(void);
28+
29+#endif /* AVUTIL_TIME_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