[FFmpeg-cvslog] avserver: move avserver-specific code from ffmdec.c to avserver.c

Mans Rullgard git at videolan.org
Wed Oct 17 14:21:52 CEST 2012


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Mon Oct 15 22:24:41 2012 +0100| [3b20eb25e7b95fafdccbb594c947a69c5d027b2c] | committer: Mans Rullgard

avserver: move avserver-specific code from ffmdec.c to avserver.c

This way avserver only depends on the data structures of the ffm
demuxer, which it already does, and not also on private functions
being exported by the library.

Signed-off-by: Mans Rullgard <mans at mansr.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3b20eb25e7b95fafdccbb594c947a69c5d027b2c
---

 avserver.c           |   32 ++++++++++++++++++++++++++++++++
 libavformat/ffm.h    |    4 ----
 libavformat/ffmdec.c |   33 ---------------------------------
 3 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/avserver.c b/avserver.c
index 6b01b15..994edcd 100644
--- a/avserver.c
+++ b/avserver.c
@@ -39,6 +39,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/lfg.h"
 #include "libavutil/dict.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/random_seed.h"
 #include "libavutil/parseutils.h"
@@ -323,6 +324,37 @@ static AVLFG random_state;
 
 static FILE *logfile = NULL;
 
+static int64_t ffm_read_write_index(int fd)
+{
+    uint8_t buf[8];
+
+    lseek(fd, 8, SEEK_SET);
+    if (read(fd, buf, 8) != 8)
+        return AVERROR(EIO);
+    return AV_RB64(buf);
+}
+
+static int ffm_write_write_index(int fd, int64_t pos)
+{
+    uint8_t buf[8];
+    int i;
+
+    for(i=0;i<8;i++)
+        buf[i] = (pos >> (56 - i * 8)) & 0xff;
+    lseek(fd, 8, SEEK_SET);
+    if (write(fd, buf, 8) != 8)
+        return AVERROR(EIO);
+    return 8;
+}
+
+static void ffm_set_write_index(AVFormatContext *s, int64_t pos,
+                                int64_t file_size)
+{
+    FFMContext *ffm = s->priv_data;
+    ffm->write_index = pos;
+    ffm->file_size = file_size;
+}
+
 /* FIXME: make avserver work with IPv6 */
 /* resolve host with also IP address parsing */
 static int resolve_host(struct in_addr *sin_addr, const char *hostname)
diff --git a/libavformat/ffm.h b/libavformat/ffm.h
index 6ce5e04..70c3e88 100644
--- a/libavformat/ffm.h
+++ b/libavformat/ffm.h
@@ -56,8 +56,4 @@ typedef struct FFMContext {
     uint8_t packet[FFM_PACKET_SIZE];
 } FFMContext;
 
-int64_t ffm_read_write_index(int fd);
-int ffm_write_write_index(int fd, int64_t pos);
-void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
-
 #endif /* AVFORMAT_FFM_H */
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 50c7416..e6730eb 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -24,39 +24,6 @@
 #include "avformat.h"
 #include "internal.h"
 #include "ffm.h"
-#if CONFIG_AVSERVER
-#include <unistd.h>
-
-int64_t ffm_read_write_index(int fd)
-{
-    uint8_t buf[8];
-
-    lseek(fd, 8, SEEK_SET);
-    if (read(fd, buf, 8) != 8)
-        return AVERROR(EIO);
-    return AV_RB64(buf);
-}
-
-int ffm_write_write_index(int fd, int64_t pos)
-{
-    uint8_t buf[8];
-    int i;
-
-    for(i=0;i<8;i++)
-        buf[i] = (pos >> (56 - i * 8)) & 0xff;
-    lseek(fd, 8, SEEK_SET);
-    if (write(fd, buf, 8) != 8)
-        return AVERROR(EIO);
-    return 8;
-}
-
-void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size)
-{
-    FFMContext *ffm = s->priv_data;
-    ffm->write_index = pos;
-    ffm->file_size = file_size;
-}
-#endif // CONFIG_AVSERVER
 
 static int ffm_is_avail_data(AVFormatContext *s, int size)
 {



More information about the ffmpeg-cvslog mailing list