From 02222d851bd82d8aa1d005502bc5037a1a39d50b Mon Sep 17 00:00:00 2001
From: Tim Retout <tim@retout.co.uk>
Date: Wed, 17 Nov 2010 22:54:31 +0000
Subject: [PATCH 2/2] Replace RTMP::getUptime() with clocktimr::getTicks()

Signed-off-by: Tim Retout <tim@retout.co.uk>
---
 libbase/RTMP.cpp |   26 +++++---------------------
 libbase/RTMP.h   |    5 ++---
 2 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/libbase/RTMP.cpp b/libbase/RTMP.cpp
index 25d113e..377fd61 100644
--- a/libbase/RTMP.cpp
+++ b/libbase/RTMP.cpp
@@ -23,14 +23,6 @@
 
 #include "GnashSystemNetHeaders.h"
 
-// Replace!!
-#ifndef _WIN32
-# include <sys/times.h>
-#else
-// TODO: use uptime properly on win32.
-# include <ctime>
-#endif
-
 #include "RTMP.h"
 #include "log.h"
 #include "AMF.h"
@@ -38,6 +30,10 @@
 #include "URL.h"
 #include "ClockTime.h"
 
+namespace clocktime {
+     boost::uint64_t getTicks();
+}
+
 namespace gnash {
 namespace rtmp {
 
@@ -53,7 +49,6 @@ namespace {
     void handleClientBW(RTMP& r, const RTMPPacket& packet);
     
     void setupInvokePacket(RTMPPacket& packet);
-    boost::uint32_t getUptime();
 
     boost::int32_t decodeInt32LE(const boost::uint8_t* c);
     int encodeInt32LE(boost::uint8_t *output, int nVal);
@@ -595,7 +590,7 @@ RTMP::sendPacket(RTMPPacket& packet)
     RTMPHeader& hr = packet.header;
 
     hr.dataSize = payloadSize(packet);
-    hr._timestamp = getUptime();
+    hr._timestamp = clocktime::getTicks();
 
     // Relative timestamp for our message.
     boost::uint64_t delta = 0;
@@ -1175,17 +1170,6 @@ encodeInt32(boost::uint8_t *output, boost::uint8_t *outend, int nVal)
     return output + 4;
 }
 
-boost::uint32_t
-getUptime()
-{
-#if defined(__amigaos4__)
-    struct tms t;
-    return times(&t) * 1000 / 50;
-#else
-    return std::clock() * 1000 / CLOCKS_PER_SEC;
-#endif
-}
-
 } // anonymous namespace
 
 std::ostream&
diff --git a/libbase/RTMP.h b/libbase/RTMP.h
index 209295f..7b432c8 100644
--- a/libbase/RTMP.h
+++ b/libbase/RTMP.h
@@ -168,9 +168,8 @@ struct RTMPHeader
 
     /// The timestamp.
     //
-    /// This is encoded either as in the 3-byte relative timestamp field or the
-    /// 4 byte extended (absolute) timestamp field.
-    boost::uint32_t _timestamp;
+    /// This is stored as returned by clocktime::getTicks()
+    boost::uint64_t _timestamp;
 
     /// This seems to be used for NetStream.play.
     boost::uint32_t _streamID;
-- 
1.7.2.3

