[rtmpdump] [PATCH] Resuming for files larger than 4 GB (and 2 GB as well)

ze bop zebop117 at gmail.com
Sat Nov 16 17:02:21 CET 2013


commit df503880ca21179d1bcf90c790ef7e0a3a4acbb3
Author: nospam <no at spam.com>
Date:   Sat Nov 16 19:53:08 2013 +0400

    Resuming for files larger than 4 GB (and 2 GB as well). Tested on
Windows only.

diff --git a/rtmpdump.c b/rtmpdump.c
index 13741a7..103e07f 100644
--- a/rtmpdump.c
+++ b/rtmpdump.c
@@ -36,10 +36,12 @@
 #ifdef WIN32
 #define fseeko fseeko64
 #define ftello ftello64
+typedef off64_t z_off_t;
 #include <io.h>
 #include <fcntl.h>
 #define    SET_BINMODE(f)    setmode(fileno(f), O_BINARY)
 #else
+typedef off_t z_off_t;
 #define    SET_BINMODE(f)
 #endif

@@ -133,7 +135,7 @@ static const AVal av_true = AVC("true");
 int
 OpenResumeFile(const char *flvFile,    // file name [in]
            FILE ** file,    // opened file [out]
-           off_t * size,    // size of the file [out]
+           z_off_t * size,    // size of the file [out]
            char **metaHeader,    // meta data read from the file [out]
            uint32_t * nMetaHeaderSize,    // length of metaHeader [out]
            double *duration)    // duration of the stream in ms [out]
@@ -148,9 +150,9 @@ OpenResumeFile(const char *flvFile,    // file name [in]
   if (!*file)
     return RD_SUCCESS;        // RD_SUCCESS, because we go to fresh
file mode instead of quiting

-  fseek(*file, 0, SEEK_END);
+  fseeko(*file, 0, SEEK_END);
   *size = ftello(*file);
-  fseek(*file, 0, SEEK_SET);
+  fseeko(*file, 0, SEEK_SET);

   if (*size > 0)
     {
@@ -178,7 +180,7 @@ OpenResumeFile(const char *flvFile,    // file name [in]
     }

       uint32_t dataOffset = AMF_DecodeInt32(hbuf + 5);
-      fseek(*file, dataOffset, SEEK_SET);
+      fseeko(*file, dataOffset, SEEK_SET);

       if (fread(hbuf, 1, 4, *file) != 4)
     {
@@ -194,7 +196,7 @@ OpenResumeFile(const char *flvFile,    // file name [in]
     }

       // go through the file to find the meta data!
-      off_t pos = dataOffset + 4;
+      z_off_t pos = dataOffset + 4;
       int bFoundMetaHeader = FALSE;

       while (pos < *size - 4 && !bFoundMetaHeader)
@@ -282,12 +284,12 @@ GetLastKeyframe(FILE * file,    // output file [in]
   char buffer[bufferSize];
   uint8_t dataType;
   int bAudioOnly;
-  off_t size;
+  z_off_t size;

-  fseek(file, 0, SEEK_END);
+  fseeko(file, 0, SEEK_END);
   size = ftello(file);

-  fseek(file, 4, SEEK_SET);
+  fseeko(file, 4, SEEK_SET);
   if (fread(&dataType, sizeof(uint8_t), 1, file) != 1)
     return RD_FAILED;

@@ -301,7 +303,7 @@ GetLastKeyframe(FILE * file,    // output file [in]
   //if(!bAudioOnly) // we have to handle video/video+audio different
since we have non-seekable frames
   //{
   // find the last seekable frame
-  off_t tsize = 0;
+  z_off_t tsize = 0;
   uint32_t prevTagSize = 0;

   // go through the file and find the last video keyframe
@@ -447,7 +449,7 @@ Download(RTMP * rtmp,        // connected RTMP object
   int bufferSize = 64 * 1024;
   char *buffer;
   int nRead = 0;
-  off_t size = ftello(file);
+  z_off_t size = ftello(file);
   unsigned long lastPercent = 0;

   rtmp->m_read.timestamp = dSeek;
@@ -1213,7 +1215,7 @@ main(int argc, char **argv)
   if (!bLiveStream && !bRealtimeStream && !(protocol & RTMP_FEATURE_HTTP))
     rtmp.Link.lFlags |= RTMP_LF_BUFX;

-  off_t size = 0;
+  z_off_t size = 0;

   // ok, we have to get the timestamp of the last keyframe (only
keyframes are seekable) / last audio frame (audio only streams)
   if (bResume)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: commit-df50388
Type: application/octet-stream
Size: 3322 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/rtmpdump/attachments/20131116/462f22b6/attachment.obj>


More information about the rtmpdump mailing list