Good day!

For some reasons i want to have class MPEG1or2FileServerDemux seekable
to have the possibility to seek on the input file. My small patch do
this work. I hope that this possibility will be usefull not only for me
and will be included in future releases of live555.

-- 
See you!
---
Vityusha V. Vinokurov - programmer
mailto:vic...@dialog.su
http://www.dialog.su
--- ..\live\liveMedia\include\MPEG1or2FileServerDemux.hh        2010-06-21 
09:23:58.000000000 +0400
+++ liveMedia\include\MPEG1or2FileServerDemux.hh        2010-07-01 
14:01:49.093270700 +0400
@@ -27,6 +27,9 @@
 #ifndef _MPEG_1OR2_DEMUXED_ELEMENTARY_STREAM_HH
 #include "MPEG1or2DemuxedElementaryStream.hh"
 #endif
+#ifndef _BYTE_STREAM_FILE_SOURCE_HH
+#include "ByteStreamFileSource.hh"
+#endif
 
 class MPEG1or2FileServerDemux: public Medium {
 public:
@@ -43,6 +46,8 @@
   unsigned fileSize() const { return fFileSize; }
   float fileDuration() const { return fFileDuration; }
 
+  void SeekStream(float offset);
+
 private:
   MPEG1or2FileServerDemux(UsageEnvironment& env, char const* fileName,
                          Boolean reuseFirstSource);
@@ -59,6 +64,7 @@
   unsigned fFileSize;
   float fFileDuration;
   Boolean fReuseFirstSource;
+  ByteStreamFileSource* fileSource;
   MPEG1or2Demux* fSession0Demux;
   MPEG1or2Demux* fLastCreatedDemux;
   u_int8_t fLastClientSessionId;

--- ..\live\liveMedia\MPEG1or2FileServerDemux.cpp       2010-06-21 
09:23:58.000000000 +0400
+++ liveMedia\MPEG1or2FileServerDemux.cpp       2010-07-01 14:01:34.624520700 
+0400
@@ -20,7 +20,6 @@
 
 #include "MPEG1or2FileServerDemux.hh"
 #include "MPEG1or2DemuxedServerMediaSubsession.hh"
-#include "ByteStreamFileSource.hh"
 
 MPEG1or2FileServerDemux*
 MPEG1or2FileServerDemux::createNew(UsageEnvironment& env, char const* fileName,
@@ -77,7 +76,7 @@
     // happening automatically.
     if (fSession0Demux == NULL) {
       // Open our input file as a 'byte-stream file source':
-      ByteStreamFileSource* fileSource
+      fileSource
        = ByteStreamFileSource::createNew(envir(), fFileName);
       if (fileSource == NULL) return NULL;
       fSession0Demux = MPEG1or2Demux::createNew(envir(), fileSource, 
False/*note!*/);
@@ -88,7 +87,7 @@
     // demux for it:
     if (clientSessionId != fLastClientSessionId) {
       // Open our input file as a 'byte-stream file source':
-      ByteStreamFileSource* fileSource
+      fileSource
        = ByteStreamFileSource::createNew(envir(), fFileName);
       if (fileSource == NULL) return NULL;
 
@@ -108,6 +107,10 @@
   return demuxToUse->newElementaryStream(streamIdTag);
 }
 
+void MPEG1or2FileServerDemux::SeekStream(float offset) {
+  u_int64_t bOffset = (u_int64_t)(fileSource->fileSize() * offset);
+  fileSource->seekToByteAbsolute(bOffset);
+}
 
 static Boolean getMPEG1or2TimeCode(FramedSource* dataSource,
                                   MPEG1or2Demux& parentDemux,
_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to