]> git.vomp.tv Git - vompclient.git/commitdiff
Demuxer::scanForVideo()
authorMark Calderbank <mark@vomp.tv>
Sat, 25 Nov 2006 01:43:39 +0000 (01:43 +0000)
committerMark Calderbank <mark@vomp.tv>
Sat, 25 Nov 2006 01:43:39 +0000 (01:43 +0000)
demuxer.cc
demuxer.h

index 293536f40f503d83b006e6ac8a029887876f740b..dbdf0095dd1ede88042820307f39a41416fe931b 100644 (file)
@@ -353,6 +353,21 @@ UINT Demuxer::stripAudio(UCHAR* buf, UINT len)
   return write_pos;
 }
 
+bool Demuxer::scanForVideo(UCHAR* buf, UINT len)
+{
+  UINT pos = 3;
+  UINT pattern;
+  if (len < 4) return false;
+  pattern = (buf[0] << 16) | (buf[1] << 8) | (buf[2]);
+  while (pos < len)
+  {
+    pattern = ((pattern & 0xFFFFFF) << 8) | buf[pos++];
+    if (pattern >= (0x100|PESTYPE_VID0) && pattern <= (0x100|PESTYPE_VIDMAX))
+      return true;
+  }
+  return false;
+}
+
 bool* Demuxer::getmpAudioChannels()
 {
   return avail_mpaudchan;
index 74716246551b0b40fb193f117a367d3a646a2cd7..5cd081973451f2625cf1efe8253b9d266297067f 100644 (file)
--- a/demuxer.h
+++ b/demuxer.h
@@ -110,6 +110,11 @@ protected:
     // *static function*
     static UINT stripAudio(UCHAR* buf, UINT len);
 
+    // Scan a buffer to see if video packets are present.
+    // Returns true if video exists; false if not.
+    // *static function*
+    static bool scanForVideo(UCHAR* buf, UINT len);
+
   protected:
     // General demuxer objects and status indicators
     static Demuxer* instance;