]> git.vomp.tv Git - vompclient.git/commitdiff
21 CWFs
authorChris Tallon <chris@vomp.tv>
Mon, 16 Mar 2020 23:11:29 +0000 (23:11 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 16 Mar 2020 23:11:29 +0000 (23:11 +0000)
stream.cc
stream.h
tcp.cc
tcp.h
vdr.cc

index 64049c577c840a9322d36b4e4cd36549cb40c502..e3d94df9f06d46a9ce720ab53ac60763df0d9001 100644 (file)
--- a/stream.cc
+++ b/stream.cc
@@ -1,5 +1,6 @@
 /*
     Copyright 2005-2006 Mark Calderbank
+    Copyright 2020 Chris Tallon
 
     This file is part of VOMP.
 
@@ -14,8 +15,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #include <stdlib.h>
@@ -32,13 +32,16 @@ Stream::~Stream()
 void Stream::shutdown()
 {
   if (initted) free(outbuf);
+
   initted = 0;
 }
 
 int Stream::init(DrainTarget* tdt, int bufsize)
 {
-  outbuf = (UCHAR*)malloc(bufsize);
+  outbuf = static_cast<UCHAR*>(malloc(bufsize));
+
   if (!outbuf) return 0;
+
   draintarget = tdt;
   bufferSize = bufsize;
   initted = 1;
@@ -55,50 +58,59 @@ void Stream::flush()
   if (draintarget) draintarget->ResetTimeOffsets();
 }
 
-int Stream::put(const UCHAR* inbuf, int len, UCHAR type,unsigned int index)
+int Stream::put(const UCHAR* inbuf, int len, UCHAR type, unsigned int index)
 {
   int ret = 0;
+
   if (!draintarget) return 0;
+
   MediaPacket newPacket;
   newPacket.length = len;
   newPacket.pos_buffer = 0;
   newPacket.type = type;
-  newPacket.pts=0;
-  newPacket.dts=0;
-  newPacket.synched=false;
-  newPacket.index=index;
-  newPacket.disconti=false;
-  newPacket.presentation_time=0;
-
-  if (type!=MPTYPE_MPEG_AUDIO_LAYER3) {//no PES
+  newPacket.pts = 0;
+  newPacket.dts = 0;
+  newPacket.synched = false;
+  newPacket.index = index;
+  newPacket.disconti = false;
+  newPacket.presentation_time = 0;
+
+  if (type != MPTYPE_MPEG_AUDIO_LAYER3) //no PES
+  {
     //Extract the pts...
-      bool hasdts=false;
-    if ((inbuf[7] & 0x80) && len>14 ) {
-        newPacket.synched=true;
-        newPacket.pts=((ULLONG)(inbuf[9] & 0x0E) << 29 ) |
-                    ( (ULLONG)(inbuf[10])        << 22 ) |
-                    ( (ULLONG)(inbuf[11] & 0xFE) << 14 ) |
-                     ( (ULLONG)(inbuf[12])        <<  7 ) |
-                     ( (ULLONG)(inbuf[13] & 0xFE) >>  1 );
-        if ((inbuf[7] & 0x40) && len>19) {
-            newPacket.dts=((ULLONG)(inbuf[14] & 0x0E) << 29 ) |
-                    ( (ULLONG)(inbuf[15])        << 22 ) |
-                    ( (ULLONG)(inbuf[16] & 0xFE) << 14 ) |
-                     ( (ULLONG)(inbuf[17])        <<  7 ) |
-                     ( (ULLONG)(inbuf[18] & 0xFE) >>  1 );
-            hasdts=true;
-        }
-        //ok we have the pts now convert it to a continously time code in 100ns units
-        if (hasdts && draintarget->dtsTimefix()) newPacket.presentation_time=(ULLONG)(newPacket.dts*10000LL/90LL);
-        else newPacket.presentation_time=(ULLONG)(newPacket.pts*10000LL/90LL);
-
-        //newPacket.presentation_time-=draintarget->SetStartOffset((ULLONG)(newPacket.pts*10000LL/90LL),&newPacket.disconti);
-        newPacket.presentation_time-=draintarget->SetStartOffset((ULLONG)(newPacket.pts*10000LL/90LL),&newPacket.disconti);
+    bool hasdts = false;
+
+    if ((inbuf[7] & 0x80) && len > 14 )
+    {
+      newPacket.synched = true;
+      newPacket.pts = ( static_cast<ULLONG>(inbuf[9] & 0x0E)  << 29 ) |
+                      ( static_cast<ULLONG>(inbuf[10])        << 22 ) |
+                      ( static_cast<ULLONG>(inbuf[11] & 0xFE) << 14 ) |
+                      ( static_cast<ULLONG>(inbuf[12])        <<  7 ) |
+                      ( static_cast<ULLONG>(inbuf[13] & 0xFE) >>  1 );
+
+      if ((inbuf[7] & 0x40) && len > 19)
+      {
+        newPacket.dts = ( static_cast<ULLONG>(inbuf[14] & 0x0E) << 29 ) |
+                        ( static_cast<ULLONG>(inbuf[15])        << 22 ) |
+                        ( static_cast<ULLONG>(inbuf[16] & 0xFE) << 14 ) |
+                        ( static_cast<ULLONG>(inbuf[17])        <<  7 ) |
+                        ( static_cast<ULLONG>(inbuf[18] & 0xFE) >>  1 );
+        hasdts = true;
+      }
+
+      //ok we have the pts now convert it to a continously time code in 100ns units
+      if (hasdts && draintarget->dtsTimefix()) newPacket.presentation_time = static_cast<ULLONG>(newPacket.dts * 10000LL / 90LL);
+      else newPacket.presentation_time = static_cast<ULLONG>(newPacket.pts * 10000LL / 90LL);
+
+      //newPacket.presentation_time-=draintarget->SetStartOffset(static_cast<ULLONG>(newPacket.pts*10000LL/90LL),&newPacket.disconti);
+      newPacket.presentation_time -= draintarget->SetStartOffset(static_cast<ULLONG>(newPacket.pts * 10000LL / 90LL), &newPacket.disconti);
     }
   }
 
   mutex.lock();
   int front, back;
+
   if (mediapackets.empty())
   {
     back = 0; front = bufferSize;
@@ -107,8 +119,10 @@ int Stream::put(const UCHAR* inbuf, int len, UCHAR type,unsigned int index)
   {
     front = mediapackets.front().pos_buffer;
     back = mediapackets.back().pos_buffer + mediapackets.back().length;
+
     if (back == bufferSize) back = 0;
   }
+
   mutex.unlock();
 
   if (back <= front)
@@ -135,34 +149,46 @@ int Stream::put(const UCHAR* inbuf, int len, UCHAR type,unsigned int index)
     mutex.lock();
     mediapackets.push_back(newPacket);
     mutex.unlock();
-  } else {
-     // Log::getInstance()->log("Stream", Log::DEBUG, "We are full %d!",bufferSize);
+  }
+  else
+  {
+    // Log::getInstance()->log("Stream", Log::DEBUG, "We are full %d!",bufferSize);
   }
 
   return ret;
 }
 
-bool Stream::drain(bool * dataavail)
+bool Stream::drain(bool* dataavail)
 {
   bool ret = false;
+
   if (dataavail) *dataavail = false;
+
   if (draintarget->DrainTargetBufferFull()) return false; //We are full, no need to do something else
+
   mutex.lock();
   UINT listlength = mediapackets.size();
+
   if (listlength != 0)
   {
     draintarget->PrepareMediaSample(mediapackets, cur_packet_pos);
     mutex.unlock();
+
     if (dataavail && draintarget->DrainTargetReady()) *dataavail = true;
+
     UINT consumed = draintarget->DeliverMediaSample(outbuf, &cur_packet_pos);
     mutex.lock();
+
     if (consumed != 0) ret = true;
+
     if (consumed > listlength) consumed = listlength;
-    while (consumed--) 
+
+    while (consumed--)
     {
-        mediapackets.pop_front();
+      mediapackets.pop_front();
     }
   }
+
   mutex.unlock();
   return ret;
 }
index 301138f90a0e933295b28c1f1e23e48bb0910b55..b9ab4cfc887cc2325f7020e18344abd1eb98c00c 100644 (file)
--- a/stream.h
+++ b/stream.h
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 #ifndef STREAM_H
diff --git a/tcp.cc b/tcp.cc
index be2133afcbd47ae6bf4722fb5ed71d1e0e18d14b..40f1f95162fa8a44452d44b6ca67b73031100ab3 100644 (file)
--- a/tcp.cc
+++ b/tcp.cc
@@ -53,7 +53,7 @@ void TCP::disableTimeout()
   timeoutEnabled = 0;
 }
 
-void TCP::getMAC(char* dest)
+void TCP::getMAC(UCHAR* dest)
 {
 #ifndef WIN32
   struct ifreq ifr;
diff --git a/tcp.h b/tcp.h
index f0537529e1f3d8debca056efe3c66638065e60f1..ceacc3cad23d6a9131939b8aefeef8fad43eda12 100644 (file)
--- a/tcp.h
+++ b/tcp.h
@@ -63,7 +63,7 @@ class TCP
 
     static void dump(unsigned char* data, ULONG size);
 
-    void getMAC(char* dest); // copies 6 MAC bytes to dest
+    void getMAC(UCHAR* dest); // copies 6 MAC bytes to dest
     void setReceiveWindow(size_t rxBufferSize);
 
   private:
diff --git a/vdr.cc b/vdr.cc
index bb97ca421a0778470d805706a74c4f7c52a9d1c0..8fda12f3e66697ce34aaa4f631a8db3592531d61 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -120,7 +120,7 @@ VDR::VDR()
   if (instance) return;
   instance = this;
 
-  TEMP_SINGLE_VDR_PR = NULL;
+  TEMP_SINGLE_VDR_PR = NULL; // FIXME what is this
 #ifdef VOMP_MEDIAPLAYER
   providerId=MPROVIDERID_VDR;
   subRange=MPROVIDERRANGE_VDR;
@@ -590,7 +590,7 @@ VDR_ResponsePacket* VDR::RequestResponse(VDR_RequestPacket* vrp)
   edMutex.lock();
 
 
-  if ((ULONG)tcp->sendData(vrp->getPtr(), vrp->getLen()) != vrp->getLen())
+  if (static_cast<ULONG>(tcp->sendData(vrp->getPtr(), vrp->getLen())) != vrp->getLen())
   {
     edMutex.unlock();
     edUnregister(&vdrpr);
@@ -625,7 +625,7 @@ bool VDR::sendKA(ULONG timeStamp)
   buffer[pos++]=(ul>>16)&0xff;
   buffer[pos++]=(ul>>8)&0xff;
   buffer[pos++]=ul &0xff;
-  if ((ULONG)tcp->sendData(buffer, 8) != 8) return false;
+  if (static_cast<ULONG>(tcp->sendData(buffer, 8)) != 8) return false;
   return true;
 }
 
@@ -687,9 +687,9 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne
   VDR_RequestPacket vrp;
   if (!vrp.init(VDR_LOGIN, true, 6)) return 0;
 
-  char* mactemp[6];
-  tcp->getMAC((char*)mactemp);
-  if (!vrp.copyin((UCHAR*)mactemp, 6)) return 0;
+  UCHAR mactemp[6];
+  tcp->getMAC(mactemp);
+  if (!vrp.copyin(mactemp, 6)) return 0;
 
   VDR_ResponsePacket* vresp = RequestResponse(&vrp);
   if (vresp->noResponse()) { delete vresp; return 0; }