Changeset 732


Ignore:
Timestamp:
02/03/12 19:47:41 (4 months ago)
Author:
shiretu
Message:

-- imported changes for common library from commercial version (evostream)

Location:
trunk/sources/common
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/common/include/defines.h

    r696 r732  
    323323#define CONF_PROTOCOL_RTSP_RTCP "inboundRtspRtcp" 
    324324#define CONF_PROTOCOL_RTSP_RTCP_LEN 15 
     325#define CONF_PROTOCOL_TCP_PASSTHROUGH "tcpPassThrough" 
     326#define CONF_PROTOCOL_TCP_PASSTHROUGH_LEN 14 
     327#define CONF_PROTOCOL_UDP_PASSTHROUGH "udpPassThrough" 
     328#define CONF_PROTOCOL_UDP_PASSTHROUGH_LEN 14 
    325329#define CONF_PROTOCOL_UDP_RTCP "inboundUdpRtcp" 
    326330#define CONF_PROTOCOL_UDP_RTCP_LEN 14 
     
    373377#define HTTP_HEADERS_SERVER "Server" 
    374378#define HTTP_HEADERS_SERVER_LEN 6 
    375 #define HTTP_HEADERS_SERVER_US "C++ RTMP Server (http://www.rtmpd.com)" 
    376 #define HTTP_HEADERS_SERVER_US_LEN 38 
     379#define HTTP_HEADERS_SERVER_US "EVOSTREAM Streaming Router (www.evostream.com)" 
     380#define HTTP_HEADERS_SERVER_US_LEN 46 
    377381#define HTTP_HEADERS_TRANSFER_ENCODING "Transfer-Encoding" 
    378382#define HTTP_HEADERS_TRANSFER_ENCODING_LEN 17 
     
    385389#define HTTP_HEADERS_X_POWERED_BY "X-Powered-By" 
    386390#define HTTP_HEADERS_X_POWERED_BY_LEN 12 
    387 #define HTTP_HEADERS_X_POWERED_BY_US "C++ RTMP Server (http://www.rtmpd.com)" 
    388 #define HTTP_HEADERS_X_POWERED_BY_US_LEN 38 
     391#define HTTP_HEADERS_X_POWERED_BY_US "EVOSTREAM Streaming Router (www.evostream.com)" 
     392#define HTTP_HEADERS_X_POWERED_BY_US_LEN 46 
    389393#define HTTP_METHOD "method" 
    390394#define HTTP_METHOD_LEN 6 
     
    743747#define RTSP_HEADERS_SERVER "Server" 
    744748#define RTSP_HEADERS_SERVER_LEN 6 
    745 #define RTSP_HEADERS_SERVER_US "C++ RTMP Server (http://www.rtmpd.com)" 
    746 #define RTSP_HEADERS_SERVER_US_LEN 38 
     749#define RTSP_HEADERS_SERVER_US "EVOSTREAM Streaming Router (www.evostream.com)" 
     750#define RTSP_HEADERS_SERVER_US_LEN 46 
    747751#define RTSP_HEADERS_SESSION "Session" 
    748752#define RTSP_HEADERS_SESSION_LEN 7 
     
    751755#define RTSP_HEADERS_X_POWERED_BY "X-Powered-By" 
    752756#define RTSP_HEADERS_X_POWERED_BY_LEN 12 
    753 #define RTSP_HEADERS_X_POWERED_BY_US "C++ RTMP Server (http://www.rtmpd.com)" 
    754 #define RTSP_HEADERS_X_POWERED_BY_US_LEN 38 
     757#define RTSP_HEADERS_X_POWERED_BY_US "EVOSTREAM Streaming Router (www.evostream.com)" 
     758#define RTSP_HEADERS_X_POWERED_BY_US_LEN 46 
    755759#define RTSP_METHOD "method" 
    756760#define RTSP_METHOD_LEN 6 
  • trunk/sources/common/include/platform/dfreebsd/dfreebsdplatform.h

    r703 r732  
    193193void installQuitSignal(SignalFnc pQuitSignalFnc); 
    194194void installConfRereadSignal(SignalFnc pConfRereadSignalFnc); 
    195  
    196  
    197195#endif /* _DFREEBSDPLATFORM_H */ 
    198196#endif /* DFREEBSD */ 
  • trunk/sources/common/include/platform/freebsd/freebsdplatform.h

    r703 r732  
    193193void installQuitSignal(SignalFnc pQuitSignalFnc); 
    194194void installConfRereadSignal(SignalFnc pConfRereadSignalFnc); 
    195  
    196  
    197195#endif /* _FREEBSDPLATFORM_H */ 
    198196#endif /* FREEBSD */ 
  • trunk/sources/common/include/platform/linux/linuxplatform.h

    r703 r732  
    197197void installQuitSignal(SignalFnc pQuitSignalFnc); 
    198198void installConfRereadSignal(SignalFnc pConfRereadSignalFnc); 
    199  
    200199#endif /* _LINUXPLATFORM_H */ 
    201200#endif /* LINUX */ 
  • trunk/sources/common/include/platform/openbsd/openbsdplatform.h

    r703 r732  
    195195void installQuitSignal(SignalFnc pQuitSignalFnc); 
    196196void installConfRereadSignal(SignalFnc pConfRereadSignalFnc); 
    197  
    198  
    199197#endif /* _OPENBSDPLATFORM_H */ 
    200198#endif /* OPENBSD */ 
  • trunk/sources/common/include/platform/osx/osxplatform.h

    r703 r732  
    193193void installQuitSignal(SignalFnc pQuitSignalFnc); 
    194194void installConfRereadSignal(SignalFnc pConfRereadSignalFnc); 
    195  
    196  
    197195#endif /* _OSXPLATFORM_H */ 
    198196#endif /* OSX */ 
  • trunk/sources/common/include/platform/solaris/solarisplatform.h

    r703 r732  
    198198int vasprintf(char **ret, const char *format, va_list args); 
    199199int asprintf(char **strp, const char *fmt, ...); 
    200  
    201200#endif /* _SOLARISPLATFORM_H */ 
    202201#endif /* SOLARIS */ 
  • trunk/sources/common/include/platform/windows/max.h

    r56 r732  
    2222#define _MAX_H 
    2323 
     24#include <stdint.h> 
     25 
     26/* 
    2427#ifdef UINT64_MAX 
    2528#undef UINT64_MAX 
     
    103106#define INT8_MIN   ((int8_t)(0x80)) 
    104107#endif 
     108*/ 
    105109 
    106110#endif /* _MAX_H */ 
  • trunk/sources/common/include/platform/windows/win32platform.h

    r702 r732  
    107107#include <cctype> 
    108108#include <algorithm> 
     109#include <stdint.h> 
    109110using namespace std; 
    110111 
    111 typedef unsigned char uint8_t; 
     112/*typedef unsigned char uint8_t; 
    112113typedef unsigned short int uint16_t; 
    113114typedef unsigned long int uint32_t; 
     
    116117typedef short int int16_t; 
    117118typedef long int int32_t; 
    118 typedef long long int int64_t; 
     119typedef long long int int64_t;*/ 
    119120#define atoll atol 
    120121 
     
    135136#define READ_FD _read 
    136137#define WRITE_FD _write 
    137 #define CLOSE_SOCKET(fd) if((fd)>=0) closesocket((fd)) 
     138#define CLOSE_SOCKET(fd) do{ if(fd>=0) closesocket(fd);fd=-1;}while(0) 
    138139#define LASTSOCKETERROR WSAGetLastError() 
    139140#define SOCKERROR_CONNECT_IN_PROGRESS   WSAEWOULDBLOCK 
    140141#define SOCKERROR_SEND_IN_PROGRESS              WSAEWOULDBLOCK 
     142#define SOCKERROR_RECV_IN_PROGRESS              WSAEWOULDBLOCK 
     143#define SOCKERROR_RECV_CONN_RESET               WSAECONNRESET 
    141144#define SET_UNKNOWN 0 
    142145#define SET_READ 1 
     
    229232DLLEXP bool deleteFile(string path); 
    230233DLLEXP bool deleteFolder(string path, bool force); 
     234DLLEXP bool createFolder(string path, bool recursive); 
    231235DLLEXP string getHostByName(string name); 
    232236DLLEXP bool isNumeric(string value); 
     
    257261DLLEXP HMODULE UnicodeLoadLibrary(string fileName); 
    258262DLLEXP int inet_aton(const char *pStr, struct in_addr *pRes); 
    259  
    260  
    261263#endif /* _WIN32PLATFORM_H */ 
    262264#endif /* WIN32 */ 
  • trunk/sources/common/include/utils/buffering/iobuffer.h

    r712 r732  
    207207         */ 
    208208 
    209         static string DumpBuffer(uint8_t *pBuffer, uint32_t length); 
     209        static string DumpBuffer(const uint8_t *pBuffer, uint32_t length); 
    210210        string ToString(uint32_t startIndex = 0, uint32_t limit = 0); 
    211211        operator string(); 
  • trunk/sources/common/include/utils/logging/logger.h

    r633 r732  
    5050        static bool AddLogLocation(BaseLogLocation *pLogLocation); 
    5151        static void SignalFork(); 
     52        static void SetLevel(int32_t level); 
    5253}; 
    5354 
  • trunk/sources/common/include/utils/lua/luautils.h

    r422 r732  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    2222#define _LUAUTILS_H 
    2323 
    24 extern "C" { 
    25 #include <lualib.h> 
    26 #include <lauxlib.h> 
    27 } 
     24struct lua_State; 
    2825#include "platform/platform.h" 
    2926#include "utils/misc/variant.h" 
  • trunk/sources/common/include/utils/misc/timersmanager.h

    r274 r732  
    4848        vector<uint32_t> _periodsVector; 
    4949        map<uint32_t, uint32_t> _periodsMap; 
     50        bool _inExecution; 
     51        vector<uint32_t> _pendingForRemoval; 
    5052public: 
    5153        TimersManager(ProcessTimerEvent processTimerEvent); 
  • trunk/sources/common/include/utils/misc/variant.h

    r625 r732  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    218218        bool SerializeToJSON(string &result); 
    219219 
    220         static bool DeserializeFromCmdLineArgs(uint32_t count, char **pArguments, 
     220        static bool DeserializeFromCmdLineArgs(uint32_t count, const char **pArguments, 
    221221                        Variant &result); 
    222222private: 
  • trunk/sources/common/src/platform/android/androidplatform.cpp

    r722 r732  
    484484 
    485485#endif /* ANDROID */ 
    486  
  • trunk/sources/common/src/platform/dfreebsd/dfreebsdplatform.cpp

    r722 r732  
    485485} 
    486486 
    487  
    488 #endif /* FREEBSD */ 
    489  
     487#endif /* DFREEBSD */ 
  • trunk/sources/common/src/platform/freebsd/freebsdplatform.cpp

    r722 r732  
    500500} 
    501501 
    502  
    503502#endif /* FREEBSD */ 
    504  
  • trunk/sources/common/src/platform/linux/linuxplatform.cpp

    r722 r732  
    500500 
    501501#endif /* LINUX */ 
    502  
  • trunk/sources/common/src/platform/openbsd/openbsdplatform.cpp

    r722 r732  
    490490} 
    491491 
    492  
    493492#endif /* OPENBSD */ 
    494  
  • trunk/sources/common/src/platform/osx/osxplatform.cpp

    r722 r732  
    504504} 
    505505 
    506  
    507506#endif /* OSX */ 
    508  
  • trunk/sources/common/src/platform/solaris/solarisplatform.cpp

    r722 r732  
    532532 
    533533#endif /* SOLARIS */ 
    534  
  • trunk/sources/common/src/platform/windows/win32platform.cpp

    r700 r732  
    5959 
    6060bool fileExists(string path) { 
    61         char *lpStr2 = (char *) path.c_str(); 
    62         if (PathFileExists(lpStr2)) 
     61#ifdef UNICODE 
     62        //TODO: Add the unicode implementation here 
     63        NYIR; 
     64#else 
     65        if (PathFileExists(STR(path))) 
    6366                return true; 
    6467        else 
    6568                return false; 
     69#endif /* UNICODE */ 
    6670} 
    6771 
     
    263267 
    264268bool setFdKeepAlive(int32_t fd) { 
    265         BOOL value = TRUE; 
    266         if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &value, sizeof (BOOL)) == SOCKET_ERROR) { 
    267                 FATAL("Error #%u", WSAGetLastError()); 
    268                 return false; 
     269        int value = 1; 
     270        if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &value, sizeof (int)) != 0) { 
     271                WARN("setsockopt failed with error #%u. This could be an UDP socket which on windows doesn't support SO_KEEPALIVE", WSAGetLastError()); 
    269272        } 
    270273        return true; 
     
    470473 
    471474bool deleteFolder(string path, bool force) { 
    472         NYIA; 
     475        char fileFound[256]; 
     476        memset(fileFound, 0x00, sizeof (fileFound)); 
     477        WIN32_FIND_DATA info; 
     478        HANDLE hp; 
     479        sprintf(fileFound, "%s\\*.*", path.c_str()); 
     480        hp = FindFirstFile(fileFound, &info); 
     481        do { 
     482                if (!((strcmp(info.cFileName, ".") == 0) || 
     483                                (strcmp(info.cFileName, "..") == 0))) { 
     484                        if ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 
     485                                        FILE_ATTRIBUTE_DIRECTORY) { 
     486                                string subFolder = path.c_str(); 
     487                                subFolder.append("\\"); 
     488                                subFolder.append(info.cFileName); 
     489                                deleteFolder((char*) subFolder.c_str(), true); 
     490                                RemoveDirectory(subFolder.c_str()); 
     491                        } else { 
     492                                sprintf(fileFound, "%s\\%s", path.c_str(), info.cFileName); 
     493                                BOOL retVal = DeleteFile(fileFound); 
     494                        } 
     495                } 
     496 
     497        } while (FindNextFile(hp, &info)); 
     498        FindClose(hp); 
    473499        return false; 
     500} 
     501 
     502bool createFolder(string path, bool recursive) { 
     503        char DirName[256]; 
     504        char* p = (char*) path.c_str(); 
     505        char* q = DirName; 
     506        while (*p) { 
     507                if (('\\' == *p) || ('/' == *p)) { 
     508                        if (':' != *(p - 1)) { 
     509                                CreateDirectory(DirName, NULL); 
     510                        } 
     511                } 
     512                *q++ = *p++; 
     513                *q = '\0'; 
     514        } 
     515        CreateDirectory(DirName, NULL); 
     516        return true; 
    474517} 
    475518 
     
    482525        return true; 
    483526} 
    484  
    485527#endif /* WIN32 */ 
  • trunk/sources/common/src/utils/buffering/iobuffer.cpp

    r722 r732  
    426426} 
    427427 
    428 string IOBuffer::DumpBuffer(uint8_t *pBuffer, uint32_t length) { 
     428string IOBuffer::DumpBuffer(const uint8_t *pBuffer, uint32_t length) { 
    429429        IOBuffer temp; 
    430430        temp.ReadFromBuffer(pBuffer, length); 
  • trunk/sources/common/src/utils/logging/logger.cpp

    r722 r732  
    150150        } 
    151151} 
     152 
     153void Logger::SetLevel(int32_t level) { 
     154        LOCK; 
     155        if (_pLogger == NULL) 
     156                return; 
     157 
     158        FOR_VECTOR(_pLogger->_logLocations, i) { 
     159                _pLogger->_logLocations[i]->SetLevel(level); 
     160        } 
     161} 
  • trunk/sources/common/src/utils/lua/luautils.cpp

    r646 r732  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    2020 
    2121#ifdef HAS_LUA 
     22extern "C" { 
     23#include <lualib.h> 
     24#include <lauxlib.h> 
     25} 
    2226#include "utils/lua/luautils.h" 
    2327#include "utils/logging/logging.h" 
     
    189193 
    190194                        lua_pushstring(pLuaState, VAR_MONTH); 
    191                         lua_pushnumber(pLuaState, tempTm.tm_mon+1); 
     195                        lua_pushnumber(pLuaState, tempTm.tm_mon + 1); 
    192196                        lua_settable(pLuaState, -3); 
    193197 
     
    197201 
    198202                        lua_pushstring(pLuaState, VAR_HOUR); 
    199                         lua_pushnumber(pLuaState, tempTm.tm_hour); 
     203                        lua_pushnumber(pLuaState, tempTm.tm_hour + 1); 
    200204                        lua_settable(pLuaState, -3); 
    201205 
     
    230234 
    231235                        lua_pushstring(pLuaState, VAR_MONTH); 
    232                         lua_pushnumber(pLuaState, tempTm.tm_mon); 
     236                        lua_pushnumber(pLuaState, tempTm.tm_mon + 1); 
    233237                        lua_settable(pLuaState, -3); 
    234238 
     
    262266 
    263267                        lua_pushstring(pLuaState, VAR_HOUR); 
    264                         lua_pushnumber(pLuaState, tempTm.tm_hour); 
     268                        lua_pushnumber(pLuaState, tempTm.tm_hour + 1); 
    265269                        lua_settable(pLuaState, -3); 
    266270 
  • trunk/sources/common/src/utils/mempool/mempool.cpp

    r722 r732  
    8888        if (pResult == NULL) { 
    8989                _created++; 
    90                 return ::operator new(_size, std::nothrow); 
     90                return ::operator new(_size, nothrow); 
    9191        } else { 
    9292                _pEntries = _pEntries->pNext; 
  • trunk/sources/common/src/utils/misc/file.cpp

    r702 r732  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    4545                case FILE_OPEN_MODE_READ: 
    4646                { 
    47                         openMode = "r"; 
     47                        openMode = "rb"; 
    4848                        break; 
    4949                } 
    5050                case FILE_OPEN_MODE_TRUNCATE: 
    5151                { 
    52                         openMode = "w+"; 
     52                        openMode = "w+b"; 
    5353                        break; 
    5454                } 
    5555                case FILE_OPEN_MODE_APPEND: 
    5656                { 
    57                         openMode = "a+"; 
     57                        openMode = "a+b"; 
    5858                        break; 
    5959                } 
  • trunk/sources/common/src/utils/misc/timersmanager.cpp

    r413 r732  
    2828        _pSlots = NULL; 
    2929        _slotsCount = 0; 
     30#ifdef NET_IOCP 
     31        _inExecution=false; 
     32#endif 
    3033} 
    3134 
     
    3538} 
    3639 
     40#ifdef NET_IOCP 
     41void TimersManager::RemoveTimer(uint32_t eventTimerId) { 
     42        for (uint32_t i = 0; i < _slotsCount; i++) { 
     43                if (MAP_HAS1(_pSlots[i].timers, eventTimerId)) { 
     44                        if(_inExecution){ 
     45                                _pSlots[i].timers[eventTimerId].pUserData=NULL; 
     46                                ADD_VECTOR_END(_pendingForRemoval,eventTimerId); 
     47                        } else { 
     48                                _pSlots[i].timers.erase(eventTimerId); 
     49                        } 
     50                } 
     51        } 
     52} 
     53#else 
    3754void TimersManager::RemoveTimer(uint32_t eventTimerId) { 
    3855        for (uint32_t i = 0; i < _slotsCount; i++) { 
     
    4259        } 
    4360} 
     61#endif 
    4462 
    4563void TimersManager::AddTimer(TimerEvent& timerEvent) { 
     
    5977} 
    6078 
     79#ifdef NET_IOCP 
     80void TimersManager::TimeElapsed(uint64_t currentTime) { 
     81        _inExecution=true; 
     82        int64_t delta = currentTime - _lastTime; 
     83        _lastTime = currentTime; 
     84 
     85        if (delta <= 0 || _slotsCount == 0){ 
     86                _inExecution=false; 
     87                return; 
     88        } 
     89 
     90        for (int32_t i = 0; i < delta; i++) { 
     91 
     92                FOR_MAP(_pSlots[_currentSlotIndex % _slotsCount].timers, uint32_t, TimerEvent, j) { 
     93                        _processTimerEvent(MAP_VAL(j)); 
     94                } 
     95                _currentSlotIndex++; 
     96        } 
     97        _inExecution=false; 
     98        for(uint32_t i=0;i<_pendingForRemoval.size();i++) { 
     99                RemoveTimer(_pendingForRemoval[i]); 
     100        } 
     101        _pendingForRemoval.clear(); 
     102} 
     103#else 
    61104void TimersManager::TimeElapsed(uint64_t currentTime) { 
    62105        int64_t delta = currentTime - _lastTime; 
     
    74117        } 
    75118} 
     119#endif 
    76120 
    77121void TimersManager::UpdatePeriods(uint32_t period) { 
     
    109153                return 0; 
    110154        uint32_t result = a * b / GCD(a, b); 
    111         FINEST("a: %u; b: %u; r: %u", a, b, result); 
     155        //FINEST("a: %u; b: %u; r: %u", a, b, result); 
    112156        return result; 
    113157} 
  • trunk/sources/common/src/utils/misc/uri.cpp

    r730 r732  
    102102        bool hasAuthentication = false; 
    103103        pos = stringUri.find("@", cursor); 
    104         if (pos != string::npos && pos < limit) { 
     104        if (pos != string::npos) { 
    105105                if (limit != string::npos) { 
    106106                        hasAuthentication = pos<limit; 
    107                 } 
    108                 hasAuthentication = true; 
     107                } else { 
     108                        hasAuthentication = true; 
     109                } 
    109110        } 
    110111        if (hasAuthentication) { 
  • trunk/sources/common/src/utils/misc/variant.cpp

    r722 r732  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    10621062 
    10631063        if (detectedType == V_TIME || detectedType == V_TIMESTAMP) { 
    1064                 temp.tm_hour = (int) ((int32_t) (*this)["hour"]); 
     1064                temp.tm_hour = (int) ((int32_t) (*this)["hour"]) - 1; 
    10651065                temp.tm_min = (int) ((int32_t) (*this)["min"]); 
    10661066                temp.tm_sec = (int) (HasKey("sec") ? 
     
    16561656} 
    16571657 
    1658 bool Variant::DeserializeFromCmdLineArgs(uint32_t count, char **pArguments, 
     1658bool Variant::DeserializeFromCmdLineArgs(uint32_t count, const char **pArguments, 
    16591659                Variant &result) { 
    16601660        if (count < 1) { 
     
    19041904                { 
    19051905                        VARIANT_CHECK_BOUNDS(4); 
    1906                         variant = ENTOHLP(PTR); //----MARKED-LONG--- 
     1906                        variant = (uint32_t) ENTOHLP(PTR); //----MARKED-LONG--- 
    19071907                        cursor += 4; 
    19081908                        return true; 
Note: See TracChangeset for help on using the changeset viewer.