Changeset 734


Ignore:
Timestamp:
02/03/12 20:52:54 (4 months ago)
Author:
shiretu
Message:

-- imported changes thelib and crtmpserver from commercial version (evostream)

Location:
trunk/sources
Files:
49 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/crtmpserver/src/crtmpserver.cpp

    r702 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    6969#endif 
    7070 
    71 int main(int argc, char **argv) { 
     71int main(int argc, const char **argv) { 
    7272        SRAND(); 
    7373        InitNetworking(); 
  • trunk/sources/thelib/include/mediaformats/mp4/atomdata.h

    r10 r734  
    4141 
    4242        virtual bool Read(); 
    43         std::string Hierarchy(uint32_t indent); 
     43        string Hierarchy(uint32_t indent); 
    4444}; 
    4545 
  • trunk/sources/thelib/include/mediaformats/mp4/generateatom.sh

    r2 r734  
    4444echo "" >>$FILENAME 
    4545echo "    virtual bool Read();" >>$FILENAME 
    46 echo "    std::string Hierarchy(uint32_t indent);" >>$FILENAME 
     46echo "    string Hierarchy(uint32_t indent);" >>$FILENAME 
    4747echo "};" >>$FILENAME 
    4848echo "" >>$FILENAME 
  • trunk/sources/thelib/include/netio/fdstats.h

    r722 r734  
    3636#endif /* GLOBALLY_ACCOUNT_BYTES */ 
    3737 
    38 class BaseFdStats { 
     38class DLLEXP BaseFdStats { 
    3939private: 
    4040        int64_t _current; 
     
    9595}; 
    9696 
    97 class FdStats { 
     97class DLLEXP FdStats { 
    9898private: 
    9999        BaseFdStats _managedTcp; 
  • trunk/sources/thelib/include/netio/netio.h

    r706 r734  
    8282#endif 
    8383 
    84 #ifdef NET_IOCP2 
    85 #include "netio/iocp2/iohandler.h" 
    86 #include "netio/iocp2/iohandlermanager.h" 
    87 #include "netio/iocp2/iohandlermanagertoken.h" 
    88 #include "netio/iocp2/iotimer.h" 
    89 #include "netio/iocp2/tcpacceptor.h" 
    90 #include "netio/iocp2/tcpcarrier.h" 
    91 #include "netio/iocp2/udpcarrier.h" 
    92 #include "netio/iocp2/tcpconnector.h" 
    93 #include "netio/iocp2/stdiocarrier.h" 
    94 #define NETWORK_REACTOR "iocp2" 
    95 #endif 
    96  
    9784#endif  /* _NETIO_H */ 
    9885 
  • trunk/sources/thelib/include/protocols/cli/basecliappprotocolhandler.h

    r397 r734  
    3737        virtual bool ProcessMessage(BaseProtocol *pFrom, Variant &message) = 0; 
    3838protected: 
    39         bool Send(BaseProtocol *pTo, string status, string description, Variant &data); 
    40         bool SendFail(BaseProtocol *pTo, string description); 
    41         bool SendSuccess(BaseProtocol *pTo, string description, Variant &data); 
     39        static bool SendFail(BaseProtocol *pTo, string description); 
     40        static bool SendSuccess(BaseProtocol *pTo, string description, Variant &data); 
     41private: 
     42        static bool Send(BaseProtocol *pTo, string status, string description, Variant &data); 
    4243}; 
    4344 
  • trunk/sources/thelib/include/protocols/cli/inboundbasecliprotocol.h

    r191 r734  
    2626class BaseCLIAppProtocolHandler; 
    2727 
    28 class InboundBaseCLIProtocol 
     28class DLLEXP InboundBaseCLIProtocol 
    2929: public BaseProtocol { 
    3030private: 
  • trunk/sources/thelib/include/protocols/cli/inboundjsoncliprotocol.h

    r210 r734  
    2525#include "protocols/cli/inboundbasecliprotocol.h" 
    2626 
    27 class InboundJSONCLIProtocol 
     27class DLLEXP InboundJSONCLIProtocol 
    2828: public InboundBaseCLIProtocol { 
    2929private: 
  • trunk/sources/thelib/include/protocols/liveflv/innetliveflvstream.h

    r694 r734  
    2525#include "streaming/baseinnetstream.h" 
    2626 
    27 class InNetLiveFLVStream 
     27class DLLEXP InNetLiveFLVStream 
    2828: public BaseInNetStream { 
    2929private: 
  • trunk/sources/thelib/include/protocols/protocoltypes.h

    r696 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    8080#define PT_INBOUND_RAW_HTTP_STREAM              MAKE_TAG4('I','R','H','S') 
    8181 
     82//pass through protocol 
     83#define PT_PASSTHROUGH MAKE_TAG2('P','T') 
     84 
    8285#endif  /* _PROTOCOLTYPES_H */ 
    8386 
  • trunk/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h

    r722 r734  
    2727#include "protocols/rtmp/rtmpprotocolserializer.h" 
    2828#include "protocols/rtmp/sharedobjects/somanager.h" 
    29 #include "streaming/baseoutstream.h" 
    30 #include "streaming/baseoutfilestream.h" 
    3129 
    3230class OutboundRTMPProtocol; 
  • trunk/sources/thelib/include/protocols/rtmp/basertmpprotocol.h

    r718 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/baseoutnetrtmpstream.h

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    3535        uint32_t _chunkSize; 
    3636        BaseRTMPProtocol *_pRTMPProtocol; 
    37  
    38         double _deltaVideoTime; 
    39         double _deltaAudioTime; 
    40         double *_pDeltaVideoTime; 
    41         double *_pDeltaAudioTime; 
    4237        double _seekTime; 
     38        double _start; 
    4339 
    4440        uint32_t _isFirstVideoFrame; 
     
    114110        bool AllowExecution(uint32_t totalProcessed, uint32_t dataLength, bool isAudio); 
    115111        void InternalReset(); 
    116         void FixTimeBase(); 
    117112}; 
    118113 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/infilertmpstream.h

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  *   
     4 * 
    55 *  This file is part of crtmpserver. 
    66 *  crtmpserver is free software: you can redistribute it and/or modify 
     
    88 *  the Free Software Foundation, either version 3 of the License, or 
    99 *  (at your option) any later version. 
    10  *   
     10 * 
    1111 *  crtmpserver is distributed in the hope that it will be useful, 
    1212 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 *  GNU General Public License for more details. 
    15  *   
     15 * 
    1616 *  You should have received a copy of the GNU General Public License 
    1717 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     
    100100        virtual ~InFileRTMPStream(); 
    101101 
    102         virtual bool Initialize(int32_t clientSideBufferLength); 
     102        virtual bool Initialize(int32_t clientSideBufferLength, bool hasTimer); 
    103103 
    104104        virtual bool FeedData(uint8_t *pData, uint32_t dataLength, 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/innetrtmpstream.h

    r718 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/outfilertmpflvstream.h

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/outnetrtmp4rtmpstream.h

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  *   
     4 * 
    55 *  This file is part of crtmpserver. 
    66 *  crtmpserver is free software: you can redistribute it and/or modify 
     
    88 *  the Free Software Foundation, either version 3 of the License, or 
    99 *  (at your option) any later version. 
    10  *   
     10 * 
    1111 *  crtmpserver is distributed in the hope that it will be useful, 
    1212 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 *  GNU General Public License for more details. 
    15  *   
     15 * 
    1616 *  You should have received a copy of the GNU General Public License 
    1717 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/outnetrtmp4tsstream.h

    r729 r734  
    3939        virtual ~OutNetRTMP4TSStream(); 
    4040 
    41         virtual void SignalAttachedToInStream(); 
    42  
    4341        virtual bool IsCompatibleWithType(uint64_t type); 
    4442 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/rtmpstream.h

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  *   
     4 * 
    55 *  This file is part of crtmpserver. 
    66 *  crtmpserver is free software: you can redistribute it and/or modify 
     
    88 *  the Free Software Foundation, either version 3 of the License, or 
    99 *  (at your option) any later version. 
    10  *   
     10 * 
    1111 *  crtmpserver is distributed in the hope that it will be useful, 
    1212 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 *  GNU General Public License for more details. 
    15  *   
     15 * 
    1616 *  You should have received a copy of the GNU General Public License 
    1717 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
  • trunk/sources/thelib/include/protocols/tcpprotocol.h

    r496 r734  
    2626class IOHandler; 
    2727 
    28 class TCPProtocol 
     28class DLLEXP TCPProtocol 
    2929: public BaseProtocol { 
    3030private: 
  • trunk/sources/thelib/include/protocols/ts/innettsstream.h

    r729 r734  
    4343#endif 
    4444        IOBuffer _audioBucket; 
    45         double _lastGotAudioTimestamp; 
    4645        double _lastSentAudioTimestamp; 
    4746        uint64_t _audioPacketsCount; 
     
    6867 
    6968        StreamCapabilities _streamCapabilities; 
    70  
    71         double _deltaTime; 
    7269 
    7370        IOBuffer _SPS; 
  • trunk/sources/thelib/include/streaming/baseinfilestream.h

    r594 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    3535        @class BaseInFileStream 
    3636        @brief 
    37 */ 
     37 */ 
    3838class DLLEXP BaseInFileStream 
    3939: public BaseInStream { 
     
    7878        bool _paused; 
    7979        bool _audioVideoCodecsSent; 
    80          
     80 
    8181        //seek offsets 
    8282        uint64_t _seekBaseOffset; 
    8383        uint64_t _framesBaseOffset; 
    8484        uint64_t _timeToIndexOffset; 
    85          
     85 
    8686        //stream capabilities 
    8787        StreamCapabilities _streamCapabilities; 
    88          
     88 
    8989        //when to stop playback 
    9090        double _playLimit; 
     
    9494        virtual ~BaseInFileStream(); 
    9595 
     96        bool StreamCompleted(); 
     97 
    9698        /*! 
    9799          @brief Returns the stream capabilities. Specifically, codec and codec related info 
    98         */ 
     100         */ 
    99101        virtual StreamCapabilities * GetCapabilities(); 
    100102 
     
    102104                @brief Extracts the complete metadata from partial metadata 
    103105                @param metaData - the partial metadata containing at least the media file name 
    104         */ 
     106         */ 
    105107        static bool ResolveCompleteMetadata(Variant &metaData); 
    106108 
     
    108110                @brief This will initialize the stream internally. 
    109111                @param clientSideBufferLength - the client side buffer length expressed in seconds 
    110         */ 
    111         virtual bool Initialize(int32_t clientSideBufferLength); 
     112         */ 
     113        virtual bool Initialize(int32_t clientSideBufferLength, bool hasTimer); 
    112114 
    113115        /*! 
    114116                @brief Called when a play command was issued 
    115117                @param absoluteTimestamp - the timestamp where we want to seek before start the feeding process 
    116         */ 
     118         */ 
    117119        virtual bool SignalPlay(double &absoluteTimestamp, double &length); 
    118120 
    119121        /*! 
    120122                @brief Called when a pasue command was issued 
    121         */ 
     123         */ 
    122124        virtual bool SignalPause(); 
    123125 
    124126        /*! 
    125127                @brief Called when a resume command was issued 
    126         */ 
     128         */ 
    127129        virtual bool SignalResume(); 
    128130 
     
    130132                @brief Called when a seek command was issued 
    131133                @param absoluteTimestamp 
    132         */ 
     134         */ 
    133135        virtual bool SignalSeek(double &absoluteTimestamp); 
    134136 
    135137        /*! 
    136138                @brief Called when a stop command was issued 
    137         */ 
     139         */ 
    138140        virtual bool SignalStop(); 
    139141 
    140142        /*! 
    141143                @brief This is called by the framework. The networking layer signaled the availability for sending data 
    142         */ 
     144         */ 
    143145        virtual void ReadyForSend(); 
    144146 
     
    151153                @brief This will seek to the specified point in time. 
    152154                @param absoluteTimestamp - the timestamp where we want to seek before start the feeding process 
    153         */ 
     155         */ 
    154156        bool InternalSeek(double &absoluteTimestamp); 
    155157 
     158public: 
    156159        /*! 
    157160                @brief This is the function that will actually do the feeding. 
    158161                @discussion It is called by the framework and it must deliver one frame at a time to all subscribers 
    159         */ 
     162         */ 
     163 
    160164        virtual bool Feed(); 
    161  
     165private: 
    162166        /*! 
    163167                @brief GetFile function will open a file and will cache it if is a regular file. 
     
    165169                ReleaseFile will do the opposite: It will close the file if the references 
    166170                count will reach 0. This always happens in case of mmap file 
    167         */ 
     171         */ 
    168172#ifdef HAS_MMAP 
    169173        static MmapFile* GetFile(string filePath, uint32_t windowSize); 
     
    176180        /*! 
    177181                @brief This function will ensure that the codec packets are sent. Also it preserves the current timings and frame index 
    178         */ 
     182         */ 
    179183        bool SendCodecs(); 
    180184}; 
  • trunk/sources/thelib/include/streaming/streamcapabilities.h

    r598 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    3939        DLLEXP _VIDEO_AVC(); 
    4040        DLLEXP virtual ~_VIDEO_AVC(); 
    41         bool Init(uint8_t *pSPS, uint32_t spsLength, uint8_t *pPPS, uint32_t ppsLength); 
     41        bool Init(const uint8_t *pSPS, uint32_t spsLength, const uint8_t *pPPS, uint32_t ppsLength); 
    4242        void Clear(); 
    4343 
     
    5757        DLLEXP _AUDIO_AAC(); 
    5858        DLLEXP virtual ~_AUDIO_AAC(); 
    59         bool Init(uint8_t *pBuffer, uint32_t length); 
     59        bool Init(const uint8_t *pBuffer, uint32_t length); 
    6060        void Clear(); 
    6161        DLLEXP string GetRTSPFmtpConfig(); 
     
    7777        virtual ~StreamCapabilities(); 
    7878 
    79         bool InitAudioAAC(uint8_t *pBuffer, uint32_t length); 
     79        bool InitAudioAAC(const uint8_t *pBuffer, uint32_t length); 
    8080        bool InitAudioADTS(); 
    8181        bool InitAudioMP3(); 
    82         bool InitVideoH264(uint8_t *pSPS, uint32_t spsLength, uint8_t *pPPS, 
     82        bool InitVideoH264(const uint8_t *pSPS, uint32_t spsLength, const uint8_t *pPPS, 
    8383                        uint32_t ppsLength); 
    8484 
  • trunk/sources/thelib/include/streaming/streamstypes.h

    r497 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    3232#define ST_IN_NET_AAC                   MAKE_TAG3('I','N','A') 
    3333#define ST_IN_NET_MP3                   MAKE_TAG3('I','N','M') 
     34#define ST_IN_NET_EXT                   MAKE_TAG5('I','N','E','X','T') 
     35#define ST_IN_NET_PASSTHROUGH   MAKE_TAG3('I','N','S') 
    3436#define ST_IN_FILE                              MAKE_TAG2('I','F') 
    3537#define ST_IN_FILE_RTMP                 MAKE_TAG3('I','F','R') 
     
    4143#define ST_OUT_NET_RTP                  MAKE_TAG3('O','N','P') 
    4244#define ST_OUT_NET_RAW                  MAKE_TAG3('O','N','W') 
     45#define ST_OUT_NET_TS                   MAKE_TAG4('O','N','T','S') 
     46#define ST_OUT_NET_PASSTHROUGH  MAKE_TAG3('O','N','S') 
    4347#define ST_OUT_FILE                             MAKE_TAG2('O','F') 
    4448#define ST_OUT_FILE_RTMP                MAKE_TAG3('O','F','R') 
    4549#define ST_OUT_FILE_RTMP_FLV    MAKE_TAG6('O','F','R','F','L','V') 
    4650#define ST_OUT_FILE_HLS                 MAKE_TAG5('O','F','H','L','S') 
     51#define ST_OUT_FILE_HDS                 MAKE_TAG5('O','F','H','D','S') 
    4752 
    4853#endif  /* _STREAMSTYPES_H */ 
  • trunk/sources/thelib/src/configuration/configfile.cpp

    r690 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    165165        } 
    166166 
    167         for (int32_t i = 0; i < instancesCount; i++) { 
    168                 pid_t pid = fork(); 
    169                 if (pid < 0) { 
    170                         FATAL("Unable to start child instance. fork() failed"); 
    171                         return false; 
    172                 } 
    173  
    174                 if (pid == 0) { 
    175                         _isOrigin = false; 
    176                         Logger::SignalFork(); 
    177                         break; 
    178                 } 
    179         } 
    180  
    181167        FOR_MAP(_modules, string, Module, i) { 
    182168                MAP_VAL(i).config["isOrigin"] = (bool)_isOrigin; 
  • trunk/sources/thelib/src/mediaformats/mp4/atomdata.cpp

    r413 r734  
    143143} 
    144144 
    145 std::string AtomDATA::Hierarchy(uint32_t indent) { 
    146         return std::string(4 * indent, ' ') + GetTypeString(); 
     145string AtomDATA::Hierarchy(uint32_t indent) { 
     146        return string(4 * indent, ' ') + GetTypeString(); 
    147147} 
    148148 
  • trunk/sources/thelib/src/mediaformats/mp4/generateatom.sh

    r2 r734  
    4747echo "}" >>$FILENAME 
    4848echo "" >>$FILENAME 
    49 echo "std::string $CLASSNAME::Hierarchy(uint32_t indent) {" >>$FILENAME 
    50 echo "    return std::string(4 * indent, ' ') + GetTypeString();" >>$FILENAME 
     49echo "string $CLASSNAME::Hierarchy(uint32_t indent) {" >>$FILENAME 
     50echo "    return string(4 * indent, ' ') + GetTypeString();" >>$FILENAME 
    5151echo "}" >>$FILENAME 
    5252echo "" >>$FILENAME 
  • trunk/sources/thelib/src/netio/select/iohandlermanager.cpp

    r712 r734  
    257257 
    258258bool IOHandlerManager::UpdateFdSets(int32_t fd) { 
     259        if( fd == 0 ) 
     260                return true; 
    259261        uint8_t state = 0; 
    260262 
  • trunk/sources/thelib/src/protocols/baseprotocol.cpp

    r705 r734  
    5252BaseProtocol::~BaseProtocol() { 
    5353#ifdef LOG_CONSTRUCTOR_DESTRUCTOR 
    54         FINEST("Protocol with id %u of type %s going to be deleted; F: %p,N: %p, DF: %hhu, DN: %hhu", 
    55                         _id, STR(tagToString(_type)), 
    56                         _pFarProtocol, _pNearProtocol, _deleteFar, _deleteNear); 
     54        FINEST("Protocol with id %"PRIu32"(%p) of type %s going to be deleted; F: %p,N: %p, DF: %"PRIu8", DN: %"PRIu8, 
     55                        _id, 
     56                        this, 
     57                        STR(tagToString(_type)), 
     58                        _pFarProtocol, 
     59                        _pNearProtocol, 
     60                        _deleteFar, 
     61                        _deleteNear); 
    5762#endif 
    5863        BaseProtocol *pFar = _pFarProtocol; 
     
    7479        } 
    7580#ifdef LOG_CONSTRUCTOR_DESTRUCTOR 
    76         FINEST("Protocol with id %u of type %s deleted; F: %p,N: %p, DF: %hhu, DN: %hhu", 
    77                         _id, STR(tagToString(_type)), 
    78                         _pFarProtocol, _pNearProtocol, _deleteFar, _deleteNear); 
     81        FINEST("Protocol with id %"PRIu32"(%p) of type %s deleted; F: %p,N: %p, DF: %"PRIu8", DN: %"PRIu8, 
     82                        _id, 
     83                        this, 
     84                        STR(tagToString(_type)), 
     85                        _pFarProtocol, 
     86                        _pNearProtocol, 
     87                        _deleteFar, 
     88                        _deleteNear); 
    7989#endif 
    8090        ProtocolManager::UnRegisterProtocol(this); 
  • trunk/sources/thelib/src/protocols/cli/basecliappprotocolhandler.cpp

    r560 r734  
    3838} 
    3939 
     40bool BaseCLIAppProtocolHandler::SendFail(BaseProtocol *pTo, string description) { 
     41        Variant dummy; 
     42        return Send(pTo, "FAIL", description, dummy); 
     43} 
     44 
     45bool BaseCLIAppProtocolHandler::SendSuccess(BaseProtocol *pTo, string description, Variant &data) { 
     46        return Send(pTo, "SUCCESS", description, data); 
     47} 
     48 
    4049bool BaseCLIAppProtocolHandler::Send(BaseProtocol *pTo, string status, string description, Variant &data) { 
     50        if (pTo == NULL) 
     51                return true; 
    4152        //1. Prepare the final message 
    4253        Variant message; 
     
    5465        } 
    5566} 
    56  
    57 bool BaseCLIAppProtocolHandler::SendFail(BaseProtocol *pTo, string description) { 
    58         Variant dummy; 
    59         return Send(pTo, "FAIL", description, dummy); 
    60 } 
    61  
    62 bool BaseCLIAppProtocolHandler::SendSuccess(BaseProtocol *pTo, string description, Variant &data) { 
    63         return Send(pTo, "SUCCESS", description, data); 
    64 } 
    65  
    6667#endif /* HAS_PROTOCOL_CLI */ 
  • trunk/sources/thelib/src/protocols/cli/inboundbasecliprotocol.cpp

    r471 r734  
    1818 */ 
    1919 
    20 #include "netio/kqueue/iohandlermanager.h" 
    21  
    22  
    2320#ifdef HAS_PROTOCOL_CLI 
    2421#include "protocols/cli/inboundbasecliprotocol.h" 
    2522#include "application/clientapplicationmanager.h" 
    2623#include "protocols/cli/basecliappprotocolhandler.h" 
     24#include "netio/netio.h" 
    2725 
    2826InboundBaseCLIProtocol::InboundBaseCLIProtocol(uint64_t type) 
  • trunk/sources/thelib/src/protocols/liveflv/innetliveflvstream.cpp

    r695 r734  
    109109        info["audio"]["bytesCount"] = _audioBytesCount; 
    110110        info["audio"]["packetsCount"] = _audioPacketsCount; 
    111         info["audio"]["droppedPacketsCount"] = 0; 
     111        info["audio"]["droppedPacketsCount"] = (uint32_t) 0; 
    112112        info["video"]["bytesCount"] = _videoBytesCount; 
    113113        info["video"]["packetsCount"] = _videoPacketsCount; 
    114         info["video"]["droppedPacketsCount"] = 0; 
     114        info["video"]["droppedPacketsCount"] = (uint32_t) 0; 
    115115} 
    116116 
  • trunk/sources/thelib/src/protocols/protocolfactorymanager.cpp

    r413 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
  • trunk/sources/thelib/src/protocols/rtmp/basertmpprotocol.cpp

    r722 r734  
    508508                return NULL; 
    509509        } 
     510        bool hasTimer = true; 
     511        if (metadata.HasKeyChain(V_BOOL, true, 1, "hasTimer")) 
     512                hasTimer = (bool)metadata["hasTimer"]; 
    510513        if (!pRTMPInFileStream->Initialize( 
    511                         (int32_t) metadata[CONF_APPLICATION_CLIENTSIDEBUFFER])) { 
     514                        (int32_t) metadata[CONF_APPLICATION_CLIENTSIDEBUFFER], hasTimer)) { 
    512515                FATAL("Unable to initialize file inbound stream"); 
    513516                delete pRTMPInFileStream; 
  • trunk/sources/thelib/src/protocols/rtmp/messagefactories/connectionmessagefactory.cpp

    r422 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  *   
     4 * 
    55 *  This file is part of crtmpserver. 
    66 *  crtmpserver is free software: you can redistribute it and/or modify 
     
    88 *  the Free Software Foundation, either version 3 of the License, or 
    99 *  (at your option) any later version. 
    10  *   
     10 * 
    1111 *  crtmpserver is distributed in the hope that it will be useful, 
    1212 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 *  GNU General Public License for more details. 
    15  *   
     15 * 
    1616 *  You should have received a copy of the GNU General Public License 
    1717 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     
    128128Variant ConnectionMessageFactory::GetInvokeConnectError(Variant request, 
    129129                string decription, string level, string code) { 
    130         double objectEncoding = 0; 
    131         if (M_INVOKE_PARAM(request, 0).HasKey(RM_INVOKE_PARAMS_RESULT_OBJECTENCODING)) 
    132                 objectEncoding = M_INVOKE_PARAM(request, 0)[RM_INVOKE_PARAMS_RESULT_OBJECTENCODING]; 
    133130        return GetInvokeConnectError( 
    134131                        VH_CI(request), 
  • trunk/sources/thelib/src/protocols/rtmp/rtmpprotocolserializer.cpp

    r693 r734  
    577577                { 
    578578                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    579                         message[RM_USRCTRL_STREAMID] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
     579                        message[RM_USRCTRL_STREAMID] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    580580                        if (!buffer.Ignore(4)) { 
    581581                                FATAL("Unable to ignore 4 bytes"); 
     
    587587                { 
    588588                        AMF_CHECK_BOUNDARIES(buffer, 8); 
    589                         message[RM_USRCTRL_STREAMID] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
     589                        message[RM_USRCTRL_STREAMID] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    590590                        if (!buffer.Ignore(4)) { 
    591591                                FATAL("Unable to ignore 4 bytes"); 
    592592                                return false; 
    593593                        } 
    594                         message[RM_USRCTRL_BUFFLEN] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
     594                        message[RM_USRCTRL_BUFFLEN] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    595595                        if (!buffer.Ignore(4)) { 
    596596                                FATAL("Unable to ignore 4 bytes"); 
     
    602602                { 
    603603                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    604                         message[RM_USRCTRL_PING] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
     604                        message[RM_USRCTRL_PING] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    605605                        if (!buffer.Ignore(4)) { 
    606606                                FATAL("Unable to ignore 4 bytes"); 
     
    612612                { 
    613613                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    614                         message[RM_USRCTRL_PONG] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
     614                        message[RM_USRCTRL_PONG] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    615615                        if (!buffer.Ignore(4)) { 
    616616                                FATAL("Unable to ignore 4 bytes"); 
     
    623623                { 
    624624                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    625                         message[RM_USRCTRL_UNKNOWN_U32] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
     625                        message[RM_USRCTRL_UNKNOWN_U32] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    626626                        if (!buffer.Ignore(4)) { 
    627627                                FATAL("Unable to ignore 4 bytes"); 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/baseoutnetrtmpstream.cpp

    r722 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    9898        } else if (TAG_KIND_OF(inStreamType, ST_IN_NET_TS) 
    9999                        || TAG_KIND_OF(inStreamType, ST_IN_NET_RTP) 
    100                         || TAG_KIND_OF(inStreamType, ST_IN_NET_AAC)) { 
     100                        || TAG_KIND_OF(inStreamType, ST_IN_NET_AAC) 
     101                        || TAG_KIND_OF(inStreamType, ST_IN_NET_EXT)) { 
    101102                pResult = new OutNetRTMP4TSStream(pProtocol, pStreamsManager, name, 
    102103                                rtmpStreamId, chunkSize); 
     
    173174                uint32_t processedLength, uint32_t totalLength, 
    174175                double absoluteTimestamp, bool isAudio) { 
     176        if (_start < 0) 
     177                _start = absoluteTimestamp; 
     178        absoluteTimestamp -= _start; 
    175179        if (_paused) 
    176180                return true; 
     
    191195                        } 
    192196 
    193                         if ((*_pDeltaAudioTime) < 0) 
    194                                 (*_pDeltaAudioTime) = absoluteTimestamp; 
    195                         if ((*_pDeltaAudioTime) > absoluteTimestamp) { 
    196                                 //FINEST("A: WAIT: D: %.2f", (*_pDeltaAudioTime) - absoluteTimestamp); 
    197                                 _pRTMPProtocol->EnqueueForOutbound(); 
    198                                 return true; 
    199                         } 
    200  
    201                         H_IA(_audioHeader) = true; 
    202                         H_TS(_audioHeader) = (uint32_t) (absoluteTimestamp - (*_pDeltaAudioTime) + _seekTime); 
    203                         if ((pData[0] >> 4) == 10 
    204                                         && (pData[1] == 0)) { 
     197                        if ((pData[0] >> 4) == 10 && (pData[1] == 0)) { 
    205198                                //AAC codec setup. Keep _isFirstAudioFrame == true; 
    206199                                _isFirstAudioFrame = true; 
     200                                if (absoluteTimestamp < 0) { 
     201                                        //WARN("negative A. Force it to 0 because is a codec setup"); 
     202                                        absoluteTimestamp = 0; 
     203                                } 
    207204                        } else { 
    208205                                //not AAC codec setup 
     206                                if (absoluteTimestamp < 0) { 
     207                                        //WARN("negative A and not a codec. Drop it"); 
     208                                        _pRTMPProtocol->EnqueueForOutbound(); 
     209                                        return true; 
     210                                } 
    209211                                _isFirstAudioFrame = false; 
    210212                        } 
     213 
     214                        H_IA(_audioHeader) = true; 
     215                        H_TS(_audioHeader) = (uint32_t) (absoluteTimestamp + _seekTime); 
    211216                } else { 
    212217                        ALLOW_EXECUTION(processedLength, dataLength, isAudio); 
    213218                        H_IA(_audioHeader) = false; 
    214219                        if (processedLength == 0) 
    215                                 H_TS(_audioHeader) = (uint32_t) ((absoluteTimestamp - (*_pDeltaAudioTime) + _seekTime) 
     220                                H_TS(_audioHeader) = (uint32_t) ((absoluteTimestamp + _seekTime) 
    216221                                        - _pChannelAudio->lastOutAbsTs); 
    217222                } 
     
    247252                        } 
    248253 
    249                         if ((*_pDeltaVideoTime) < 0) 
    250                                 (*_pDeltaVideoTime) = absoluteTimestamp; 
    251                         if ((*_pDeltaVideoTime) > absoluteTimestamp) { 
    252                                 //FINEST("V: WAIT: D: %.2f", (*_pDeltaVideoTime) - absoluteTimestamp); 
    253                                 _pRTMPProtocol->EnqueueForOutbound(); 
    254                                 return true; 
    255                         } 
    256  
    257                         H_IA(_videoHeader) = true; 
    258                         H_TS(_videoHeader) = (uint32_t) (absoluteTimestamp - (*_pDeltaVideoTime) + _seekTime); 
    259  
    260                         if ((pData[0] == 0x17) //AVC keyframe 
    261                                         && (pData[1] == 0)) { //codec setup 
     254                        if ((pData[0] == 0x17) && (pData[1] == 0)) { 
    262255                                // h264 codec setup. Keep _isFirstVideoFrame == true 
    263256                                _isFirstVideoFrame = true; 
     257                                if (absoluteTimestamp < 0) { 
     258                                        //WARN("negative V. Force it to 0 because is a codec setup"); 
     259                                        absoluteTimestamp = 0; 
     260                                } 
    264261                        } else { 
    265262                                //not h264 codec setup 
     263                                if (absoluteTimestamp < 0) { 
     264                                        //WARN("negative V and not a codec. Drop it"); 
     265                                        _pRTMPProtocol->EnqueueForOutbound(); 
     266                                        return true; 
     267                                } 
    266268                                _isFirstVideoFrame = false; 
    267269                        } 
     270 
     271                        H_IA(_videoHeader) = true; 
     272                        H_TS(_videoHeader) = (uint32_t) (absoluteTimestamp + _seekTime); 
    268273                } else { 
    269274                        ALLOW_EXECUTION(processedLength, dataLength, isAudio); 
    270275                        H_IA(_videoHeader) = false; 
    271276                        if (processedLength == 0) 
    272                                 H_TS(_videoHeader) = (uint32_t) ((absoluteTimestamp - (*_pDeltaVideoTime) + _seekTime) 
     277                                H_TS(_videoHeader) = (uint32_t) ((absoluteTimestamp + _seekTime) 
    273278                                        - _pChannelVideo->lastOutAbsTs); 
    274279                } 
     
    310315                _feederChunkSize = 0xffffffff; 
    311316        } 
    312  
    313         //3. Fix the time base 
    314         FixTimeBase(); 
    315  
    316317 
    317318        //4. Store the metadata 
     
    511512bool BaseOutNetRTMPStream::SignalPlay(double &absoluteTimestamp, double &length) { 
    512513        _paused = false; 
    513  
    514514        return true; 
    515515} 
     
    546546 
    547547bool BaseOutNetRTMPStream::SignalSeek(double &absoluteTimestamp) { 
    548  
    549548        //1. Stream eof 
    550549        Variant message = StreamMessageFactory::GetUserControlStreamEof(_rtmpStreamId); 
     
    650649        InternalReset(); 
    651650 
    652         FixTimeBase(); 
    653  
    654651        _seekTime = absoluteTimestamp; 
    655652 
     
    863860                        || (_pChannelCommands == NULL)) 
    864861                return; 
    865         _deltaAudioTime = -1; 
    866         _deltaVideoTime = -1; 
    867         _pDeltaAudioTime = &_deltaAudioTime; 
    868         _pDeltaVideoTime = &_deltaVideoTime; 
     862        _start = -1; 
    869863        _seekTime = 0; 
    870864 
     
    894888        } 
    895889} 
    896  
    897 void BaseOutNetRTMPStream::FixTimeBase() { 
    898         //3. Fix the time base 
    899         if (_pInStream != NULL) { 
    900                 uint64_t attachedStreamType = _pInStream->GetType(); 
    901                 if ((TAG_KIND_OF(attachedStreamType, ST_IN_FILE_RTMP)) 
    902                                 || (TAG_KIND_OF(attachedStreamType, ST_IN_NET_RTMP)) 
    903                                 || (TAG_KIND_OF(attachedStreamType, ST_IN_NET_LIVEFLV)) 
    904                                 || (TAG_KIND_OF(attachedStreamType, ST_IN_NET_RTP)) 
    905                                 || (TAG_KIND_OF(attachedStreamType, ST_IN_NET_MP3)) 
    906                                 || (TAG_KIND_OF(attachedStreamType, ST_IN_NET_AAC)) 
    907                                 ) { 
    908                         //RTMP streams are having the same time base for audio and video 
    909                         _pDeltaAudioTime = &_deltaAudioTime; 
    910                         _pDeltaVideoTime = &_deltaAudioTime; 
    911                 } else { 
    912                         //otherwise consider them separate 
    913                         _pDeltaAudioTime = &_deltaAudioTime; 
    914                         _pDeltaVideoTime = &_deltaVideoTime; 
    915                 } 
    916         } else { 
    917                 _pDeltaAudioTime = &_deltaAudioTime; 
    918                 _pDeltaVideoTime = &_deltaVideoTime; 
    919         } 
    920 } 
    921890#endif /* HAS_PROTOCOL_RTMP */ 
    922891 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/infilertmpstream.cpp

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  *   
     4 * 
    55 *  This file is part of crtmpserver. 
    66 *  crtmpserver is free software: you can redistribute it and/or modify 
     
    88 *  the Free Software Foundation, either version 3 of the License, or 
    99 *  (at your option) any later version. 
    10  *   
     10 * 
    1111 *  crtmpserver is distributed in the hope that it will be useful, 
    1212 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 *  GNU General Public License for more details. 
    15  *   
     15 * 
    1616 *  You should have received a copy of the GNU General Public License 
    1717 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
     
    193193} 
    194194 
    195 bool InFileRTMPStream::Initialize(int32_t clientSideBufferLength) { 
     195bool InFileRTMPStream::Initialize(int32_t clientSideBufferLength, bool hasTimer) { 
    196196        //1. Base init 
    197         if (!BaseInFileStream::Initialize(clientSideBufferLength)) { 
     197        if (!BaseInFileStream::Initialize(clientSideBufferLength, hasTimer)) { 
    198198                FATAL("Unable to initialize stream"); 
    199199                return false; 
     
    249249 
    250250bool InFileRTMPStream::IsCompatibleWithType(uint64_t type) { 
    251         return TAG_KIND_OF(type, ST_OUT_NET_RTMP); 
     251        return TAG_KIND_OF(type, ST_OUT_NET_RTMP) 
     252                        || TAG_KIND_OF(type, ST_OUT_FILE_HLS); 
    252253} 
    253254 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/innetrtmpstream.cpp

    r718 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    6868                        || TAG_KIND_OF(type, ST_OUT_FILE_RTMP) 
    6969                        || TAG_KIND_OF(type, ST_OUT_NET_RTP) 
     70                        || TAG_KIND_OF(type, ST_OUT_NET_TS) 
    7071                        || TAG_KIND_OF(type, ST_OUT_FILE_HLS); 
     72 
    7173} 
    7274 
     
    227229 
    228230void InNetRTMPStream::SignalOutStreamDetached(BaseOutStream *pOutStream) { 
    229         FINEST("outbound stream %u detached from inbound stream %u", 
    230                         pOutStream->GetUniqueId(), GetUniqueId()); 
     231        //FINEST("outbound stream %u detached from inbound stream %u", 
     232        //              pOutStream->GetUniqueId(), GetUniqueId()); 
    231233} 
    232234 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/outfilertmpflvstream.cpp

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/outnetrtmp4rtmpstream.cpp

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/outnetrtmp4tsstream.cpp

    r729 r734  
    4444} 
    4545 
    46 void OutNetRTMP4TSStream::SignalAttachedToInStream() { 
    47         if (_pInStream == NULL) 
    48                 return; 
    49         if (_inboundStreamIsRTP && GetCapabilities() != NULL) { 
    50                 _videoCodecSent = (GetCapabilities()->videoCodecId != CODEC_VIDEO_AVC); 
    51         } 
    52         BaseOutNetRTMPStream::SignalAttachedToInStream(); 
    53 } 
    54  
    5546bool OutNetRTMP4TSStream::IsCompatibleWithType(uint64_t type) { 
    56         _inboundStreamIsRTP = TAG_KIND_OF(type, ST_IN_NET_RTP); 
     47        _inboundStreamIsRTP = TAG_KIND_OF(type, ST_IN_NET_RTP) || TAG_KIND_OF(type, ST_IN_NET_EXT); 
    5748        _videoCodecSent = (type == ST_IN_NET_AAC); 
    5849        return TAG_KIND_OF(type, ST_IN_NET_TS) 
    5950                        || TAG_KIND_OF(type, ST_IN_NET_RTP) 
    60                         || TAG_KIND_OF(type, ST_IN_NET_AAC); 
     51                        || TAG_KIND_OF(type, ST_IN_NET_AAC) 
     52                        || TAG_KIND_OF(type, ST_IN_NET_EXT); 
    6153} 
    6254 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/rtmpstream.cpp

    r721 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
    4  *   
     4 * 
    55 *  This file is part of crtmpserver. 
    66 *  crtmpserver is free software: you can redistribute it and/or modify 
     
    88 *  the Free Software Foundation, either version 3 of the License, or 
    99 *  (at your option) any later version. 
    10  *   
     10 * 
    1111 *  crtmpserver is distributed in the hope that it will be useful, 
    1212 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 *  GNU General Public License for more details. 
    15  *   
     15 * 
    1616 *  You should have received a copy of the GNU General Public License 
    1717 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>. 
  • trunk/sources/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp

    r714 r734  
    16571657        result += format("o=- %"PRIu32" 0 IN IP4 %s\r\n", pFrom->GetId(), STR(nearAddress)); 
    16581658        result += "s=" + targetStreamName + "\r\n"; 
    1659         result += "u=http://www.evostream.com\r\n"; 
     1659        result += "u=www.evostream.com\r\n"; 
    16601660        result += "e=contact@evostream.com\r\n"; 
    16611661        result += "c=IN IP4 " + nearAddress + "\r\n"; 
  • trunk/sources/thelib/src/protocols/rtp/sdp.cpp

    r714 r734  
    503503 
    504504        vector<string> parts; 
     505        trim(line); 
    505506        split(line, " ", parts); 
    506507        if (parts.size() != 4) 
     
    536537 
    537538        if ((string) result["addressType"] != "IP4") { 
    538                 FATAL("Unsupported address type: %s", STR(result["addressType"])); 
    539                 return false; 
     539                if ((string) result["addressType"] != "IPV4") { 
     540                        FATAL("Unsupported address type: %s", STR(result["addressType"])); 
     541                        return false; 
     542                } else { 
     543                        WARN("Tolerate IPV4 value inside line %s", STR(result["addressType"])); 
     544                        result["addressType"] = "IP4"; 
     545                } 
    540546        } 
    541547 
  • trunk/sources/thelib/src/protocols/rtp/streaming/innetrtpstream.cpp

    r729 r734  
    8181        _rtcpDetectionStart = 0; 
    8282 
    83         _avCodecsSent=false; 
     83        _avCodecsSent = false; 
    8484} 
    8585 
     
    9393bool InNetRTPStream::IsCompatibleWithType(uint64_t type) { 
    9494        return (type == ST_OUT_NET_RTMP_4_TS) 
     95                        || (type == ST_OUT_NET_TS) 
    9596                        || (type == ST_OUT_FILE_HLS) 
     97                        || (type == ST_OUT_FILE_HDS) 
    9698                        || (type == ST_OUT_NET_RTP); 
    9799} 
     
    107109                                FeedVideoCodecSetup(pOutStream); 
    108110                                FeedAudioCodecSetup(pOutStream); 
    109                                 _avCodecsSent=true; 
     111                                _avCodecsSent = true; 
    110112                        } 
    111113                } 
     
    113115                if (_videoLastTs != 0) { 
    114116                        FeedVideoCodecSetup(pOutStream); 
    115                         _avCodecsSent=true; 
     117                        _avCodecsSent = true; 
    116118                } 
    117119                if (_audioLastTs != 0) { 
    118120                        FeedAudioCodecSetup(pOutStream); 
    119                         _avCodecsSent=true; 
     121                        _avCodecsSent = true; 
    120122                } 
    121123        } 
  • trunk/sources/thelib/src/protocols/ts/innettsstream.cpp

    r729 r734  
    3939        _dtsTimeAudio = 0; 
    4040#endif 
    41         _lastGotAudioTimestamp = 0; 
    4241        _lastSentAudioTimestamp = 0; 
    4342        _audioPacketsCount = 0; 
     
    5655        _dtsTimeVideo = 0; 
    5756#endif 
    58  
    59         _deltaTime = -1; 
    6057        _videoPacketsCount = 0; 
    6158        _videoBytesCount = 0; 
     
    135132        double &dtsTime = isAudio ? _dtsTimeAudio : _dtsTimeVideo; 
    136133#endif 
    137         double absoluteTime = 0; 
    138134        if (packetStart) { 
    139135                if (isAudio) { 
     
    231227                        } 
    232228 
    233                         if (_deltaTime < 0) 
    234                                 _deltaTime = ptsTime; 
    235  
    236                         absoluteTime = (ptsTime - _deltaTime); 
    237  
    238229                        pData += 9 + pesHeaderLength; 
    239230                        length -= (9 + pesHeaderLength); 
     
    330321                } 
    331322        } 
    332         double timestamp = _ptsTimeAudio - _deltaTime; 
    333         if (_ptsTimeAudio < 0 || _deltaTime < 0 || timestamp < 0) { 
     323        if ((_ptsTimeAudio < 0) 
     324                        || (GETAVAILABLEBYTESCOUNT(_audioBucket) < 2) 
     325                        || (GETIBPOINTER(_audioBucket)[0] != 0xff) 
     326                        || ((GETIBPOINTER(_audioBucket)[1] >> 4) != 0x0f) 
     327                        ) { 
    334328                _audioBucket.IgnoreAll(); 
    335329                return true; 
     
    345339                        GETAVAILABLEBYTESCOUNT(_audioBucket)); 
    346340 
    347         if (_lastGotAudioTimestamp != timestamp) { 
    348                 _audioPacketsCount = 0; 
    349         } 
    350         _lastGotAudioTimestamp = timestamp; 
     341        _audioPacketsCount = 0; 
    351342 
    352343        for (;;) { 
     
    381372                } 
    382373 
    383                 double ts = timestamp + (((double) _audioPacketsCount * 1024.00) / (double) _streamCapabilities.aac._sampleRate)*1000.0; 
     374                double ts = _ptsTimeAudio + (((double) _audioPacketsCount * 1024.00) / (double) _streamCapabilities.aac._sampleRate)*1000.0; 
    384375                _audioPacketsCount++; 
    385376                if (_lastSentAudioTimestamp >= ts) { 
     
    404395 
    405396bool InNetTSStream::HandleVideoData() { 
    406         double timestamp = _ptsTimeVideo - _deltaTime; 
    407         if (_ptsTimeVideo < 0 || _deltaTime < 0 || timestamp < 0) { 
     397        if (_ptsTimeVideo < 0 || GETAVAILABLEBYTESCOUNT(_videoBucket) == 0) { 
     398                _videoDroppedPacketsCount++; 
     399                _videoDroppedBytesCount += GETAVAILABLEBYTESCOUNT(_videoBucket); 
    408400                _videoBucket.IgnoreAll(); 
    409401                return true; 
    410402        } 
     403        _videoPacketsCount++; 
     404        _videoBytesCount += GETAVAILABLEBYTESCOUNT(_videoBucket); 
    411405 
    412406        uint32_t cursor = 0; 
     
    438432                found = false; 
    439433                if (pNalStart != NULL) { 
    440                         if (!ProcessNal(pNalStart, pNalEnd - pNalStart, timestamp)) { 
     434                        if (!ProcessNal(pNalStart, pNalEnd - pNalStart, _ptsTimeVideo)) { 
    441435                                FATAL("Unable to process NAL"); 
    442436                                return false; 
     
    447441        if (pNalStart != NULL) { 
    448442                int32_t lastLength = length - (pNalStart - pBuffer); 
    449                 if (!ProcessNal(pNalStart, lastLength, timestamp)) { 
     443                if (!ProcessNal(pNalStart, lastLength, _ptsTimeVideo)) { 
    450444                        FATAL("Unable to process NAL"); 
    451445                        return false; 
  • trunk/sources/thelib/src/streaming/baseinfilestream.cpp

    r617 r734  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    9999} 
    100100 
     101bool BaseInFileStream::StreamCompleted() { 
     102        if (_currentFrameIndex >= _totalFrames) 
     103                return true; 
     104        if ((_playLimit >= 0) && ((_playLimit < (double) _totalSentTime))) 
     105                return true; 
     106        return false; 
     107} 
     108 
    101109StreamCapabilities * BaseInFileStream::GetCapabilities() { 
    102110        return &_streamCapabilities; 
     
    168176} 
    169177 
    170 bool BaseInFileStream::Initialize(int32_t clientSideBufferLength) { 
     178bool BaseInFileStream::Initialize(int32_t clientSideBufferLength, bool hasTimer) { 
    171179        //1. Check to see if we have an universal seeking file 
    172180        string seekFilePath = GetName() + "."MEDIA_TYPE_SEEK; 
     
    251259 
    252260        //6. Create the timer 
    253         _pTimer = new InFileStreamTimer(this); 
    254         _pTimer->EnqueueForTimeEvent(_clientSideBufferLength - _clientSideBufferLength / 3); 
     261        if (hasTimer) { 
     262                _pTimer = new InFileStreamTimer(this); 
     263                _pTimer->EnqueueForTimeEvent(_clientSideBufferLength - _clientSideBufferLength / 3); 
     264        } 
    255265 
    256266        //7. Done 
  • trunk/sources/thelib/src/streaming/streamcapabilities.cpp

    r665 r734  
    328328} 
    329329 
    330 bool _VIDEO_AVC::Init(uint8_t *pSPS, uint32_t spsLength, uint8_t *pPPS, 
     330bool _VIDEO_AVC::Init(const uint8_t *pSPS, uint32_t spsLength, const uint8_t *pPPS, 
    331331                uint32_t ppsLength) { 
    332332        Clear(); 
     
    386386                } 
    387387        } 
    388          
     388 
    389389        if (!ReadPPS(ppsBa, _PPSInfo)) { 
    390390                WARN("Unable to read PPS info"); 
     
    484484} 
    485485 
    486 bool _AUDIO_AAC::Init(uint8_t *pBuffer, uint32_t length) { 
     486bool _AUDIO_AAC::Init(const uint8_t *pBuffer, uint32_t length) { 
    487487        Clear(); 
    488488        //http://wiki.multimedia.cx/index.php?title=MP4A#Audio_Specific_Config 
     
    618618} 
    619619 
    620 bool StreamCapabilities::InitAudioAAC(uint8_t *pBuffer, uint32_t length) { 
     620bool StreamCapabilities::InitAudioAAC(const uint8_t *pBuffer, uint32_t length) { 
    621621        ClearAudio(); 
    622622        if (!aac.Init(pBuffer, length)) { 
     
    640640} 
    641641 
    642 bool StreamCapabilities::InitVideoH264(uint8_t *pSPS, uint32_t spsLength, 
    643                 uint8_t *pPPS, uint32_t ppsLength) { 
     642bool StreamCapabilities::InitVideoH264(const uint8_t *pSPS, uint32_t spsLength, 
     643                const uint8_t *pPPS, uint32_t ppsLength) { 
    644644        ClearVideo(); 
    645645        if (!avc.Init(pSPS, spsLength, pPPS, ppsLength)) { 
Note: See TracChangeset for help on using the changeset viewer.