Changeset 96


Ignore:
Timestamp:
08/24/10 06:51:02 (18 months ago)
Author:
shiretu
Message:

-- android related

Location:
trunk/sources
Files:
2 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/androidapplestreaming/src/api.cpp

    r91 r96  
    9999        //7. Create the RTSP acceptor 
    100100        Variant acceptorConfig; 
    101         acceptorConfig[CONF_IP] = "127.0.0.1"; 
     101        acceptorConfig[CONF_IP] = ip; 
    102102        acceptorConfig[CONF_PORT] = (uint16_t) port; 
    103103        acceptorConfig[CONF_PROTOCOL] = CONF_PROTOCOL_INBOUND_RTSP; 
    104104        vector<uint64_t> chain; 
    105         chain = ProtocolFactoryManager::ResolveProtocolChain(CONF_PROTOCOL_INBOUND_RTSP); 
    106         if (chain.size() == 0) { 
    107                 ASSERT("Invalid protocol chain: %s", CONF_PROTOCOL_INBOUND_RTSP); 
    108         } 
    109         TCPAcceptor *pAcceptor = new TCPAcceptor(ip, 
     105        chain = ProtocolFactoryManager::ResolveProtocolChain(acceptorConfig[CONF_PROTOCOL]); 
     106        if (chain.size() == 0) { 
     107                ASSERT("Invalid protocol chain: %s", STR(acceptorConfig[CONF_PROTOCOL])); 
     108        } 
     109        TCPAcceptor *pAcceptor = new TCPAcceptor(acceptorConfig[CONF_IP], 
    110110                        (uint16_t) acceptorConfig[CONF_PORT], acceptorConfig, chain); 
    111111        if (!pAcceptor->StartAccept(pApp)) { 
     
    116116        acceptorConfig[CONF_PORT] = (uint16_t) (port + 1); 
    117117        acceptorConfig[CONF_PROTOCOL] = CONF_PROTOCOL_INBOUND_BIN_VARIANT; 
    118         chain = ProtocolFactoryManager::ResolveProtocolChain(CONF_PROTOCOL_INBOUND_BIN_VARIANT); 
    119         if (chain.size() == 0) { 
    120                 ASSERT("Invalid protocol chain: %s", CONF_PROTOCOL_INBOUND_BIN_VARIANT); 
    121         } 
    122         pAcceptor = new TCPAcceptor(ip, (uint16_t) acceptorConfig[CONF_PORT], 
     118        chain = ProtocolFactoryManager::ResolveProtocolChain(acceptorConfig[CONF_PROTOCOL]); 
     119        if (chain.size() == 0) { 
     120                ASSERT("Invalid protocol chain: %s", STR(acceptorConfig[CONF_PROTOCOL])); 
     121        } 
     122        pAcceptor = new TCPAcceptor(acceptorConfig[CONF_IP], (uint16_t) acceptorConfig[CONF_PORT], 
    123123                        acceptorConfig, chain); 
    124124        if (!pAcceptor->StartAccept(pApp)) { 
     
    129129        acceptorConfig[CONF_PORT] = (uint16_t) (port + 2); 
    130130        acceptorConfig[CONF_PROTOCOL] = CONF_PROTOCOL_INBOUND_XML_VARIANT; 
    131         chain = ProtocolFactoryManager::ResolveProtocolChain(CONF_PROTOCOL_INBOUND_XML_VARIANT); 
    132         if (chain.size() == 0) { 
    133                 ASSERT("Invalid protocol chain: %s", CONF_PROTOCOL_INBOUND_XML_VARIANT); 
    134         } 
    135         pAcceptor = new TCPAcceptor(ip, (uint16_t) acceptorConfig[CONF_PORT], 
     131        chain = ProtocolFactoryManager::ResolveProtocolChain(acceptorConfig[CONF_PROTOCOL]); 
     132        if (chain.size() == 0) { 
     133                ASSERT("Invalid protocol chain: %s", STR(acceptorConfig[CONF_PROTOCOL])); 
     134        } 
     135        pAcceptor = new TCPAcceptor(acceptorConfig[CONF_IP], (uint16_t) acceptorConfig[CONF_PORT], 
    136136                        acceptorConfig, chain); 
    137137        if (!pAcceptor->StartAccept(pApp)) { 
     
    142142        acceptorConfig[CONF_PORT] = (uint16_t) (1935); 
    143143        acceptorConfig[CONF_PROTOCOL] = CONF_PROTOCOL_INBOUND_RTMP; 
    144         chain = ProtocolFactoryManager::ResolveProtocolChain(CONF_PROTOCOL_INBOUND_RTMP); 
    145         if (chain.size() == 0) { 
    146                 ASSERT("Invalid protocol chain: %s", CONF_PROTOCOL_INBOUND_RTMP); 
    147         } 
    148         pAcceptor = new TCPAcceptor(ip, (uint16_t) acceptorConfig[CONF_PORT], 
     144        chain = ProtocolFactoryManager::ResolveProtocolChain(acceptorConfig[CONF_PROTOCOL]); 
     145        if (chain.size() == 0) { 
     146                ASSERT("Invalid protocol chain: %s", STR(acceptorConfig[CONF_PROTOCOL])); 
     147        } 
     148        pAcceptor = new TCPAcceptor(acceptorConfig[CONF_IP], (uint16_t) acceptorConfig[CONF_PORT], 
    149149                        acceptorConfig, chain); 
    150150        if (!pAcceptor->StartAccept(pApp)) { 
    151151                ASSERT("Unable to fire up acceptor"); 
    152152        } 
     153 
     154        //10. Create the timer UDP protocol 
     155#ifdef HAS_MS_TIMER 
     156        acceptorConfig[CONF_PORT] = (uint16_t) (port + 3); 
     157        acceptorConfig[CONF_PROTOCOL] = "fineTimer"; 
     158        acceptorConfig["FineTimerPeriod"] = 0.2; 
     159        chain = ProtocolFactoryManager::ResolveProtocolChain(acceptorConfig[CONF_PROTOCOL]); 
     160        if (chain.size() == 0) { 
     161                ASSERT("Invalid protocol chain: %s", STR(acceptorConfig[CONF_PROTOCOL])); 
     162        } 
     163        UDPCarrier *pUDPCarrier = UDPCarrier::Create(acceptorConfig[CONF_IP], (uint16_t) acceptorConfig[CONF_PORT]); 
     164        if (pUDPCarrier == NULL) { 
     165                ASSERT("Unable to bind on udp://%s:%d", STR(acceptorConfig[CONF_IP]), (uint16_t) acceptorConfig[CONF_PORT]); 
     166        } 
     167        BaseProtocol *pTimer = ProtocolFactoryManager::CreateProtocolChain(chain, acceptorConfig); 
     168        pTimer->GetFarEndpoint()->SetIOHandler(pUDPCarrier); 
     169        pUDPCarrier->SetProtocol(pTimer->GetFarEndpoint()); 
     170        pApp->SetFineTimerId(pTimer->GetId()); 
     171#endif /* HAS_MS_TIMER */ 
    153172 
    154173        inet_aton("127.0.0.1", &gAddress.sin_addr); 
  • trunk/sources/androidapplestreaming/src/main.cpp

    r88 r96  
    8383} 
    8484 
    85 #define MY_URL "http://mediadownloads.mlb.com/mlbam/2010/06/29/9505835_m3u8/128/dropf_9505835_100m_128K.m3u8" 
    86 #define MY_SESSION_ID "" 
    87 #define MY_KEY "" 
     85//#define MY_URL "http://mediadownloads.mlb.com/mlbam/2010/06/29/9505835_m3u8/128/dropf_9505835_100m_128K.m3u8" 
     86//#define MY_SESSION_ID "" 
     87//#define MY_KEY "" 
    8888 
    8989//#define MY_URL "http://mlbvod-akc.mlb.com/mlbam/2010/04/08/MLB_GAME_VIDEO_LANPIT_HOME_20100408/master_wired.m3u8" 
     
    108108 
    109109 
     110//#define MY_URL "http://mlbsegqa.mlb.com/mlbam/2010/08/23/MLB_GAME_VIDEO_TBAANA_HOME_20100823/master_mobile.m3u8" 
     111//#define MY_KEY "adCJvZ98pHD+RtwZXu5DAnud3zk=" 
     112//#define MY_SESSION_ID "playback=HTTP_CLOUD_MOBILE&contentId=100000000001&appAccountName=mlb&eventId=14-265677-2010-08-23&ipid=23272205&sessionKey=1Mdu%2B0CADyV4ewOJTgKsPSqMPQE%3D&deviceId=ANDROID_354957033071773&country=us&postalCode=10011&platform=ANDROID" 
    110113 
     114#define MY_URL "http://mlbsegqa.mlb.com/mlbam/2010/08/17/MLB_GAME_VIDEO_DETNYA_HOME_20100817/master_mobile.m3u8" 
     115#define MY_KEY "pFD3++v0LKfm38F2mCgIu0sXzn4=" 
     116#define MY_SESSION_ID "playback=HTTP_CLOUD_MOBILE&contentId=10111969&appAccountName=mlb&eventId=14-265611-2010-08-18&ipid=23272205&sessionKey=6bdsqzUU7oBI4gixJxFFON2QHwA%3D&deviceId=ANDROID_354957033071773&country=us&postalCode=10011&platform=ANDROID" 
    111117 
    112118//#define CONDENSED_CONN_STRING "base64:aHR0cDovL21sYnZvZC1ha2MubWxiLmNvbS9tbGJhbS8yMDEwLzA0LzA4L01MQl9HQU1FX1ZJREVPX0xBTlBJVF9IT01FXzIwMTAwNDA4L21hc3Rlcl93aXJlZC5tM3U4fHlNQmVFcEl6OEJEaUFYV0k0dUdIUm1UaHdIRT18cGxheWJhY2s9SFRUUF9DTE9VRF9XSVJFRCZjb250ZW50SWQ9NzMyMDA4NSZhcHBBY2NvdW50TmFtZT1tbGImZXZlbnRJZD0xNC0yNjM4NDktMjAxMC0wNC0wOCZpcGlkPTExNjI3NzA2JnNlc3Npb25LZXk9cUNveGRIaUlOY3FDbHlEcEZoU2dma3dJSWc0JTNE" 
     
    120126        result = CommandPlay(contextId, MY_URL, MY_SESSION_ID, MY_KEY); 
    121127        FINEST("result:\n%s", STR(result.ToString())); 
     128 
     129        //      sleep(30); 
     130        // 
     131        //      ContextCloseAll(); 
    122132        //      result = CommandPlay(contextId, CONDENSED_CONN_STRING); 
    123133        //      FINEST("result:\n%s", STR(result.ToString())); 
  • trunk/sources/applications/applestreamingclient/include/applestreamingclientapplication.h

    r85 r96  
    3636class VariantAppProtocolHandler; 
    3737class ProtocolFactory; 
     38#ifdef HAS_MS_TIMER 
     39class FineTimer; 
     40#endif /* HAS_MS_TIMER */ 
    3841 
    3942class AppleStreamingClientApplication 
     
    5154        VariantAppProtocolHandler *_pVariantHandler; 
    5255        ProtocolFactory *_pFactory; 
     56#ifdef HAS_MS_TIMER 
     57        uint32_t _fineTimerId; 
     58#endif /* HAS_MS_TIMER */ 
    5359#ifdef ANDROID 
    5460        CallBackInfo _ci; 
     
    6167 
    6268        virtual bool Initialize(); 
    63  
     69#ifdef HAS_MS_TIMER 
     70        void SetFineTimerId(uint32_t fineTimerId); 
     71        FineTimer *GetFineTimer(); 
     72#endif /* HAS_MS_TIMER */ 
    6473#ifdef ANDROID 
    6574        void SetJavaCallBackInterface(CallBackInfo ci); 
  • trunk/sources/applications/applestreamingclient/include/clientcontext.h

    r88 r96  
    109109        bool SignalMasterPlaylistAvailable(); 
    110110        bool SignalChildPlaylistAvailable(uint32_t bw); 
     111        bool SignalChildPlaylistNotAvailable(uint32_t bw); 
    111112        bool SignalAESKeyAvailable(Variant &parameters); 
    112113        bool SignalTSProtocolAvailable(uint32_t protocolId, uint32_t bw); 
  • trunk/sources/applications/applestreamingclient/include/protocols/m3u8/basem3u8protocol.h

    r2 r96  
    4040        virtual Playlist *GetPlaylist() = 0; 
    4141        virtual bool SignalPlaylistAvailable() = 0; 
     42        virtual bool SignalPlaylistFailed() = 0; 
    4243}; 
    4344 
  • trunk/sources/applications/applestreamingclient/include/protocols/m3u8/childm3u8protocol.h

    r56 r96  
    3636        virtual Playlist *GetPlaylist(); 
    3737        virtual bool SignalPlaylistAvailable(); 
     38        virtual bool SignalPlaylistFailed(); 
    3839}; 
    3940 
  • trunk/sources/applications/applestreamingclient/include/protocols/m3u8/masterm3u8protocol.h

    r56 r96  
    3333        virtual Playlist *GetPlaylist(); 
    3434        virtual bool SignalPlaylistAvailable(); 
     35        virtual bool SignalPlaylistFailed(); 
    3536}; 
    3637 
  • trunk/sources/applications/applestreamingclient/include/protocols/protocolfactory.h

    r7 r96  
    3939#define PC_ITEM                         "bufferedHttp" 
    4040 
     41#ifdef HAS_MS_TIMER 
     42#define PT_FINE_TIMER           MAKE_TAG4('F','T','M','R') 
     43#define PC_FINE_TIMER           "fineTimer" 
     44#endif /* HAS_MS_TIMER */ 
     45 
    4146class DLLEXP ProtocolFactory 
    4247: public BaseProtocolFactory { 
  • trunk/sources/applications/applestreamingclient/src/applestreamingclientapplication.cpp

    r89 r96  
    2727#include "protocols/ts/tsappprotocolhandler.h" 
    2828#include "protocols/aes/aesappprotocolhandler.h" 
     29#include "protocols/protocolmanager.h" 
    2930#include "streaming/basestream.h" 
    3031#include "streaming/streamstypes.h" 
     
    161162} 
    162163 
     164#ifdef HAS_MS_TIMER 
     165 
     166void AppleStreamingClientApplication::SetFineTimerId(uint32_t fineTimerId) { 
     167        _fineTimerId = fineTimerId; 
     168} 
     169 
     170FineTimer *AppleStreamingClientApplication::GetFineTimer() { 
     171        return (FineTimer *) ProtocolManager::GetProtocol(_fineTimerId); 
     172} 
     173#endif /* HAS_MS_TIMER */ 
     174 
    163175#ifdef ANDROID 
    164176 
  • trunk/sources/applications/applestreamingclient/src/clientcontext.cpp

    r95 r96  
    3333#include "streaming/streamsmanager.h" 
    3434#include "protocols/ts/innettsstream.h" 
     35#include "applestreamingclientapplication.h" 
     36#include "protocols/timer/finetimer.h" 
    3537 
    3638uint32_t ClientContext::_idGenerator = 0; 
     
    8688                _pEventSink = NULL; 
    8789        } 
     90#ifdef HAS_MS_TIMER 
     91        AppleStreamingClientApplication *pApp = GetApplication(); 
     92        if (pApp != NULL) { 
     93                FineTimer *pFineTimer = pApp->GetFineTimer(); 
     94                if (pFineTimer != NULL) { 
     95                        pFineTimer->UnRegisterContextId(_id); 
     96                } 
     97        } 
     98#endif /* HAS_MS_TIMER */ 
    8899} 
    89100 
     
    227238 
    228239        //5. Add the recurring job for consuming the A/V data buffer 
     240#ifdef HAS_MS_TIMER 
     241        AppleStreamingClientApplication *pApp = GetApplication(); 
     242        if (pApp != NULL) { 
     243                FineTimer *pFineTimer = pApp->GetFineTimer(); 
     244                if (pFineTimer != NULL) { 
     245                        pFineTimer->RegisterContextId(_id); 
     246                } else { 
     247                        ASSERT("Unable to find fine timer"); 
     248                } 
     249        } else { 
     250                ASSERT("Unable to find application"); 
     251        } 
     252#else 
    229253        Variant job; 
    230254        job["type"] = "consumeAVBuffer"; 
    231255        pScheduleTimer->AddJob(job, true); 
     256#endif /* HAS_MS_TIMER */ 
    232257 
    233258        //      job["type"] = "testJNICallback"; 
     
    339364        } 
    340365 
    341         //5. Does it have any registered consumers AND sps/pps? Return if not 
     366        //5. Does it have any registered consumers? 
    342367        if (pStream->GetOutStreams().size() <= 0) { 
    343368                WARN("No registered consumers or stream capabilities not yet known. Take a break..."); 
     
    349374 
    350375        //6. Feed 
    351         while ((wallClockDelta + 2000 > pStream->GetFeedTime()) && 
     376        //      FINEST("BEFORE: wallClockDelta: %.2f; GetFeedTime: %.2f", 
     377        //                      wallClockDelta, pStream->GetFeedTime()); 
     378        while ((wallClockDelta > (pStream->GetFeedTime())) && 
    352379                        (GETAVAILABLEBYTESCOUNT(_avData) > 8192)) { 
    353380                if (!pTS->SignalInputData(_avData)) { 
     
    356383                } 
    357384        } 
     385        //      FINEST(" AFTER: wallClockDelta: %.2f; GetFeedTime: %.2f", 
     386        //                      wallClockDelta, pStream->GetFeedTime()); 
    358387 
    359388        //7. Done 
     
    462491bool ClientContext::SignalChildPlaylistAvailable(uint32_t bw) { 
    463492        _parsedChildPlaylistsCount++; 
     493        return StartFeeding(); 
     494} 
     495 
     496bool ClientContext::SignalChildPlaylistNotAvailable(uint32_t bw) { 
     497        if (!MAP_HAS1(_childPlaylists, bw)) 
     498                return true; 
     499        Playlist *pPl = _childPlaylists[bw]; 
     500        delete pPl; 
     501        _childPlaylists.erase(bw); 
     502        WARN("bw %d removed", bw); 
    464503        return StartFeeding(); 
    465504} 
     
    614653                if (_pEventSink->GetType() == EVENT_SYNC_VARIANT) { 
    615654                        _avData.IgnoreAll(); 
     655                        InNetTSStream *pStream = (InNetTSStream *) _pStreamsManager->FindByUniqueId( 
     656                                        _streamId); 
     657                        if (pStream == NULL) { 
     658                                FATAL("Unable to get the inbound stream"); 
     659                                return false; 
     660                        } 
     661                        StreamCapabilities *pSC = pStream->GetCapabilities(); 
     662                        pSC->Clear(); 
     663                        _pEventSink->SignalStreamUnRegistered(_streamName); 
    616664                } 
    617665                if (_lastUsedBw < bw) { 
  • trunk/sources/applications/applestreamingclient/src/protocols/m3u8/basem3u8protocol.cpp

    r81 r96  
    5858                                STR(pHttpProtocol->GetHeaders().ToString())); 
    5959                FATAL("Additional data:\n%s", STR(GetCustomParameters().ToString())); 
    60                 return false; 
     60                if (!SignalPlaylistFailed()) { 
     61                        FATAL("Unable to signal playlist available"); 
     62                        return false; 
     63                } 
     64                buffer.IgnoreAll(); 
     65                EnqueueForDelete(); 
     66                return true; 
    6167        } 
    6268 
  • trunk/sources/applications/applestreamingclient/src/protocols/m3u8/childm3u8protocol.cpp

    r56 r96  
    6868        return true; 
    6969} 
     70 
     71bool ChildM3U8Protocol::SignalPlaylistFailed() { 
     72        //1. Get the context 
     73        ClientContext *pContext = GetContext(); 
     74        if (pContext == NULL) { 
     75                FATAL("Unable to get the context"); 
     76                return false; 
     77        } 
     78 
     79        //2. Signal the context about the new playlist 
     80        if (!pContext->SignalChildPlaylistNotAvailable(_bw)) { 
     81                FATAL("Unable to signal master M3U8 playlist available"); 
     82                return false; 
     83        } 
     84 
     85        //3. Done 
     86        return true; 
     87} 
  • trunk/sources/applications/applestreamingclient/src/protocols/m3u8/masterm3u8protocol.cpp

    r56 r96  
    7070        return true; 
    7171} 
     72 
     73bool MasterM3U8Protocol::SignalPlaylistFailed() { 
     74        NYIR; 
     75} 
  • trunk/sources/applications/applestreamingclient/src/protocols/protocolfactory.cpp

    r7 r96  
    2626#include "protocols/aes/inboundaesprotocol.h" 
    2727#include "protocols/httpbuff/httpbufferprotocol.h" 
     28#include "protocols/timer/finetimer.h" 
    2829 
    2930ProtocolFactory::ProtocolFactory() { 
     
    4142        ADD_VECTOR_END(result, PT_HTTP_BUFF); 
    4243        ADD_VECTOR_END(result, PT_INBOUND_AES); 
     44#ifdef HAS_MS_TIMER 
     45        ADD_VECTOR_END(result, PT_FINE_TIMER); 
     46#endif /* HAS_MS_TIMER */ 
    4347        return result; 
    4448} 
     
    4650vector<string> ProtocolFactory::HandledProtocolChains() { 
    4751        vector<string> result; 
     52#ifdef HAS_MS_TIMER 
     53        ADD_VECTOR_END(result, PC_FINE_TIMER); 
     54#endif /* HAS_MS_TIMER */ 
     55 
    4856        ADD_VECTOR_END(result, PC_MASTER_PLAYLIST); 
    4957        ADD_VECTOR_END(result, PC_CHILD_PLAYLIST); 
     
    5866vector<uint64_t> ProtocolFactory::ResolveProtocolChain(string name) { 
    5967        vector<uint64_t> result; 
    60         if (name == PC_MASTER_PLAYLIST) { 
     68        if (false) { 
     69 
     70        } 
     71#ifdef HAS_MS_TIMER 
     72        else if (name == PC_FINE_TIMER) { 
     73                ADD_VECTOR_END(result, PT_UDP); 
     74                ADD_VECTOR_END(result, PT_FINE_TIMER); 
     75        } 
     76#endif /* HAS_MS_TIMER */ 
     77        else if (name == PC_MASTER_PLAYLIST) { 
    6178                ADD_VECTOR_END(result, PT_TCP); 
    6279                ADD_VECTOR_END(result, PT_OUTBOUND_HTTP); 
     
    99116        BaseProtocol *pResult = NULL; 
    100117        switch (type) { 
     118#ifdef HAS_MS_TIMER 
     119                case PT_FINE_TIMER: 
     120                        pResult = new FineTimer(); 
     121                        break; 
     122#endif /* HAS_MS_TIMER */ 
    101123                case PT_INBOUND_MASTER_M3U8: 
    102124                        pResult = new MasterM3U8Protocol(); 
  • trunk/sources/common/include/platform/android/androidplatform.h

    r58 r96  
    108108}while (0); 
    109109 
     110#define GETCUSTOMNTP(result,value) \ 
     111do { \ 
     112        struct timeval tv; \ 
     113        tv.tv_sec=value/CLOCKS_PER_SECOND; \ 
     114        tv.tv_usec=value-tv.tv_sec*CLOCKS_PER_SECOND; \ 
     115        result=(((uint64_t)tv.tv_sec + 2208988800U)<<32)|((((uint32_t)tv.tv_usec) << 12) + (((uint32_t)tv.tv_usec) << 8) - ((((uint32_t)tv.tv_usec) * 1825) >> 5)); \ 
     116}while (0); 
     117 
    110118class AndroidPlatform 
    111119: public BasePlatform { 
  • trunk/sources/common/include/platform/freebsd/freebsdplatform.h

    r58 r96  
    112112}while (0); 
    113113 
     114#define GETCUSTOMNTP(result,value) \ 
     115do { \ 
     116        struct timeval tv; \ 
     117        tv.tv_sec=value/CLOCKS_PER_SECOND; \ 
     118        tv.tv_usec=value-tv.tv_sec*CLOCKS_PER_SECOND; \ 
     119        result=(((uint64_t)tv.tv_sec + 2208988800U)<<32)|((((uint32_t)tv.tv_usec) << 12) + (((uint32_t)tv.tv_usec) << 8) - ((((uint32_t)tv.tv_usec) * 1825) >> 5)); \ 
     120}while (0); 
     121 
    114122class FreeBSDPlatform 
    115123: public BasePlatform { 
  • trunk/sources/common/include/platform/linux/linuxplatform.h

    r58 r96  
    112112}while (0); 
    113113 
     114#define GETCUSTOMNTP(result,value) \ 
     115do { \ 
     116        struct timeval tv; \ 
     117        tv.tv_sec=value/CLOCKS_PER_SECOND; \ 
     118        tv.tv_usec=value-tv.tv_sec*CLOCKS_PER_SECOND; \ 
     119        result=(((uint64_t)tv.tv_sec + 2208988800U)<<32)|((((uint32_t)tv.tv_usec) << 12) + (((uint32_t)tv.tv_usec) << 8) - ((((uint32_t)tv.tv_usec) * 1825) >> 5)); \ 
     120}while (0); 
     121 
    114122class LinuxPlatform 
    115123: public BasePlatform { 
  • trunk/sources/common/include/platform/osx/osxplatform.h

    r58 r96  
    111111}while (0); 
    112112 
     113#define GETCUSTOMNTP(result,value) \ 
     114do { \ 
     115        struct timeval tv; \ 
     116        tv.tv_sec=value/CLOCKS_PER_SECOND; \ 
     117        tv.tv_usec=value-tv.tv_sec*CLOCKS_PER_SECOND; \ 
     118        result=(((uint64_t)tv.tv_sec + 2208988800U)<<32)|((((uint32_t)tv.tv_usec) << 12) + (((uint32_t)tv.tv_usec) << 8) - ((((uint32_t)tv.tv_usec) * 1825) >> 5)); \ 
     119}while (0); 
     120 
    113121class OSXPlatform 
    114122: public BasePlatform { 
  • trunk/sources/common/include/platform/solaris/solarisplatform.h

    r58 r96  
    113113}while (0); 
    114114 
     115#define GETCUSTOMNTP(result,value) \ 
     116do { \ 
     117        struct timeval tv; \ 
     118        tv.tv_sec=value/CLOCKS_PER_SECOND; \ 
     119        tv.tv_usec=value-tv.tv_sec*CLOCKS_PER_SECOND; \ 
     120        result=(((uint64_t)tv.tv_sec + 2208988800U)<<32)|((((uint32_t)tv.tv_usec) << 12) + (((uint32_t)tv.tv_usec) << 8) - ((((uint32_t)tv.tv_usec) * 1825) >> 5)); \ 
     121}while (0); 
     122 
    115123class SolarisPlatform 
    116124: public BasePlatform { 
  • trunk/sources/common/include/platform/windows/win32platform.h

    r58 r96  
    103103}while (0); 
    104104 
     105#define GETCUSTOMNTP(result,value) \ 
     106do { \ 
     107        struct timeval tv; \ 
     108        tv.tv_sec=value/CLOCKS_PER_SECOND; \ 
     109        tv.tv_usec=value-tv.tv_sec*CLOCKS_PER_SECOND; \ 
     110        result=(((uint64_t)tv.tv_sec + 2208988800U)<<32)|((((uint32_t)tv.tv_usec) << 12) + (((uint32_t)tv.tv_usec) << 8) - ((((uint32_t)tv.tv_usec) * 1825) >> 5)); \ 
     111}while (0); 
     112 
    105113typedef void (*SignalFnc)(void); 
    106114 
  • trunk/sources/thelib/include/protocols/rtp/connectivity/outboundconnectivity.h

    r87 r96  
    5050        BaseOutNetRTPUDPStream *_pOutStream; 
    5151        msghdr _message; 
     52        double _startupTime; 
    5253public: 
    5354        OutboundConnectivity(); 
  • trunk/sources/thelib/src/protocols/rtp/connectivity/outboundconnectivity.cpp

    r88 r96  
    6969        sent = sendmsg(fd, &vd, 0); \ 
    7070    } \ 
    71     RTP_DEBUG_MESSAGE(sent); \ 
    72 } while(0) 
     71        /*FATAL("TS: %02x%02x%02x%02x", \ 
     72                ((uint8_t *)vd.msg_iov[0].iov_base)[4], \ 
     73                ((uint8_t *)vd.msg_iov[0].iov_base)[5], \ 
     74                ((uint8_t *)vd.msg_iov[0].iov_base)[6], \ 
     75                ((uint8_t *)vd.msg_iov[0].iov_base)[7]); */\ 
     76        RTP_DEBUG_MESSAGE(sent); \ 
     77} \ 
     78while (0) 
    7379 
    7480OutboundConnectivity::OutboundConnectivity() 
     
    9399        _message.msg_iovlen = 1; 
    94100        _message.msg_namelen = sizeof (sockaddr_in); 
     101 
     102        _startupTime = 0; 
    95103        WARN("OC created: %p", this); 
    96104} 
     
    396404        put_htonl(pDest + 4, ssrc); //SSRC 
    397405 
    398         //5. NTP 
     406        FINEST("-----%s-----", isAudio ? "AUDIO" : "VIDEO"); 
     407 
     408        //5. setup the startup time 
     409        if (_startupTime == 0) { 
     410                GETCLOCKS(_startupTime); 
     411        } 
     412        FINEST("_startupTime: %.2f", _startupTime); 
     413 
     414        //6. Get the current time 
     415        double currentTime; 
     416        GETCLOCKS(currentTime); 
     417        FINEST("currentTime: %.2f", currentTime); 
     418 
     419        //7. NTP 
    399420        uint64_t ntp; 
    400         //GETCUSTOMNTP(ntp, (ntohlp(pSrc + 4) / rate)*1000); 
    401         GETNTP(ntp); 
     421        GETCUSTOMNTP(ntp, currentTime); 
    402422        put_htonll(pDest + 8, ntp); 
    403423 
    404424        //6. RTP 
    405         //      double rtpDouble; 
    406         //      GETCLOCKS(rtpDouble); 
    407         //      rtpDouble = (rtpDouble / CLOCKS_PER_SEC) * rate; 
    408         //      uint32_t rtp = (uint32_t) rtpDouble; 
    409         //      put_htonl(pDest + 16, rtp); 
    410         memcpy(pDest + 16, pSrc + 4, 4); 
     425        FINEST("rate: %d", rate); 
     426        double rtpDouble = ((currentTime - _startupTime) / (double) CLOCKS_PER_SEC) * rate; 
     427        FINEST("rtpDouble: %.2f", rtpDouble); 
     428        uint32_t rtp = (uint32_t) rtpDouble; 
     429        FINEST("rtp: %d", rtp); 
     430        put_htonl(pDest + 16, rtp); 
     431        //memcpy(pDest + 16, pSrc + 4, 4); 
    411432 
    412433        //7. sender's packet count 
Note: See TracChangeset for help on using the changeset viewer.