├── AVSDK ├── avutil │ ├── src │ │ ├── rsa.cpp │ │ ├── socket_win32.cpp │ │ ├── sps.cpp │ │ ├── i420writer.cpp │ │ ├── i420reader.cpp │ │ ├── fecrq │ │ │ ├── fecrepo_reader.cpp │ │ │ ├── fecrq.h │ │ │ ├── fecrqa.cpp │ │ │ └── fecrqtest.cpp │ │ ├── mstringlist.cpp │ │ ├── buffer.cpp │ │ ├── clock.cpp │ │ └── LogFile.cpp │ └── include │ │ ├── config.h │ │ ├── sps.h │ │ ├── fecrq │ │ ├── fecrepo.h │ │ └── fecxor.h │ │ ├── rc4.h │ │ ├── i420writer.h │ │ ├── rsa.h │ │ ├── i420reader.h │ │ ├── LogFile.h │ │ ├── mstringlist.h │ │ ├── dllloader.h │ │ ├── wavreader.h │ │ ├── waveoperator.h │ │ ├── file.h │ │ ├── thread.h │ │ ├── datetime.h │ │ ├── clock.h │ │ ├── BaseSocket.h │ │ ├── fmem.h │ │ ├── buffer.h │ │ ├── error.h │ │ ├── common.h │ │ ├── mstring.h │ │ ├── http.h │ │ ├── protocol.h │ │ ├── codec.h │ │ └── logging.h ├── avmixer │ ├── audiomixer.cpp │ ├── generalaudiomixer.h │ ├── picturemixer.hpp │ ├── audiomixer.h │ └── generalaudiomixer.cpp ├── MediaIO │ └── hpsp │ │ ├── public_api.h │ │ └── jitter_if.h └── src │ └── Adapter │ ├── audiopacketbuffer.h │ └── audiopacket.h ├── src ├── Ini.h ├── Ini.cpp ├── Log.cpp ├── Channel.h ├── MutexObj.h ├── MutexObj.cpp ├── cppcmn.h ├── cppcmn.cpp ├── TcpChannel.h ├── clockex.cpp ├── avmmixercomm.h ├── clockex.h ├── topodef.h ├── BufSerialize.h ├── netendian.h ├── fmtbuffer.h ├── avmBizsChannel.h ├── fbuffer.h ├── stmassembler.h ├── fecrepo_reader.cpp ├── bits.h ├── accumu.h ├── avmGridChannel.h ├── BaseTypeDef.h ├── sync.h ├── fec.h ├── userproto.h ├── fecrepo_hdr.h ├── Log.h ├── misc.h ├── fqueue.h ├── misc.cpp ├── mqthread.h └── fast_fec.h ├── readme ├── proto ├── run_make_cfile.sh └── AVMixer2BizsMessage.proto ├── bin └── codecmixer.conf ├── lib └── copylibfrommidiacodec.sh ├── .gitignore └── include ├── rapidjson ├── internal │ ├── strfunc.h │ └── ieee754.h ├── memorystream.h ├── memorybuffer.h ├── filereadstream.h ├── filewritestream.h └── stringbuffer.h ├── videofilter.h └── google └── protobuf ├── generated_enum_util.h ├── stubs ├── atomic_sequence_num.h ├── singleton.h ├── atomicops_internals_pnacl.h └── platform_macros.h ├── source_context.proto ├── util ├── type_resolver_util.h └── type_resolver.h ├── compiler ├── ruby │ └── ruby_generator.h ├── csharp │ └── csharp_generator.h ├── objectivec │ └── objectivec_generator.h ├── java │ ├── java_generator.h │ └── java_names.h ├── cpp │ └── cpp_generator.h ├── javanano │ └── javanano_generator.h └── plugin.h ├── io └── strtod.h ├── empty.proto └── generated_message_util.h /AVSDK/avutil/src/rsa.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "../include/common.h" -------------------------------------------------------------------------------- /src/Ini.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhwanglj/CodecMixer/HEAD/src/Ini.h -------------------------------------------------------------------------------- /src/Ini.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhwanglj/CodecMixer/HEAD/src/Ini.cpp -------------------------------------------------------------------------------- /src/Log.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhwanglj/CodecMixer/HEAD/src/Log.cpp -------------------------------------------------------------------------------- /AVSDK/avutil/src/socket_win32.cpp: -------------------------------------------------------------------------------- 1 | 2 | #ifdef WIN32 3 | 4 | 5 | 6 | 7 | #endif -------------------------------------------------------------------------------- /src/Channel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhwanglj/CodecMixer/HEAD/src/Channel.h -------------------------------------------------------------------------------- /src/MutexObj.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhwanglj/CodecMixer/HEAD/src/MutexObj.h -------------------------------------------------------------------------------- /src/MutexObj.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhwanglj/CodecMixer/HEAD/src/MutexObj.cpp -------------------------------------------------------------------------------- /AVSDK/avutil/src/sps.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhwanglj/CodecMixer/HEAD/AVSDK/avutil/src/sps.cpp -------------------------------------------------------------------------------- /readme: -------------------------------------------------------------------------------- 1 | first make MediaCodec project 2 | copy libmediacommon.so file to LD_LIBRARY_PATH directory:wqa 3 | -------------------------------------------------------------------------------- /src/cppcmn.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_CPPCMN_H 2 | #define _CPPCMN_CPPCMN_H 3 | 4 | namespace cppcmn { 5 | void InitializeCppcmn(); 6 | } 7 | 8 | #endif -------------------------------------------------------------------------------- /src/cppcmn.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | namespace cppcmn { 4 | void InitializeMQThread(); 5 | void InitializeCppcmn() { 6 | InitializeMQThread(); 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /proto/run_make_cfile.sh: -------------------------------------------------------------------------------- 1 | 2 | protoc --cpp_out=./ AVMixer2BizsMessage.proto 3 | mv AVMixer2BizsMessage.pb.h AVMixer2BizsMessage.h 4 | mv AVMixer2BizsMessage.pb.cc AVMixer2BizsMessage.cpp 5 | -------------------------------------------------------------------------------- /bin/codecmixer.conf: -------------------------------------------------------------------------------- 1 | [confsvr] 2 | ip=114.55.232.127 3 | port=3000 4 | [local] 5 | name=CCNHZALI001 6 | type=avcodec 7 | logdir=/home/wlj1/codec/mediacloud/prototypes/codecmix/CodecMixer/bin/log/ 8 | loglevel=15 9 | maxroom=20 10 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/config.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_COMMONCONFIG_H 3 | #define _MEDIACLOUD_COMMONCONFIG_H 4 | 5 | #ifdef WIN32 6 | 7 | #include 8 | #include 9 | #else 10 | 11 | #define nullptr NULL 12 | #endif 13 | 14 | #endif -------------------------------------------------------------------------------- /AVSDK/avutil/include/sps.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPS_H_ 2 | #define __SPS_H_ 3 | 4 | namespace MediaCloud 5 | { 6 | namespace Common 7 | { 8 | bool h264_decode_seq_parameter_set(unsigned char * buf, unsigned int nLen, unsigned int &Width, unsigned int &Height); 9 | 10 | } 11 | } 12 | #endif -------------------------------------------------------------------------------- /lib/copylibfrommidiacodec.sh: -------------------------------------------------------------------------------- 1 | cp /home/wlj1/codec/MediaCodec/staticlib/libmediacommon.a ./ 2 | cp /home/wlj1/codec/MediaCodec/build/linux/obj/libavcodec.a ./ 3 | cp /home/wlj1/codec/MediaCodec/build/linux/obj/libavutil.a ./ 4 | cp /home/wlj1/codec/MediaCodec/build/linux/obj/libfdkAAC.a ./ 5 | cp /home/wlj1/codec/MediaCodec/build/linux/obj/libx264.a ./ 6 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/fecrq/fecrepo.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_FECREPO_H 3 | #define _MEDIACLOUD_FECREPO_H 4 | 5 | #include 6 | 7 | struct fecParam { 8 | int K, T, KP, S, H, W, L, P, P1, U, B, J; 9 | }; 10 | 11 | struct fecRepoInfo { 12 | fecParam param; 13 | uint8_t *matrix; 14 | uint32_t matrixSize; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | *.a 32 | tags 33 | cscope.* 34 | *.yuv 35 | *.wav 36 | *.h264 37 | *_bk 38 | .* 39 | *.log 40 | core 41 | codecmixer 42 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/rc4.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_RC4_H 3 | #define _MEDIACLOUD_RC4_H 4 | 5 | #include 6 | 7 | namespace MediaCloud 8 | { 9 | namespace Common 10 | { 11 | class RC4 12 | { 13 | public: 14 | ~RC4() {} 15 | 16 | static RC4* Create(const uint8_t cipher[], int length); 17 | 18 | void Process(const uint8_t *indata, uint8_t *outdata, int length); 19 | void SetXY(uint8_t x, uint8_t y); 20 | 21 | private: 22 | RC4() {} 23 | 24 | uint8_t _data[256]; 25 | uint8_t _x, _y; 26 | }; 27 | } 28 | } 29 | 30 | #endif -------------------------------------------------------------------------------- /AVSDK/avutil/include/i420writer.h: -------------------------------------------------------------------------------- 1 | // 2 | // i420writer.h 3 | // mediacommon 4 | // 5 | // Created by xingyanjun on 15/1/14. 6 | // Copyright (c) 2015年 xingyanjun. All rights reserved. 7 | // 8 | 9 | #ifndef __mediacommon__i420writer__ 10 | #define __mediacommon__i420writer__ 11 | 12 | #include 13 | 14 | 15 | class I420Writer 16 | { 17 | public: 18 | I420Writer(); 19 | ~I420Writer(); 20 | 21 | void Open(const char * fileName); 22 | void Close(); 23 | 24 | int Write(const char* buf, int bufsize); 25 | 26 | private: 27 | FILE *_file; 28 | 29 | }; 30 | 31 | 32 | 33 | #endif /* defined(__mediacommon__i420writer__) */ 34 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/rsa.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_RSA_H 3 | #define _MEDIACLOUD_RSA_H 4 | 5 | namespace MediaCloud 6 | { 7 | namespace Common 8 | { 9 | class RSAHelper 10 | { 11 | public: 12 | static RSAHelper* GetSingleton(); 13 | 14 | virtual unsigned int GetLengthOfN() const = 0; 15 | virtual unsigned int GetLengthOfE() const = 0; 16 | virtual int GetN(void *buffer, unsigned int length) const = 0; 17 | virtual int GetE(void *buffer, unsigned int length) const = 0; 18 | virtual int Decrypt(void *indata, unsigned int inLength, void *outData, unsigned int outLength) = 0; 19 | 20 | protected: 21 | virtual ~RSAHelper(); 22 | }; 23 | } 24 | } 25 | 26 | 27 | #endif -------------------------------------------------------------------------------- /AVSDK/avutil/include/i420reader.h: -------------------------------------------------------------------------------- 1 | // 2 | // i420reader.h 3 | // mediacommon 4 | // 5 | // Created by xingyanjun on 15/1/14. 6 | // Copyright (c) 2015年 xingyanjun. All rights reserved. 7 | // 8 | 9 | #ifndef __mediacommon__i420reader__ 10 | #define __mediacommon__i420reader__ 11 | 12 | #include 13 | #include 14 | 15 | 16 | 17 | class I420Reader 18 | { 19 | public: 20 | I420Reader(); 21 | virtual ~I420Reader(); 22 | 23 | void Open(const char* filename, int width, int height); 24 | int Read(uint8_t* buf, int bufLen); 25 | void Close(); 26 | void reset(); 27 | 28 | private: 29 | int _width; 30 | int _height; 31 | int _bufferSize; 32 | 33 | FILE *_file; 34 | }; 35 | 36 | 37 | 38 | #endif /* defined(__mediacommon__i420reader__) */ 39 | -------------------------------------------------------------------------------- /AVSDK/avmixer/audiomixer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // audiomixer.h 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 14/12/4. 6 | // Copyright (c) 2014年 smyk. All rights reserved. 7 | // 8 | 9 | 10 | #include "audiomixer.h" 11 | #include "generalaudiomixer.h" 12 | using namespace MediaCloud::Public; 13 | using namespace MediaCloud::Adapter; 14 | 15 | AudioMixer* AudioMixer::CreateAudioMixer(const AudioStreamFormat& fmt, int numStreams) 16 | { 17 | #if !defined(ANDROID) 18 | #if 0 19 | IosHardAudioMixer* mixer = new IosHardAudioMixer(fmt, numStreams); 20 | #else 21 | GeneralAudioMixer* mixer = new GeneralAudioMixer(fmt, numStreams); 22 | #endif 23 | #else 24 | GeneralAudioMixer* mixer = new GeneralAudioMixer(fmt, numStreams); 25 | #endif 26 | return (AudioMixer*)mixer; 27 | } 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/i420writer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // i420writer.cpp 3 | // mediacommon 4 | // 5 | // Created by xingyanjun on 15/1/14. 6 | // Copyright (c) 2015年 xingyanjun. All rights reserved. 7 | // 8 | 9 | #include "i420writer.h" 10 | 11 | I420Writer::I420Writer() 12 | { 13 | _file = NULL; 14 | } 15 | 16 | I420Writer::~I420Writer() 17 | { 18 | Close(); 19 | } 20 | 21 | 22 | void I420Writer::Open(const char * fileName) 23 | { 24 | if (fileName == NULL) { 25 | return ; 26 | } 27 | 28 | _file = fopen(fileName, "wb"); 29 | 30 | } 31 | 32 | void I420Writer::Close() 33 | { 34 | if (_file) { 35 | fclose(_file); 36 | _file = NULL; 37 | } 38 | } 39 | 40 | 41 | int I420Writer::Write(const char* buf, int bufsize) 42 | { 43 | return (int)fwrite(buf, 1, bufsize, _file); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /proto/AVMixer2BizsMessage.proto: -------------------------------------------------------------------------------- 1 | message CCNState 2 | { 3 | required uint32 uiCur=1; 4 | required uint32 uiMax=2; 5 | } 6 | 7 | message CCNLogin{ 8 | required string ccname =1; 9 | } 10 | 11 | message CCNUser 12 | { 13 | optional string uid=1; 14 | optional uint32 identity=2; 15 | } 16 | 17 | message CCNNotify 18 | { 19 | required bytes sessionid=1; 20 | optional string config=2; 21 | repeated CCNUser user=3; 22 | required uint32 timeout=4; 23 | } 24 | 25 | message CCMigrationSessions 26 | { 27 | repeated bytes session=1; 28 | } 29 | 30 | message CCSessionReleaseNotify 31 | { 32 | required bytes sessionid=1; 33 | } 34 | 35 | message CCNMessage 36 | { 37 | optional CCNState state=1; 38 | optional CCNNotify notify=2; 39 | optional CCMigrationSessions migrate_sessions=3; 40 | optional CCSessionReleaseNotify session_release_notify=4; 41 | optional CCNLogin login=5; 42 | } 43 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/fecrq/fecxor.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_FECXOR_H 3 | #define _MEDIACLOUD_FECXOR_H 4 | 5 | #include 6 | #include 7 | 8 | namespace MediaCloud 9 | { 10 | namespace Common 11 | { 12 | class FECXOR 13 | { 14 | public: 15 | 16 | /// xor the input symbols with differ length, and returning the result heading with 16bit xored length 17 | static uint16_t Encoding(const std::pair sourceSymbols[], 18 | int symbolNum, 19 | uint8_t repairedSymbol[]); 20 | 21 | static uint16_t Decoding(const std::pair sourceSymbols[], 22 | int symbolNum, 23 | const std::pair repairedSymbol, 24 | uint8_t recoveredSymbol[]); 25 | }; 26 | } 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/LogFile.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOGFILE_H_ 2 | #define _LOGFILE_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | class CLogFile 14 | { 15 | public: 16 | CLogFile(); 17 | CLogFile(string label); 18 | virtual ~CLogFile(); 19 | 20 | static string GetFileName(); 21 | static string GetFilePath(); 22 | void SetLabel(string label); 23 | bool WriteLog(string logText, bool crlf = false); 24 | bool WriteLog(char * buffer, unsigned int len, bool crlf = false); 25 | 26 | private: 27 | string m_FileName; 28 | FILE * m_file; 29 | string m_label; 30 | pthread_mutex_t m_mutex_log; 31 | }; 32 | 33 | extern CLogFile g_log_info; 34 | extern CLogFile g_log_Warn; 35 | extern CLogFile g_log_error; 36 | extern CLogFile g_log_msg; 37 | extern CLogFile g_log_rev; 38 | extern CLogFile g_log_print; 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif -------------------------------------------------------------------------------- /AVSDK/avutil/include/mstringlist.h: -------------------------------------------------------------------------------- 1 | #ifndef MSTRINGLIST_H 2 | #define MSTRINGLIST_H 3 | 4 | #include 5 | #include "mstring.h" 6 | 7 | using namespace std; 8 | 9 | class MStringList : public list 10 | { 11 | public: 12 | explicit MStringList(); 13 | ~MStringList(); 14 | 15 | bool isEmpty() const; 16 | int length(); 17 | 18 | MString &operator[](int i); 19 | const MString& operator[](int i) const; 20 | 21 | MStringList &operator<<(const MString &str); 22 | MStringList &operator<<(const MStringList &other); 23 | MStringList &operator=(const MStringList &other); 24 | 25 | MString &at(int pos); 26 | const MString& at(int pos) const; 27 | 28 | MString join(const MString &sep); 29 | 30 | MStringList mid(int start, int length); 31 | 32 | public: 33 | friend ostream & operator<<(ostream &o, const MStringList& a); 34 | }; 35 | 36 | typedef MStringList::iterator MStringListItor; 37 | typedef MStringList::const_iterator MStringListConstItor; 38 | 39 | #endif // MSTRINGLIST_H -------------------------------------------------------------------------------- /src/TcpChannel.h: -------------------------------------------------------------------------------- 1 | #ifndef __TCPCHANNEL_H__ 2 | #define __TCPCHANNEL_H__ 3 | 4 | #include "Channel.h" 5 | 6 | class CTCPChannel : public CChannel 7 | { 8 | public: 9 | CTCPChannel(); 10 | CTCPChannel(int aiSocket); 11 | 12 | virtual bool CreateChannel(const char* acpszLocalIP, unsigned short ausLocalPort, bool abThreadSafe=false); 13 | virtual void DestoryChannel(); 14 | 15 | int Connect(const char* acpszRemoteIP, unsigned short ausRemotePort); 16 | int Listen(int iBackLog); 17 | int Accept(char* apszPeerIP, unsigned short* apusPeerPort); 18 | 19 | virtual int SendPacket(const char* acpszPacket, int aiPacketLent); 20 | //return value -2:timeout -1:error 0<:send data length 21 | virtual int SendPacketEx(const char* acpszPacket, int aiPacketLen, int iWaitMillisecond); 22 | 23 | virtual int RecvPacket(char* apPacket, int aiPacketLen); 24 | //return value -2:timeout -1:error 0:peer shutdown 0<:send data length 25 | virtual int RecvPacketEx(char* apPacket, int aiPacketLen, int iWaitMillisecond); 26 | 27 | }; 28 | 29 | 30 | #endif // __TCPCHANNEL_H__ 31 | -------------------------------------------------------------------------------- /AVSDK/avmixer/generalaudiomixer.h: -------------------------------------------------------------------------------- 1 | // 2 | // generalaudiomixer.h 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 14/12/4. 6 | // Copyright (c) 2014年 smyk. All rights reserved. 7 | // 8 | 9 | #ifndef __mediacloud__generalaudiomixer__ 10 | #define __mediacloud__generalaudiomixer__ 11 | 12 | #include 13 | #include "audiomixer.h" 14 | 15 | namespace MediaCloud 16 | { 17 | namespace Adapter 18 | { 19 | class GeneralAudioMixer:public AudioMixer 20 | { 21 | public: 22 | GeneralAudioMixer(const AudioStreamFormat& fmt, int numStreams); 23 | ~GeneralAudioMixer(); 24 | bool MixData(void* output, int packetNum, int packetLen, double sampleTime, AudioDataInfo* samples, int numStream); 25 | void Reset(); 26 | int EnableStream(unsigned int idx, bool enable, float volume); 27 | 28 | private: 29 | int _numStreams; 30 | AudioStreamFormat _streamFormat; 31 | AudioDataInfo* _sampleData; 32 | }; 33 | } 34 | } 35 | #endif /* defined(__mediacloud__generalaudiomixer__) */ 36 | -------------------------------------------------------------------------------- /src/clockex.cpp: -------------------------------------------------------------------------------- 1 | #include "clockex.h" 2 | #include 3 | #include 4 | 5 | namespace cppcmn { 6 | 7 | #ifdef __MACH__ 8 | #include 9 | #define ORWL_NANO (+1.0E-9) 10 | #define ORWL_GIGA UINT64_C(1000000000) 11 | 12 | static double orwl_timebase = 0.0; 13 | static uint64_t orwl_timestart = 0; 14 | 15 | Tick NowEx() { 16 | // be more careful in a multithreaded environement 17 | if (!orwl_timestart) { 18 | mach_timebase_info_data_t tb = { 0 }; 19 | mach_timebase_info(&tb); 20 | orwl_timebase = tb.numer; 21 | orwl_timebase /= tb.denom; 22 | orwl_timestart = mach_absolute_time(); 23 | } 24 | double diff = (mach_absolute_time() - orwl_timestart) * orwl_timebase; 25 | return Tick(diff / 1000); 26 | } 27 | #else 28 | Tick NowEx() { 29 | struct timespec ts; 30 | if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) != 0) { 31 | return 0; 32 | } 33 | return (int64_t)ts.tv_sec * 1000000 + (int64_t)ts.tv_nsec / 1000; 34 | } 35 | #endif 36 | } 37 | 38 | -------------------------------------------------------------------------------- /AVSDK/avmixer/picturemixer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // picturemixer.hpp 3 | // MediaConvert 4 | // 5 | // Created by xingyanjun on 16/6/21. 6 | // Copyright © 2016年 xingyanjun. All rights reserved. 7 | // 8 | 9 | #ifndef picturemixer_hpp 10 | #define picturemixer_hpp 11 | 12 | #include 13 | enum MediaLibraryWaterMarkOrig 14 | { 15 | kMediaLibraryOrigLeftTop, 16 | kMediaLibraryOrigLeftBottom, 17 | kMediaLibraryOrigRightTop, 18 | kMediaLibraryOrigRightBottom 19 | }; 20 | 21 | struct MergeOtherFrameInfo 22 | { 23 | int nOffsetX; 24 | int nOffsetY; 25 | int nImgW; 26 | int nImgH; 27 | unsigned char* pData[4];//y,u,v,a 28 | MediaLibraryWaterMarkOrig OrigType; 29 | }; 30 | 31 | 32 | struct MergeMainFrameInfo 33 | { 34 | int nFormat; 35 | void *pData; // 36 | unsigned int nLength; //length 37 | int nFrameWidth; 38 | int nFrameHeight; 39 | }; 40 | 41 | class CPictureMixer{ 42 | public: 43 | CPictureMixer(); 44 | ~CPictureMixer(); 45 | public: 46 | static void MergeFrame(MergeMainFrameInfo& frameInfo, MergeOtherFrameInfo* otherInfos, int otherCount); 47 | }; 48 | 49 | #endif /* picturemixer_hpp */ 50 | -------------------------------------------------------------------------------- /src/avmmixercomm.h: -------------------------------------------------------------------------------- 1 | #ifndef __AVM_MIXERCOMMON_H__ 2 | #define __AVM_MIXERCOMMON_H__ 3 | 4 | 5 | #define AVM_MAX_URL_LENGTH 1024 6 | #define AVM_MAX_NETPEER_SIZE 1 7 | 8 | 9 | namespace MediaCloud 10 | { 11 | typedef enum e_PeerRoleType 12 | { 13 | E_AVM_PEERROLE_UNKNOW, 14 | E_AVM_PEERROLE_LEADING, 15 | E_AVM_PEERROLE_MINOR, 16 | E_AVM_PEERROLE_OTHER, 17 | }E_PEERROLETYPE; 18 | 19 | typedef enum e_PicMixType 20 | { 21 | E_AVM_PICMIX_UNKNOW, 22 | E_AVM_PICMIX_RIGHT, 23 | E_AVM_PICMIX_BOTTOM, 24 | }E_PICMIXTYPE; 25 | 26 | typedef struct t_PicMixConf 27 | { 28 | E_PICMIXTYPE eType; 29 | int iEdgeSpace; 30 | t_PicMixConf() 31 | { 32 | eType=E_AVM_PICMIX_UNKNOW; 33 | iEdgeSpace=0; 34 | } 35 | t_PicMixConf& operator=(const t_PicMixConf& rhs) 36 | { 37 | if(this == &rhs) 38 | *this; 39 | eType = rhs.eType; 40 | iEdgeSpace = rhs.iEdgeSpace; 41 | return *this; 42 | } 43 | }T_PICMIXCONF, *PT_PICMIXCONF; 44 | 45 | } 46 | 47 | #endif /* __AVM_MIXERCOMMON_H__ */ 48 | -------------------------------------------------------------------------------- /src/clockex.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_CLOCK_H 2 | #define _CPPCMN_CLOCK_H 3 | 4 | #include 5 | 6 | namespace cppcmn { 7 | 8 | // the microseconds starting from bootup 9 | // it is always > 0; < 0 - means invalid tick 10 | typedef int64_t Tick; 11 | 12 | Tick NowEx(); 13 | 14 | inline Tick InfiniteTick() { 15 | return -1LL; 16 | } 17 | 18 | inline bool IsInfiniteTick(Tick tick) { 19 | return tick < 0; 20 | } 21 | 22 | inline Tick TickFromMilliseconds(int64_t ms) { 23 | return ms * 1000; 24 | } 25 | 26 | inline int64_t TickToMilliseconds(Tick tick) { 27 | return tick / 1000; 28 | } 29 | 30 | inline Tick TickFromSeconds(int64_t s) { 31 | return TickFromMilliseconds(s * 1000); 32 | } 33 | 34 | inline int64_t TickToSeconds(Tick t) { 35 | return t / 1000000; 36 | } 37 | 38 | inline Tick TickAfterMilliseconds(int64_t ms) { 39 | return NowEx() + TickFromMilliseconds(ms); 40 | } 41 | 42 | inline Tick TickMultiply(Tick tick, double factor) { 43 | return (Tick)((double)tick * factor); 44 | } 45 | 46 | inline int64_t TickDeltaInMilliseconds(Tick now, Tick earlier) { 47 | return TickToMilliseconds(now - earlier); 48 | } 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/dllloader.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEDIACLOUD_DLLLOADER_H 2 | #define _MEDIACLOUD_DLLLOADER_H 3 | 4 | #ifndef WIN32 5 | #include 6 | #include 7 | #include "logging.h" 8 | 9 | namespace MediaCloud 10 | { 11 | namespace Common 12 | { 13 | __inline void* LoadLibrary(char* fileName) 14 | { 15 | void* h = (void*)dlopen( fileName, RTLD_LAZY ); 16 | if (h != NULL) 17 | return h; 18 | 19 | LogError("Uitls","LoadLibrary %s err, errno %d", fileName, errno); 20 | return NULL; 21 | } 22 | 23 | __inline bool FreeLibrary(void* module) 24 | { 25 | bool ret = dlclose(module) == 0; 26 | if (ret) 27 | return true; 28 | 29 | return false; 30 | } 31 | 32 | __inline void* GetProcAddress(void* module, char* procName) 33 | { 34 | void* procAddr = (void*)dlsym(module, procName); 35 | if (procAddr != NULL) 36 | return procAddr; 37 | 38 | return NULL; 39 | } 40 | 41 | } 42 | } 43 | #endif 44 | 45 | #endif//_DLLLOADER_H 46 | -------------------------------------------------------------------------------- /src/topodef.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_TOPODEF_H 2 | #define _CPPCMN_TOPODEF_H 3 | 4 | #include 5 | #include "../socket.h" 6 | 7 | namespace cppcmn { 8 | 9 | // the max name length for router or clients 10 | #define MAX_GRID_NAME_LEN 11 11 | #define MAX_GRID_NAME_LEN_NULLABLE (MAX_GRID_NAME_LEN + 1) 12 | #define MAX_RSP_NUM_PER_ROUTER 10 13 | #define MAX_CSP_NUM_PER_ROUTER 10 14 | #define MAX_NEIGHBOR_NUM_PER_ROUTER 10 15 | // the max number of csps for client to connect 16 | #define MAX_CSP_NUM_FOR_CLIENT 10 17 | // the max biz address number for mnode to connect 18 | #define MAX_BIZ_NUM_FOR_MNODE 5 19 | // how many mep ports a mnode can have 20 | #define MAX_MEP_NUM_PER_MNODE 10 21 | // how many clients are allowed to connect on a router at same time 22 | #define MAX_CLIENT_NUM_PER_ROUTER 20 23 | #define MAX_STREAM_DATA_LEN 2048 24 | 25 | // UTF-8 26 | #define MAX_UID_LENGTH 128 27 | 28 | typedef uint32_t GridNameIndex; 29 | 30 | struct GridName { 31 | char name[MAX_GRID_NAME_LEN_NULLABLE]; 32 | int namelen; 33 | GridNameIndex index; 34 | }; 35 | 36 | /* struct SinkPoint { 37 | SocketAddr sinkAddr; 38 | SocketAddr bindAddr; 39 | uint64_t isp; 40 | }; 41 | */ 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /AVSDK/avmixer/audiomixer.h: -------------------------------------------------------------------------------- 1 | // 2 | // audiomixer.h 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 14/12/4. 6 | // Copyright (c) 2014年 smyk. All rights reserved. 7 | // 8 | 9 | #ifndef mediacloud_Header_h 10 | #define mediacloud_Header_h 11 | 12 | #include 13 | using namespace MediaCloud::Public; 14 | 15 | namespace MediaCloud 16 | { 17 | namespace Adapter 18 | { 19 | class AudioMixer 20 | { 21 | public: 22 | struct AudioDataInfo 23 | { 24 | int _bufferSize; 25 | uint8_t *_leftData; 26 | int _leftLength; 27 | bool _enabled; 28 | }; 29 | static AudioMixer* CreateAudioMixer(const AudioStreamFormat& fmt, int numStreams); 30 | AudioMixer() {} 31 | virtual ~AudioMixer() {} 32 | virtual bool MixData(void* output, int packetNum, int packetLen, double sampleTime, AudioDataInfo* samples, int numStream) = 0; 33 | virtual void Reset() = 0; 34 | virtual int EnableStream(unsigned int idx, bool enable, float volume) = 0; 35 | private: 36 | AudioMixer(const AudioMixer&); 37 | AudioMixer& operator == (AudioMixer &); 38 | }; 39 | } 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /AVSDK/MediaIO/hpsp/public_api.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_PUBLIC_API_H 3 | #define _MEDIACLOUD_PUBLIC_API_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace MComp { 10 | 11 | /// Media cloud use 32bit to identify a user and media room in the scope of developer GUID 12 | typedef uint32_t Identity; 13 | #define InvalidIdentity (0) 14 | 15 | class PublicAPI { 16 | public: 17 | class IDelegate { 18 | public: 19 | virtual ~IDelegate() {} 20 | 21 | // for reader 22 | enum { // the value must be consistent with HPSPReaderMsgType 23 | SESSION_JOINING = 1, 24 | SESSION_JOINED, 25 | PEER_ALIVE, // evtParam - peer identity 26 | PEER_LEFT, 27 | STREAM_END, 28 | }; 29 | virtual void OnSessionEvent(int evtType, int64_t evtParam) = 0; 30 | virtual void OnSessionStream(void *sessionFrameInfo) = 0; 31 | 32 | // for writer 33 | virtual bool OnSessionStreamBitrateAdjust(bool increase, uint32_t targetBitrate) = 0; 34 | }; 35 | 36 | enum { 37 | SUBSCRIBE_LIVE_VIDEO = 1, // identity > 0 - subscribe live video; identity == 0 - unsubscribe 38 | UPLOAD_CONTROL, // allow video or audio upload, allowed by default; param - high 16bit for video; low 16bit for audio 39 | }; 40 | }; 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /AVSDK/avutil/include/wavreader.h: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------------------------------ 2 | * Copyright (C) 2009 Martin Storsjo 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 | * express or implied. 14 | * See the License for the specific language governing permissions 15 | * and limitations under the License. 16 | * ------------------------------------------------------------------- 17 | */ 18 | 19 | #ifndef WAVREADER_H 20 | #define WAVREADER_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | void* wav_read_open(const char *filename); 28 | void wav_read_close(void* obj); 29 | 30 | int wav_get_header(void* obj, int* format, int* channels, int* sample_rate, int* bits_per_sample, unsigned int* data_length); 31 | int wav_read_data(void* obj, unsigned char* data, unsigned int length); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/i420reader.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // i420reader.cpp 3 | // mediacommon 4 | // 5 | // Created by xingyanjun on 15/1/14. 6 | // Copyright (c) 2015年 xingyanjun. All rights reserved. 7 | 8 | 9 | #include "i420reader.h" 10 | #include 11 | #include 12 | 13 | I420Reader::I420Reader() 14 | { 15 | _width = 0; 16 | _height = 0; 17 | _bufferSize = 0; 18 | 19 | _file = NULL; 20 | } 21 | 22 | I420Reader::~I420Reader() 23 | { 24 | Close(); 25 | } 26 | 27 | void I420Reader::Open(const char* filename, int width, int height) 28 | { 29 | Close(); 30 | 31 | _width = width; 32 | _height = height; 33 | _bufferSize = width * height * 3 / 2; 34 | _file = fopen(filename, "rb"); 35 | } 36 | 37 | int I420Reader::Read(uint8_t* buf, int bufLen) 38 | { 39 | if (bufLen < _bufferSize) { 40 | return -1; 41 | } 42 | 43 | if (_file) 44 | { 45 | return (int)fread(buf, 1, _bufferSize, _file); 46 | } 47 | else 48 | { 49 | return 0; 50 | } 51 | 52 | } 53 | 54 | void I420Reader::Close() 55 | { 56 | _width = 0; 57 | _height = 0; 58 | _bufferSize = 0; 59 | 60 | 61 | if (_file) 62 | { 63 | fclose(_file); 64 | _file = NULL; 65 | } 66 | } 67 | 68 | void I420Reader::reset() 69 | { 70 | if (_file) 71 | { 72 | fseek(_file, 0, SEEK_SET); 73 | } 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/BufSerialize.h: -------------------------------------------------------------------------------- 1 | //BasePacket.h 2 | // 3 | #ifndef __BUFFER_SERIALIZE__ 4 | #define __BUFFER_SERIALIZE__ 5 | 6 | 7 | #include "BaseTypeDef.h" 8 | 9 | 10 | 11 | class CBufSerialize 12 | { 13 | public: 14 | CBufSerialize(void); 15 | virtual ~CBufSerialize(void); 16 | 17 | public: 18 | static char* WriteUInt8(char* pBuf, uint8_t usData); 19 | static char* ReadUInt8(char* pBuf, uint8_t& usData); 20 | 21 | static char* WriteUInt16(char* pBuf, uint16_t uisData); 22 | static char* ReadUInt16(char* pBuf, uint16_t& uisData); 23 | 24 | static char* WriteUInt16_Net(char* pBuf, uint16_t uisData); 25 | static char* ReadUInt16_Net(char* pBuf, uint16_t& uisData); 26 | 27 | static char* WriteUInt32_Net(char* pBuf, uint32_t uilData); 28 | static char* ReadUInt32_Net(char* pBuf, uint32_t& uilData); 29 | 30 | static char* WriteUInt32(char* pBuf, uint32_t uilData); 31 | static char* ReadUInt32(char* pBuf, uint32_t& uilData); 32 | 33 | static char* WriteUInt64(char* pBuf, uint64_t uillData); 34 | static char* ReadUInt64(char* pBuf, uint64_t& uillData); 35 | 36 | static char* WriteBuf(char* pBuf, const char* cpSrc, uint32_t uilSrcLen); 37 | static char* ReadBuf(char* pBuf, char* pDes, uint32_t uilDesLen); 38 | 39 | static char* WriteString(char* pBuf, const char* cpsz); 40 | static char* ReadString(char* pBuf, char* psz, int& iszLen); 41 | 42 | }; 43 | 44 | #endif //__BUFFER_SERIALIZE__ 45 | 46 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/waveoperator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _WAVE_H 4 | #define _WAVE_H 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #pragma pack(1) 11 | typedef struct _WaveFormat 12 | { 13 | unsigned short nFormatag; 14 | unsigned short nChannels; 15 | unsigned int nSamplerate; 16 | unsigned int nAvgBytesRate; 17 | unsigned short nblockalign; 18 | unsigned short nBitsPerSample; 19 | } WaveFormat; 20 | #pragma pack() 21 | 22 | 23 | class CWaveWriter 24 | { 25 | public: 26 | 27 | CWaveWriter(WaveFormat wf); 28 | ~CWaveWriter(); 29 | bool Open(const char* pFileName); 30 | void Close(); 31 | int WriteData(unsigned char* pData, int nLen); 32 | bool IsOpened(); 33 | private: 34 | int WriteHeader(); 35 | int WriteTail(); 36 | private: 37 | 38 | FILE* m_pFile; 39 | int m_nFileLen; 40 | int m_nOffSetFileLen; 41 | int m_nDataLen; 42 | int m_nOffSetDataLen; 43 | WaveFormat m_wf; 44 | }; 45 | 46 | class CWaveReader 47 | { 48 | public: 49 | CWaveReader(); 50 | ~CWaveReader(); 51 | bool Open(const char* pFileName); 52 | void Close(); 53 | int ReadData(unsigned char* pData, int nLen); 54 | bool GetFormat(WaveFormat* pWaveFormat); 55 | FILE* Handle(); 56 | private: 57 | bool ReadHeader(); 58 | private: 59 | FILE* m_pFile; 60 | int m_nDataLen; 61 | WaveFormat m_WaveFormat; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/file.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_FILE_H 3 | #define _MEDIACLOUD_FILE_H 4 | 5 | #include 6 | #include 7 | 8 | namespace MediaCloud 9 | { 10 | namespace Common 11 | { 12 | class SimpleFile 13 | { 14 | public: 15 | static SimpleFile* OpenForWrite(const char *filename); 16 | static SimpleFile* OpenForRead(const char *filename); 17 | static void Close(SimpleFile *file); 18 | void Flush(); 19 | 20 | unsigned int GetSize() const; 21 | unsigned int GetOffset() const; 22 | int SetOffset(unsigned int offset); 23 | 24 | int Write(void *buffer, int length); 25 | int Read(void *buffer, int length); 26 | 27 | static int Rename(const char *srcFilename, const char *dstFilename); 28 | static int Delete(const char *filename); 29 | 30 | struct Stat 31 | { 32 | unsigned int size; 33 | unsigned long long createTime; 34 | unsigned long long lastModifiedTime; 35 | }; 36 | static Stat GetStat(const char *filename); 37 | 38 | static int EnumFilesInFolder(const char *foldername, void(*filecb)(const char *filename)); 39 | static const char* GetFilename(const char *path); 40 | static const char* GetExtensionName(const char *path); 41 | 42 | private: 43 | FILE *_file; 44 | }; 45 | } 46 | } 47 | 48 | #endif // WEBRTC_BASE_MD5_H_ 49 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/thread.h: -------------------------------------------------------------------------------- 1 | // 2 | // thread.h 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 14/12/14. 6 | // Copyright (c) 2014年 smyk. All rights reserved. 7 | // 8 | 9 | #ifndef mediacloud_thread_h 10 | #define mediacloud_thread_h 11 | 12 | #include 13 | #include 14 | 15 | namespace MediaCloud 16 | { 17 | namespace Common 18 | { 19 | typedef bool(*ThreadRunFunction)(void*); 20 | 21 | enum ThreadPrior 22 | { 23 | lowPrio = 1, 24 | normalPrio = 2, 25 | highPrio = 3, 26 | highestPrio = 4, 27 | realtimePrio = 5 28 | }; 29 | 30 | class GeneralThread 31 | { 32 | public: 33 | enum {threadMaxNameLen = 64}; 34 | 35 | virtual ~GeneralThread(){}; 36 | 37 | static GeneralThread* Create(ThreadRunFunction func, void* obj, bool selfdelete = false, ThreadPrior prio = normalPrio, const char* thread_name = 0); 38 | static int Release(GeneralThread* mediathr); 39 | 40 | virtual bool Start() = 0; 41 | virtual bool Stop() = 0; 42 | }; 43 | 44 | unsigned long GetThreadId(); 45 | 46 | /// sleep current thread for a while. 47 | /// ms - zero : give up the current CPU slide. 48 | void ThreadSleep(unsigned int ms); 49 | 50 | void SetThreadName(char* name); 51 | void GetThreadName(char* name, int bufsize); 52 | } 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /src/netendian.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_ENDIAN_H 2 | #define _CPPCMN_ENDIAN_H 3 | 4 | #include 5 | 6 | namespace cppcmn { 7 | 8 | //NET BE to LE MODE 9 | inline uint16_t byte_to_u16(const uint8_t *ptr) { 10 | return (ptr[0] << 8) | ptr[1]; 11 | } 12 | 13 | inline uint32_t byte_to_u24(const uint8_t *ptr) { 14 | return ptr[0] << 16 | ptr[1] << 8 | ptr[2]; 15 | } 16 | 17 | inline uint32_t byte_to_u32(const uint8_t *ptr) { 18 | return ptr[0] << 24 | ptr[1] << 16 | ptr[2] << 8 | ptr[3]; 19 | } 20 | 21 | inline uint64_t byte_to_u64(const uint8_t *ptr) { 22 | return ((uint64_t)byte_to_u32(ptr)) << 32 | byte_to_u32(ptr + 4); 23 | } 24 | 25 | //LE MODE to NET BE 26 | inline void u16_to_byte(uint16_t x, uint8_t *ptr) { 27 | ptr[0] = (uint8_t)((x >> 8) & 0xff); 28 | ptr[1] = (uint8_t)(x & 0xff); 29 | } 30 | 31 | inline void u24_to_byte(uint32_t x, uint8_t *ptr) { 32 | ptr[0] = (uint8_t)((x >> 16) & 0xff); 33 | ptr[1] = (uint8_t)((x >> 8) & 0xff); 34 | ptr[2] = (uint8_t)(x & 0xff); 35 | } 36 | 37 | inline void u32_to_byte(uint32_t x, uint8_t *ptr) { 38 | ptr[0] = (uint8_t)(x >> 24); 39 | ptr[1] = (uint8_t)((x >> 16) & 0xff); 40 | ptr[2] = (uint8_t)((x >> 8) & 0xff); 41 | ptr[3] = (uint8_t)(x & 0xff); 42 | } 43 | 44 | inline void u64_to_byte(uint64_t x, uint8_t *ptr) { 45 | u32_to_byte((uint32_t)(x >> 32), ptr); 46 | u32_to_byte((uint32_t)(x & 0xffffffff), ptr + 4); 47 | } 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Custom strlen() which works on different character types. 24 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 25 | \param s Null-terminated input string. 26 | \return Number of characters in the string. 27 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 28 | */ 29 | template 30 | inline SizeType StrLen(const Ch* s) { 31 | const Ch* p = s; 32 | while (*p) ++p; 33 | return SizeType(p - s); 34 | } 35 | 36 | } // namespace internal 37 | RAPIDJSON_NAMESPACE_END 38 | 39 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 40 | -------------------------------------------------------------------------------- /src/fmtbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_FMTBUFFER_H 2 | #define _CPPCMN_FMTBUFFER_H 3 | 4 | #include "memory.h" 5 | #include "flist.h" 6 | #include "fbuffer.h" 7 | #include "fchain.h" 8 | #include "sync.h" 9 | #include "misc.h" 10 | 11 | namespace cppcmn { 12 | 13 | /* 14 | * Ref count a buffer, and 15 | * quick allocation from one thread, and freed from other threads. 16 | */ 17 | class MTFixedSizeAllocator { 18 | public: 19 | /* 20 | size - returned size for each alloc call 21 | reservedCount - the allocator reserves reservedCount slots when no free buffer 22 | */ 23 | explicit MTFixedSizeAllocator(int size, int reservedCount, int alignment); 24 | ~MTFixedSizeAllocator(); 25 | 26 | int AlignedSize() const { return _allocator.AlignedSize(); } 27 | 28 | /* 29 | The allocated slot lifetime is maintained by a refcount 30 | The refcount is 1 after Alloc returned 31 | The slot will be freed to cache if DecRef leads to refcount 0 32 | AddRef/DecRef can be called by multiple threads 33 | */ 34 | void* Alloc(); 35 | void AddRef(void *slot); 36 | bool DecRef(void *slot); 37 | int RefCnt(void *slot); 38 | 39 | static void Validate(void *slot); 40 | 41 | /* 42 | Forcely recycle the freed buffer to allocator cache 43 | */ 44 | void Recycle(); 45 | void RecycleAll(); 46 | 47 | private: 48 | DISALLOW_COPY_AND_ASSIGN(MTFixedSizeAllocator); 49 | 50 | FixedSizeAllocator _allocator; 51 | FixedSizeAllocator _recycleAllocator; 52 | typedef Chain<100, void*> RecycleChain; 53 | RecycleChain _recycleChain; 54 | Mutex _recycleLock; 55 | }; 56 | } 57 | 58 | #endif -------------------------------------------------------------------------------- /AVSDK/MediaIO/hpsp/jitter_if.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_JITTER_IF_H 3 | #define _MEDIACLOUD_JITTER_IF_H 4 | 5 | #include 6 | #include 7 | #include "public_api.h" 8 | #include 9 | using namespace MediaCloud::Common; 10 | 11 | namespace MComp { 12 | 13 | /* DON'T change the enum values */ 14 | enum { 15 | SESSION_STREAM_AUDIO = 0, 16 | SESSION_STREAM_THUMBNAIL_VIDEO = 1, 17 | SESSION_STREAM_LIVE_VIDEO = 2, 18 | SESSION_STREAM_MAX = 3, 19 | SESSION_STREAM_ALL = 3 20 | }; 21 | 22 | enum { 23 | VIDEO_I_FRAME, 24 | VIDEO_P_FRAME, 25 | VIDEO_B_FRAME, 26 | VIDEO_LP_FRAME, 27 | }; 28 | 29 | struct FrameIDs { 30 | uint16_t idOfLiveVideo; 31 | uint16_t idOfThumbnailVideo; 32 | uint16_t idOfAudio; 33 | }; 34 | 35 | // for uploading 36 | struct JitterFrameInfo { 37 | enum { 38 | // FLAG_GOP_END = 1, // remove this, because it is never known for dynamic gop 39 | FLAG_GOP_BEGIN = 2, 40 | FLAG_SWITCH_SOURCE = 4 // set for the first I frame after switching camera 41 | }; 42 | 43 | int flag; 44 | int streamType; // audio, thumbnail or live video 45 | int frameType; // I/P/B frame 46 | BUF_ARG_REF uint8_t *payload; 47 | uint32_t payloadSize; 48 | 49 | Clock::Tick ts; 50 | void *fecGen; 51 | }; 52 | 53 | // for receiving 54 | struct SessionFrameInfo { 55 | Identity identity; 56 | int streamType; 57 | int frameType; 58 | uint16_t frameId; 59 | BUF_ARG_MOVE const uint8_t *payload; 60 | uint32_t payloadSize; 61 | }; 62 | } 63 | 64 | #endif -------------------------------------------------------------------------------- /include/videofilter.h: -------------------------------------------------------------------------------- 1 | // 2 | // videofilter.h 3 | // mediacommon 4 | // 5 | // Created by xingyanjun on 15/2/13. 6 | // Copyright (c) 2015年 xingyanjun. All rights reserved. 7 | // 8 | 9 | #ifndef mediacommon_videofilter_h 10 | #define mediacommon_videofilter_h 11 | 12 | #include "mediacommon.h" 13 | 14 | struct Image 15 | { 16 | int format; 17 | int width; 18 | int height; 19 | int stride[4]; 20 | unsigned char* plane[4]; 21 | }; 22 | 23 | struct ImageConvertContext 24 | { 25 | Image imageSrc; 26 | Image imageDst; 27 | }; 28 | 29 | // Supported rotation. 30 | enum ImageRotateRotationMode { 31 | kImageRotate0 = 0, // No rotation. 32 | kImageRotate90 = 90, // Rotate 90 degrees clockwise. 33 | kImageRotate180 = 180, // Rotate 180 degrees. 34 | kImageRotate270 = 270, // Rotate 270 degrees clockwise. 35 | }; 36 | 37 | struct ImageRotateContext 38 | { 39 | Image imageSrc; 40 | Image imageDst; 41 | ImageRotateRotationMode mode; 42 | }; 43 | 44 | class CVideoFilter 45 | { 46 | public: 47 | virtual ~CVideoFilter(){}; 48 | virtual bool Init(void* pParam) = 0; 49 | virtual int Control(int nType, void* Param1, void* Param2) = 0; 50 | virtual int Process(void * pIn) = 0; 51 | virtual void DeInit() = 0; 52 | 53 | virtual int FilterID() = 0; 54 | }; 55 | 56 | CVideoFilter* CreateVideoFilter(int nFilterId); 57 | int ReleaseVideoFilter(CVideoFilter * pFilter); 58 | #endif 59 | -------------------------------------------------------------------------------- /src/avmBizsChannel.h: -------------------------------------------------------------------------------- 1 | #ifndef __AVM_BIZCHANNEL_H__ 2 | #define __AVM_BIZCHANNEL_H__ 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "../AVSDK/src/Adapter/audiopacketbuffer.h" 14 | #include "avmmixercomm.h" 15 | #include "TcpChannel.h" 16 | #include "commonstruct.h" 17 | 18 | 19 | namespace MediaCloud 20 | { 21 | class CAVMGridChannel; 22 | 23 | class CAVMBizsChannel 24 | { 25 | public: 26 | CAVMBizsChannel(); 27 | ~CAVMBizsChannel(); 28 | 29 | bool CreateAndConnect(char* szIP, unsigned short usPort); 30 | void DestoryChannel(); 31 | 32 | void* BizsWorkThreadImp(void* param); 33 | 34 | bool Start(); 35 | void Stop(); 36 | 37 | bool SendReleaseSessionNotify(uint8_t* bSessionID); 38 | 39 | void SetGridChannel(CAVMGridChannel* pGrid); 40 | private: 41 | void ProcessJoinSessionMsg(char* pPack, uint16_t usPackLen); 42 | void ReleaseUserJoinMsg(PT_USERJOINMSG pUserJoinMsg); 43 | bool SendKeepalive(); 44 | bool SendLogin(); 45 | 46 | void TestCode_InsertAUser(); 47 | 48 | private: 49 | string m_strBizSvrIP; 50 | unsigned short m_usBizSvrPort; 51 | 52 | CTCPChannel m_tcpChannel; 53 | pthread_t m_idWorkThread; 54 | bool m_bStopFlag; 55 | CAVMGridChannel* m_pAVMGridChannel; 56 | }; 57 | 58 | } 59 | 60 | 61 | #endif /* __AVM_PEER_H__ */ 62 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/datetime.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_DATETIME_H 3 | #define _MEDIACLOUD_DATETIME_H 4 | 5 | #include 6 | 7 | namespace MediaCloud 8 | { 9 | namespace Common 10 | { 11 | struct DateTime 12 | { 13 | /// return local UTC time. 14 | static uint32_t UTCSeconds(); 15 | static uint64_t UTCMilliseconds(); 16 | static uint64_t UTCMicroseconds(); 17 | 18 | /// get tickcount offset since Platform Initialized in milliseconds. 19 | /// it will meet max value about 50 days later, but it is okay for phone 20 | static uint32_t TickCount(); 21 | 22 | /// should we provide a 64bit tick count ? so that the tick count will never be wrapped 23 | static uint64_t LargeTickCount(); 24 | 25 | static __inline uint32_t TickDistance(uint32_t later, uint32_t prev) 26 | { 27 | return later - prev; 28 | } 29 | 30 | static __inline bool IsNewerTickCount(uint32_t newer, uint32_t prev) 31 | { 32 | return newer != prev && (newer - prev) < 0x80000000; 33 | } 34 | 35 | static __inline bool IsEarlierTickCount(uint32_t earlier, uint32_t newer) 36 | { 37 | return earlier != newer && (newer - earlier) < 0x80000000; 38 | } 39 | 40 | static __inline unsigned int LatestTickCount(uint32_t tick1, uint32_t tick2) 41 | { 42 | return IsNewerTickCount(tick1, tick2) ? tick1 : tick2; 43 | } 44 | }; 45 | } 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /AVSDK/avutil/src/fecrq/fecrepo_reader.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "fecrqm.h" 4 | #include "../../include/fecrq/fecrepo.h" 5 | #include "../../include/common.h" 6 | 7 | using namespace MediaCloud::Common; 8 | 9 | extern fecRepoInfo fecrepoinfo_2[]; 10 | // loading the A matrix directly from pre-calculated 11 | uint8_t *LoadFECRQCoreMatrix(uint8_t symbolSize, 12 | uint16_t srcNum, uint16_t overload, FECRQParam::Param *param, bool onlyParam) 13 | { 14 | AssertMsg(symbolSize >= 2, "invalid symbol size"); 15 | AssertMsg(srcNum >= 8 && srcNum <= 200, "invalid src number"); 16 | 17 | fecRepoInfo &repoInfo = fecrepoinfo_2[srcNum - 8]; 18 | if (param != nullptr) { 19 | param->K = repoInfo.param.K; 20 | param->T = symbolSize; // only T is different 21 | param->KP = repoInfo.param.KP; 22 | param->S = repoInfo.param.S; 23 | param->H = repoInfo.param.H; 24 | param->W = repoInfo.param.W; 25 | param->L = repoInfo.param.L; 26 | param->P = repoInfo.param.P; 27 | param->P1 = repoInfo.param.P1; 28 | param->U = repoInfo.param.U; 29 | param->B = repoInfo.param.B; 30 | param->J = repoInfo.param.J; 31 | Assert(param->K == srcNum); // K is the src num 32 | Assert(param->L == repoInfo.matrixSize); // L is the A matrix size 33 | } 34 | 35 | if (onlyParam) { 36 | return nullptr; 37 | } 38 | 39 | int size = repoInfo.matrixSize; 40 | uint8_t *matrix = new uint8_t[(size + overload) * size]; 41 | memcpy(matrix, repoInfo.matrix, size * size); 42 | if (overload > 0) { 43 | memset(matrix + size * size, 0, overload * size); 44 | } 45 | return matrix; 46 | } 47 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/clock.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_CLOCK_H 3 | #define _MEDIACLOUD_CLOCK_H 4 | 5 | #include 6 | 7 | namespace MediaCloud { 8 | namespace Common { 9 | 10 | /// Used to replace the system tick (which only get better supported on windows) 11 | struct Clock { 12 | 13 | /// A monotonic microseconds time from system start 14 | /// Or it is used for delta between ticks in microseconds 15 | typedef int64_t Tick; 16 | static Tick Now(); 17 | 18 | /// represent an invalid tick value 19 | __inline static Tick InfiniteTick() { 20 | return -1LL; 21 | } 22 | 23 | /// used to represent an immediate tick delta 24 | __inline static Tick ZeroTick() { 25 | return 0; 26 | } 27 | 28 | __inline static bool IsZero(Tick tick) { 29 | return tick == 0; 30 | } 31 | 32 | __inline static bool IsInfinite(Tick tick) { 33 | return tick < 0; 34 | } 35 | 36 | __inline static Tick FromMilliseconds(int64_t ms) { 37 | return ms * 1000; 38 | } 39 | 40 | __inline static int64_t ToMilliseconds(Tick tick) { 41 | return tick / 1000; 42 | } 43 | 44 | __inline static Clock::Tick AfterMilliseconds(int64_t ms) { 45 | return Clock::Now() + Clock::FromMilliseconds(ms); 46 | } 47 | 48 | __inline static Tick Multiply(Tick tick, double factor) { 49 | return (Tick)((double)tick * factor); 50 | } 51 | 52 | __inline static Tick DeltaInMilliseconds(Tick now, Tick earlier) { 53 | return ToMilliseconds(now - earlier); 54 | } 55 | }; 56 | }} 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/fbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_FBUFFER_H 2 | #define _CPPCMN_FBUFFER_H 3 | 4 | #include "flist.h" 5 | #include "misc.h" 6 | 7 | namespace cppcmn { 8 | 9 | /* 10 | * Define an interface to catch N allocators for different slot sizes. 11 | * The key and size should be agreed by caller and providers 12 | */ 13 | class FixedSizeAllocator; 14 | class IFixedSizeAllocatorFarm { 15 | public: 16 | virtual FixedSizeAllocator* GetAllocator(int key, int size) = 0; 17 | }; 18 | 19 | class IFixedSizeAllocatorFarmFactory { 20 | public: 21 | virtual IFixedSizeAllocatorFarm* GetFarm(int key) = 0; 22 | }; 23 | 24 | /* 25 | * A buffer allocator to allocate fixed size buffer very quickly without lock 26 | */ 27 | class FixedSizeAllocator { 28 | public: 29 | explicit FixedSizeAllocator(int size, int reservedCount, int alignment); 30 | ~FixedSizeAllocator(); 31 | 32 | void* Alloc(); 33 | void Free(void *slot); 34 | 35 | inline int RawSize() const { return _rawSize; } 36 | inline int AlignedSize() const { return _alignedSize; } 37 | inline int BufferCount() const { return _bufferCnt; } 38 | inline int FreeCount() const { return _freeCnt; } 39 | inline int BusyCount() const { return _busyCnt; } 40 | 41 | static void Validate(void *slot); 42 | 43 | private: 44 | DISALLOW_COPY_AND_ASSIGN(FixedSizeAllocator); 45 | 46 | int _rawSize; 47 | int _alignedSize; 48 | int _reservedCnt; 49 | int _alignment; 50 | int _bufferCnt; 51 | int _freeCnt; 52 | int _busyCnt; 53 | ListHead _bufferHdr; 54 | ListHead _freeHdr; 55 | ListHead _busyHdr; 56 | }; 57 | } 58 | 59 | #endif -------------------------------------------------------------------------------- /src/stmassembler.h: -------------------------------------------------------------------------------- 1 | #ifndef _HPSP_STMASSEMBLER_H 2 | #define _HPSP_STMASSEMBLER_H 3 | 4 | #include 5 | #include "clockex.h" 6 | 7 | namespace hpsp { 8 | 9 | /* 10 | * StmAssembler handles the stream packet from rgrid, and assembly the frame segments into frames 11 | * StmAssembler should be instanced for each session id 12 | * It doesn't support concurrent calling for now 13 | */ 14 | class StmAssembler { 15 | public: 16 | struct Frame { 17 | uint32_t identity; 18 | uint16_t fid; 19 | // 0 - audio stream, 2 - video stream 20 | int stmtype; 21 | // 0 - I frame, 1 - P frame, 2 - B frame 22 | int frmtype; 23 | int length; 24 | const uint8_t *payload; 25 | }; 26 | 27 | struct IDelegate { 28 | virtual ~IDelegate() {} 29 | 30 | // the caller can save the pointer frame.payload, 31 | // but it must be released by ReleaseFramePayload 32 | // 33 | // NOTICE: 34 | // the calling thread may deadlock if deleting StmAssembler in the callback of HandleRGridFrameRecved !! 35 | virtual void HandleRGridFrameRecved(const Frame &frame) = 0; 36 | }; 37 | 38 | StmAssembler(IDelegate *delegate); 39 | virtual ~StmAssembler(); 40 | 41 | /* 42 | * The data is the body part of the grid stream packet 43 | */ 44 | void HandleRGridStream(const uint8_t *data, int length, cppcmn::Tick tick); 45 | 46 | static void ReleaseFramePayload(const void *payload); 47 | 48 | private: 49 | int _assemblerId; 50 | IDelegate *_delegate; 51 | }; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/BaseSocket.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseSocket.h 3 | // Socket 4 | // 5 | // Created by 姜元福 on 16/6/6. 6 | // Copyright © 2016年 姜元福. All rights reserved. 7 | // 8 | 9 | #ifndef BaseSocket_h 10 | #define BaseSocket_h 11 | #include 12 | 13 | namespace MediaCloud{ 14 | namespace Common{ 15 | typedef enum _SOCKETType{ 16 | SocketClient = 0, 17 | SocketServer, 18 | }SocketType; 19 | 20 | typedef enum _SOCKETProtocol{ 21 | SocketTCP = 0, 22 | SocketUDP, 23 | }SOCKETProtocol; 24 | 25 | typedef struct _Socket_in{ 26 | struct sockaddr_in addr; 27 | char sin_zero[12]; 28 | }Socket_in; 29 | 30 | typedef struct _Socket_in6{ 31 | struct sockaddr_in6 addr; 32 | }Socket_in6; 33 | 34 | typedef struct _SocketAddr{ 35 | __uint8_t s_family; 36 | union{ 37 | Socket_in socket_in; 38 | Socket_in6 socket_in6; 39 | }sin_addr; 40 | }SocketAddr; 41 | 42 | typedef struct _IPAddr{ 43 | char * ip; 44 | unsigned int len; 45 | }IPAddr; 46 | 47 | bool Getaddrinfo(const char * host, unsigned int port, SocketType socketType, SOCKETProtocol protocol, struct addrinfo *& server_addr); 48 | int CreateBaseSocket(const char * host, unsigned int port, SocketType socketType, SOCKETProtocol protocol, IPAddr ip, struct sockaddr * sockAddr); 49 | int CloseBaseSocket(int sock); 50 | 51 | bool GetBaseSocketAddress(const struct sockaddr * address, char * addr, unsigned int * port); 52 | int BaseSocketAcceptTCPConnection(int server_sock); 53 | int BaseSocketHandleTCPClient(int clntSocket); 54 | } 55 | } 56 | 57 | #endif /* BaseSocket_h */ 58 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/fmem.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_FMEM_H 3 | #define _MEDIACLOUD_FMEM_H 4 | 5 | #include 6 | 7 | #include "fcirclequeue.h" 8 | #include "flist.h" 9 | 10 | namespace MediaCloud { namespace Common { 11 | 12 | /* 13 | * Provide fast mem allocation/free in one thread access 14 | * but it doesn't support allocation of random size 15 | */ 16 | class FastThreadBuffer { 17 | public: 18 | // new or get the instance per thread 19 | // it must be destoried when the thread quit 20 | static FastThreadBuffer* GetCurrent(); 21 | static void FreeCurrent(); 22 | 23 | /* 24 | * Before allocating memory, the allocation size must be registered first 25 | * with the capability 26 | */ 27 | int RegisterCache(int itemSize, int capability); 28 | /* 29 | * All allocated from this cache must be freed firstly 30 | */ 31 | void UnregisterCache(int cacheIdx); 32 | 33 | void* AllocFromCache(int cacheIdx); 34 | void FreeToCache(int cacheIdx, void *buffer); 35 | 36 | private: 37 | FastThreadBuffer(); 38 | ~FastThreadBuffer(); 39 | 40 | struct ItemHdr { 41 | ItemHdr *prev; 42 | ItemHdr *next; 43 | }; 44 | 45 | struct Cache { 46 | int itemSize; 47 | int capability; 48 | FastList bufferList; 49 | ItemHdr freeHdr; 50 | ItemHdr busyHdr; 51 | uint32_t freeCnt; 52 | uint32_t busyCnt; 53 | 54 | Cache(int bufferSize) : bufferList(bufferSize) {} 55 | }; 56 | 57 | FastCircleQueue _caches; 58 | 59 | void AllocateBufferInCache(Cache *cache); 60 | void DestoryCache(Cache *cache); 61 | Cache *GetCacheByIdx(int cacheIdx, bool setNull); 62 | }; 63 | }} 64 | 65 | #endif -------------------------------------------------------------------------------- /src/fecrepo_reader.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "fecrepo_hdr.h" 4 | 5 | using namespace FecRepo; 6 | 7 | extern MatrixInfo _matrix_A_repos[]; 8 | extern MatrixInfo _matrix_X_repos[]; 9 | extern EncodeCInfo _encode_C_repos[]; 10 | extern EncodeVecOpInfo _encode_Vector_Ops_repos[]; 11 | extern TupleInfo _tuples_repo[]; 12 | extern ParamInfo _param_repo[]; 13 | 14 | const Param* RepoReader::GetParam(int K) 15 | { 16 | assert(K >= MinK && K <= MaxK); 17 | return &_param_repo[K - MinK].param; 18 | } 19 | 20 | const Tuple* RepoReader::GetTuple(const Param *param, int isi, 21 | const uint8_t* <Idxes, uint8_t &numOfIdx) 22 | { 23 | assert(param->K >= MinK && param->K <= MaxK); 24 | const TupleInfo &tupleInfo = _tuples_repo[_param_repo[param->K - MinK].idxOfTuples]; 25 | if (isi < tupleInfo.tupleNum) { 26 | ltIdxes = tupleInfo.tupleIdxData + tupleInfo.tupleIdxes[isi].idxOffset; 27 | numOfIdx = tupleInfo.tupleIdxes[isi].numOfIdxes; 28 | return tupleInfo.tuples + isi; 29 | } 30 | ltIdxes = nullptr; 31 | numOfIdx = 0; 32 | return nullptr; 33 | } 34 | 35 | const MatrixInfo* RepoReader::GetMatrixA(const Param *param) 36 | { 37 | assert(param->K >= MinK && param->K <= MaxK); 38 | return &_matrix_A_repos[_param_repo[param->K - MinK].idxOfMatrixA]; 39 | } 40 | 41 | const MatrixInfo* RepoReader::GetMatrixX(const Param *param) 42 | { 43 | assert(param->K >= MinK && param->K <= MaxK); 44 | return &_matrix_X_repos[_param_repo[param->K - MinK].idxOfMatrixX]; 45 | } 46 | 47 | const EncodeCInfo* RepoReader::GetEncodeC(const Param *param) 48 | { 49 | assert(param->K >= MinK && param->K <= MaxK); 50 | return &_encode_C_repos[_param_repo[param->K - MinK].idxOfEncodeC]; 51 | } 52 | 53 | const EncodeVecOpInfo* RepoReader::GetEncodeVecOps(const Param *param) 54 | { 55 | assert(param->K >= MinK && param->K <= MaxK); 56 | return &_encode_Vector_Ops_repos[_param_repo[param->K - MinK].idxOfEncodeOps]; 57 | } 58 | -------------------------------------------------------------------------------- /src/bits.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_BITS_H 2 | #define _CPPCMN_BITS_H 3 | 4 | #include 5 | #include "logging.h" 6 | 7 | using namespace MediaCloud::Common; 8 | 9 | namespace cppcmn { 10 | 11 | struct BitAlgorithum { 12 | static inline bool IsSet(const uint8_t *buf, int index) { 13 | return (buf[index / 8] & (1 << (index % 8))) != 0; 14 | } 15 | 16 | static inline void Set(uint8_t *buf, int index) { 17 | buf[index / 8] |= 1 << (index % 8); 18 | } 19 | 20 | static inline void Clear(uint8_t *buf, int index) { 21 | buf[index / 8] &= ~(1 << (index % 8)); 22 | } 23 | 24 | static inline int NumOfBitOne(uint32_t nValue) { 25 | nValue = ((0xaaaaaaaa & nValue) >> 1) + (0x55555555 & nValue); 26 | nValue = ((0xcccccccc & nValue) >> 2) + (0x33333333 & nValue); 27 | nValue = ((0xf0f0f0f0 & nValue) >> 4) + (0x0f0f0f0f & nValue); 28 | nValue = ((0xff00ff00 & nValue) >> 8) + (0x00ff00ff & nValue); 29 | nValue = ((0xffff0000 & nValue) >> 16) + (0x0000ffff & nValue); 30 | Assert(nValue >= 0 && nValue <= 32); 31 | return nValue; 32 | } 33 | }; 34 | 35 | template 36 | class BitArray { 37 | public: 38 | // N is bit number count 39 | BitArray() { 40 | memset(_bits, 0, sizeof(_bits)); 41 | } 42 | 43 | inline bool IsSet(int bitIdx) const { 44 | Assert(bitIdx < N); 45 | return BitAlgorithum::IsSet(_bits, bitIdx); 46 | } 47 | 48 | inline void Set(int bitIdx, bool v) { 49 | Assert(bitIdx < N); 50 | if (v) { 51 | BitAlgorithum::Set(_bits, bitIdx); 52 | } 53 | else { 54 | BitAlgorithum::Clear(_bits, bitIdx); 55 | } 56 | } 57 | 58 | inline void Reset() { 59 | memset(_bits, 0, sizeof(_bits)); 60 | } 61 | 62 | private: 63 | uint8_t _bits[N / 8 + 1]; 64 | }; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/accumu.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_ACCUMU_H 2 | #define _CPPCMN_ACCUMU_H 3 | 4 | #include 5 | 6 | namespace cppcmn { 7 | 8 | // used to detect if all src symbols get received 9 | class IntAccumulator { 10 | /* 11 | NOTICE: 12 | the raw src number start from 0, 13 | it will cause AddRange missing the case with one symbol segment starting with esi 0 14 | So, we have to revise the src number starting from 1 15 | */ 16 | uint32_t _accumu; 17 | uint16_t _srcNum; 18 | uint32_t _sum; 19 | bool _met; 20 | 21 | // [1, _srcNum + 1) 22 | void GenAccumu() { 23 | if ((_srcNum % 2) == 0) { 24 | _accumu = (_srcNum + 1) * (_srcNum / 2); 25 | } 26 | else { 27 | _accumu = ((_srcNum + 1) / 2) * _srcNum; 28 | } 29 | } 30 | 31 | public: 32 | IntAccumulator(uint16_t srcNum) 33 | : _srcNum(srcNum) 34 | , _sum(0) 35 | , _met(0) { 36 | GenAccumu(); 37 | } 38 | 39 | inline bool IsMet() const { return _met; } 40 | inline uint16_t SrcNum() const { return _srcNum; } 41 | 42 | // the range must not overlap 43 | inline bool AddRange(uint16_t begin, uint16_t cnt) { 44 | if (_met) { 45 | return true; 46 | } 47 | 48 | if (begin >= _srcNum || cnt == 0) { 49 | return false; 50 | } 51 | 52 | uint16_t end = begin + cnt - 1; 53 | if (end > _srcNum - 1) { 54 | end = _srcNum - 1; 55 | } 56 | 57 | cnt = end - begin + 1; 58 | 59 | // begin is starting from 0, but we calculate the range by revising it to start from 1 60 | ++begin; 61 | ++end; 62 | 63 | uint32_t sum = 0; 64 | if ((cnt % 2) == 0) { 65 | sum = (begin + end) * (cnt / 2); 66 | } 67 | else { 68 | sum = (begin + (cnt / 2)) * cnt; 69 | } 70 | 71 | _sum += sum; 72 | if (_sum == _accumu) { 73 | _met = true; 74 | } 75 | return _met; 76 | } 77 | }; 78 | } 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/buffer.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_BUFFER_H 3 | #define _MEDIACLOUD_BUFFER_H 4 | #include 5 | namespace MediaCloud 6 | { 7 | namespace Common 8 | { 9 | void* AllocBuffer(unsigned int size, bool clear = false, int alignment = 8); 10 | void FreeBuffer(void *buffer); 11 | 12 | /// used to help fast allocate the fixed size buffer 13 | class BufferCache 14 | { 15 | public: 16 | static BufferCache* Create(int size); 17 | 18 | void *Allocate(bool clear = false, int alignment = 8); 19 | void Free(void *buffer); 20 | 21 | int BufferSize() const; 22 | ~BufferCache(); 23 | protected: 24 | BufferCache(int size); 25 | BufferCache& operator=(const BufferCache& buf); 26 | private: 27 | BufferCache(); 28 | int _bufSize; 29 | }; 30 | 31 | class RefBuffer 32 | { 33 | public: 34 | RefBuffer(const RefBuffer &refbuf); 35 | ~RefBuffer(); 36 | 37 | RefBuffer& operator=(const RefBuffer& refbuf); 38 | 39 | int AddRef(); /// return the previous ref count 40 | 41 | /// call this to release the RefBuffer instance 42 | /// return true if the buffer pointer can't be used anymore 43 | bool ReleaseRef(); 44 | 45 | int Size() const; 46 | void *Buffer() const; 47 | 48 | private: 49 | RefBuffer(); 50 | }; 51 | 52 | /// a buffer with reference count 53 | class RefBufferCache 54 | { 55 | public: 56 | 57 | static RefBufferCache* Create(int size); 58 | 59 | /// create a ref buffer with any size 60 | static RefBuffer Allocate(int size, bool clear = false); 61 | 62 | /// the returned buffer have reference count 1 63 | RefBuffer Allocate(bool clear = false); 64 | }; 65 | } 66 | } 67 | 68 | #endif -------------------------------------------------------------------------------- /src/avmGridChannel.h: -------------------------------------------------------------------------------- 1 | #ifndef __AVM_GRIDHANNEL_H__ 2 | #define __AVM_GRIDCHANNEL_H__ 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "../AVSDK/src/Adapter/audiopacketbuffer.h" 14 | #include "avmmixercomm.h" 15 | #include "TcpChannel.h" 16 | #include "commonstruct.h" 17 | #include 18 | #include "avmSession.h" 19 | 20 | using namespace MComp; 21 | 22 | namespace MediaCloud 23 | { 24 | bool ptrCCNUserCmp(PT_CCNUSER pfirst, PT_CCNUSER pSecond); 25 | 26 | typedef CAVMSession* PT_CAVMSESSION; 27 | typedef std::map MAP_PT_CAVMSESSION; 28 | typedef MAP_PT_CAVMSESSION::iterator ITR_MAP_PT_CAVMSESSION; 29 | 30 | 31 | class CAVMBizsChannel; 32 | class CAVMGridChannel 33 | { 34 | public: 35 | CAVMGridChannel(); 36 | ~CAVMGridChannel(); 37 | 38 | bool CreateAndConnect(char* szIP, unsigned short usPort); 39 | void DestoryChannel(); 40 | void SetBizChannelObj(CAVMBizsChannel* pObj); 41 | 42 | void* GridWorkThreadImp(void* param); 43 | 44 | int InsertUserJoinMsg(PT_USERJOINMSG pUserJoinMsg); 45 | 46 | void ProcessRecvPacket(char* pRecvPack, int uiRecvPackLen, int iType); 47 | 48 | bool Start(); 49 | void Stop(); 50 | 51 | bool SendKeepalive(); 52 | int SendBeanInSession(); 53 | void DestoryOldSession(); 54 | bool SendLogin(); 55 | 56 | private: 57 | string m_strRGridSvrIP; 58 | unsigned short m_usRGridSvrPort; 59 | 60 | CTCPChannel m_tcpChannel; 61 | pthread_t m_idWorkThread; 62 | bool m_bStopFlag; 63 | 64 | CAVMBizsChannel* m_pBizsChannel; 65 | 66 | CriticalSection* m_csMapSession; 67 | MAP_PT_CAVMSESSION m_mapSession; 68 | }; 69 | 70 | } 71 | 72 | 73 | #endif /* __AVM_PEER_H__ */ 74 | -------------------------------------------------------------------------------- /src/BaseTypeDef.h: -------------------------------------------------------------------------------- 1 | #ifndef __BASE_TYPE_DEFINE__ 2 | #define __BASE_TYPE_DEFINE__ 3 | 4 | #ifdef WIN32 5 | typedef char int8_t; 6 | typedef unsigned char uint8_t; 7 | typedef short int16_t; 8 | typedef unsigned short uint16_t; 9 | typedef int int32_t; 10 | typedef unsigned int uint32_t; 11 | typedef __int64 int64_t; 12 | typedef unsigned __int64 uint64_t; 13 | 14 | typedef __int64 INT64; 15 | typedef int socklen_t; 16 | 17 | #else 18 | #include 19 | 20 | typedef int SOCKET; 21 | typedef long long INT64; 22 | typedef float FLOAT; 23 | //typedef int socklen_t; 24 | 25 | #ifndef INVALID_SOCKET 26 | #define INVALID_SOCKET ~0 27 | #endif 28 | #ifndef INVALID_HANDLE_VALUE 29 | #define INVALID_HANDLE_VALUE -1 30 | #endif 31 | 32 | #define SOCKET_ERROR (-1) 33 | #define closesocket(s) close(s) 34 | 35 | #define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD)(a) & 0xff)) | ((WORD)((BYTE)((DWORD)(b) & 0xff))) << 8)) 36 | #define MAKELONG(a, b) ((LONG)(((WORD)((DWORD)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD)(b) & 0xffff))) << 16)) 37 | #define LOWORD(l) ((WORD)((DWORD)(l) & 0xffff)) 38 | #define HIWORD(l) ((WORD)((DWORD)(l) >> 16)) 39 | #define LOBYTE(w) ((BYTE)((DWORD)(w) & 0xff)) 40 | #define HIBYTE(w) ((BYTE)((DWORD)(w) >> 8)) 41 | #endif //WIN32 42 | 43 | typedef unsigned char BYTE; 44 | typedef unsigned short WORD; 45 | typedef unsigned int UINT; 46 | typedef unsigned long DWORD; 47 | typedef int BOOL; 48 | 49 | #ifndef NULL 50 | #define NULL 0 51 | #endif 52 | 53 | #ifndef FALSE 54 | #define FALSE 0 55 | #endif 56 | 57 | #ifndef TRUE 58 | #define TRUE 1 59 | #endif 60 | 61 | #ifndef WIN32 62 | #ifndef INVALID_SOCKET 63 | #define INVALID_SOCKET (unsigned int)(~0) 64 | #endif //INVALID_SOCKET 65 | #endif //WIN32 66 | 67 | #define MAX_IP_LEN 16 68 | #define MAX_PATH_LEN 1024 69 | #define MAX_UDP_PACK_LEN 512 70 | #define MAX_TCP_PACK_LEN 512 71 | 72 | 73 | #endif //__BASE_TYPE_DEFINE__ -------------------------------------------------------------------------------- /src/sync.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _CPPCMN_SYNC_H 3 | #define _CPPCMN_SYNC_H 4 | 5 | #include 6 | #include 7 | 8 | namespace cppcmn { 9 | 10 | class Mutex { 11 | public: 12 | Mutex() { 13 | ::pthread_mutex_init(&_mutex, nullptr); 14 | } 15 | 16 | ~Mutex() { 17 | ::pthread_mutex_destroy(&_mutex); 18 | } 19 | 20 | void Enter() { 21 | ::pthread_mutex_lock(&_mutex); 22 | } 23 | 24 | void Leave() { 25 | ::pthread_mutex_unlock(&_mutex); 26 | } 27 | 28 | private: 29 | pthread_mutex_t _mutex; 30 | }; 31 | 32 | class ScopedMutexLock { 33 | Mutex &_mutex; 34 | ScopedMutexLock(const ScopedMutexLock&) = delete; 35 | ScopedMutexLock& operator=(const ScopedMutexLock&) = delete; 36 | public: 37 | ScopedMutexLock(Mutex &mutex) : _mutex(mutex) { 38 | mutex.Enter(); 39 | } 40 | ~ScopedMutexLock() { 41 | _mutex.Leave(); 42 | } 43 | }; 44 | 45 | class RWLock { 46 | pthread_rwlock_t _rwlock; 47 | public: 48 | RWLock() { 49 | int ret = pthread_rwlock_init(&_rwlock, nullptr); 50 | assert(ret == 0); 51 | } 52 | 53 | ~RWLock() { 54 | pthread_rwlock_destroy(&_rwlock); 55 | } 56 | 57 | void Lock(bool forReading) { 58 | int ret = 0; 59 | if (forReading) { 60 | ret = pthread_rwlock_rdlock(&_rwlock); 61 | } 62 | else { 63 | ret = pthread_rwlock_wrlock(&_rwlock); 64 | } 65 | assert(ret == 0); 66 | } 67 | 68 | void Unlock(bool forReading) { 69 | int ret = pthread_rwlock_unlock(&_rwlock); 70 | assert(ret == 0); 71 | } 72 | }; 73 | 74 | class AtomicOperation { 75 | public: 76 | // returning the changed value 77 | static int Increment(int* i, int val) { 78 | return __sync_add_and_fetch(i, val); 79 | } 80 | 81 | static int Decrement(int* i, int val) { 82 | return __sync_sub_and_fetch(i, val); 83 | } 84 | }; 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /AVSDK/src/Adapter/audiopacketbuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // audiopacketbuffer.h 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 14/11/27. 6 | // Copyright (c) 2014年 smyk. All rights reserved. 7 | // 8 | 9 | #ifndef __mediacloud__audidpacketbuffer__ 10 | #define __mediacloud__audidpacketbuffer__ 11 | 12 | #include 13 | #include "audiopacket.h" 14 | 15 | namespace MediaCloud 16 | { 17 | namespace Adapter 18 | { 19 | class AudioPacketBuffer 20 | { 21 | public: 22 | enum BufferReturnCodes { 23 | kOK = 0, 24 | kFlushed, 25 | kNotFound, 26 | kBufferEmpty, 27 | kInvalidPacket, 28 | kInvalidPointer 29 | }; 30 | 31 | static bool DeleteFirstPacket(AudioPacketList* packet_list); 32 | static void DeleteAllPackets(AudioPacketList* packet_list); 33 | 34 | public: 35 | explicit AudioPacketBuffer(int32_t maxPacketnum); 36 | ~AudioPacketBuffer(); 37 | 38 | void Flush(); 39 | bool Empty() const; 40 | int32_t InsertPacket(AudioPacket* packet); 41 | int32_t InsertPacketList(AudioPacketList* packet_list); 42 | int32_t NextTimestamp(uint32_t* next_timestamp) const; 43 | int32_t NextHigherTimestamp(uint32_t timestamp, uint32_t* next_timestamp) const; 44 | 45 | const AudioPacketHeader* NextHeader() const; 46 | AudioPacket* GetNextPacket(int32_t* discard_count); 47 | 48 | int32_t DiscardNextPacket(); 49 | int32_t DiscardOldPackets(uint32_t timestamp_limit); 50 | int32_t durationInBuffer() const; 51 | int32_t NumPacketsInBuffer() const; 52 | void BufferStat(int32_t* num_packets, int32_t* max_num_packets) const; 53 | 54 | private: 55 | AudioPacketBuffer(const AudioPacketBuffer& packet); 56 | AudioPacketBuffer& operator =(AudioPacketBuffer&); 57 | private: 58 | int32_t _maxPacketnum; 59 | AudioPacketList _buffer; 60 | }; 61 | } 62 | } 63 | #endif /* defined(__mediacloud__audidpacketbuffer__) */ 64 | -------------------------------------------------------------------------------- /src/fec.h: -------------------------------------------------------------------------------- 1 | #ifndef _HPSP_FEC_H 2 | #define _HPSP_FEC_H 3 | 4 | #include 5 | #include "logging.h" 6 | #include "fbuffer.h" 7 | #include "fast_fec.h" 8 | 9 | using namespace MediaCloud::Common; 10 | 11 | namespace hpsp { 12 | 13 | class FecBufferAllocator : public fec::IAllocator { 14 | public: 15 | // actually, fast-fec only support max matrix size = 233 for 200 src symbols 16 | static const int MaxL = 256; 17 | 18 | FecBufferAllocator() 19 | // size = max matrix size + matrix column index buffer 20 | : _tmpMatrixAllocator(MaxL * MaxL + MaxL * sizeof(int), 4, 16) 21 | , _tmpUnknownAllocator(MaxL * 8, 4, 0) 22 | // lt symbol buffer has column index at the begin 23 | , _ltAllocator(MaxL * (MaxL + 4), 1, 16) 24 | { 25 | } 26 | 27 | virtual void* AllocFecBuffer(int size, int alignment, int purpose) override 28 | { 29 | if (purpose == PurposeLT) { 30 | Assert(size <= _ltAllocator.AlignedSize()); 31 | return _ltAllocator.Alloc(); 32 | } 33 | 34 | if (purpose == PurposeTmpMatrix) { 35 | Assert(size <= _tmpMatrixAllocator.AlignedSize()); 36 | return _tmpMatrixAllocator.Alloc(); 37 | } 38 | 39 | Assert(purpose == PurposeUnknown); 40 | Assert(size <= _tmpUnknownAllocator.AlignedSize()); 41 | return _tmpUnknownAllocator.Alloc(); 42 | } 43 | 44 | virtual void FreeFecBuffer(void *buffer, int purpose) override 45 | { 46 | if (buffer != nullptr) { 47 | if (purpose == PurposeLT) { 48 | _ltAllocator.Free(buffer); 49 | } 50 | else if (purpose == PurposeTmpMatrix) { 51 | _tmpMatrixAllocator.Free(buffer); 52 | } 53 | else { 54 | Assert(purpose == PurposeUnknown); 55 | _tmpUnknownAllocator.Free(buffer); 56 | } 57 | } 58 | } 59 | 60 | cppcmn::FixedSizeAllocator _tmpMatrixAllocator; 61 | cppcmn::FixedSizeAllocator _tmpUnknownAllocator; 62 | cppcmn::FixedSizeAllocator _ltAllocator; 63 | }; 64 | } 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /src/userproto.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_USERPROTO_H 2 | #define _CPPCMN_USERPROTO_H 3 | 4 | #include 5 | #include "../socket.h" 6 | 7 | namespace cppcmn { 8 | 9 | // protobuf type from user 10 | enum UserProtoType { 11 | UserProtoTypeUnknown = 0, 12 | UserProtoTypeLogin = 1, 13 | UserProtoTypeLoginResp, 14 | UserProtoTypeJoin, 15 | UserProtoTypeJoinResp, 16 | UserProtoTypePing, 17 | UserProtoTypePingResp, 18 | UserProtoTypeEnd, 19 | UserProtoTypeIdentity, 20 | }; 21 | 22 | struct UserProtoLogin { 23 | uint32_t identity; 24 | char token[16]; 25 | }; 26 | 27 | struct UserProtoLoginResp { 28 | int errcode; 29 | }; 30 | 31 | struct UserProtoJoin { 32 | char session[16]; 33 | }; 34 | 35 | struct UserProtoJoinResp { 36 | char session[16]; 37 | int errcode; 38 | }; 39 | 40 | struct UserProtoPing { 41 | uint32_t tick; 42 | uint32_t delay; 43 | }; 44 | 45 | struct UserProtoEnd { 46 | uint32_t streams; 47 | }; 48 | 49 | struct UserProtoIdentities { 50 | struct UserInfo { 51 | uint32_t identity; 52 | const char *uid; 53 | int uidlen; 54 | }; 55 | UserInfo *infos; 56 | int infoNum; 57 | }; 58 | 59 | struct UserProtocol { 60 | static bool ParseUserLogin(void *packet, int packlen, UserProtoLogin &userLogin); 61 | static bool ParseUserJoin(void *packet, int packlen, UserProtoJoin &userJoin); 62 | static bool ParseUserPing(void *packet, int packlen, UserProtoPing &userPing); 63 | static bool ParseUserEnd(void *packet, int packlen, UserProtoEnd &userEnd); 64 | static int SerializeUserLoginResp(int errcode, void *buffer); 65 | static int SerializeUserJoinResp(const char sessionid[], int errcode, void *buffer); 66 | static int SerializeUserPingResp(uint32_t tick, uint32_t delay, void *buffer); 67 | static int SerializeUserIdentities(const UserProtoIdentities &identities, void *buffer); 68 | 69 | // flag is at high 5 bits ! 70 | static inline void SetStreamSliceHeader(uint8_t type, uint8_t flag, uint16_t ploadlen, void *buffer) 71 | { 72 | uint8_t *pbuf = (uint8_t*)buffer; 73 | pbuf[0] = type; 74 | pbuf[1] = (flag & 0xF8) | (ploadlen >> 8); 75 | pbuf[2] = ploadlen & 0xFF; 76 | } 77 | }; 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/google/protobuf/generated_enum_util.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ 32 | #define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ 33 | 34 | #include 35 | 36 | namespace google { 37 | namespace protobuf { 38 | 39 | // This type trait can be used to cause templates to only match proto2 enum 40 | // types. 41 | template struct is_proto_enum : ::google::protobuf::internal::false_type {}; 42 | 43 | } // namespace protobuf 44 | 45 | } // namespace google 46 | #endif // GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__ 47 | -------------------------------------------------------------------------------- /AVSDK/src/Adapter/audiopacket.h: -------------------------------------------------------------------------------- 1 | // 2 | // audiopacket.h 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 14/11/27. 6 | // Copyright (c) 2014年 smyk. All rights reserved. 7 | // 8 | 9 | #ifndef mediacloud_audiopacket_h 10 | #define mediacloud_audiopacket_h 11 | #include 12 | #include 13 | 14 | namespace MediaCloud 15 | { 16 | namespace Adapter 17 | { 18 | struct AudioPacketHeader 19 | { 20 | uint32_t _identity; 21 | uint8_t _payloadType; 22 | uint16_t _sequenceNumber; 23 | uint32_t _timestamp; 24 | uint32_t _duration; 25 | bool _iscontinue; 26 | 27 | unsigned int _fileTotalSize; 28 | unsigned int _fileTotalTime; 29 | float _percent; 30 | }; 31 | typedef struct AudioPacket 32 | { 33 | AudioPacketHeader _header; 34 | uint8_t* _payload; 35 | int _payloadLen; 36 | 37 | AudioPacket() : 38 | _payload(NULL), 39 | _payloadLen(0) 40 | { 41 | } 42 | 43 | bool operator ==(const AudioPacket& rhs) const { 44 | return (_header._timestamp == rhs._header._timestamp && 45 | _header._sequenceNumber == rhs._header._sequenceNumber); 46 | } 47 | 48 | bool operator!=(const AudioPacket& rhs) const 49 | { 50 | return !operator==(rhs); 51 | } 52 | 53 | bool operator<(const AudioPacket& rhs) const 54 | { 55 | return ((uint32_t)(rhs._header._timestamp - _header._timestamp) < 0xFFFFFFFF / 2); 56 | } 57 | 58 | bool operator>(const AudioPacket& rhs) const 59 | { 60 | return rhs.operator<(*this); 61 | } 62 | 63 | bool operator<=(const AudioPacket& rhs) const 64 | { 65 | return !operator>(rhs); 66 | } 67 | 68 | bool operator>=(const AudioPacket& rhs) const 69 | { 70 | return !operator<(rhs); 71 | } 72 | }AudioPacket; 73 | 74 | typedef std::list AudioPacketList; 75 | } 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /include/google/protobuf/stubs/atomic_sequence_num.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2014 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | #ifndef GOOGLE_PROTOBUF_ATOMIC_SEQUENCE_NUM_H_ 31 | #define GOOGLE_PROTOBUF_ATOMIC_SEQUENCE_NUM_H_ 32 | 33 | #include 34 | 35 | namespace google { 36 | namespace protobuf { 37 | namespace internal { 38 | 39 | class SequenceNumber { 40 | public: 41 | SequenceNumber() : word_(0) {} 42 | 43 | AtomicWord GetNext() { 44 | return NoBarrier_AtomicIncrement(&word_, 1) - 1; 45 | } 46 | private: 47 | AtomicWord word_; 48 | }; 49 | 50 | } // namespace internal 51 | } // namespace protobuf 52 | } // namespace google 53 | 54 | #endif // GOOGLE_PROTOBUF_ATOMIC_SEQUENCE_NUM_H_ 55 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/error.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_ERROR_H 3 | #define _MEDIACLOUD_ERROR_H 4 | 5 | #include 6 | 7 | namespace MediaCloud 8 | { 9 | namespace Common 10 | { 11 | enum ErrCode 12 | { 13 | ErrCodeNone = 0, 14 | ErrCodeUnknown = -1000, 15 | ErrCodeArgument, 16 | ErrCodeNoImpl, 17 | ErrCodeNoData, 18 | ErrCodeNoRoom, 19 | ErrCodeNotAvailable, 20 | ErrCodeNotInit, 21 | ErrCodeOutOfMemory, 22 | ErrCodeNotReady, 23 | ErrCodeAlready, 24 | ErrCodeRecovery, 25 | ErrCodeDiscover, 26 | ErrCodeNetwork, 27 | ErrCodeNoUser, /// UserOnline doesn't called before making session operations 28 | ErrCodeIdentity, /// the user/mr identity is not valid on server 29 | ErrCodeAccount, 30 | ErrCodeSignature, 31 | ErrCodeToken, 32 | ErrCodeAttribute, 33 | ErrCodeBuffer, 34 | ErrCodeLimitation, /// the limitation is met, like: the max online user number is satisfied. 35 | 36 | ErrCodeAccountCookie, /// the account cookie is not valid, the app need to verify its account again to get new cookie 37 | ErrCodeUserCookie, /// the user cookie is not valid on server matching the user identity 38 | 39 | ErrCodeTerminated, 40 | ErrCodeNotSupport, 41 | ErrCodeReject, 42 | ErrCodeTimeout, 43 | ErrCodeClosed, 44 | ErrCodeSocket, 45 | ErrCodeSocketEagain, 46 | ErrCodeInPhoneCall, 47 | ErrCodeBusy, 48 | ErrCodeSession, 49 | ErrCodeAccessRight, 50 | ErrCodeVersion, 51 | ErrCodeKickOut, 52 | 53 | ErrCodeEncoder, 54 | 55 | ErrCodeAudioProperty, 56 | ErrCodeAudioSession, 57 | ErrCodeAudioDevice, 58 | ErrCodeAudioFormat, 59 | ErrCodeAudioResampler, 60 | 61 | ErrCodePacket, 62 | ErrCodePort, 63 | 64 | ErrCodeRender, 65 | ErrCodeOpenGL, 66 | ErrCodeTexture, 67 | ErrCodeShader, 68 | 69 | ErrCodeFile, 70 | }; 71 | 72 | struct Error 73 | { 74 | int code; 75 | std::string message; 76 | }; 77 | } 78 | } 79 | 80 | #endif -------------------------------------------------------------------------------- /include/google/protobuf/source_context.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option java_package = "com.google.protobuf"; 37 | option java_outer_classname = "SourceContextProto"; 38 | option java_multiple_files = true; 39 | option java_generate_equals_and_hash = true; 40 | option objc_class_prefix = "GPB"; 41 | 42 | // `SourceContext` represents information about the source of a 43 | // protobuf element, like the file in which it is defined. 44 | message SourceContext { 45 | // The path-qualified name of the .proto file that contained the associated 46 | // protobuf element. For example: `"google/protobuf/source_context.proto"`. 47 | string file_name = 1; 48 | } 49 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/mstringlist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "mstringlist.h" 4 | 5 | MStringList::MStringList() 6 | { 7 | } 8 | 9 | MStringList::~MStringList() 10 | { 11 | } 12 | 13 | bool MStringList::isEmpty() const 14 | { 15 | return empty(); 16 | } 17 | 18 | int MStringList::length() 19 | { 20 | return (int)size(); 21 | } 22 | 23 | MString &MStringList::operator [](int i) 24 | { 25 | list::iterator iter = begin(); 26 | for (int c = 0; c < i; ++c) { 27 | ++iter; 28 | } 29 | return *iter; 30 | } 31 | 32 | const MString &MStringList::operator [](int i) const 33 | { 34 | MStringListConstItor iter = begin(); 35 | for (int c = 0; c < i; ++c) { 36 | ++iter; 37 | } 38 | return *iter; 39 | } 40 | 41 | MStringList &MStringList::operator <<(const MString &str) 42 | { 43 | this->push_back(str); 44 | return *this; 45 | } 46 | 47 | MStringList &MStringList::operator <<(const MStringList &other) 48 | { 49 | for (unsigned int i = 0; i < other.size(); ++i) { 50 | this->push_back(other.at(i)); 51 | } 52 | 53 | return *this; 54 | } 55 | 56 | MStringList &MStringList::operator=(const MStringList &other) 57 | { 58 | this->clear(); 59 | return *this << other; 60 | } 61 | 62 | MString &MStringList::at(int pos) 63 | { 64 | assert((unsigned int)pos < size()); 65 | return (*this)[pos]; 66 | } 67 | 68 | const MString &MStringList::at(int pos) const 69 | { 70 | assert((unsigned int)pos < size()); 71 | return (*this)[pos]; 72 | } 73 | 74 | MString MStringList::join(const MString &sep) 75 | { 76 | if (size() == 1) { 77 | return front(); 78 | } 79 | 80 | MString ret; 81 | for (list::iterator iter = begin(); iter != end(); ++iter) { 82 | ret.append(*iter); 83 | ret.append(sep); 84 | } 85 | 86 | return ret; 87 | } 88 | 89 | MStringList MStringList::mid(int start, int length) 90 | { 91 | // // TODO : imp 92 | MStringList ret; 93 | 94 | assert(true); 95 | return ret; 96 | } 97 | 98 | ostream & operator<<(ostream &o, const MStringList& a) 99 | { 100 | o << "("; 101 | for (unsigned int i = 0; i < a.size(); ++i) { 102 | const MString &str = a[i]; 103 | o << "\"" << str << "\""; 104 | if (i < a.size() -1) { 105 | o << ","; 106 | } 107 | } 108 | o << ")"; 109 | 110 | return o; 111 | } 112 | -------------------------------------------------------------------------------- /include/google/protobuf/util/type_resolver_util.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__ 33 | 34 | #include 35 | 36 | #include 37 | namespace google { 38 | namespace protobuf { 39 | class DescriptorPool; 40 | namespace util { 41 | class TypeResolver; 42 | 43 | // Creates a TypeResolver that serves type information in the given descriptor 44 | // pool. Caller takes ownership of the returned TypeResolver. 45 | LIBPROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool( 46 | const string& url_prefix, const DescriptorPool* pool); 47 | 48 | } // namespace util 49 | } // namespace protobuf 50 | 51 | } // namespace google 52 | #endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__ 53 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/common.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_COMMON_H 3 | #define _MEDIACLOUD_COMMON_H 4 | 5 | #include 6 | #include 7 | #include "config.h" 8 | #include "utils.h" 9 | #include "msgqueue.h" 10 | #include "codec.h" 11 | #include "socket.h" 12 | #include "buffer.h" 13 | #include "datetime.h" 14 | #include "logging.h" 15 | #include "sync.h" 16 | #include "http.h" 17 | #include "error.h" 18 | #include "rc4.h" 19 | #include "rsa.h" 20 | #include "thread.h" 21 | #include "dllloader.h" 22 | #include "waveoperator.h" 23 | #include "file.h" 24 | #include "sps.h" 25 | #include "clock.h" 26 | #include "flist.h" 27 | #include "fcirclequeue.h" 28 | #include "http.h" 29 | #include "fmem.h" 30 | #include "avcommon.h" 31 | #include "BaseSocket.h" 32 | 33 | 34 | 35 | namespace MediaCloud 36 | { 37 | namespace Common 38 | { 39 | #define BUF_ARG_MOVE // a buffer owner transfer to callee from caller 40 | #define BUF_ARG_REF // no buffer owner transfer, just for reference 41 | #define BUF_ARG_OUT // a buffer created from callee to be ownered by caller 42 | 43 | void InitializeCommonLib(); 44 | 45 | __inline bool IsNewerSeqNumber(uint16_t newer, uint16_t prev) 46 | { 47 | return newer != prev && static_cast(newer - prev) < 0x8000u; 48 | } 49 | 50 | __inline uint16_t LatestSeqNumber(uint16_t seq1, uint16_t seq2) 51 | { 52 | return IsNewerSeqNumber(seq1, seq2) ? seq1 : seq2; 53 | } 54 | 55 | __inline uint16_t SeqNumberDistance(uint16_t newer, uint16_t prev) 56 | { 57 | return newer - prev; 58 | } 59 | 60 | __inline uint32_t NumOfBitOne(uint32_t nValue) 61 | { 62 | nValue = ((0xaaaaaaaa & nValue) >> 1) + (0x55555555 & nValue); 63 | nValue = ((0xcccccccc & nValue) >> 2) + (0x33333333 & nValue); 64 | nValue = ((0xf0f0f0f0 & nValue) >> 4) + (0x0f0f0f0f & nValue); 65 | nValue = ((0xff00ff00 & nValue) >> 8) + (0x00ff00ff & nValue); 66 | nValue = ((0xffff0000 & nValue) >> 16) + (0x0000ffff & nValue); 67 | return nValue; 68 | } 69 | 70 | void *ProtectedAlloc(unsigned int length, int reason = 0); 71 | void ProtectedFree(void *buffer, int reason = 0); 72 | void VerifyPointer(void *buffer); 73 | void DumpAllocHistoryOnce(); 74 | 75 | void AddTraceTime(const char* name,bool bclear = false); 76 | } 77 | } 78 | 79 | unsigned char InitSockets(); 80 | 81 | void CleanupSockets(); 82 | 83 | #endif -------------------------------------------------------------------------------- /include/google/protobuf/compiler/ruby/ruby_generator.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__ 32 | #define GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__ 33 | 34 | #include 35 | 36 | #include 37 | 38 | namespace google { 39 | namespace protobuf { 40 | namespace compiler { 41 | namespace ruby { 42 | 43 | class LIBPROTOC_EXPORT Generator 44 | : public google::protobuf::compiler::CodeGenerator { 45 | virtual bool Generate( 46 | const FileDescriptor* file, 47 | const string& parameter, 48 | GeneratorContext* generator_context, 49 | string* error) const; 50 | }; 51 | 52 | } // namespace ruby 53 | } // namespace compiler 54 | } // namespace protobuf 55 | } // namespace google 56 | 57 | #endif // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__ 58 | 59 | -------------------------------------------------------------------------------- /include/google/protobuf/compiler/csharp/csharp_generator.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ 32 | #define GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ 33 | 34 | #include 35 | 36 | #include 37 | 38 | namespace google { 39 | namespace protobuf { 40 | namespace compiler { 41 | namespace csharp { 42 | 43 | class LIBPROTOC_EXPORT Generator 44 | : public google::protobuf::compiler::CodeGenerator { 45 | virtual bool Generate( 46 | const FileDescriptor* file, 47 | const string& parameter, 48 | GeneratorContext* generator_context, 49 | string* error) const; 50 | }; 51 | 52 | } // namespace csharp 53 | } // namespace compiler 54 | } // namespace protobuf 55 | } // namespace google 56 | 57 | #endif // GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__ 58 | 59 | -------------------------------------------------------------------------------- /include/google/protobuf/io/strtod.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // A locale-independent version of strtod(), used to parse floating 32 | // point default values in .proto files, where the decimal separator 33 | // is always a dot. 34 | 35 | #ifndef GOOGLE_PROTOBUF_IO_STRTOD_H__ 36 | #define GOOGLE_PROTOBUF_IO_STRTOD_H__ 37 | 38 | namespace google { 39 | namespace protobuf { 40 | namespace io { 41 | 42 | // A locale-independent version of the standard strtod(), which always 43 | // uses a dot as the decimal separator. 44 | double NoLocaleStrtod(const char* str, char** endptr); 45 | 46 | // Casts a double value to a float value. If the value is outside of the 47 | // representable range of float, it will be converted to positive or negative 48 | // infinity. 49 | float SafeDoubleToFloat(double value); 50 | 51 | } // namespace io 52 | } // namespace protobuf 53 | 54 | } // namespace google 55 | #endif // GOOGLE_PROTOBUF_IO_STRTOD_H__ 56 | -------------------------------------------------------------------------------- /include/google/protobuf/empty.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/empty"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "EmptyProto"; 39 | option java_multiple_files = true; 40 | option java_generate_equals_and_hash = true; 41 | option objc_class_prefix = "GPB"; 42 | option cc_enable_arenas = true; 43 | 44 | // A generic empty message that you can re-use to avoid defining duplicated 45 | // empty messages in your APIs. A typical example is to use it as the request 46 | // or the response type of an API method. For instance: 47 | // 48 | // service Foo { 49 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 50 | // } 51 | // 52 | // The JSON representation for `Empty` is empty JSON object `{}`. 53 | message Empty {} 54 | -------------------------------------------------------------------------------- /src/fecrepo_hdr.h: -------------------------------------------------------------------------------- 1 | #ifndef _FECREPO_HEADER_H 2 | #define _FECREPO_HEADER_H 3 | 4 | #include 5 | 6 | namespace FecRepo { 7 | 8 | struct MatrixInfo { 9 | const uint8_t *data; 10 | int rows; 11 | int cols; 12 | int stride; 13 | int L; 14 | }; 15 | 16 | struct EncodeCInfo { 17 | const uint16_t *data; 18 | int L; 19 | }; 20 | 21 | enum VectorOps { 22 | VectorOps_SwapRows = 1, 23 | VectorOps_XorRows, 24 | VectorOps_DivRow, 25 | VectorOps_MulMatrix, 26 | VectorOps_Reorder 27 | }; 28 | 29 | struct EncodeVecOp { 30 | uint8_t ops; 31 | uint8_t factor; 32 | uint16_t row1; // has i for MulMatrix 33 | uint16_t row2; 34 | }; 35 | 36 | struct EncodeVecOpInfo { 37 | const EncodeVecOp *ops; 38 | int opsNum; 39 | int L; 40 | }; 41 | 42 | struct Tuple { 43 | uint32_t d, a, b, d1, a1, b1; 44 | }; 45 | 46 | struct TupleIndexes { 47 | int idxOffset; // the offset in tupleIdxData; 48 | uint8_t numOfIdxes; // the number of uint8_t in tupleIdxData; 49 | // actually, when K <= 200, the max numOfIdxes is 32 50 | }; 51 | 52 | struct TupleInfo { 53 | const Tuple *tuples; // the tuples indexed by isi 54 | const TupleIndexes *tupleIdxes; // it is the intermediate symbols indexes output from tuple 55 | const uint8_t *tupleIdxData; 56 | int tupleNum; 57 | int KP; 58 | int L; 59 | }; 60 | 61 | struct Param { 62 | int K, T, KP, S, H, W, L, P, P1, U, B, J; 63 | }; 64 | 65 | struct ParamInfo { 66 | Param param; 67 | int idxOfMatrixA; 68 | int idxOfMatrixX; 69 | int idxOfEncodeC; 70 | int idxOfEncodeOps; 71 | int idxOfTuples; 72 | }; 73 | 74 | class RepoReader { 75 | public: 76 | const static int MinK = 8; 77 | const static int MaxK = 200; 78 | 79 | static const Param* GetParam(int K); 80 | /* 81 | * ltIdxes - a pointer to uint8_t array, each element is an index of intermediate symbols 82 | * numOfIdx - the size of ltIdxes array 83 | */ 84 | static const Tuple* GetTuple(const Param *param, int isi, const uint8_t* <Idxes, uint8_t &numOfIdx); 85 | static const MatrixInfo* GetMatrixA(const Param *param); 86 | static const MatrixInfo* GetMatrixX(const Param *param); 87 | static const EncodeCInfo* GetEncodeC(const Param *param); 88 | static const EncodeVecOpInfo* GetEncodeVecOps(const Param *param); 89 | }; 90 | } 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /include/rapidjson/memorystream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYSTREAM_H_ 16 | #define RAPIDJSON_MEMORYSTREAM_H_ 17 | 18 | #include "rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | 22 | //! Represents an in-memory input byte stream. 23 | /*! 24 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. 25 | 26 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. 27 | 28 | Differences between MemoryStream and StringStream: 29 | 1. StringStream has encoding but MemoryStream is a byte stream. 30 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 31 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). 32 | \note implements Stream concept 33 | */ 34 | struct MemoryStream { 35 | typedef char Ch; // byte 36 | 37 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} 38 | 39 | Ch Peek() const { return (src_ == end_) ? '\0' : *src_; } 40 | Ch Take() { return (src_ == end_) ? '\0' : *src_++; } 41 | size_t Tell() const { return static_cast(src_ - begin_); } 42 | 43 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 44 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 45 | void Flush() { RAPIDJSON_ASSERT(false); } 46 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 47 | 48 | // For encoding detection only. 49 | const Ch* Peek4() const { 50 | return Tell() + 4 <= size_ ? src_ : 0; 51 | } 52 | 53 | const Ch* src_; //!< Current read position. 54 | const Ch* begin_; //!< Original head of the string. 55 | const Ch* end_; //!< End of stream. 56 | size_t size_; //!< Size of the stream. 57 | }; 58 | 59 | RAPIDJSON_NAMESPACE_END 60 | 61 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 62 | -------------------------------------------------------------------------------- /include/google/protobuf/stubs/singleton.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2014 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | #ifndef GOOGLE_PROTOBUF_STUBS_SINGLETON_H__ 31 | #define GOOGLE_PROTOBUF_STUBS_SINGLETON_H__ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | namespace google { 38 | namespace protobuf { 39 | namespace internal { 40 | template 41 | class Singleton { 42 | public: 43 | static T* get() { 44 | GoogleOnceInit(&once_, &Singleton::Init); 45 | return instance_; 46 | } 47 | static void ShutDown() { 48 | delete instance_; 49 | instance_ = NULL; 50 | } 51 | private: 52 | static void Init() { 53 | instance_ = new T(); 54 | } 55 | static ProtobufOnceType once_; 56 | static T* instance_; 57 | }; 58 | 59 | template 60 | ProtobufOnceType Singleton::once_; 61 | 62 | template 63 | T* Singleton::instance_ = NULL; 64 | } // namespace internal 65 | } // namespace protobuf 66 | } // namespace google 67 | 68 | #endif // GOOGLE_PROTOBUF_STUBS_SINGLETON_H__ 69 | -------------------------------------------------------------------------------- /src/Log.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * 3 | * Copyright (c) 2010 fetion.com, Inc. All Rights Reserved 4 | * 5 | **************************************************************************/ 6 | /** 7 | * @file log.h 8 | * @author liyi(liyi@fetion.com) 9 | * @date 2009/07/05 23:28:12 10 | * @brief 11 | * 12 | **/ 13 | #ifndef _LOG_H_ 14 | #define _LOG_H_ 15 | #include 16 | #include 17 | 18 | #ifdef WIN32 19 | //#define LOG_EMERG 0 /* system is unusable */ 20 | //#define LOG_ALERT 1 /* action must be taken immediately */ 21 | //#define LOG_CRIT 2 /* critical conditions */ 22 | #define LOG_ERR 3 /* error conditions */ 23 | #define LOG_WARNING 4 /* warning conditions */ 24 | #define LOG_NOTICE 5 /* normal but significant condition */ 25 | #define LOG_INFO 6 /* informational */ 26 | //#define LOG_DEBUG 7 /* debug-level messages */ 27 | 28 | #else 29 | #include 30 | #endif 31 | 32 | #define XLOG_INFO __FILE__, __LINE__, LOG_INFO 33 | #define XLOG_ERR __FILE__, __LINE__, LOG_ERR 34 | #define XLOG_WARNING __FILE__, __LINE__, LOG_WARNING 35 | #define XLOG_NOTICE __FILE__, __LINE__, LOG_NOTICE 36 | 37 | #define FILENAMESIZE 1024 38 | 39 | #define PRF_LOG_ERROR 1 // 1 < 0 40 | #define PRF_LOG_WARNING 2 // 1 < 1 41 | #define PRF_LOG_INFO 4 // 1 < 2 42 | #define PRF_LOG_NOTICE 8 // 1 < 3 43 | #define PRF_LOG_ALL (PRF_LOG_ERROR | PRF_LOG_WARNING | PRF_LOG_INFO | PRF_LOG_NOTICE) // is default 44 | #define PRF_LOG_NON 0 45 | 46 | typedef struct LOG_HELPER 47 | { 48 | FILE* fp; 49 | int fp_seq; 50 | char seperator[8]; 51 | char file_name[FILENAMESIZE]; 52 | int file_max_size; 53 | int file_time_span; 54 | time_t last_time_endpt; 55 | int level; 56 | } 57 | LOG_HELPER; 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | void set_logfile_max_size(LOG_HELPER* log_helper, int max_size); 62 | void set_logfile_time_span(LOG_HELPER* log_helper, int span); 63 | LOG_HELPER* open_logfile(const char* file_name); 64 | void close_logfile(LOG_HELPER* log_helper); 65 | LOG_HELPER* open_logfile_r(FILE * fp); 66 | void close_logfile_r(LOG_HELPER* log_helper); 67 | 68 | void log_info(LOG_HELPER* log_helper, char *fmt0, ...); 69 | void log_warning(LOG_HELPER* log_helper, char *fmt0, ...); 70 | void log_notice(LOG_HELPER* log_helper, char *fmt0, ...); 71 | void log_err(LOG_HELPER* log_helper, char *fmt0, ...); 72 | void log_write(LOG_HELPER* log_helper, const char* file, int line, int level, char *fmt0, ...); 73 | void set_log_level(LOG_HELPER* log_helper, int level); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | extern LOG_HELPER* g_pLogHelper; 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /src/misc.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_MISC_H 2 | #define _CPPCMN_MISC_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace cppcmn { 9 | 10 | #define DeleteToNull(p) do { delete (p); (p) = nullptr; } while (0) 11 | #define CALCU_ALIGNMENT(a, n) (((a) + ((n) - 1)) & (~((n) - 1))) 12 | 13 | // Put this in the declarations for a class to be uncopyable. 14 | #define DISALLOW_COPY(TypeName) \ 15 | TypeName(const TypeName&) = delete 16 | 17 | // Put this in the declarations for a class to be unassignable. 18 | #define DISALLOW_ASSIGN(TypeName) \ 19 | void operator=(const TypeName&) = delete 20 | 21 | // A macro to disallow the copy constructor and operator= functions 22 | // This should be used in the private: declarations for a class 23 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 24 | TypeName(const TypeName&) = delete; \ 25 | void operator=(const TypeName&) = delete 26 | 27 | // A macro to disallow all the implicit constructors, namely the 28 | // default constructor, copy constructor and operator= functions. 29 | // 30 | // This should be used in the private: declarations for a class 31 | // that wants to prevent anyone from instantiating it. This is 32 | // especially useful for classes containing only static methods. 33 | #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ 34 | TypeName() = delete; \ 35 | DISALLOW_COPY_AND_ASSIGN(TypeName) 36 | 37 | 38 | bool StartProcess(const char *binaryPath, const char *args[]); 39 | uint64_t GetProcessCpuAffinity(); 40 | 41 | void StartThread(void (*func) (void*), void* param); 42 | void SetCurrentThreadCpuAffinity(uint64_t cpumask); 43 | 44 | inline uint8_t UUIDCharTo4Bits(char c) { 45 | int cl = tolower(c); 46 | if (cl >= '0' && cl <= '9') { 47 | return cl - '0'; 48 | } 49 | if (cl >= 'a' && cl <= 'f') { 50 | return cl - 'a' + 10; 51 | } 52 | assert(false); 53 | return 0; 54 | } 55 | 56 | inline char UUID4BitsToChar(uint8_t byte) { 57 | assert(byte < 16); 58 | if (byte < 10) { 59 | return '0' + byte; 60 | } 61 | return 'a' + (byte - 10); 62 | } 63 | 64 | // 32 char to 16 bytes 65 | inline void UUIDString2Bytes(const char *str, uint8_t *bytes) { 66 | for (int i = 0; i < 16; i++) { 67 | bytes[i] = UUIDCharTo4Bits(str[i * 2]) << 4; 68 | bytes[i] |= UUIDCharTo4Bits(str[i * 2 + 1]); 69 | } 70 | } 71 | 72 | // 16 bytes to 32 char 73 | inline void UUIDBytes2String(const uint8_t *bytes, char *str) { 74 | for (int i = 0; i < 16; i++) { 75 | str[i * 2] = UUID4BitsToChar(bytes[i] >> 4); 76 | str[i * 2 + 1] = UUID4BitsToChar(bytes[i] & 0xf); 77 | } 78 | } 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/google/protobuf/compiler/objectivec/objectivec_generator.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Generates ObjectiveC code for a given .proto file. 32 | 33 | #ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__ 34 | #define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__ 35 | 36 | #include 37 | #include 38 | 39 | namespace google { 40 | namespace protobuf { 41 | namespace compiler { 42 | namespace objectivec { 43 | 44 | class LIBPROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator { 45 | public: 46 | ObjectiveCGenerator(); 47 | ~ObjectiveCGenerator(); 48 | 49 | // implements CodeGenerator ---------------------------------------- 50 | bool Generate(const FileDescriptor* file, const string& parameter, 51 | OutputDirectory* output_directory, string* error) const; 52 | 53 | private: 54 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectiveCGenerator); 55 | }; 56 | 57 | } // namespace objectivec 58 | } // namespace compiler 59 | } // namespace protobuf 60 | } // namespace google 61 | #endif // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__ 62 | -------------------------------------------------------------------------------- /include/rapidjson/memorybuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYBUFFER_H_ 16 | #define RAPIDJSON_MEMORYBUFFER_H_ 17 | 18 | #include "rapidjson.h" 19 | #include "internal/stack.h" 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Represents an in-memory output byte stream. 24 | /*! 25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. 26 | 27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. 28 | 29 | Differences between MemoryBuffer and StringBuffer: 30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. 32 | 33 | \tparam Allocator type for allocating memory buffer. 34 | \note implements Stream concept 35 | */ 36 | template 37 | struct GenericMemoryBuffer { 38 | typedef char Ch; // byte 39 | 40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 41 | 42 | void Put(Ch c) { *stack_.template Push() = c; } 43 | void Flush() {} 44 | 45 | void Clear() { stack_.Clear(); } 46 | void ShrinkToFit() { stack_.ShrinkToFit(); } 47 | Ch* Push(size_t count) { return stack_.template Push(count); } 48 | void Pop(size_t count) { stack_.template Pop(count); } 49 | 50 | const Ch* GetBuffer() const { 51 | return stack_.template Bottom(); 52 | } 53 | 54 | size_t GetSize() const { return stack_.GetSize(); } 55 | 56 | static const size_t kDefaultCapacity = 256; 57 | mutable internal::Stack stack_; 58 | }; 59 | 60 | typedef GenericMemoryBuffer<> MemoryBuffer; 61 | 62 | //! Implement specialized version of PutN() with memset() for better performance. 63 | template<> 64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { 65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); 66 | } 67 | 68 | RAPIDJSON_NAMESPACE_END 69 | 70 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 71 | -------------------------------------------------------------------------------- /src/fqueue.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_FQUEUE_H 2 | #define _CPPCMN_FQUEUE_H 3 | 4 | #include 5 | #include 6 | 7 | using namespace MediaCloud::Common; 8 | 9 | namespace cppcmn { 10 | 11 | template 12 | class FixedSizeCircleQueue { 13 | public: 14 | static const int Capability = N; 15 | static const int SlotSize = S; 16 | 17 | FixedSizeCircleQueue() 18 | : _slotBegin(0), _slotCnt(0) { 19 | } 20 | 21 | inline int Count() const { return _slotCnt; } 22 | inline bool IsEmpty() const { return _slotCnt == 0; } 23 | inline bool IsFull() const { return _slotCnt == N; } 24 | 25 | inline void* FirstSlot() const { 26 | Assert(_slotBegin < N); 27 | return _slotCnt == 0 ? nullptr : (void*)(_buffer + _slotBegin * S); 28 | } 29 | 30 | inline void* LastSlot() const { 31 | if (_slotCnt == 0) { 32 | return nullptr; 33 | } 34 | 35 | int lastIdx = _slotBegin + _slotCnt - 1; 36 | if (lastIdx >= N) { 37 | lastIdx -= N; 38 | } 39 | return (void*)(_buffer + lastIdx * S); 40 | } 41 | 42 | // Becareful, it never returning null for meeting the last slot 43 | // The caller must take care of the loop count 44 | inline void* NextSlot(void* curSlot) const { 45 | curSlot = (char*)curSlot + S; 46 | if (curSlot >= _buffer + N * S) { 47 | Assert(curSlot == _buffer + N * S); 48 | curSlot = (void*)(_buffer); 49 | } 50 | return curSlot; 51 | } 52 | 53 | inline void* PrevSlot(void* curSlot) const { 54 | return curSlot == _buffer ? 55 | (void*)(_buffer + N * S - S) : (void*)((char*)curSlot - S); 56 | } 57 | 58 | inline void* At(int idx) const { 59 | Assert(idx < _slotCnt); 60 | idx = _slotBegin + idx; 61 | if (idx >= N) { 62 | idx -= N; 63 | } 64 | return (void*)(_buffer + idx * S); 65 | } 66 | 67 | /* 68 | * NOTICE: AppendSlot is forbidden during iteratoring the queue in loop 69 | */ 70 | inline void* AppendSlot() { 71 | Assert(_slotCnt < N); 72 | int newIdx = _slotBegin + _slotCnt; 73 | if (newIdx >= N) { 74 | newIdx -= N; 75 | } 76 | _slotCnt++; 77 | return _buffer + newIdx * S; 78 | } 79 | 80 | inline void EraseFirstNSlot(int eraseNum) { 81 | Assert(eraseNum <= _slotCnt); 82 | _slotBegin += eraseNum; 83 | if (_slotBegin >= N) { 84 | _slotBegin -= N; 85 | } 86 | _slotCnt -= eraseNum; 87 | } 88 | 89 | inline void EraseLastNSlot(int eraseNum) { 90 | Assert(eraseNum <= _slotCnt); 91 | _slotCnt -= eraseNum; 92 | } 93 | 94 | inline void Reset() { 95 | _slotBegin = 0; 96 | _slotCnt = 0; 97 | } 98 | 99 | private: 100 | char _buffer[N * S]; 101 | int _slotBegin; 102 | int _slotCnt; 103 | }; 104 | } 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /src/misc.cpp: -------------------------------------------------------------------------------- 1 | #include "misc.h" 2 | #include "logging.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace MediaCloud::Common; 9 | 10 | namespace cppcmn { 11 | 12 | bool StartProcess(const char *binaryPath, const char *cmdline[]) 13 | { 14 | int fret = fork(); 15 | if (fret == -1) { 16 | return false; 17 | } 18 | 19 | if (fret != 0) { 20 | // ignore the child process exit signal for avoding the child zombie status 21 | signal(SIGCHLD, SIG_IGN); 22 | // parent 23 | LogInfo("misc.c", "start process - child pid: %d, ppid: %d\n", fret, getpid()); 24 | return true; 25 | } 26 | 27 | execv(binaryPath, (char* const *)cmdline); 28 | exit(0); 29 | } 30 | 31 | uint64_t GetProcessCpuAffinity() 32 | { 33 | cpu_set_t set; 34 | CPU_ZERO(&set); 35 | if (0 != sched_getaffinity(0, sizeof(set), &set)) { 36 | LogWarning("misc.c","failed to get process cpuaffinity err = %d\n", errno); 37 | return 0; 38 | } 39 | 40 | uint64_t mask = 0; 41 | for (int i = 0; i < 64; i++) { 42 | if (CPU_ISSET(i, &set)) { 43 | mask |= 1llu << i; 44 | } 45 | } 46 | LogInfo("misc.c","getting process cpuaffinity = %llu\n", mask); 47 | return mask; 48 | } 49 | 50 | struct StartThreadParam { 51 | void (*func) (void*); 52 | void *param; 53 | }; 54 | 55 | static void* StartThreadEntrance(void *param) 56 | { 57 | StartThreadParam *p = reinterpret_cast(param); 58 | p->func(p->param); 59 | delete p; 60 | return nullptr; 61 | } 62 | 63 | void StartThread(void (*func) (void*), void* param) 64 | { 65 | StartThreadParam *p = new StartThreadParam(); 66 | p->func = func; 67 | p->param = param; 68 | 69 | pthread_t tid; 70 | int ret = pthread_create(&tid, nullptr, StartThreadEntrance, p); 71 | Assert(ret == 0); 72 | } 73 | 74 | void SetCurrentThreadCpuAffinity(uint64_t cpumask) 75 | { 76 | cpu_set_t cpuset; 77 | CPU_ZERO(&cpuset); 78 | for (int i = 0; i < 64; i++) { 79 | if (cpumask & (1llu << i)) { 80 | CPU_SET(i, &cpuset); 81 | } 82 | } 83 | 84 | pthread_t tid = pthread_self(); 85 | if (pthread_setaffinity_np(tid, sizeof(cpuset), &cpuset) == -1) { 86 | LogWarning("misc.c","set curthread affinity failed, mask = %llu, tid = %u\n", cpumask, (uint32_t)tid); 87 | } 88 | else { 89 | LogDebug("misc.c","set curthread affinity mask = %llu, tid = %u\n", cpumask, (uint32_t)tid); 90 | } 91 | } 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/mstring.h: -------------------------------------------------------------------------------- 1 | #ifndef MSTRING_H 2 | #define MSTRING_H 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | typedef int mint32; 9 | typedef unsigned int muint32; 10 | typedef unsigned long long muint64; 11 | typedef string::iterator MStringIterator; 12 | class MStringList; 13 | 14 | /*! 15 | @brief extend of standard string 16 | never used in this format : 17 | string * a = new MString; 18 | delete a; 19 | this will lead to mem leak. 20 | */ 21 | 22 | class MString : public string 23 | { 24 | public: 25 | MString(); 26 | MString(const char *str); 27 | MString(const char *str, int n); 28 | MString(const string &str); 29 | //MString(const string &str, size_t pos, size_t len = npos); 30 | MString(size_t n, char c); 31 | 32 | virtual ~MString(); 33 | 34 | string toStdString(); 35 | 36 | void chop(int n); 37 | MString trimmed() const; 38 | void truncate(int position); 39 | 40 | /** 41 | * @brief C-Style sprintf 42 | * @see int vsprintf(char *str, const char *format, va_list ap) 43 | */ 44 | MString &sprintf(const char *cformat, ...); 45 | 46 | bool contains(const MString &str) const; 47 | bool contains(const string &str) const; 48 | bool contains(const char *str) const; 49 | bool contains(const char *str, size_t len) const; 50 | 51 | bool startWith(const MString &str) const; 52 | bool startWith(const string &str) const; 53 | bool startWith(const char *str) const; 54 | 55 | bool endWith(const MString &str) const; 56 | bool endWith(const string &str) const; 57 | bool endWith(const char *str) const; 58 | 59 | /** 60 | * @brief replace string 61 | * @retval *this 62 | * @snippet 63 | * Mstring a("///////a/bc////cc"); 64 | * a.replace("//", "/"); // now a = "/a/bc/c" 65 | * a.replace("//", "/", false); // a = "//////a/bc////cc" 66 | */ 67 | MString &replace(const MString &before, const MString &after, bool replaceAll = true); 68 | 69 | int toInt(bool *ok = 0, int base = 10); 70 | short toShort(bool *ok = 0, int base = 10); 71 | MString toHex(); 72 | muint64 toInt64(bool *ok = 0, int base = 10); 73 | 74 | inline bool isEmpty() const { return empty(); } 75 | 76 | MStringList split(const MString &sep); 77 | 78 | /** 79 | * prepend \a str 80 | * @snippet 81 | * MString pd("before"); 82 | * pd.prepend("123"); // pd : "123before" 83 | */ 84 | MString &prepend(const MString &str); 85 | MString &prepend(const char *str, int size); 86 | 87 | MString & operator <<(mint32 value); 88 | MString & operator <<(muint64 value); 89 | MString & operator <<(const MString &str); 90 | 91 | public: 92 | static MString number(mint32 n, int base = 10); 93 | static MString number(muint64 n, int base = 10); 94 | static MString number(size_t n, int base = 10); 95 | }; 96 | 97 | #endif // MSTRING_H 98 | -------------------------------------------------------------------------------- /src/mqthread.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPCMN_MQTHREAD_H 2 | #define _CPPCMN_MQTHREAD_H 3 | 4 | #include 5 | #include 6 | #include "socket.h" 7 | #include "clockex.h" 8 | 9 | namespace cppcmn { 10 | 11 | /* 12 | Provide internal thread socket and timer 13 | Pipe between mqthread for communication 14 | */ 15 | class MQThread { 16 | public: 17 | struct IDelegate { 18 | // return false - to quit the mq thread 19 | virtual bool HandleMQThreadCommand(int cmd, const void *param, int paramlen, Tick tick) = 0; 20 | virtual bool HandleSocketReady(const SocketPoll::ReadyItem &readyItem, Tick tick) = 0; 21 | virtual bool HandlePreSocketPoll(int &timeout) = 0; 22 | virtual bool HandlePostSocketPoll(Tick tick) = 0; 23 | }; 24 | 25 | /* 26 | attachCurrentThread: true - convert current thread into a mqthread 27 | */ 28 | static MQThread* Create(const char *name, int socketPollCapability, 29 | IDelegate *delegate, bool attachCurrentThread); 30 | static void Destory(MQThread *thread); 31 | 32 | static MQThread* GetCurrent(); 33 | 34 | /* 35 | Start infinite loop 36 | For attached current thread, never return until handler returning false 37 | For new thread, returning immediately 38 | */ 39 | void Run(); 40 | 41 | inline SocketPoll* GetSocketPoll() { return _socketPoll; } 42 | 43 | /* 44 | There must 4 bytes room before the param 45 | */ 46 | void SendCommand(int cmd, void *param, int paramlen); 47 | 48 | void SetCpuAffinity(uint64_t mask); 49 | 50 | /* 51 | Used for saving per-thread data, for example: 52 | For MEP thread, it saves all allocators for FrameMgr, Client, Quic 53 | */ 54 | inline void* GetTag() const { return _tag; } 55 | inline void SetTag(void *tag) { _tag = tag; } 56 | 57 | inline const Tick& LoopTick() const { return _tick; } 58 | 59 | private: 60 | MQThread() {} 61 | virtual ~MQThread() {} 62 | 63 | static void* MQThreadFunc(void *param); 64 | bool HandleCmdRecvSocket(const SocketPoll::ReadyItem &readyItem, Tick now); 65 | void Loop(); 66 | 67 | enum class State { 68 | Stop, 69 | Ready, 70 | Run 71 | }; 72 | 73 | State _state; 74 | std::string _name; 75 | IDelegate *_delegate; 76 | bool _attachCurrent; 77 | void *_tag; 78 | SocketPoll *_socketPoll; 79 | AsyncSocket _cmdRecvSocket; 80 | AsyncSocket _cmdSendSocket; 81 | 82 | pthread_t _tid; 83 | bool _loopEnd; 84 | 85 | uint8_t _cmdBuf[4096]; 86 | int _cmdIndex; 87 | 88 | SocketPoll::ReadyItem *_readyItems; 89 | int _readyItemNum; // capability + 1 90 | 91 | Tick _tick; 92 | }; 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/http.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_HTTP_H 3 | #define _MEDIACLOUD_HTTP_H 4 | 5 | #include 6 | #include 7 | #include "msgqueue.h" 8 | #include "socket.h" 9 | 10 | 11 | namespace MediaCloud 12 | { 13 | namespace Common 14 | { 15 | #define HTTPSTREAMRECVLEN 100000 16 | class HttpRequest : public ISocketDelegate 17 | { 18 | public: 19 | typedef struct _ResponseInfo{ 20 | unsigned int content_length; 21 | unsigned int content_fileSize; 22 | unsigned int rangeStart; 23 | unsigned int rangeEnd; 24 | }ResponseInfo; 25 | 26 | virtual ~HttpRequest(); 27 | 28 | enum Method 29 | { 30 | MethodGet, 31 | /// MethodPost, 32 | }; 33 | 34 | static HttpRequest* Create(const char *url, Method method, unsigned int timeout = 20 * 000); 35 | 36 | int Connect(bool *socket_running_flag); 37 | int Begin(Method httpMethod, char * param = NULL); 38 | int ReadResponseData(char ** buffer, int & len, ResponseInfo & resInfo); 39 | int ReadData(char **buffer, ResponseInfo & resInfo); 40 | int End(); 41 | 42 | bool GetIP(char *& localIP, char *& remoteIP); 43 | 44 | protected: 45 | 46 | /// ISocketDelegate 47 | virtual void HandleSocketEvent(AsyncSocket *socket, Event sockEvent); 48 | 49 | private: 50 | HttpRequest(const char *url, const char *hostname, Method method, 51 | unsigned int timeout); 52 | 53 | 54 | void CompleteRequest(int sockErr); 55 | bool SendRequest(char * param = NULL); 56 | int ParseHeader(char buf[], int bufLeng,const char**datastartpos, char *& nParam, unsigned int & nParamLen, unsigned int & rangeStart, unsigned int & rangeEnd); 57 | int GetChunk(const char*buff,int len,int*chunksize,int*countchunksize); 58 | enum 59 | { 60 | HttpMsgTimeout = 21 61 | }; 62 | 63 | enum HttpStatus 64 | { 65 | HttpNone, 66 | HttpConnecting, 67 | HttpRecving, 68 | HttpClosed, 69 | } _status; 70 | 71 | std::string _url; 72 | std::string _hostname; 73 | Method _method; 74 | unsigned int _timeout; 75 | AsyncSocket *_socket; 76 | bool _checkhttp; 77 | char _recvBuffer[HTTPSTREAMRECVLEN]; 78 | char _chunckBuffer[HTTPSTREAMRECVLEN]; 79 | int _fileSize;//远端文件总长度 80 | int _receiveFilelength;//本次请求文件总长 81 | int _chuncksize;//分片大小 82 | int _countchunksize;//累计分片字节数 83 | int _usechunk;//是否使用分片 84 | }; 85 | } 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /include/google/protobuf/util/type_resolver.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__ 32 | #define GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | 40 | namespace google { 41 | namespace protobuf { 42 | class Type; 43 | class Enum; 44 | } // namespace protobuf 45 | 46 | 47 | namespace protobuf { 48 | class DescriptorPool; 49 | namespace util { 50 | 51 | // Abstract interface for a type resovler. 52 | // 53 | // Implementations of this interface must be thread-safe. 54 | class LIBPROTOBUF_EXPORT TypeResolver { 55 | public: 56 | TypeResolver() {} 57 | virtual ~TypeResolver() {} 58 | 59 | // Resolves a type url for a message type. 60 | virtual util::Status ResolveMessageType( 61 | const string& type_url, google::protobuf::Type* message_type) = 0; 62 | 63 | // Resolves a type url for an enum type. 64 | virtual util::Status ResolveEnumType(const string& type_url, 65 | google::protobuf::Enum* enum_type) = 0; 66 | 67 | private: 68 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeResolver); 69 | }; 70 | 71 | } // namespace util 72 | } // namespace protobuf 73 | 74 | } // namespace google 75 | #endif // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__ 76 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/protocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // protocol.h 3 | // Main 4 | // 5 | // Created by 姜元福 on 15/12/2. 6 | // Copyright © 2015年 姜元福. All rights reserved. 7 | // 8 | 9 | #ifndef protocol_h 10 | #define protocol_h 11 | 12 | #include 13 | #include 14 | #include 15 | #ifdef __APPLE__ 16 | #include 17 | #include 18 | #endif 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | using namespace std; 25 | 26 | typedef struct{ 27 | unsigned int year; 28 | char month; 29 | char day; 30 | char hour; 31 | char minite; 32 | char second; 33 | unsigned int milliSecond; 34 | }MsgTime; 35 | 36 | typedef struct _TimeFilter{ 37 | unsigned int ID; 38 | unsigned int filterTime; 39 | }TimeFilter; 40 | 41 | MsgTime CreateMsgTime(); 42 | MsgTime CreateMsgTime(struct timeval & tv, struct timezone & tz, struct tm *& p); 43 | 44 | bool Compare(const MsgTime info1, const MsgTime info2); 45 | bool operator==(const MsgTime info1, const MsgTime info2); 46 | bool operator!=(const MsgTime info1, const MsgTime info2); 47 | 48 | void PrintfLog(char * src, char *& dst, bool ms=false); 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | bool AbsolutePath(string path, string & absolutePath); 55 | bool GetCurrentDir(string & path); 56 | extern bool GetWorkDir(string & path); 57 | 58 | class MTime 59 | { 60 | public: 61 | MTime(unsigned long long time = 0); 62 | virtual ~MTime(); 63 | 64 | string GetStr(); 65 | static string GetStr(unsigned long long time); 66 | 67 | unsigned int day; 68 | unsigned int hour; 69 | unsigned int min; 70 | unsigned int sec; 71 | 72 | private: 73 | void Init(); 74 | 75 | private: 76 | unsigned long long m_time; 77 | string m_str; 78 | }; 79 | 80 | class SaveFile 81 | { 82 | public: 83 | SaveFile(char * fileName, char * mode = NULL); 84 | virtual ~SaveFile(); 85 | 86 | bool Write(char * data, unsigned int len); 87 | bool Write(string str); 88 | void Flush(); 89 | 90 | private: 91 | FILE * m_file; 92 | pthread_mutex_t m_mutex; 93 | }; 94 | 95 | class BandWidth 96 | { 97 | public: 98 | BandWidth(unsigned long long bits = 0); 99 | virtual ~BandWidth(); 100 | 101 | string GetStr(); 102 | static string GetStr(unsigned long long bits); 103 | static float KB(unsigned long long bits); 104 | 105 | unsigned int tb; 106 | unsigned int gb; 107 | unsigned int mb; 108 | unsigned int kb; 109 | 110 | private: 111 | void Init(); 112 | private: 113 | unsigned long long m_bits; 114 | }; 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* protocol_h */ 121 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/fecrq/fecrq.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_FECRQ_H 3 | #define _MEDIACLOUD_FECRQ_H 4 | 5 | #include 6 | #include 7 | #include "fecrqm.h" 8 | 9 | /// raptorQ rfc6330 implementation 10 | class FECRQEncoder 11 | { 12 | public: 13 | 14 | FECRQEncoder(const uint8_t data[], int length, int symbolSize); 15 | // caller quarantee the last src symbol has zero padding !! 16 | FECRQEncoder(const uint8_t* symbols[], int payloadLength, int symbolSize); 17 | virtual ~FECRQEncoder(); 18 | 19 | int NumOfSourceSymbols() const { return _param.K; } 20 | int SymbolSize() const { return _param.T; } 21 | 22 | // length >= symbolSize 23 | // esi < K is source symbols; otherwise it is repair symbols 24 | // if K * symbolSize > length, the last source symbol will be padded with zero. 25 | void GetEncodedSymbols(int esi, uint8_t data[]); 26 | 27 | // used to create the intermediate symbols explicitly 28 | void ForceEncoding(); 29 | 30 | private: 31 | FECRQEncoder(const FECRQParam::Param ¶m, FECRQVector &cSymbols, int length); 32 | void GenerateCSymbols(); 33 | 34 | uint8_t *_dbuf; 35 | int _length; // the real length; 36 | FECRQParam::Param _param; 37 | FECRQVector _cSymbols; 38 | FECRQMatrix _coreMatrix; 39 | 40 | friend class FECRQDecoder; 41 | }; 42 | 43 | class FECRQDecoder 44 | { 45 | public: 46 | 47 | // overload determine when to start real decoding process 48 | FECRQDecoder(int dataLength, int symbolSize, int numOfSourceSymbols, int overload); 49 | virtual ~FECRQDecoder(); 50 | 51 | int SymbolSize() const { return _param.T; } 52 | int NumOfSourceSymbols() const { return _param.K; } 53 | int DataLength() const { return _dataLength; } 54 | 55 | // for server decoding 56 | // symbols is the pointer to symbol data from esi is [0 - esiEnd) 57 | // no symbol have nullprt in symbols[], symbolNum is the pointer number in symbols[] 58 | static FECRQEncoder* Decode(int dataLength, int symbolSize, 59 | const uint8_t* symbols[], uint16_t symbolNum, uint16_t esiEnd); 60 | 61 | // this is another way to decode for client 62 | // symbols is a buffer that has format of symbolNum pairs of | 2byte esi | symbol data | 63 | // the last src symbol has zero padding !! 64 | static uint8_t* Decode(int dataLength, int symbolSize, 65 | const uint8_t* symbols, uint16_t symbolNum); 66 | 67 | // the data length >= symbolSize 68 | // returning true if the decoding successfully completed 69 | bool AddEncodedSymbols(int esi, const uint8_t data[]); 70 | 71 | // esi < numOfSourceSymbols 72 | // returning buffer pointer directly 73 | const uint8_t* GetSourceSymbols(int esi) const; 74 | 75 | const uint8_t* GetBuffer() const { return _data; } 76 | 77 | private: 78 | void TryDecoding(); 79 | 80 | uint8_t *_data; // only save the K source symbols 81 | FECRQParam::Param _param; 82 | int _overload; 83 | uint8_t *_sourceSymbolMask; 84 | int _sourceSymbolNum; 85 | int _dataLength; 86 | std::vector> _repairSymbols; 87 | }; 88 | 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/fecrq/fecrqa.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "fecrqm.h" 3 | #include 4 | 5 | // creating A 6 | FECRQMatrix GenCoreMatrix(const FECRQParam::Param ¶m, int overload) 7 | { 8 | assert(overload >= 0); 9 | uint8_t *data = new uint8_t[param.L * (param.L + overload)]; 10 | memset(data, 0, param.L * (param.L + overload)); 11 | FECRQMatrix A(data, param.L + overload, param.L, true); 12 | 13 | // LDPC1 & Identity [B, S] & LDPC2 14 | for (int row = 0; row < param.S; ++row) 15 | { 16 | for (int col = 0; col < param.B; ++col) 17 | { 18 | uint16_t submtx = col / param.S; 19 | if ((row == (col % param.S)) || (row == (col + submtx + 1) % param.S) || (row == (col + 2 * (submtx + 1)) % param.S)) 20 | { 21 | A.SetAt(row, col, 1); 22 | } 23 | } 24 | 25 | A.SetAt(row, param.B + row, 1); 26 | 27 | for (int col = 0; col < param.P; ++col) 28 | { 29 | if (col == (row % param.P) || col == ((row + 1) % param.P)) 30 | A.SetAt(row, col + param.W, 1); 31 | } 32 | } 33 | 34 | // HDPC 35 | // make MT 36 | uint8_t *mtdata = new uint8_t[param.H * (param.KP + param.S)]; 37 | FECRQMatrix MT(mtdata, param.H, param.KP + param.S, true); 38 | for (int row = 0; row < param.H; ++row) 39 | { 40 | int col = 0; 41 | for (; col < param.KP + param.S - 1; ++col) 42 | { 43 | uint32_t tmp = FECRQParam::Rand(col + 1, 6, param.H); 44 | if ((row == tmp) || (row == (tmp + FECRQParam::Rand(col + 1, 7, param.H - 1) + 1) % param.H)) 45 | MT.SetAt(row, col, 1); 46 | else 47 | MT.SetAt(row, col, 0); 48 | } 49 | // last column: alpha ^^ i, as in rfc6330 50 | MT.SetAt(row, col, fecOCT_EXP[row]); 51 | } 52 | // make GAMMA 53 | uint8_t *gammadata = new uint8_t[(param.KP + param.S) * (param.KP + param.S)]; 54 | FECRQMatrix GAMMA(gammadata, param.KP + param.S, param.KP + param.S, true); 55 | for (int row = 0; row < param.KP + param.S; ++row) 56 | { 57 | int col = 0; 58 | for (; col <= row; ++col) 59 | // alpha ^^ (i-j), as in rfc6330, pg24 60 | // rfc only says "i-j", but we could go well over oct_exp size. 61 | // we hope they just missed a modulus :/ 62 | GAMMA.SetAt(row, col, fecOCT_EXP[row - col]); 63 | 64 | for (; col < param.KP + param.S; ++col) 65 | GAMMA.SetAt(row, col, 0); 66 | } 67 | 68 | // A[HDPC] = MT * GAMMA 69 | A.MulMatrix2(MT, GAMMA, param.S, param.H, param.KP + param.S); 70 | 71 | // Identity [H, L - H] 72 | for (int row = 0; row < param.H; ++row) 73 | A.SetAt(param.S + row, param.KP + param.S + row, 1); 74 | 75 | // G_ENC 76 | uint16_t idxes[128]; 77 | for (int row = param.S + param.H; row < param.L; ++row) 78 | { 79 | int idxnum = FECRQParam::GetEncodedIntermediateSymbolIdx(param, row - param.S - param.H, idxes, 128); 80 | for (int j = 0; j < idxnum; j++) 81 | A.SetAt(row, idxes[j], 1); 82 | } 83 | 84 | return A; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /include/google/protobuf/stubs/atomicops_internals_pnacl.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2012 Google Inc. All rights reserved. 3 | // http://code.google.com/p/protobuf/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // This file is an internal atomic implementation, use atomicops.h instead. 32 | 33 | #ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ 34 | #define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ 35 | 36 | namespace google { 37 | namespace protobuf { 38 | namespace internal { 39 | 40 | inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, 41 | Atomic32 old_value, 42 | Atomic32 new_value) { 43 | return __sync_val_compare_and_swap(ptr, old_value, new_value); 44 | } 45 | 46 | inline void MemoryBarrier() { 47 | __sync_synchronize(); 48 | } 49 | 50 | inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, 51 | Atomic32 old_value, 52 | Atomic32 new_value) { 53 | Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value); 54 | MemoryBarrier(); 55 | return ret; 56 | } 57 | 58 | inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { 59 | MemoryBarrier(); 60 | *ptr = value; 61 | } 62 | 63 | inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { 64 | Atomic32 value = *ptr; 65 | MemoryBarrier(); 66 | return value; 67 | } 68 | 69 | } // namespace internal 70 | } // namespace protobuf 71 | } // namespace google 72 | 73 | #endif // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_ 74 | -------------------------------------------------------------------------------- /include/rapidjson/internal/ieee754.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_IEEE754_ 16 | #define RAPIDJSON_IEEE754_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | class Double { 24 | public: 25 | Double() {} 26 | Double(double d) : d(d) {} 27 | Double(uint64_t u) : u(u) {} 28 | 29 | double Value() const { return d; } 30 | uint64_t Uint64Value() const { return u; } 31 | 32 | double NextPositiveDouble() const { 33 | RAPIDJSON_ASSERT(!Sign()); 34 | return Double(u + 1).Value(); 35 | } 36 | 37 | bool Sign() const { return (u & kSignMask) != 0; } 38 | uint64_t Significand() const { return u & kSignificandMask; } 39 | int Exponent() const { return ((u & kExponentMask) >> kSignificandSize) - kExponentBias; } 40 | 41 | bool IsNan() const { return (u & kExponentMask) == kExponentMask && Significand() != 0; } 42 | bool IsInf() const { return (u & kExponentMask) == kExponentMask && Significand() == 0; } 43 | bool IsNormal() const { return (u & kExponentMask) != 0 || Significand() == 0; } 44 | bool IsZero() const { return (u & (kExponentMask | kSignificandMask)) == 0; } 45 | 46 | uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); } 47 | int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; } 48 | uint64_t ToBias() const { return (u & kSignMask) ? ~u + 1 : u | kSignMask; } 49 | 50 | static unsigned EffectiveSignificandSize(int order) { 51 | if (order >= -1021) 52 | return 53; 53 | else if (order <= -1074) 54 | return 0; 55 | else 56 | return order + 1074; 57 | } 58 | 59 | private: 60 | static const int kSignificandSize = 52; 61 | static const int kExponentBias = 0x3FF; 62 | static const int kDenormalExponent = 1 - kExponentBias; 63 | static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000); 64 | static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); 65 | static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); 66 | static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); 67 | 68 | union { 69 | double d; 70 | uint64_t u; 71 | }; 72 | }; 73 | 74 | } // namespace internal 75 | RAPIDJSON_NAMESPACE_END 76 | 77 | #endif // RAPIDJSON_IEEE754_ 78 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/buffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // buffer.cpp 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 15/1/6. 6 | // Copyright (c) 2015年 smyk. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "../include/common.h" 14 | 15 | using namespace MediaCloud::Common; 16 | struct BufferHeader 17 | { 18 | uint32_t headSignature; 19 | uint32_t tailPos; 20 | }; 21 | 22 | struct BufferTail 23 | { 24 | uint32_t tailSignature; 25 | }; 26 | 27 | static uint32_t gHeadSignature = 0xEAAEEAAE; 28 | static uint32_t gTailSignature = 0xCDCEECDC; 29 | 30 | void* MediaCloud::Common::AllocBuffer(uint32_t size, bool clear, int alignment) 31 | { 32 | uint32_t realsize = sizeof(BufferHeader) + sizeof(BufferTail) + size + sizeof(uintptr_t) + alignment - 1; 33 | if (size > 0) 34 | { 35 | BufferHeader *header = (BufferHeader*)malloc(realsize); 36 | AssertMsg(header != NULL, "Alloc Failed with size", size); 37 | header->headSignature = gHeadSignature; 38 | uintptr_t alignStartPos = (uintptr_t)(header + 1); 39 | alignStartPos += sizeof(uintptr_t); 40 | uintptr_t alignedPos = (alignStartPos + alignment - 1) & ~(alignment - 1); 41 | void* alignedPointer = (void*)alignedPos; 42 | 43 | uintptr_t subHeaderPos = alignedPos - sizeof(uintptr_t); 44 | void* SubHeaderPointer = (void*) subHeaderPos; 45 | memcpy(SubHeaderPointer, &header, sizeof(uintptr_t)); 46 | 47 | if (clear) 48 | memset(alignedPointer, 0, size); 49 | 50 | header->tailPos = realsize - sizeof(BufferTail); 51 | BufferTail *tail = (BufferTail*)((char*)header + header->tailPos); 52 | tail->tailSignature = gTailSignature; 53 | return alignedPointer; 54 | } 55 | 56 | return NULL; 57 | } 58 | 59 | void MediaCloud::Common::FreeBuffer(void *buffer) 60 | { 61 | if (buffer) 62 | { 63 | uintptr_t alignedPos = (uintptr_t)buffer; 64 | uintptr_t subHeaderPos = alignedPos - sizeof(uintptr_t); 65 | 66 | uintptr_t memoryStartPos = *(uintptr_t*)subHeaderPos; 67 | BufferHeader* header = (BufferHeader*)memoryStartPos; 68 | AssertMsg(header->headSignature == gHeadSignature , "signature"); 69 | 70 | uint32_t tailPos = header->tailPos; 71 | BufferTail *tail = (BufferTail*)((char*)header + tailPos); 72 | AssertMsg(tail->tailSignature == gTailSignature, "signaturetail"); 73 | free(header); 74 | } 75 | } 76 | 77 | 78 | BufferCache* BufferCache::Create(int size) 79 | { 80 | return new BufferCache(size); 81 | } 82 | 83 | BufferCache::BufferCache(int size) 84 | { 85 | _bufSize = size; 86 | } 87 | 88 | BufferCache::~BufferCache() 89 | { 90 | } 91 | 92 | void *BufferCache::Allocate(bool clear, int alignment) 93 | { 94 | return AllocBuffer(_bufSize, clear, alignment); 95 | } 96 | 97 | void BufferCache::Free(void *buffer) 98 | { 99 | return FreeBuffer(buffer); 100 | } 101 | 102 | int BufferCache::BufferSize() const 103 | { 104 | return _bufSize; 105 | } 106 | -------------------------------------------------------------------------------- /include/google/protobuf/compiler/java/java_generator.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // http://code.google.com/p/protobuf/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // Generates Java code for a given .proto file. 36 | 37 | #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ 38 | #define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ 39 | 40 | #include 41 | #include 42 | 43 | namespace google { 44 | namespace protobuf { 45 | namespace compiler { 46 | namespace java { 47 | 48 | // CodeGenerator implementation which generates Java code. If you create your 49 | // own protocol compiler binary and you want it to support Java output, you 50 | // can do so by registering an instance of this CodeGenerator with the 51 | // CommandLineInterface in your main() function. 52 | class LIBPROTOC_EXPORT JavaGenerator : public CodeGenerator { 53 | public: 54 | JavaGenerator(); 55 | ~JavaGenerator(); 56 | 57 | // implements CodeGenerator ---------------------------------------- 58 | bool Generate(const FileDescriptor* file, 59 | const string& parameter, 60 | GeneratorContext* context, 61 | string* error) const; 62 | 63 | private: 64 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator); 65 | }; 66 | 67 | } // namespace java 68 | } // namespace compiler 69 | } // namespace protobuf 70 | 71 | } // namespace google 72 | #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__ 73 | -------------------------------------------------------------------------------- /include/google/protobuf/compiler/cpp/cpp_generator.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // http://code.google.com/p/protobuf/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // Generates C++ code for a given .proto file. 36 | 37 | #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ 38 | #define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ 39 | 40 | #include 41 | #include 42 | 43 | namespace google { 44 | namespace protobuf { 45 | namespace compiler { 46 | namespace cpp { 47 | 48 | // CodeGenerator implementation which generates a C++ source file and 49 | // header. If you create your own protocol compiler binary and you want 50 | // it to support C++ output, you can do so by registering an instance of this 51 | // CodeGenerator with the CommandLineInterface in your main() function. 52 | class LIBPROTOC_EXPORT CppGenerator : public CodeGenerator { 53 | public: 54 | CppGenerator(); 55 | ~CppGenerator(); 56 | 57 | // implements CodeGenerator ---------------------------------------- 58 | bool Generate(const FileDescriptor* file, 59 | const string& parameter, 60 | GeneratorContext* generator_context, 61 | string* error) const; 62 | 63 | private: 64 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator); 65 | }; 66 | 67 | } // namespace cpp 68 | } // namespace compiler 69 | } // namespace protobuf 70 | 71 | } // namespace google 72 | #endif // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__ 73 | -------------------------------------------------------------------------------- /include/google/protobuf/stubs/platform_macros.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2012 Google Inc. All rights reserved. 3 | // http://code.google.com/p/protobuf/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_PLATFORM_MACROS_H_ 32 | #define GOOGLE_PROTOBUF_PLATFORM_MACROS_H_ 33 | 34 | #include 35 | 36 | // Processor architecture detection. For more info on what's defined, see: 37 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 38 | // http://www.agner.org/optimize/calling_conventions.pdf 39 | // or with gcc, run: "echo | gcc -E -dM -" 40 | #if defined(_M_X64) || defined(__x86_64__) 41 | #define GOOGLE_PROTOBUF_ARCH_X64 1 42 | #define GOOGLE_PROTOBUF_ARCH_64_BIT 1 43 | #elif defined(_M_IX86) || defined(__i386__) 44 | #define GOOGLE_PROTOBUF_ARCH_IA32 1 45 | #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 46 | #elif defined(__QNX__) 47 | #define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1 48 | #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 49 | #elif defined(__ARMEL__) 50 | #define GOOGLE_PROTOBUF_ARCH_ARM 1 51 | #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 52 | #elif defined(__MIPSEL__) 53 | #define GOOGLE_PROTOBUF_ARCH_MIPS 1 54 | #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 55 | #elif defined(__pnacl__) 56 | #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 57 | #elif defined(__ppc__) 58 | #define GOOGLE_PROTOBUF_ARCH_PPC 1 59 | #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 60 | #else 61 | #error Host architecture was not detected as supported by protobuf 62 | #endif 63 | 64 | #if defined(__APPLE__) 65 | #define GOOGLE_PROTOBUF_OS_APPLE 66 | #elif defined(__native_client__) 67 | #define GOOGLE_PROTOBUF_OS_NACL 68 | #endif 69 | 70 | #endif // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_ 71 | -------------------------------------------------------------------------------- /include/rapidjson/filereadstream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEREADSTREAM_H_ 16 | #define RAPIDJSON_FILEREADSTREAM_H_ 17 | 18 | #include "rapidjson.h" 19 | #include 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! File byte stream for input using fread(). 24 | /*! 25 | \note implements Stream concept 26 | */ 27 | class FileReadStream { 28 | public: 29 | typedef char Ch; //!< Character type (byte). 30 | 31 | //! Constructor. 32 | /*! 33 | \param fp File pointer opened for read. 34 | \param buffer user-supplied buffer. 35 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 36 | */ 37 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 38 | RAPIDJSON_ASSERT(fp_ != 0); 39 | RAPIDJSON_ASSERT(bufferSize >= 4); 40 | Read(); 41 | } 42 | 43 | Ch Peek() const { return *current_; } 44 | Ch Take() { Ch c = *current_; Read(); return c; } 45 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 46 | 47 | // Not implemented 48 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 49 | void Flush() { RAPIDJSON_ASSERT(false); } 50 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 51 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 52 | 53 | // For encoding detection only. 54 | const Ch* Peek4() const { 55 | return (current_ + 4 <= bufferLast_) ? current_ : 0; 56 | } 57 | 58 | private: 59 | void Read() { 60 | if (current_ < bufferLast_) 61 | ++current_; 62 | else if (!eof_) { 63 | count_ += readCount_; 64 | readCount_ = fread(buffer_, 1, bufferSize_, fp_); 65 | bufferLast_ = buffer_ + readCount_ - 1; 66 | current_ = buffer_; 67 | 68 | if (readCount_ < bufferSize_) { 69 | buffer_[readCount_] = '\0'; 70 | ++bufferLast_; 71 | eof_ = true; 72 | } 73 | } 74 | } 75 | 76 | std::FILE* fp_; 77 | Ch *buffer_; 78 | size_t bufferSize_; 79 | Ch *bufferLast_; 80 | Ch *current_; 81 | size_t readCount_; 82 | size_t count_; //!< Number of characters read 83 | bool eof_; 84 | }; 85 | 86 | RAPIDJSON_NAMESPACE_END 87 | 88 | #endif // RAPIDJSON_FILESTREAM_H_ 89 | -------------------------------------------------------------------------------- /include/rapidjson/filewritestream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEWRITESTREAM_H_ 16 | #define RAPIDJSON_FILEWRITESTREAM_H_ 17 | 18 | #include "rapidjson.h" 19 | #include 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Wrapper of C file stream for input using fread(). 24 | /*! 25 | \note implements Stream concept 26 | */ 27 | class FileWriteStream { 28 | public: 29 | typedef char Ch; //!< Character type. Only support char. 30 | 31 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { 32 | RAPIDJSON_ASSERT(fp_ != 0); 33 | } 34 | 35 | void Put(char c) { 36 | if (current_ >= bufferEnd_) 37 | Flush(); 38 | 39 | *current_++ = c; 40 | } 41 | 42 | void PutN(char c, size_t n) { 43 | size_t avail = static_cast(bufferEnd_ - current_); 44 | while (n > avail) { 45 | std::memset(current_, c, avail); 46 | current_ += avail; 47 | Flush(); 48 | n -= avail; 49 | avail = static_cast(bufferEnd_ - current_); 50 | } 51 | 52 | if (n > 0) { 53 | std::memset(current_, c, n); 54 | current_ += n; 55 | } 56 | } 57 | 58 | void Flush() { 59 | if (current_ != buffer_) { 60 | fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); 61 | current_ = buffer_; 62 | } 63 | } 64 | 65 | // Not implemented 66 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 67 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 68 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 69 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 70 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 71 | 72 | private: 73 | // Prohibit copy constructor & assignment operator. 74 | FileWriteStream(const FileWriteStream&); 75 | FileWriteStream& operator=(const FileWriteStream&); 76 | 77 | std::FILE* fp_; 78 | char *buffer_; 79 | char *bufferEnd_; 80 | char *current_; 81 | }; 82 | 83 | //! Implement specialized version of PutN() with memset() for better performance. 84 | template<> 85 | inline void PutN(FileWriteStream& stream, char c, size_t n) { 86 | stream.PutN(c, n); 87 | } 88 | 89 | RAPIDJSON_NAMESPACE_END 90 | 91 | #endif // RAPIDJSON_FILESTREAM_H_ 92 | -------------------------------------------------------------------------------- /include/google/protobuf/compiler/java/java_names.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // Provides a mechanism for mapping a descriptor to the 36 | // fully-qualified name of the corresponding Java class. 37 | 38 | #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__ 39 | #define GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__ 40 | 41 | #include 42 | 43 | namespace google { 44 | namespace protobuf { 45 | 46 | class Descriptor; 47 | class EnumDescriptor; 48 | class FileDescriptor; 49 | class ServiceDescriptor; 50 | 51 | namespace compiler { 52 | namespace java { 53 | 54 | // Requires: 55 | // descriptor != NULL 56 | // 57 | // Returns: 58 | // The fully-qualified Java class name. 59 | string ClassName(const Descriptor* descriptor); 60 | 61 | // Requires: 62 | // descriptor != NULL 63 | // 64 | // Returns: 65 | // The fully-qualified Java class name. 66 | string ClassName(const EnumDescriptor* descriptor); 67 | 68 | // Requires: 69 | // descriptor != NULL 70 | // 71 | // Returns: 72 | // The fully-qualified Java class name. 73 | string ClassName(const FileDescriptor* descriptor); 74 | 75 | // Requires: 76 | // descriptor != NULL 77 | // 78 | // Returns: 79 | // The fully-qualified Java class name. 80 | string ClassName(const ServiceDescriptor* descriptor); 81 | 82 | } // namespace java 83 | } // namespace compiler 84 | } // namespace protobuf 85 | } // namespace google 86 | 87 | #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__ 88 | -------------------------------------------------------------------------------- /include/google/protobuf/compiler/javanano/javanano_generator.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // http://code.google.com/p/protobuf/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // Generates Java nano code for a given .proto file. 36 | 37 | #ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__ 38 | #define GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__ 39 | 40 | #include 41 | #include 42 | 43 | namespace google { 44 | namespace protobuf { 45 | namespace compiler { 46 | namespace javanano { 47 | 48 | // CodeGenerator implementation which generates Java nano code. If you create your 49 | // own protocol compiler binary and you want it to support Java output for the 50 | // nano runtime, you can do so by registering an instance of this CodeGenerator with 51 | // the CommandLineInterface in your main() function. 52 | class LIBPROTOC_EXPORT JavaNanoGenerator : public CodeGenerator { 53 | public: 54 | JavaNanoGenerator(); 55 | ~JavaNanoGenerator(); 56 | 57 | // implements CodeGenerator ---------------------------------------- 58 | bool Generate(const FileDescriptor* file, 59 | const string& parameter, 60 | GeneratorContext* output_directory, 61 | string* error) const; 62 | 63 | private: 64 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaNanoGenerator); 65 | }; 66 | 67 | } // namespace javanano 68 | } // namespace compiler 69 | } // namespace protobuf 70 | 71 | } // namespace google 72 | #endif // GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__ 73 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/clock.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include "../include/clock.h" 5 | using namespace MediaCloud::Common; 6 | 7 | #if defined(WIN32) 8 | #include 9 | 10 | int64_t _tick_per_secs = 0; 11 | void InitializeClock() { 12 | LARGE_INTEGER largeInt; 13 | QueryPerformanceFrequency(&largeInt); 14 | _tick_per_secs = largeInt.QuadPart; 15 | } 16 | 17 | enum : int64_t { kQPCOverflowThreshold = 0x8637BD05AF7 }; 18 | Clock::Tick Clock::Now() { 19 | 20 | Clock::Tick now; 21 | LARGE_INTEGER perf_counter_now = {}; 22 | QueryPerformanceCounter(&perf_counter_now); 23 | 24 | // If the QPC Value is below the overflow threshold, we proceed with 25 | // simple multiply and divide. 26 | if (perf_counter_now.QuadPart < kQPCOverflowThreshold) { 27 | now = perf_counter_now.QuadPart * 1000000 / _tick_per_secs; 28 | } 29 | 30 | // Otherwise, calculate microseconds in a round about manner to avoid 31 | // overflow and precision issues. 32 | int64_t whole_seconds = perf_counter_now.QuadPart / _tick_per_secs; 33 | int64_t leftover_ticks = perf_counter_now.QuadPart - (whole_seconds * _tick_per_secs); 34 | now = (whole_seconds * 1000000) + ((leftover_ticks * 1000000) / _tick_per_secs); 35 | 36 | //LogVerbose("clock", "now = %lld\n", now); 37 | return now; 38 | } 39 | #endif 40 | 41 | #if defined(ANDROID) || defined(POSIX) 42 | #include 43 | Clock::Tick Clock::Now() { 44 | struct timespec ts; 45 | if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { 46 | return 0; 47 | } 48 | return (int64_t)ts.tv_sec * 1000000 + (int64_t)ts.tv_nsec / 1000; 49 | } 50 | #endif 51 | 52 | #if defined(IOS) || defined(MACOSX) 53 | // https://developer.apple.com/library/mac/qa/qa1398/_index.html 54 | #include 55 | #include 56 | #include 57 | #include 58 | Clock::Tick Clock::Now() { 59 | uint64_t start; 60 | uint64_t end; 61 | uint64_t elapsed; 62 | uint64_t elapsedNano; 63 | static mach_timebase_info_data_t sTimebaseInfo; 64 | 65 | // Start the clock. 66 | 67 | start = mach_absolute_time(); 68 | 69 | // Call getpid. This will produce inaccurate results because 70 | // we're only making a single system call. For more accurate 71 | // results you should call getpid multiple times and average 72 | // the results. 73 | 74 | (void) getpid(); 75 | 76 | // Stop the clock. 77 | 78 | end = mach_absolute_time(); 79 | 80 | // Calculate the duration. 81 | 82 | elapsed = end - start; 83 | 84 | // Convert to nanoseconds. 85 | 86 | // If this is the first time we've run, get the timebase. 87 | // We can use denom == 0 to indicate that sTimebaseInfo is 88 | // uninitialised because it makes no sense to have a zero 89 | // denominator is a fraction. 90 | 91 | if ( sTimebaseInfo.denom == 0 ) { 92 | (void) mach_timebase_info(&sTimebaseInfo); 93 | } 94 | 95 | // Do the maths. We hope that the multiplication doesn't 96 | // overflow; the price you pay for working in fixed point. 97 | 98 | elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom; 99 | 100 | return elapsedNano; 101 | } 102 | #endif 103 | -------------------------------------------------------------------------------- /include/google/protobuf/generated_message_util.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // http://code.google.com/p/protobuf/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // Based on original Protocol Buffers design by 33 | // Sanjay Ghemawat, Jeff Dean, and others. 34 | // 35 | // This file contains miscellaneous helper code used by generated code -- 36 | // including lite types -- but which should not be used directly by users. 37 | 38 | #ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ 39 | #define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ 40 | 41 | #include 42 | 43 | #include 44 | namespace google { 45 | namespace protobuf { 46 | namespace internal { 47 | 48 | // Annotation for the compiler to emit a deprecation message if a field marked 49 | // with option 'deprecated=true' is used in the code, or for other things in 50 | // generated code which are deprecated. 51 | // 52 | // For internal use in the pb.cc files, deprecation warnings are suppressed 53 | // there. 54 | #undef DEPRECATED_PROTOBUF_FIELD 55 | #define PROTOBUF_DEPRECATED 56 | 57 | 58 | // Constants for special floating point values. 59 | LIBPROTOBUF_EXPORT double Infinity(); 60 | LIBPROTOBUF_EXPORT double NaN(); 61 | 62 | // Constant used for empty default strings. 63 | LIBPROTOBUF_EXPORT extern const ::std::string kEmptyString; 64 | 65 | // Defined in generated_message_reflection.cc -- not actually part of the lite 66 | // library. 67 | // 68 | // TODO(jasonh): The various callers get this declaration from a variety of 69 | // places: probably in most cases repeated_field.h. Clean these up so they all 70 | // get the declaration from this file. 71 | LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str); 72 | 73 | } // namespace internal 74 | } // namespace protobuf 75 | 76 | } // namespace google 77 | #endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__ 78 | -------------------------------------------------------------------------------- /include/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_STRINGBUFFER_H_ 16 | #define RAPIDJSON_STRINGBUFFER_H_ 17 | 18 | #include "rapidjson.h" 19 | 20 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 21 | #include // std::move 22 | #endif 23 | 24 | #include "internal/stack.h" 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Represents an in-memory output stream. 29 | /*! 30 | \tparam Encoding Encoding of the stream. 31 | \tparam Allocator type for allocating memory buffer. 32 | \note implements Stream concept 33 | */ 34 | template 35 | class GenericStringBuffer { 36 | public: 37 | typedef typename Encoding::Ch Ch; 38 | 39 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 40 | 41 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 42 | GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {} 43 | GenericStringBuffer& operator=(GenericStringBuffer&& rhs) { 44 | if (&rhs != this) 45 | stack_ = std::move(rhs.stack_); 46 | return *this; 47 | } 48 | #endif 49 | 50 | void Put(Ch c) { *stack_.template Push() = c; } 51 | void Flush() {} 52 | 53 | void Clear() { stack_.Clear(); } 54 | void ShrinkToFit() { 55 | // Push and pop a null terminator. This is safe. 56 | *stack_.template Push() = '\0'; 57 | stack_.ShrinkToFit(); 58 | stack_.template Pop(1); 59 | } 60 | Ch* Push(size_t count) { return stack_.template Push(count); } 61 | void Pop(size_t count) { stack_.template Pop(count); } 62 | 63 | const Ch* GetString() const { 64 | // Push and pop a null terminator. This is safe. 65 | *stack_.template Push() = '\0'; 66 | stack_.template Pop(1); 67 | 68 | return stack_.template Bottom(); 69 | } 70 | 71 | size_t GetSize() const { return stack_.GetSize(); } 72 | 73 | static const size_t kDefaultCapacity = 256; 74 | mutable internal::Stack stack_; 75 | 76 | private: 77 | // Prohibit copy constructor & assignment operator. 78 | GenericStringBuffer(const GenericStringBuffer&); 79 | GenericStringBuffer& operator=(const GenericStringBuffer&); 80 | }; 81 | 82 | //! String buffer with UTF8 encoding 83 | typedef GenericStringBuffer > StringBuffer; 84 | 85 | //! Implement specialized version of PutN() with memset() for better performance. 86 | template<> 87 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 88 | std::memset(stream.stack_.Push(n), c, n * sizeof(c)); 89 | } 90 | 91 | RAPIDJSON_NAMESPACE_END 92 | 93 | #endif // RAPIDJSON_STRINGBUFFER_H_ 94 | -------------------------------------------------------------------------------- /AVSDK/avmixer/generalaudiomixer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // generalaudiomixer.cpp 3 | // mediacloud 4 | // 5 | // Created by xingyanjun on 14/12/4. 6 | // Copyright (c) 2014年 smyk. All rights reserved. 7 | // 8 | #include 9 | #include 10 | #include "generalaudiomixer.h" 11 | 12 | using namespace MediaCloud::Adapter; 13 | 14 | 15 | static __inline short MixerData(int* mixerData, int numData) 16 | { 17 | if(numData < 1 ) 18 | return 0; 19 | 20 | int tmp = mixerData[0]; 21 | for(int i = 1; i < numData; ++i) 22 | { 23 | int s = ((tmp>>31)&1) + ((mixerData[i]>>15)& 1); 24 | if(s == 2) 25 | tmp = tmp + mixerData[i] + (tmp*mixerData[i]>>15); 26 | else if(s == 0) 27 | tmp = tmp + mixerData[i] - (tmp*mixerData[i]>>15); 28 | else 29 | tmp = tmp + mixerData[i]; 30 | } 31 | 32 | if(tmp > 32767) tmp = 32767; 33 | if(tmp < -32768) tmp = -32768; 34 | 35 | numData = 0; 36 | return (short)tmp; 37 | } 38 | /* 39 | static __inline short MixerDataOld(int* mixerData, int numData) 40 | { 41 | if(numData < 1 ) 42 | return 0; 43 | 44 | int tmp = mixerData[0]; 45 | for(int i = 1; i < numData; ++i) 46 | tmp = mixerData[i]; 47 | 48 | if(numData > 0) 49 | tmp /= numData; 50 | 51 | if(tmp > 32768) tmp = 32768; 52 | if(tmp < -32767) tmp = -32767; 53 | 54 | return (short)tmp; 55 | } 56 | */ 57 | 58 | GeneralAudioMixer::GeneralAudioMixer(const AudioStreamFormat& fmt, int numStreams) 59 | : _numStreams(numStreams), 60 | _streamFormat(fmt), 61 | _sampleData(NULL) 62 | { 63 | } 64 | 65 | 66 | GeneralAudioMixer::~GeneralAudioMixer() 67 | { 68 | } 69 | 70 | void GeneralAudioMixer::Reset() 71 | { 72 | } 73 | 74 | 75 | int GeneralAudioMixer::EnableStream(unsigned int idx, bool enable, float volume) 76 | { 77 | return 0; 78 | } 79 | 80 | 81 | bool GeneralAudioMixer::MixData(void* output, int packetnum, int packetlen, double sampletime, AudioDataInfo* samples, int numStream) 82 | { 83 | if (numStream != _numStreams || samples == NULL || output == NULL || packetnum < 1 || packetlen == 0) 84 | { 85 | return false; 86 | } 87 | 88 | int totallen = packetnum * packetlen; 89 | int mixerData[32]; //hack hack 90 | int minlen_short= totallen/2; 91 | 92 | short* pData = (short*)output; 93 | for(int i = 0; i < minlen_short; ++i) 94 | { 95 | int cData = 0; 96 | for(int j = 0; j < _numStreams; ++j) 97 | { 98 | if(samples[j]._enabled && samples[j]._leftData) 99 | { 100 | short *p = (short*) samples[j]._leftData; 101 | mixerData[cData] = p[i]; 102 | cData++; 103 | } 104 | } 105 | pData[i] = MixerData(mixerData, cData); //MixerDataOld() 106 | } 107 | 108 | for (int i = 0; i < _numStreams; i++) 109 | { 110 | if (samples[i]._enabled && samples[i]._leftData) 111 | { 112 | if (samples[i]._leftLength > totallen) 113 | { 114 | memmove (samples[i]._leftData, (char*)samples[i]._leftData + totallen, samples[i]._leftLength - totallen); 115 | samples[i]._leftLength -= totallen; 116 | } 117 | else 118 | { 119 | samples[i]._leftLength = 0; 120 | } 121 | } 122 | } 123 | 124 | return true; 125 | } 126 | 127 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/fecrq/fecrqtest.cpp: -------------------------------------------------------------------------------- 1 | 2 | //#include "stdafx.h" 3 | #include "fecrq.h" 4 | #include 5 | #include 6 | //#include 7 | 8 | void fecRQTest2() 9 | { 10 | uint8_t data[10]; 11 | for (int i = 0; i < 10; i++) 12 | data[i] = i + 1; 13 | 14 | FECRQEncoder encoder(data, 10, 1); 15 | encoder.ForceEncoding(); 16 | 17 | uint8_t tmp[10]; 18 | for (int i = 0; i < 10; i++) 19 | { 20 | encoder.GetEncodedSymbols(i, &tmp[i]); 21 | } 22 | return; 23 | } 24 | 25 | void fecRQTest() 26 | { 27 | srand(MediaCloud::Common::DateTime::TickCount()); 28 | //srand(GetTickCount()); 29 | uint32_t r = rand(); 30 | int length = 1024 * 5 + r % 1024; 31 | int symbolSize = 64; 32 | 33 | // prepare testing data 34 | uint8_t *data = new uint8_t[length]; 35 | 36 | srand(r); 37 | uint32_t r2 = rand(); 38 | uint8_t random = r2; 39 | uint8_t step = r % 37; 40 | for (int i = 0; i < length; i++) 41 | { 42 | data[i] = random; 43 | random += step; 44 | } 45 | 46 | FECRQEncoder encoder(data, length, symbolSize); 47 | encoder.ForceEncoding(); 48 | 49 | // verify the first K encoded symbols 50 | std::vector encodedSymbols; 51 | int K = encoder.NumOfSourceSymbols(); 52 | for (int i = 0; i < 3 * K + 10; i++) 53 | { 54 | uint8_t *tmp = new uint8_t[symbolSize]; 55 | encoder.GetEncodedSymbols(i, tmp); 56 | encodedSymbols.push_back(tmp); 57 | 58 | if (i < K) 59 | { 60 | int dataLen = i + 1 < K ? symbolSize : length - symbolSize * i; 61 | assert(dataLen > 0); 62 | if (memcmp(data + symbolSize * i, tmp, dataLen) != 0) 63 | { 64 | assert(false); 65 | } 66 | } 67 | } 68 | 69 | // testing decoding 70 | bool suc = false; 71 | std::vector inputESIs; 72 | int eraseCnt = 0; 73 | 74 | FECRQDecoder decoder(symbolSize, K, 0); 75 | int inputcnt = 0; 76 | for (int i = 0; inputcnt <= K + 3; i++) 77 | { 78 | if (eraseCnt < K) 79 | { 80 | srand(r2); 81 | r2 = rand(); 82 | if ((r2 % 2) == 0) 83 | { 84 | eraseCnt++; 85 | continue; 86 | } 87 | } 88 | 89 | inputcnt++; 90 | inputESIs.push_back(i); 91 | 92 | uint32_t tick = GetTickCount(); 93 | bool ret = decoder.AddEncodedSymbols(i, encodedSymbols[i]); 94 | tick = GetTickCount() - tick; 95 | 96 | if (ret) 97 | { 98 | suc = true; 99 | 100 | printf(">> Decoding esis: "); 101 | for (auto esi : inputESIs) 102 | printf("%d ", esi); 103 | printf("<< Overhead = %d, Taking = %d ms\n", inputcnt - K, tick); 104 | for (int j = 0; j < K; j++) 105 | { 106 | const uint8_t *source = decoder.GetSourceSymbols(j); 107 | int dataLen = j + 1 < K ? symbolSize : length - symbolSize * j; 108 | assert(dataLen > 0); 109 | if (memcmp(data + symbolSize * j, source, dataLen) != 0) 110 | { 111 | assert(false); 112 | } 113 | } 114 | break; 115 | } 116 | } 117 | assert(suc); 118 | 119 | for (auto &p : encodedSymbols) 120 | delete[] p; 121 | delete[] data; 122 | } 123 | 124 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/codec.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _MEDIACLOUD_CODEC_H 4 | #define _MEDIACLOUD_CODEC_H 5 | 6 | #include 7 | 8 | namespace MediaCloud 9 | { 10 | namespace Common 11 | { 12 | /// EncoderParamSet用来描述一个Encoder的能力和编码时的参数 13 | /// 这个结构和JSON相互转化, 比如: 14 | /// { 15 | /// purpose : capbility_description/instruction // 表明这个JSON描述的用途, 是用来表述codec能力的还是Server下发的编码参数 16 | /// ver : 1.0 // 版本 17 | /// codecs : { // 包含所有codec的描述 18 | /// opus : { // 描述opus编码器, 由不同level的参数数组组成. 每个level代表一定码率下的编码参数 19 | /// [ 20 | /// level : 0 21 | /// param : { 22 | /// /// bitrate和编码参数 23 | /// } 24 | /// ] 25 | /// [ 26 | /// level : 1 27 | /// param : { 28 | /// /// bitrate和编码参数 29 | /// } 30 | /// ] 31 | /// } 32 | /// vp8 : { 33 | /// // 也是有不同的level数组组成 34 | /// } 35 | /// } 36 | /// fec : { 37 | /// // 描述Server下发的FEC的参数, 仅用于Instruction 38 | /// } 39 | /// } 40 | /// 41 | class EncoderParamSet 42 | { 43 | public: 44 | 45 | struct AudioParam 46 | { 47 | int _payLoadType; //RTPPayloadType 48 | 49 | /// ignored for PCM. 50 | /// for some codec, like AAC, profile means the encoder's capabilities. 51 | /// AAC profile:(AAC:1, EAAC:5, AAC_ADTS:101, EAAC_ADTS:105) 52 | /// OPUS profile:(OPUS_APPLICATION_VOIP:2048,OPUS_APPLICATION_AUDIO:2049,OPUS_APPLICATION_RESTRICTED_LOWDELAY:2051) 53 | int _profile; 54 | 55 | /// ignored for PCM. 56 | /// for some codec, like SPEEX AMRWB AAC, profile means the encoder's qulity(0-10). 57 | int _quality; 58 | 59 | ///Discontinuous Transmission 60 | bool _usedtx; 61 | ///Variable Bit Rate 62 | bool _usevbr; 63 | ///Inband FEC 64 | bool _useInbandfec; 65 | ///packetlossperc use for FEC 66 | int _packetlossperc; 67 | }; 68 | 69 | struct VideoParam 70 | { 71 | 72 | }; 73 | 74 | /// to describe the max/min encoder capbility 75 | /// put 2 levels in set, 76 | /// level 0 - the min capbility 77 | /// level 1 - the max capbility 78 | 79 | /// how many levels in a codec parameter description set 80 | /// type is H264, VP8, etc.. 81 | int LevelNumber(int type) const; 82 | AudioParam* GetAudioParam(int type, int levelIdx) const; 83 | VideoParam* GetVideoParam(int type, int levelIdx) const; 84 | 85 | static EncoderParamSet* Parse(const char *text); 86 | }; 87 | 88 | /// 描述Server下发的编码器参数 89 | class EncoderParamInstruction : public EncoderParamSet 90 | { 91 | public: 92 | float PreferredAudioFECRate() const; 93 | float PreferredVideoFECRate() const; 94 | 95 | static EncoderParamInstruction* Parse(const std::string &text); 96 | }; 97 | } 98 | } 99 | 100 | 101 | #endif -------------------------------------------------------------------------------- /include/google/protobuf/compiler/plugin.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // http://code.google.com/p/protobuf/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | // 33 | // Front-end for protoc code generator plugins written in C++. 34 | // 35 | // To implement a protoc plugin in C++, simply write an implementation of 36 | // CodeGenerator, then create a main() function like: 37 | // int main(int argc, char* argv[]) { 38 | // MyCodeGenerator generator; 39 | // return google::protobuf::compiler::PluginMain(argc, argv, &generator); 40 | // } 41 | // You must link your plugin against libprotobuf and libprotoc. 42 | // 43 | // To get protoc to use the plugin, do one of the following: 44 | // * Place the plugin binary somewhere in the PATH and give it the name 45 | // "protoc-gen-NAME" (replacing "NAME" with the name of your plugin). If you 46 | // then invoke protoc with the parameter --NAME_out=OUT_DIR (again, replace 47 | // "NAME" with your plugin's name), protoc will invoke your plugin to generate 48 | // the output, which will be placed in OUT_DIR. 49 | // * Place the plugin binary anywhere, with any name, and pass the --plugin 50 | // parameter to protoc to direct it to your plugin like so: 51 | // protoc --plugin=protoc-gen-NAME=path/to/mybinary --NAME_out=OUT_DIR 52 | // On Windows, make sure to include the .exe suffix: 53 | // protoc --plugin=protoc-gen-NAME=path/to/mybinary.exe --NAME_out=OUT_DIR 54 | 55 | #ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ 56 | #define GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ 57 | 58 | #include 59 | namespace google { 60 | namespace protobuf { 61 | namespace compiler { 62 | 63 | class CodeGenerator; // code_generator.h 64 | 65 | // Implements main() for a protoc plugin exposing the given code generator. 66 | LIBPROTOC_EXPORT int PluginMain(int argc, char* argv[], const CodeGenerator* generator); 67 | 68 | } // namespace compiler 69 | } // namespace protobuf 70 | 71 | } // namespace google 72 | #endif // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__ 73 | -------------------------------------------------------------------------------- /AVSDK/avutil/include/logging.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _MEDIACLOUD_LOGGING_H 3 | #define _MEDIACLOUD_LOGGING_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace MediaCloud { namespace Common { 10 | enum LogLevel 11 | { 12 | LogLevelVerbose, 13 | LogLevelDebug, 14 | LogLevelInfo, 15 | LogLevelWarning, 16 | LogLevelError, 17 | LogLevelAssert, 18 | }; 19 | 20 | typedef void (*LogFun)(LogLevel level, const char* tag, const char *text); 21 | void ConfigLog(LogFun logFun, int nLevel, const char *forbidModule = nullptr, const char *forceModule = nullptr); 22 | void LogHelper(LogLevel level, const char *module, const char *format, ...); 23 | void AssertHelper(bool condition, const char *file, const char *func, int line, const char *format, ...); 24 | 25 | #ifndef LOGGING_IMPL 26 | extern char g_forbidModule[64]; 27 | extern char g_forceModule[64]; 28 | extern int g_nLogLevel; 29 | __inline bool CheckLogFilter(LogLevel level, const char *module) { 30 | bool output = level >= g_nLogLevel; 31 | if (output && g_forbidModule[0] != '0' && module != nullptr) { 32 | if (strcmp(g_forbidModule, module) == 0) { 33 | output = false; 34 | } 35 | } 36 | 37 | if (!output && g_forceModule[0] != '0' && module != nullptr) { 38 | if (strcmp(g_forceModule, module) == 0) { 39 | output = true; 40 | } 41 | } 42 | return output; 43 | } 44 | #endif 45 | 46 | #ifdef WIN32 47 | #define Assert(e) do { if (!(e)) { AssertHelper(e, __FILE__, __FUNCTION__, __LINE__, ""); } } while(0) 48 | #define AssertMsg(e, format, ...) do { if (!(e)) { AssertHelper(e, __FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__); } } while(0) 49 | #define LogVerbose(module, format, ...) do { if (CheckLogFilter(LogLevelVerbose, module)) { LogHelper(LogLevelVerbose, module, format, __VA_ARGS__); } } while (0) 50 | #define LogDebug(module, format, ...) do { if (CheckLogFilter(LogLevelDebug, module)) { LogHelper(LogLevelDebug, module, format, __VA_ARGS__); } } while (0) 51 | #define LogInfo(module, format, ...) do { if (CheckLogFilter(LogLevelInfo, module)) { LogHelper(LogLevelInfo, module, format, __VA_ARGS__); } } while (0) 52 | #define LogWarning(module, format, ...) do { if (CheckLogFilter(LogLevelWarning, module)) { LogHelper(LogLevelWarning, module, format, __VA_ARGS__); } } while (0) 53 | #define LogError(module, format, ...) do { if (CheckLogFilter(LogLevelError, module)) { LogHelper(LogLevelError, module, format, __VA_ARGS__); } } while (0) 54 | 55 | #else 56 | #define Assert(e) do { if (!(e)) { AssertHelper(e, __FILE__, __func__, __LINE__, ""); } } while(0) 57 | #define AssertMsg(e, format, args...) do { if (!(e)) { AssertHelper(e, __FILE__, __func__, __LINE__, format, ## args); } } while(0) 58 | #define LogVerbose(module, format, args...) do { if (CheckLogFilter(LogLevelVerbose, module)) { LogHelper(LogLevelVerbose, module, format, ## args); } } while (0) 59 | #define LogDebug(module, format, args...) do { if (CheckLogFilter(LogLevelDebug, module)) { LogHelper(LogLevelDebug, module, format, ## args); } } while (0) 60 | #define LogInfo(module, format, args...) do { if (CheckLogFilter(LogLevelInfo, module)) { LogHelper(LogLevelInfo, module, format, ## args); } } while (0) 61 | #define LogWarning(module, format, args...) do { if (CheckLogFilter(LogLevelWarning, module)) { LogHelper(LogLevelWarning, module, format, ## args); } } while (0) 62 | #define LogError(module, format, args...) do { if (CheckLogFilter(LogLevelError, module)) { LogHelper(LogLevelError, module, format, ## args); } } while (0) 63 | #endif 64 | 65 | }} 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/fast_fec.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _FEC_FAST_FEC_H 3 | #define _FEC_FAST_FEC_H 4 | 5 | #include 6 | 7 | namespace fec { 8 | 9 | // keep same memory layout with FecRepo::Param 10 | struct Param { 11 | int K, T, KP, S, H, W, L, P, P1, U, B, J; 12 | 13 | /* 14 | * K - the src symbol num; T - the symbol size 15 | */ 16 | static void GetParam(int K, int T, Param ¶m); 17 | 18 | inline int ESIToISI(int esi) const { 19 | if (esi < K) 20 | return esi; 21 | return KP + (esi - K); 22 | } 23 | 24 | inline int ISIToESI(int isi) const { 25 | if (isi < K) 26 | return isi; 27 | return isi - (KP - K); 28 | } 29 | }; 30 | 31 | struct Symbol { 32 | int esi; 33 | uint8_t *data; // data length is defined in param.T 34 | }; 35 | 36 | // this is the intermediate symbols, generated by encoder and decoder 37 | // used to generate unlimited number of repair symbols 38 | struct LTSymbols { 39 | Param param; 40 | uint8_t *symbolVec; // layout - | aligned rowidx | aligned row data | 41 | /* 42 | * for the LTSymbols generated from src symbols, rowNum == param.L 43 | * for recovered from repair symbols, rowNum == the number of symbol input for decoding 44 | */ 45 | int rowNum; 46 | int length; 47 | }; 48 | 49 | class IAllocator { 50 | public: 51 | enum { 52 | PurposeUnknown, 53 | PurposeLT, 54 | PurposeTmpMatrix, 55 | }; 56 | 57 | virtual ~IAllocator() {} 58 | // alignment : 0 - no needed; 16 - align to 16 bytes 59 | virtual void* AllocFecBuffer(int size, int alignment, int purpose = PurposeUnknown) = 0; 60 | virtual void FreeFecBuffer(void *buffer, int purpose = PurposeUnknown) = 0; 61 | }; 62 | 63 | class FastFec { 64 | public: 65 | /* 66 | * the data must be padded with 0s to be the length of K * T 67 | */ 68 | static void GenLTSymbols(const Param ¶m, const uint8_t* data, int paddedLen, 69 | IAllocator *allocator, LTSymbols <Symbols); 70 | 71 | static void GenLTSymbols(const Param ¶m, const uint8_t* srcSymData[], int srcSymNum, 72 | IAllocator *allocator, LTSymbols <Symbols); 73 | 74 | /* 75 | * the returning data length is the stride of T 76 | */ 77 | static const uint8_t* GetLTSymbolData(const LTSymbols <Symbols, int idx); 78 | 79 | /* 80 | * the symbols must be ordered by esi, the last src symbol must be padded by 0s 81 | */ 82 | static bool TryDecode(const Param ¶m, const Symbol *symbols, int numOfSymbol, 83 | IAllocator *allocator, LTSymbols <Symbols); 84 | 85 | /* 86 | * symbols - start from esi 0 to maxESI [0 maxESI), if the slot is nullptr, that symbols is not valid 87 | * symbolNum - valid symbol number in symbols array, it must be greater than K 88 | * maxESI - the max esi + 1, it is also the size of symbols array 89 | */ 90 | static bool TryDecode(const Param ¶m, const uint8_t* symbols[], int maxESI, int validSymbolNum, 91 | IAllocator *allocator, LTSymbols <Symbols); 92 | 93 | /* 94 | * gen symbol from intermediate symbols, data length is larger than param.T 95 | * data should be aligned to 16bytes, length must be multiple of 16bytes ! 96 | */ 97 | static void RecoverSymbol(const LTSymbols <Symbols, 98 | int esi, uint8_t *data, int length); 99 | }; 100 | } 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /AVSDK/avutil/src/LogFile.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "protocol.h" 7 | #include "LogFile.h" 8 | 9 | 10 | CLogFile g_log_info("info"); 11 | CLogFile g_log_Warn("warn"); 12 | CLogFile g_log_error("error"); 13 | CLogFile g_log_msg("msg"); 14 | CLogFile g_log_rev("rev"); 15 | CLogFile g_log_print("pirnt"); 16 | 17 | CLogFile::CLogFile() 18 | { 19 | m_file = NULL; 20 | m_FileName.clear(); 21 | m_label.clear(); 22 | 23 | m_mutex_log = PTHREAD_MUTEX_INITIALIZER; 24 | pthread_mutex_init(&m_mutex_log, NULL); 25 | } 26 | 27 | CLogFile::CLogFile(string label) 28 | { 29 | m_file = NULL; 30 | m_FileName.clear(); 31 | m_label = label; 32 | 33 | m_mutex_log = PTHREAD_MUTEX_INITIALIZER; 34 | pthread_mutex_init(&m_mutex_log, NULL); 35 | } 36 | 37 | CLogFile::~CLogFile() 38 | { 39 | if(m_file){ 40 | try{ 41 | fclose(m_file); 42 | m_file = NULL; 43 | } 44 | catch(...){} 45 | } 46 | 47 | pthread_mutex_destroy(&m_mutex_log); 48 | m_mutex_log = PTHREAD_MUTEX_INITIALIZER; 49 | } 50 | 51 | string CLogFile::GetFileName() 52 | { 53 | MsgTime mt = CreateMsgTime(); 54 | 55 | const int nBufferSize = 56 + 200; 56 | char chBuf[nBufferSize]; 57 | memset(chBuf, 0x00, nBufferSize); 58 | char * format = (char *)"%u-%u-%u-%u-%u.log"; 59 | sprintf(chBuf, format, mt.year, mt.month, mt.day, mt.hour, mt.minite > 30 ? 1 : 0); 60 | 61 | string fileName = chBuf; 62 | return fileName; 63 | } 64 | 65 | string CLogFile::GetFilePath() 66 | { 67 | string workPath("./"); 68 | //GetWorkDir(workPath); 69 | //wlj string workPath; 70 | //wlj GetWorkDir(workPath); 71 | return workPath + "log/"; 72 | 73 | /* char szFilePath[500 + 1]; 74 | char * ch = strrchr(szFilePath, '/'); 75 | ch[1] = 0; 76 | string path = szFilePath; 77 | path += "log/"; 78 | return path; 79 | */ 80 | } 81 | 82 | void CLogFile::SetLabel(string label) 83 | { 84 | m_label = label; 85 | } 86 | 87 | bool CLogFile::WriteLog(string logText, bool crlf) 88 | { 89 | return WriteLog((char *) logText.c_str(), (unsigned int)logText.length(), crlf); 90 | } 91 | 92 | #define FILE_DELETE 93 | 94 | bool CLogFile::WriteLog(char * buffer, unsigned int len, bool crlf) 95 | { 96 | if(pthread_mutex_lock(&m_mutex_log) != 0){ 97 | return false; 98 | } 99 | 100 | bool res = false; 101 | try 102 | { 103 | string filePath = GetFilePath(); 104 | if(access(filePath.c_str(), F_OK) != 0){ 105 | if(mkdir(filePath.c_str(), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH) != 0){ 106 | pthread_mutex_unlock(&m_mutex_log); 107 | return false; 108 | } 109 | } 110 | 111 | string fileName = filePath + (m_label.empty() ? "" : m_label) + "_" + GetFileName(); 112 | #ifndef FILE_DELETE 113 | if(m_FileName != fileName && m_file){ 114 | fclose(m_file); 115 | m_file = NULL; 116 | } 117 | #endif 118 | if(m_file == NULL){ 119 | m_file = fopen(fileName.c_str(), "ab+"); 120 | } 121 | m_FileName = fileName; 122 | if(m_file && buffer && len > 0){ 123 | res = (fwrite(buffer, 1, len, m_file) == len); 124 | if(crlf){ 125 | char * add = (char *)"\r\n\r\n"; 126 | fwrite(add, 1, strlen(add), m_file); 127 | } 128 | fflush(m_file); 129 | } 130 | #ifdef FILE_DELETE 131 | fclose(m_file); 132 | m_file = NULL; 133 | #endif 134 | } 135 | catch(...) 136 | { 137 | try{ 138 | if(m_file){ 139 | fclose(m_file); 140 | } 141 | }catch(...){} 142 | m_file = NULL; 143 | pthread_mutex_unlock(&m_mutex_log); 144 | return res; 145 | } 146 | 147 | pthread_mutex_unlock(&m_mutex_log); 148 | return res; 149 | } 150 | --------------------------------------------------------------------------------