add VIDEO_CLEAR_BUFFER and VIDEO_CONTINUE when displaying iframes.
[enigma2.git] / lib / dvb / dvb.cpp
index 5508e92050aa048f32b1091fee3c403a096957db..9ea4ac8acd4c1e1db79b374312e24948791b2f13 100644 (file)
@@ -662,7 +662,7 @@ int eDVBChannelFilePush::filterRecordData(const unsigned char *_data, int len, s
        unsigned char *data = (unsigned char*)_data; /* remove that const. we know what we are doing. */
 
        eDebug("filterRecordData, size=%d (mod 188=%d), first byte is %02x", len, len %188, data[0]);
-       
+
        unsigned char *d = data;
        while ((d = (unsigned char*)memmem(d, data + len - d, "\x00\x00\x01", 3)))
        {
@@ -682,7 +682,7 @@ int eDVBChannelFilePush::filterRecordData(const unsigned char *_data, int len, s
                        {
                                        /* we are allowing data, and stop allowing data on the next frame. 
                                           we now found a frame. so stop here. */
-                               memset(data + offset, 188 - (offset%188), 0xFF); /* zero out rest of TS packet */
+                               memset(data + offset, 0, 188 - (offset%188)); /* zero out rest of TS packet */
                                current_span_remaining = 0;
                                m_iframe_state = 0;
                                unsigned char *fts = ts + 188;
@@ -692,7 +692,7 @@ int eDVBChannelFilePush::filterRecordData(const unsigned char *_data, int len, s
                                        fts[2] |= 0xff; /* drop packet */
                                        fts += 188;
                                }
-                               
+
                                return len; // ts_offset + 188; /* deliver this packet, but not more. */
                        } else
                        {
@@ -707,12 +707,11 @@ int eDVBChannelFilePush::filterRecordData(const unsigned char *_data, int len, s
                                
                                        fts += 188;
                                }
-                               
                                                /* force payload only */
                                ts[3] &= ~0x30;
                                ts[3] |=  0x10;
                                
-                               memset(ts + 4, ts_offset - 4, 0xFF);
+//                             memset(ts + 4, 0xFF, (offset % 188) - 4);
 
                                m_iframe_state = 1;
                        }
@@ -723,10 +722,11 @@ int eDVBChannelFilePush::filterRecordData(const unsigned char *_data, int len, s
                                eDebug("now locked to pid %04x", pid);
                                m_pid = pid;
                        }
-                       m_pid = 0x6e;
+//                     m_pid = 0x6e;
                        d += 4;
                } else
                        d += 4; /* ignore */
+
        }
 
        if (m_iframe_state == 1)
@@ -887,7 +887,7 @@ void eDVBChannel::cueSheetEvent(int event)
 }
 
        /* align toward zero */
-static inline int align(long long x, int align)
+static inline long long align(long long x, int align)
 {
        int sign = x < 0;
 
@@ -933,7 +933,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                max = align(m_skipmode_n, blocksize);
        }
 
-       eDebug("getNextSourceSpan, current offset is %08llx!", current_offset);
+       eDebug("getNextSourceSpan, current offset is %08llx, m_skipmode_m = %d!", current_offset, m_skipmode_m);
 
        current_offset += align(m_skipmode_m, blocksize);
 
@@ -1010,14 +1010,14 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                }
 
                eDebug("ok, resolved skip (rel: %d, diff %lld), now at %08llx", relative, pts, offset);
-               current_offset = offset;
+               current_offset = align(offset, blocksize); /* in case tstools return non-aligned offset */
        }
 
        for (std::list<std::pair<off_t, off_t> >::const_iterator i(m_source_span.begin()); i != m_source_span.end(); ++i)
        {
-               int aligned_start = align(i->first, blocksize);
-               int aligned_end = align(i->second, blocksize);
-               
+               long long aligned_start = align(i->first, blocksize);
+               long long aligned_end = align(i->second, blocksize);
+       
                if ((current_offset >= aligned_start) && (current_offset < aligned_end))
                {
                        start = current_offset;
@@ -1066,6 +1066,8 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                                start = aligned_end - len;
                                eDebug("skipping to %llx, %d", start, len);
                        }
+                       
+                       eDebug("result: %llx, %x (%llx %llx)", start, size, aligned_start, aligned_end);
                        return;
                }
        }
@@ -1078,7 +1080,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
        }
        
        start = current_offset;
-       size = blocksize;
+       size = max;
 
        eDebug("END OF CUESHEET. (%08llx, %d)", start, size);
        return;