From 823ce3ed7d0060e08955c8c6379f634c0f4539e8 Mon Sep 17 00:00:00 2001
From: thlo <smarttv640@gmail.com>
Date: Sat, 30 Nov 2013 14:00:45 +0100
Subject: Fixed Pcr method.

---
 responselive.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/responselive.c b/responselive.c
index 690789d..6204cc2 100644
--- a/responselive.c
+++ b/responselive.c
@@ -146,6 +146,7 @@ cResponseLive::cResponseLive(cHttpResource* req, string chan_id) : cResponseBase
     sendHeaders(200, "OK", NULL, "video/mpeg", -1, -1);
   }
   else {
+    *(mLog->log()) << DEBUGPREFIX << " cResponseLive::cResponseLive - Constructor - sending Error" << endl;
     sendError(404, "Not Found.", NULL, "004 Resource Busy");
   }
 }
@@ -174,6 +175,20 @@ bool cResponseLive::InitRelay(string channel_id) {
   char buf [40];
   snprintf(buf, 40, "%s", *(channel->GetChannelID()).ToString());
 
+  *(mLog->log()) << DEBUGPREFIX 
+		 << " vpid= " << channel->Vpid()
+		 << " vtype= " << channel->Vtype()
+		 << " ppid= " << channel->Ppid()
+		 << endl;
+
+  if (channel->Vpid() == 0) {
+    mStartThreshold= 10 * 188;
+    
+    *(mLog->log()) << DEBUGPREFIX << " cResponseLive::InitRelay Audio Only service  detected. mStartThreshold is " << mStartThreshold 
+		   << " (" << mStartThreshold/188 << " Pkts)" << endl;
+    mInStartPhase = true;
+  }
+
   if (channel->Vpid() != 0) {
     mVpid = channel->Vpid();
     mVtype = channel->Vtype();
@@ -252,8 +267,13 @@ int cResponseLive::fillDataBlk() {
     break;
   case 2:
     return fillDataBlk_iframe();
-    break;
+    break;    
   };
+
+  *(mLog->log()) << DEBUGPREFIX
+		 << " cResponseLive::fillDataBlk() - ERROR: should not be here " << endl;
+  
+  return ERROR;
 }
 
 int cResponseLive::fillDataBlk_pcr() {
@@ -288,8 +308,11 @@ int cResponseLive::fillDataBlk_pcr() {
 	    if (pcr != -1) {
 	      // pcr pkt found
 	      if ((r  - (offset+188)) < threshold) {
+		*(mLog->log()) << DEBUGPREFIX
+			       << " cResponseLive::fillDataBlk() - PCR found but not sufficient data " 
+			     << pcr << endl;
 		already_deleted = true;
-		mRelay->mRingBuffer->Del(offset + 188);
+		mRelay->mRingBuffer->Del(offset);
 		break;
 	      }
 	      *(mLog->log()) << DEBUGPREFIX
-- 
cgit v1.2.3