]> git.vomp.tv Git - vompclient.git/commitdiff
Mods to get 250k on first packet for demuxer.scan
authorChris Tallon <chris@vomp.tv>
Sun, 14 Aug 2005 15:23:27 +0000 (15:23 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 14 Aug 2005 15:23:27 +0000 (15:23 +0000)
playerradio.cc
playerradio.h
playervideo.cc
playervideo.h
tcp.cc
vdr.cc
vdr.h

index 0c791345b2c4a8eb4e3926394d6ad9763e12aad7..666872a04e51a61c93d617720647c1e3fde8cfbf 100644 (file)
@@ -306,14 +306,14 @@ void PlayerRadio::call()
 
 void PlayerRadio::threadMethod()
 {
-  UCHAR buf[blockSize];
-  int thisRead;
-  int writeLength;
-  int thisWrite;
+  UCHAR* buf;
+  UINT thisRead;
+  UINT writeLength;
+  UINT thisWrite;
 
   VDR* vdr = VDR::getInstance();
 
-  int askFor;
+  UINT askFor;
   while(1)
   {
     thisRead = 0;
@@ -329,7 +329,8 @@ void PlayerRadio::threadMethod()
     {
       askFor = streamLength - feedPosition;
     }
-    thisRead = vdr->getBlock(buf, feedPosition, askFor);
+    buf = vdr->getBlock(feedPosition, askFor, &thisRead);
+    if (!buf) break;
 
     // temp
     printf("Written direct: %i\n", write(audio->getFD(), buf, thisRead));
@@ -342,9 +343,9 @@ void PlayerRadio::threadMethod()
     }
     else if (feedMode == MODE_BACKWARDS)
     {
-      if (feedPosition >= 100000)
+      if (feedPosition >= blockSize)
       {
-        feedPosition -= 100000;
+        feedPosition -= blockSize;
       }
       else
       {
@@ -355,6 +356,8 @@ void PlayerRadio::threadMethod()
 
     threadCheckExit();
 
+    free(buf);
+
 /*    while(writeLength < thisRead)
     {
       thisWrite = stream.put(buf + writeLength, thisRead - writeLength);
index eb79b851fe4800c628aecca22280b7a41156051a..82a9ce0eb4b04f35df4edf6a6c4c16d21a7a6e5c 100644 (file)
@@ -67,7 +67,7 @@ class PlayerRadio : public Player
     UCHAR feedMode;
     const static UCHAR MODE_NORMAL = 1;
     const static UCHAR MODE_BACKWARDS = 2;
-    const static int blockSize = 2000;
+    const static UINT blockSize = 2000;
 
     UCHAR playing;    // As in not stopped, (playing && paused) can == TRUE
     UCHAR paused;     // Must be in playing state as well
index 8fc632f188c9e703433de2e1675d509ca4f74f72..8b4fe5e11bb981814177088becf2059e4247d315 100644 (file)
@@ -491,14 +491,14 @@ void PlayerVideo::call()
 
 void PlayerVideo::threadMethod()
 {
-  UCHAR buf[blockSize];
-  int thisRead;
-  int writeLength;
-  int thisWrite;
+  UCHAR* buf;
+  UINT thisRead;
+  UINT writeLength;
+  UINT thisWrite;
 
   VDR* vdr = VDR::getInstance();
 
-  int askFor;
+  UINT askFor;
   while(1)
   {
     thisRead = 0;
@@ -515,14 +515,36 @@ void PlayerVideo::threadMethod()
       lastRescan = time(NULL);
     }
 
-    // a bit hackey. this needs to be split to live and rec players
-    if (streamLength && (feedPosition >= streamLength)) break;
-    askFor = blockSize;
-    if (streamLength && ((feedPosition + blockSize) > streamLength))
+    if (streamLength) // is playing a recording
     {
-      askFor = streamLength - feedPosition;
+      if (feedPosition >= streamLength) break;  // finished playback
+
+      if (startup)
+      {
+        if (startupBlockSize > streamLength)
+          askFor = streamLength; // is a very small recording!
+        else
+          askFor = startupBlockSize; // normal, but a startup sized block to detect all the audio streams
+      }
+      else
+      {
+        if ((feedPosition + blockSize) > streamLength) // last block of recording
+          askFor = streamLength - feedPosition;
+        else // normal
+          askFor = blockSize;
+      }
     }
-    thisRead = vdr->getBlock(buf, feedPosition, askFor);
+    else // is playing live
+    {
+      if (startup)
+        askFor = startupBlockSize; // find audio streams sized block
+      else
+        askFor = blockSize; // normal
+    }
+
+    buf = vdr->getBlock(feedPosition, askFor, &thisRead);
+    if (!buf) break;
+
     if (startup)
     {
       int a_stream = demuxer.scan(buf, thisRead);
@@ -537,9 +559,9 @@ void PlayerVideo::threadMethod()
     }
     else if (feedMode == MODE_BACKWARDS)
     {
-      if (feedPosition >= 100000)
+      if (feedPosition >= blockSize)
       {
-        feedPosition -= 100000;
+        feedPosition -= blockSize;
         demuxer.seek();
       }
       else
@@ -566,6 +588,9 @@ void PlayerVideo::threadMethod()
 
       threadCheckExit();
     }
+
+    free(buf);
+
   }
 
   // end of recording
index 08e5ae5911be3bfbf42d804dcb8ba4c1f1a5c969..eb5884917f7bc14b559dbcd2109f52b68bc3ed1c 100644 (file)
@@ -74,7 +74,8 @@ class PlayerVideo : public Player
     time_t lastRescan;
     const static UCHAR MODE_NORMAL = 1;
     const static UCHAR MODE_BACKWARDS = 2;
-    const static int blockSize = 100000;
+    const static UINT blockSize = 100000;
+    const static UINT startupBlockSize = 250000;
 
     UCHAR playing;    // As in not stopped, (playing && paused) can == TRUE
     UCHAR paused;     // Must be in playing state as well
diff --git a/tcp.cc b/tcp.cc
index 0546d6d0378a25693f93704ae4b5fc74124e4fea..f71f0e4f13872021e08ac36dc5560b4e2a7dbb0d 100644 (file)
--- a/tcp.cc
+++ b/tcp.cc
@@ -181,9 +181,9 @@ UCHAR* TCP::receivePacket()
 
   packetLength = ntohl(packetLength);
 
-  if (packetLength > 200000)
+  if (packetLength > 500000)
   {
-    Log::getInstance()->log("TCP", Log::ERR, "Received packet > 200000");
+    Log::getInstance()->log("TCP", Log::ERR, "Received packet > 500000");
     return NULL;
   }
   if (packetLength == 0)
diff --git a/vdr.cc b/vdr.cc
index e1a899953d051fc1080c64b09f267c9e18a0f4ea..a8bb1714fbd2c89eadb2397c34a2f6149a36477a 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -475,31 +475,28 @@ int VDR::stopStreaming()
   return toReturn;
 }
 
-int VDR::getBlock(UCHAR* buf, ULLONG position, int amount)
+UCHAR* VDR::getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived)
 {
   UCHAR buffer[20];
 
   *(unsigned long*)&buffer[0] = htonl(16);
   *(unsigned long*)&buffer[4] = htonl(VDR_GETBLOCK);
   *(ULLONG*)&buffer[8]        = htonll(position);
-  *(unsigned long*)&buffer[16] = htonl(amount);
+  *(unsigned long*)&buffer[16] = htonl(maxAmount);
 
   pthread_mutex_lock(&mutex);
   int a = tcp->sendPacket(buffer, 20);
   if (a != 20)
   {
     pthread_mutex_unlock(&mutex);
-    return 0;
+    return NULL;
   }
 
   unsigned char* p = (unsigned char*)tcp->receivePacket();
   pthread_mutex_unlock(&mutex);
-  if (!p) return 0;
-  int dataLength = tcp->getDataLength();
-
-  memcpy(buf, p, dataLength);
-  free(p);
-  return dataLength;
+  if (!p) return NULL;
+  *amountReceived = tcp->getDataLength();
+  return p;
 }
 
 ULLONG VDR::streamRecording(Recording* rec)
diff --git a/vdr.h b/vdr.h
index 072adf8a263e6c25954f4269ddca19e434120195..bef6566009d8def6a5edd7d59d8edc0128409ce4 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -67,7 +67,7 @@ class VDR
     List*      getChannelsList(ULONG type);
     int        streamChannel(ULONG number);
 
-    int        getBlock(UCHAR* buf, ULLONG position, int maxAmount);
+    UCHAR*     getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived);
     int        stopStreaming();
     int        getChannelSchedule(ULONG number);
     int        configSave(char* section, char* key, char* value);