├── LICENSE ├── README.md └── trunk ├── LICENSE ├── Makefile.linux ├── README.md ├── auto └── configure ├── librtmp └── include │ └── librtmp.h ├── misc └── vc2010 │ ├── au-ds.lnt │ ├── au-misra2.lnt │ ├── au-sm123.lnt │ ├── co-msc100.h │ ├── co-msc100.lnt │ ├── env-vc10.lnt │ ├── include.lnt │ ├── lib-atl.lnt │ ├── lib-mfc.lnt │ ├── lib-ole.lnt │ ├── lib-w32.lnt │ ├── lib-wnt.lnt │ ├── lint-nt.exe │ ├── macro.lnt │ ├── options.lnt │ ├── pclint.bat │ ├── std.lnt │ ├── vs2010-m.cpp │ └── vs2010-m.lnt ├── objs └── bin │ └── conf │ ├── nginx.conf │ └── rtmpd.conf ├── src ├── core │ ├── rtmp_amf.c │ ├── rtmp_amf.h │ ├── rtmp_array.c │ ├── rtmp_array.h │ ├── rtmp_bytes.c │ ├── rtmp_bytes.h │ ├── rtmp_conf.c │ ├── rtmp_conf.h │ ├── rtmp_connection.c │ ├── rtmp_connection.h │ ├── rtmp_def.h │ ├── rtmp_error.c │ ├── rtmp_error.h │ ├── rtmp_link.c │ ├── rtmp_link.h │ ├── rtmp_log.c │ ├── rtmp_log.h │ ├── rtmp_rbtree.c │ ├── rtmp_rbtree.h │ ├── rtmp_recv.c │ ├── rtmp_send.c │ ├── rtmp_time.c │ └── rtmp_time.h ├── event │ ├── rtmp_event.h │ ├── rtmp_event_module.c │ ├── rtmp_event_timer.c │ ├── rtmp_event_timer.h │ ├── rtmp_timer.c │ └── rtmp_timer.h ├── http │ ├── rtmp_hls_module.c │ └── rtmp_http_module.c ├── librtmp │ ├── librtmp.c │ ├── librtmp_dump.c │ ├── librtmp_in.h │ ├── rtmp_alloc.c │ ├── rtmp_alloc.h │ ├── rtmp_amf.c │ ├── rtmp_amf.h │ ├── rtmp_bytes.h │ ├── rtmp_link.c │ ├── rtmp_link.h │ ├── rtmp_log.c │ ├── rtmp_log.h │ ├── rtmp_time.c │ └── rtmp_time.h ├── os │ ├── rtmp_alloc.h │ ├── rtmp_atomic.h │ ├── rtmp_config.h │ ├── rtmp_shmem.h │ ├── unix │ │ ├── rtmp_alloc.c │ │ ├── rtmp_atomic.c │ │ ├── rtmp_event_epoll.c │ │ ├── rtmp_event_select.c │ │ ├── rtmp_linux_config.h │ │ ├── rtmp_shmem.c │ │ ├── rtmp_signal.c │ │ └── rtmp_socket.c │ └── win32 │ │ ├── rtmp_alloc.c │ │ ├── rtmp_atomic.c │ │ ├── rtmp_event_select.c │ │ ├── rtmp_shmem.c │ │ ├── rtmp_socket.c │ │ └── rtmp_win32_config.h └── rtmp │ ├── rtmp_app.c │ ├── rtmp_app.h │ ├── rtmp_chunk.c │ ├── rtmp_chunk.h │ ├── rtmp_codec.c │ ├── rtmp_codec.h │ ├── rtmp_connect.c │ ├── rtmp_core.c │ ├── rtmp_core.h │ ├── rtmp_core_conf.c │ ├── rtmp_core_conf.h │ ├── rtmp_core_module.c │ ├── rtmp_cycle.c │ ├── rtmp_handler.c │ ├── rtmp_handler.h │ ├── rtmp_handshake.c │ ├── rtmp_handshake.h │ ├── rtmp_host.h │ ├── rtmp_host_module.c │ ├── rtmp_live.c │ ├── rtmp_message.c │ ├── rtmp_message.h │ ├── rtmp_play.c │ ├── rtmp_protocol.h │ ├── rtmp_publish.c │ ├── rtmp_push_module.c │ ├── rtmp_recv.c │ ├── rtmp_rtmp_module.c │ ├── rtmp_send.c │ ├── rtmp_session.c │ ├── rtmp_session.h │ └── rtmp_stream.c └── vs2010 ├── include └── openssl │ ├── aes.h │ ├── applink.c │ ├── asn1.h │ ├── asn1_mac.h │ ├── asn1t.h │ ├── bio.h │ ├── blowfish.h │ ├── bn.h │ ├── buffer.h │ ├── camellia.h │ ├── cast.h │ ├── cmac.h │ ├── cms.h │ ├── comp.h │ ├── conf.h │ ├── conf_api.h │ ├── crypto.h │ ├── des.h │ ├── des_old.h │ ├── dh.h │ ├── dsa.h │ ├── dso.h │ ├── dtls1.h │ ├── e_os2.h │ ├── ebcdic.h │ ├── ec.h │ ├── ecdh.h │ ├── ecdsa.h │ ├── engine.h │ ├── err.h │ ├── evp.h │ ├── hmac.h │ ├── idea.h │ ├── krb5_asn.h │ ├── kssl.h │ ├── lhash.h │ ├── md4.h │ ├── md5.h │ ├── mdc2.h │ ├── modes.h │ ├── obj_mac.h │ ├── objects.h │ ├── ocsp.h │ ├── opensslconf.h │ ├── opensslv.h │ ├── ossl_typ.h │ ├── pem.h │ ├── pem2.h │ ├── pkcs12.h │ ├── pkcs7.h │ ├── pqueue.h │ ├── rand.h │ ├── rc2.h │ ├── rc4.h │ ├── ripemd.h │ ├── rsa.h │ ├── safestack.h │ ├── seed.h │ ├── sha.h │ ├── srp.h │ ├── srtp.h │ ├── ssl.h │ ├── ssl2.h │ ├── ssl23.h │ ├── ssl3.h │ ├── stack.h │ ├── symhacks.h │ ├── tls1.h │ ├── ts.h │ ├── txt_db.h │ ├── ui.h │ ├── ui_compat.h │ ├── whrlpool.h │ ├── x509.h │ ├── x509_vfy.h │ └── x509v3.h ├── lib ├── libeay32.dll ├── libeay32.lib ├── ssleay32.dll └── ssleay32.lib ├── librtmp.sln ├── librtmp ├── librtmp.vcxproj └── librtmp.vcxproj.filters ├── rtmpd.sln └── rtmpd ├── conf ├── fastcgi.conf ├── fastcgi.conf.default ├── fastcgi_params ├── fastcgi_params.default ├── full.conf ├── koi-utf ├── koi-win ├── mime.types ├── mime.types.default ├── nginx.conf ├── nginx.conf.default ├── scgi_params ├── scgi_params.default ├── uwsgi_params ├── uwsgi_params.default └── win-utf ├── rtmpd.vcxproj └── rtmpd.vcxproj.filters /README.md: -------------------------------------------------------------------------------- 1 | rtmpd 2 | ===== 3 | 4 | rtmp server using c language 5 | -------------------------------------------------------------------------------- /trunk/README.md: -------------------------------------------------------------------------------- 1 | rtmpd 2 | ===== 3 | 4 | rtmp server using c language 5 | -------------------------------------------------------------------------------- /trunk/auto/configure: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/auto/configure -------------------------------------------------------------------------------- /trunk/librtmp/include/librtmp.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LIB_RTMP_H_INCLUDED__ 7 | #define __LIB_RTMP_H_INCLUDED__ 8 | 9 | #if defined(_WIN32) && !defined(__GNUC__) && defined(XRTMPDLL) 10 | #if defined(LIBRTMP_EXPORTS) 11 | #define XRTMP_API __declspec(dllexport) 12 | #else 13 | #define XRTMP_API __declspec(dllimport) 14 | #endif 15 | #else 16 | #define XRTMP_API 17 | #endif 18 | 19 | #define rtmp_proto_n "rtmp://" 20 | #define rtmp_proto_len (sizeof(rtmp_proto_n)-1) 21 | 22 | #define RTMP_MESSAGE_TYPE_AUDIO 0x08 23 | #define RTMP_MESSAGE_TYPE_VIDEO 0x09 24 | #define RTMP_MESSAGE_TYPE_AMF0 0x12 25 | #define RTMP_MESSAGE_TYPE_AMF3 0x0f 26 | 27 | #define RTMP_NULL (NULL) 28 | 29 | #define RTMP_ERR_OK ( 0) 30 | #define RTMP_ERR_ERROR (-1) 31 | #define RTMP_ERR_FAILED (-1) 32 | #define RTMP_ERR_TIMEOUT (-2) 33 | #define RTMP_ERR_BLOCK (-3) 34 | #define RTMP_ERR_RESET (-4) 35 | #define RTMP_ERR_HANDSHAKE (-5) 36 | #define RTMP_ERR_PROTOCOL (-6) 37 | #define RTMP_ERR_INVALID (-7) 38 | 39 | #define RTMP_LOG_ERR ( 0) 40 | #define RTMP_LOG_WARNING ( 1) 41 | #define RTMP_LOG_INFO ( 2) 42 | #define RTMP_LOG_NORMAL ( 3) 43 | #define RTMP_LOG_DEBUG ( 4) 44 | #define RTMP_LOG_MAX (RTMP_LOG_DEBUG+1) 45 | 46 | #define RTMP_CONN_BLOCK ( 1) 47 | #define RTMP_CONN_NONEBLOCK ( 0) 48 | 49 | typedef struct rtmp_message_s rtmp_message_t; 50 | typedef void * rtmp_net_conn_t; 51 | typedef void * rtmp_net_stream_t; 52 | 53 | typedef unsigned int uint32_t; 54 | typedef unsigned char uint8_t; 55 | typedef unsigned short uint16_t; 56 | 57 | struct rtmp_message_s { 58 | uint32_t timestamp; 59 | uint16_t type; 60 | uint16_t body_size; 61 | uint8_t *body; 62 | }; 63 | 64 | /*memory alloc and free instance*/ 65 | typedef void* (*rtmp_malloc_rt)(size_t size,void *u); 66 | typedef void (*rtmp_free_rt)(void *p,void *u); 67 | 68 | /*NetConnection*/ 69 | XRTMP_API rtmp_net_conn_t rtmp_conn_create( 70 | rtmp_malloc_rt a,rtmp_free_rt f,void *u); 71 | 72 | XRTMP_API int rtmp_conn_connect(rtmp_net_conn_t conn,const char *app); 73 | XRTMP_API int rtmp_conn_close(rtmp_net_conn_t conn); 74 | 75 | XRTMP_API int rtmp_conn_destroy(rtmp_net_conn_t conn); 76 | 77 | /*NetStream*/ 78 | XRTMP_API rtmp_net_stream_t rtmp_stream_create(rtmp_net_conn_t conn, 79 | const char *name); 80 | XRTMP_API int rtmp_stream_play(rtmp_net_stream_t stream); 81 | XRTMP_API int rtmp_stream_publish(rtmp_net_stream_t stream); 82 | 83 | XRTMP_API int rtmp_stream_recv(rtmp_net_stream_t stream,rtmp_message_t *msg); 84 | XRTMP_API int rtmp_stream_send(rtmp_net_stream_t stream,rtmp_message_t *msg); 85 | 86 | XRTMP_API int rtmp_stream_close(rtmp_net_stream_t stream); 87 | XRTMP_API int rtmp_stream_destroy(rtmp_net_stream_t stream); 88 | 89 | #endif -------------------------------------------------------------------------------- /trunk/misc/vc2010/au-ds.lnt: -------------------------------------------------------------------------------- 1 | // au-ds.lnt -- Author options - Dan Saks 2 | 3 | /* 4 | This options file can be used to explicitly activate those 5 | checks advocated by Dan Saks in his series of presentations on 6 | "C++ Gotchas". 7 | 8 | You can use this file directly when linting your programs as in: 9 | 10 | lin au-ds files 11 | 12 | */ 13 | 14 | +fsc // consider string constants as const char * 15 | +e1933 // turn on "virtual call from member detection" 16 | 17 | // The rationale for the following two options are fully described 18 | // in Dan Sak's article "const T vs. T const". Visit his web site 19 | // at www.dansaks.com and click "Published Articles". 20 | // 21 | -fqb +e963 // require T const rather than const T 22 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/co-msc100.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LINT_SUPPORT_CO_MSC100_H_ 3 | #define LINT_SUPPORT_CO_MSC100_H_ 4 | 5 | // co-msc100.h -- 6 | // This header is automatically included in every module if you use 7 | // co-msc100.lnt. (There is a -header(co-msc100.h) option therein 8 | // for this purpose.) 9 | 10 | // Microsoft's C++0x implementation does not yet include built-in support 11 | // for the new character types, so we need to disable the relevant 12 | // keywords here. (This must be done before the inclusion of any other 13 | // header file because Microsoft's library headers contain declarations of 14 | // typedef names with the same spelling.) 15 | //lint -rw(char16_t,char32_t) 16 | 17 | // Next we must compensate for the fact that class typeinfo is available 18 | // for use in the MSC compilers without an explicit definition. According 19 | // to the standard this class definition is not (available by default). 20 | #ifdef __cplusplus 21 | 22 | #include 23 | 24 | #else // C mode 25 | 26 | // co-msc100.lnt defines some macros that the Microsoft compiler defines 27 | // in C++ modes but not in C mode; we must un-define them here: 28 | #undef _CPPRTTI 29 | #undef _NATIVE_WCHAR_T_DEFINED 30 | #undef _WCHAR_T_DEFINED 31 | #undef _NATIVE_NULLPTR_SUPPORTED 32 | 33 | #endif 34 | 35 | #endif /* LINT_SUPPORT_CO_MSC100_H_ */ 36 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/include.lnt: -------------------------------------------------------------------------------- 1 | //include path 2 | //VC include 3 | -iD:/vs2010/VC/include 4 | -iD:/vs2010/VC/atlmfc/include 5 | 6 | //windows SDK include 7 | -i"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Include" 8 | 9 | -i"src/core" 10 | -i"src/event" 11 | -i"src/os" 12 | -i"src/os/win32" 13 | -i"objs" 14 | -i"src/http" 15 | -i"src/rtmp" 16 | 17 | -i"vs2010/include" 18 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/lib-atl.lnt: -------------------------------------------------------------------------------- 1 | 2 | // These options were necessary to quietly process headers: 3 | // atlbase.h and atlcom.h 4 | 5 | // Gimpel Software would like to acknowledge Mike Diack and Simon Coghlans 6 | // for providing the bulk of the options in this file 7 | 8 | 9 | // NOTE: That turning off and on lint messages from system headers must be done 10 | // using -save, -restore. (e.g., -save -e... -restore ) 11 | 12 | // These are principally for ATL problems 13 | -elib(618) // unusual order 'const static ...' 14 | -elib(1512) 15 | -elib(1070) 16 | -elib(1015) 17 | -elib(1054) 18 | 19 | -printf(1,::AtlTrace) 20 | 21 | // Make LINT moan less about typical smart pointer creations 22 | -emacro(655,CLSCTX_SERVER) 23 | 24 | // Tweaks to work around some of the fall out of using OLE, ATL and COM macros 25 | -esym(550,_acp) 26 | -esym(550,_lpa) 27 | -esym(550,_convert) 28 | -esym(550,_lpw) 29 | -esym(522,_acp) 30 | -esym(522,_lpa) 31 | -esym(1512,CThreadLocalObject) 32 | -esym(1512,CProcessLocalObject) 33 | -esym(628,ATL::GetDefaultThreads) 34 | -esym(534,CComControlBase::FireViewChange) 35 | -esym(1748,IUnknown) 36 | -esym(1928,CComObjectRootEx) 37 | -esym(665,ATL::ATLTRY) // unparenthesized macro parameter 38 | -esym(666,COLUMN_ENTRY) 39 | -esym(666,_COLUMN_ENTRY_CODE) 40 | 41 | // Fix all variants of member functions GetClsid (COM generated) 42 | // by use of wildcard and class scope operator to cover all classes! 43 | -esym(1762,*::GetClsid) 44 | 45 | -esym(955,MIDL_user_allocate) 46 | -esym(1512,_CIP) 47 | -esym(1512,_CIP<<1>,<2>>) 48 | -emacro(732,OLE2T) 49 | -emacro(732,OLE2CT) 50 | -emacro(1509,CComObjectRootEx) 51 | -esym(1509,CComObjectRootEx) 52 | -emacro(1511,DECLARE_PROTECT_FINAL_CONSTRUCT) 53 | -emacro(1511,BEGIN_COM_MAP) 54 | -emacro(613,BEGIN_COM_MAP) 55 | -emacro(737,BEGIN_COM_MAP) 56 | -emacro(785,END_OBJECT_MAP) 57 | -emacro(1511,BEGIN_MSG_MAP) 58 | -emacro(618,BEGIN_COM_MAP) 59 | -emacro(522,BEGIN_MSG_MAP) 60 | -emacro(506,END_MSG_MAP) 61 | -emacro(534,DECLARE_PROTECT_FINAL_CONSTRUCT) 62 | 63 | // Stuff for Active X and wizard generated code etc. 64 | -emacro(1516,DECLARE_MESSAGE_MAP) 65 | -emacro(1516,DECLARE_DISPATCH_MAP) 66 | -emacro(1516,DECLARE_EVENT_MAP) 67 | -emacro(1516,DECLARE_NOT_AGGREGATABLE) 68 | -emacro(786,DISP_FUNCTION) 69 | -emacro(1511,DECLARE_DYNCREATE) 70 | -emacro(665,DECLARE_VIEW_STATUS) 71 | -emacro(665,VIEWSTATUS_SOLIDBKGND) 72 | -emacro(665,VIEWSTATUS_OPAQUE) 73 | -esym(666,COLUMN_ENTRY) 74 | -esym(666,_COLUMN_ENTRY_CODE) 75 | -emacro(78,COLUMN_ENTRY) 76 | -emacro(578,BEGIN_COLUMN_MAP) 77 | -emacro(754,BEGIN_COLUMN_MAP) 78 | -emacro(666,COLUMN_ENTRY) 79 | -emacro(666,_COLUMN_ENTRY_CODE) 80 | -emacro(413,COLUMN_ENTRY) 81 | -emacro(530,COLUMN_ENTRY) 82 | -emacro(732,COLUMN_ENTRY) 83 | -emacro(831,COLUMN_ENTRY) 84 | -emacro(746,COLUMN_ENTRY) 85 | -emacro(1046,COLUMN_ENTRY) 86 | -emacro(1055,COLUMN_ENTRY) 87 | 88 | // NOTE: This slightly convoluted format ({} and --) ensures that the 89 | // multiple variables created and stubbed by this macro are all handled 90 | // sensibly including in the scope that follows (typically the use of 91 | // an OLE2T macro). Use this rather than the less potent -emacro(522,USES_CONVERSION) 92 | --emacro({522},USES_CONVERSION) 93 | 94 | // NOTE: For some of the really convoluted ATL/COM macros etc, you need to use 95 | // the more powerful form again... 96 | --emacro({1773},IMPLEMENT_DYNCREATE) 97 | --emacro({955},STDMETHOD) 98 | --emacro({1762},BEGIN_COM_MAP) 99 | --emacro({1776},OLESTR) 100 | 101 | // For the string types we can safely use with TRACE etc, turn off 437 102 | -esym(437,CString) 103 | -esym(437,CComBSTR) 104 | 105 | // 106 | +dATLASSERT=__assert // lock in the define of ASSERT to be the builtin function 107 | 108 | //End of tweaks 109 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/lib-ole.lnt: -------------------------------------------------------------------------------- 1 | 2 | // BSTR functions (part of OLE Automation) 3 | 4 | -sem( SysAllocString, @p == malloc(1p) || @p == 0, 1p ) 5 | -sem( SysAllocStringByteLen, @P == malloc(2n+1) || @p == 0 ) 6 | -sem( SysAllocStringLen, @p == malloc(2n+1) || @p == 0 ) 7 | -sem( SysStringLen, 1p ? @n == 1p - 1 : @n == 0 ) 8 | -function( free, SysFreeString ) 9 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/lib-w32.lnt: -------------------------------------------------------------------------------- 1 | 2 | // lib-w32.lnt 3 | // PC-lint Library Options File for 32-bit mode windows.h 4 | 5 | -d__FLAT__ 6 | -d_WIN32 7 | -si4 8 | -sp4 9 | -esym(14,pLocalHeap) // variable defined in windows.h 10 | -e740 // remove 'suspicious cast' messages because these must be 11 | // routinely done within Windows. 12 | -elib(46) // windows.h uses a BYTE as base of bit field. 13 | -e793 // windows breaks ANSI limits 14 | 15 | // the following functions have their return value typically ignored. 16 | // add or subtract from this list as desired. 17 | -esym(534,RegisterClass,ShowWindow,TranslateMessage,DispatchMessage) 18 | -esym(534,DrawText,GetTextMetrics,ReleaseDC,TextOut,SetTextAlign) 19 | -esym(534,SetScrollPos,SelectObject,SetBkMode,SendMessage,MessageBox) 20 | -esym(534,MessageBoxA,MessageBoxW,PostMessageA,PostMessageW) 21 | -esym(534,PatBlt,DeleteDC,SetCapture,SetCursor,StretchBlt) 22 | -esym(534,Rectangle,MoveTo,LineTo,ShowCursor,MoveWindow,SetWindowWord) 23 | -esym(534,SetPixel,FillRect,DeleteObject,KillTimer,GetProfileString) 24 | -esym(534,SetWindowLong,SetFocus,SetBkColor,SetTextColor,SetBrushOrg) 25 | -esym(534,UnrealizeObject,_lclose,Polygon,FrameRect,LoadString) 26 | -esym(534,GetInstanceData,GlobalUnlock,FreeResource,LoadString) 27 | -esym(534,DrawIcon,AppendMenu,GetObject,CheckMenuItem,SetClassWord) 28 | -esym(534,EnableMenuItem,SetMenu,DestroyMenu,TrackPopupMenu) 29 | -esym(534,AnsiUpper,Arc,BeginPaint,BitBlt,ChangeClipboardChain,Chord) 30 | -esym(534,CloseClipboard,CombineRgn,DdeClientTransaction,DdeDisconnect) 31 | -esym(534,DdeFreeStringHandle,DdeGetData,DdeNameService,DdePostAdvise) 32 | -esym(534,DdeQueryString,DdeUninitialize,DeleteMenu,DeleteMetaFile) 33 | -esym(534,DestroyWindow,DialogBox,DPtoLP,Ellipse,EmptyClipboard,EnableWindow) 34 | -esym(534,EnumChildWindows,EnumWindows,Escape,GetClassName,GetDlgItemText) 35 | -esym(534,GetFileTitle,GetMenuString,GetStrings,GetSystemMenu,GetTextFace) 36 | -esym(534,GetWindowText,GlobalDeleteAtom,GlobalFree,GlobalGetAtomName) 37 | -esym(534,LocalFree,LocalUnlock,LockResource,lstrcpy,OpenClipboard) 38 | -esym(534,Pie,PlayMetaFile,PopFindNextText,PostDataMessage,PostMessage) 39 | -esym(534,RestoreDC,SaveDC,SelectClipRgn,SendDlgItemMessage,SetClipboardData) 40 | -esym(534,SetDIBitsToDevice,SetMapMode,SetMapperFlags,SetROP2,SetStretchBltMode) 41 | -esym(534,SetTextJustification,SetTimer,SetViewportExt,SetViewportOrg) 42 | -esym(534,SetWindowExt,SetWindowOrg,StretchDIBits,WinExec) 43 | 44 | // Ignored parameters 45 | -esym(715,lpszCmdParam,lpszCmdLine) 46 | 47 | -emacro(648,PSN_*) // ignore unsigned overflow (0-200U) 48 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/lib-wnt.lnt: -------------------------------------------------------------------------------- 1 | 2 | // lib-wnt.lnt 3 | // PC-lint Library Options File for Windows NT 4 | 5 | -d__FLAT__ 6 | -d_WIN32 7 | 8 | -emacro(506,assert) // 506 (constant valued Boolean) is issued when 9 | // assert(e) is defined as (e||(__assert(),0)) 10 | -si4 11 | -sp4 12 | -esym(14,pLocalHeap) // variable defined in windows.h 13 | -e740 // remove 'suspicious cast' messages because these must be 14 | // routinely done within Windows. 15 | -elib(46) // windows.h uses a BYTE as base of bit field. 16 | -elib(1504) // useless struct definition in winnt.h 17 | -elib(659) // nothing follows '}' on same line in dlgs.h 18 | -elib(620) // using 'l' to denote Long in mmsystem.h 19 | -elib(123) // FD_SET is both a type and a macro (with arguments). 20 | -e793 // windows breaks ANSI limits 21 | 22 | // the following functions have their return value typically ignored. 23 | // add or subtract from this list as desired. 24 | -esym(534,RegisterClass,ShowWindow,TranslateMessage,DispatchMessage) 25 | -esym(534,DrawText,GetTextMetrics,ReleaseDC,TextOut,SetTextAlign) 26 | -esym(534,SetScrollPos,SelectObject,SetBkMode,SendMessage,MessageBox) 27 | -esym(534,MessageBoxA,MessageBoxW,PostMessageA,PostMessageW) 28 | -esym(534,PatBlt,DeleteDC,SetCapture,SetCursor,StretchBlt) 29 | -esym(534,Rectangle,MoveTo,LineTo,ShowCursor,MoveWindow,SetWindowWord) 30 | -esym(534,SetPixel,FillRect,DeleteObject,KillTimer,GetProfileString) 31 | -esym(534,SetWindowLong,SetFocus,SetBkColor,SetTextColor,SetBrushOrg) 32 | -esym(534,UnrealizeObject,_lclose,Polygon,FrameRect,LoadString) 33 | -esym(534,GetInstanceData,GlobalUnlock,FreeResource,LoadString) 34 | -esym(534,DrawIcon,AppendMenu,GetObject,CheckMenuItem,SetClassWord) 35 | -esym(534,EnableMenuItem,SetMenu,DestroyMenu,TrackPopupMenu) 36 | -esym(534,AnsiUpper,Arc,BeginPaint,BitBlt,ChangeClipboardChain,Chord) 37 | -esym(534,CloseClipboard,CombineRgn,DdeClientTransaction,DdeDisconnect) 38 | -esym(534,DdeFreeStringHandle,DdeGetData,DdeNameService,DdePostAdvise) 39 | -esym(534,DdeQueryString,DdeUninitialize,DeleteMenu,DeleteMetaFile) 40 | -esym(534,DestroyWindow,DialogBox,DPtoLP,Ellipse,EmptyClipboard,EnableWindow) 41 | -esym(534,EnumChildWindows,EnumWindows,Escape,GetClassName,GetDlgItemText) 42 | -esym(534,GetFileTitle,GetMenuString,GetStrings,GetSystemMenu,GetTextFace) 43 | -esym(534,GetWindowText,GlobalDeleteAtom,GlobalFree,GlobalGetAtomName) 44 | -esym(534,LocalFree,LocalUnlock,LockResource,lstrcpy,OpenClipboard) 45 | -esym(534,Pie,PlayMetaFile,PopFindNextText,PostDataMessage,PostMessage) 46 | -esym(534,RestoreDC,SaveDC,SelectClipRgn,SendDlgItemMessage,SetClipboardData) 47 | -esym(534,SetDIBitsToDevice,SetMapMode,SetMapperFlags,SetROP2,SetStretchBltMode) 48 | -esym(534,SetTextJustification,SetTimer,SetViewportExt,SetViewportOrg) 49 | -esym(534,SetWindowExt,SetWindowOrg,StretchDIBits,WinExec) 50 | 51 | // Ignored parameters 52 | -esym(715,lpszCmdParam,lpszCmdLine) 53 | 54 | -emacro(648,PSN_*) // ignore unsigned overflow (0-200U) 55 | -printf( 1, CString::Format ) // this function behaves like printf 56 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/lint-nt.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/misc/vc2010/lint-nt.exe -------------------------------------------------------------------------------- /trunk/misc/vc2010/macro.lnt: -------------------------------------------------------------------------------- 1 | -dHAVE_OS_WIN32 2 | -dHAVE_PCLINT_CHECK 3 | -dWIN32 4 | -dUNICODE -------------------------------------------------------------------------------- /trunk/misc/vc2010/options.lnt: -------------------------------------------------------------------------------- 1 | // Please note -- this is a representative set of error suppression 2 | // options. Please adjust to suit your own policies 3 | // See manual (chapter LIVING WITH LINT) 4 | // for further details. 5 | 6 | -e720 // allow direct test of assignment 7 | -e502 -e713 -e737 -eau // don't report on signed/unsigned mismatches 8 | -e734 // allow sub-integer loss of information 9 | -e701 -e703 // shifting int left is OK 10 | -e718 // allow calls to undeclared C functions 11 | -e746 // allow calls w/o prototypes in C. 12 | -e783 13 | -e900 14 | -e952 15 | -e818 16 | -e413 17 | -e755 18 | -e714 19 | -e534 20 | -e757 21 | -e768 22 | -e756 23 | -e1904 24 | -e1924 25 | -e717 26 | -e1784 //in cpp previously declared as "C" 27 | +fqb 28 | -e801 -------------------------------------------------------------------------------- /trunk/misc/vc2010/pclint.bat: -------------------------------------------------------------------------------- 1 | SET PCLINT_PATH=misc\vc2010 2 | "%PCLINT_PATH%\lint-nt.exe" -i"%PCLINT_PATH%" std.lnt %1 3 | -------------------------------------------------------------------------------- /trunk/misc/vc2010/std.lnt: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ 2008, -si4 -sp4, lib-atl.lnt lib-mfc.lnt lib-w32.lnt lib-wnt.lnt 2 | // Standard lint options 3 | 4 | au-sm123.lnt au-ds.lnt 5 | co-msc100.lnt env-vc10.lnt 6 | lib-atl.lnt lib-mfc.lnt lib-w32.lnt lib-wnt.lnt 7 | options.lnt -si4 -sp4 8 | include.lnt 9 | macro.lnt 10 | 11 | -------------------------------------------------------------------------------- /trunk/objs/bin/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | daemon on; 2 | workers 12; 3 | 4 | pid_file logs/rtmpd.pid; 5 | lock_file logs/rtmpd.lock; 6 | log_file logs/error.log error; 7 | 8 | event { 9 | use select; 10 | work_connections 2048; 11 | } 12 | 13 | rtmp { 14 | stat_file logs/stat.html; 15 | 16 | ping 5000; 17 | acknowledgement 2500000; 18 | chunk_size 1024; 19 | 20 | server { 21 | root host/www.test.com; 22 | server_name www.test.com default; 23 | listen 127.0.0.1:1935; 24 | listen 127.0.0.1:1935; 25 | 26 | app myapp { 27 | push rtmp://192.168.9.254:1936/$app/$stream; 28 | allow publish 192.168.9.25/24; 29 | deny play 192.168.9.24/32; 30 | } 31 | 32 | app myapp2 { 33 | pull rtmp://192.168.9.22:1936/$app/$stream; 34 | allow publish 192.168.9.25/24; 35 | deny play 192.168.9.24/32; 36 | } 37 | } 38 | 39 | server { 40 | root host/example.com; 41 | server_name www.example.com; 42 | 43 | listen 0.0.0.0:1935; 44 | listen 127.0.0.1:1935; 45 | 46 | app myapp { 47 | push rtmp://192.168.9.254:1936/$app/$stream; 48 | allow publish 192.168.9.25/24; 49 | deny play 192.168.9.24/32; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /trunk/objs/bin/conf/rtmpd.conf: -------------------------------------------------------------------------------- 1 | daemon on; 2 | workers 12; 3 | 4 | event { 5 | use epoll; 6 | work_connections 2048; 7 | } 8 | 9 | rtmp { 10 | out_queue 1024; 11 | 12 | server { 13 | listen 1935 default; 14 | #listen 172.27.35.2:1936; 15 | #listen 192.168.109.1:1935; 16 | # 17 | 18 | server_name www.test.com; 19 | ping 5000; 20 | acknowledgement 2500000; 21 | chunk_size 1024; 22 | 23 | allow publish 192.168.9.25/24; 24 | deny play 192.168.9.24/32; 25 | 26 | app myapp { 27 | 28 | push rtmp://192.168.9.254:1936/$app/$stream; 29 | 30 | allow publish 192.168.9.25/24; 31 | deny play 192.168.9.24/32; 32 | 33 | } 34 | } 35 | 36 | server { 37 | 38 | listen 127.0.0.1:1935 default; 39 | #listen 0.0.0.0:1935 default ; 40 | #listen 172.27.35.2:1935 default; 41 | 42 | server_name www.example.com; 43 | ping 5000; 44 | acknowledgement 2500000; 45 | chunk_size 1024; 46 | 47 | app live_server { 48 | 49 | push rtmp://192.168.9.254:1936/$app/$stream; 50 | 51 | allow publish 192.168.9.25/24; 52 | deny play 192.168.9.24/32; 53 | 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_amf.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __AMF_H_INCLUDED__ 7 | #define __AMF_H_INCLUDED__ 8 | 9 | #define SCRIPT_AMF0 0 10 | #define SCRIPT_AMF3 3 11 | 12 | /*AMF0 data types*/ 13 | 14 | #define amf_number 0x00 15 | #define amf_boolean 0x01 16 | #define amf_string 0x02 17 | #define amf_object 0x03 18 | #define amf_movieclip 0x04 /* reserved */ 19 | #define amf_null 0x05 20 | #define amf_undefined 0x06 21 | #define amf_reference 0x07 22 | #define amf_ecma_array 0x08 23 | #define amf_object_end 0x09 24 | #define amf_strict_array 0x0a 25 | #define amf_date 0x0b 26 | #define amf_long_string 0x0c 27 | #define amf_unsupported 0x0d 28 | #define amf_recordset 0x0e /* reserved */ 29 | #define amf_xml_document 0x0f 30 | #define amf_typed_object 0x10 31 | #define amf_avmplus_object 0x11 32 | #define amf_invalid 0xff 33 | 34 | /*AMF3 data types*/ 35 | 36 | #define amf3_null 0x01 37 | #define amf3_false 0x02 38 | #define amf3_true 0x03 39 | #define amf3_integer 0x04 40 | #define amf3_double 0x05 41 | #define amf3_string 0x06 42 | #define amf3_xml_doc 0x07 43 | #define amf3_date 0x08 44 | #define amf3_array 0x09 45 | #define amf3_object 0x0a 46 | #define amf3_xml 0x0c 47 | #define amf3_byte_array 0x0d 48 | #define amf3_invalid 0xff 49 | 50 | #define amf_new_bool(b) amf_new(amf_boolean,(uint32_t)b) 51 | #define amf_new_string(s,len) amf_new(amf_string,(const char*)s,(int32_t)len) 52 | #define amf_new_number(n) amf_new(amf_number,(double)n) 53 | #define amf_new_date(n,tz) amf_new(amf_date,(double)n,(int32_t)tz) 54 | #define amf_new_object() amf_new(amf_object) 55 | #define amf_new_ecma_array() amf_new(amf_ecma_array) 56 | #define amf_new_null() amf_new(amf_null) 57 | 58 | /*memory*/ 59 | typedef void* (*amf_malloc)(size_t size,void *u); 60 | typedef void (*amf_free)(void *p,void *u); 61 | 62 | /*data types*/ 63 | typedef void * amf_data_t; 64 | 65 | char* amf_get_string(amf_data_t *data); 66 | uint8_t amf_get_bool(amf_data_t *data); 67 | double amf_get_number(amf_data_t *data); 68 | double amf_get_date(amf_data_t *data); 69 | 70 | int amf_init(amf_malloc alloc,amf_free free,void *u); 71 | 72 | amf_data_t* amf_new(uint8_t type,...); 73 | 74 | uint8_t amf_data_type(amf_data_t * data); 75 | 76 | void amf_free_data(amf_data_t * data); 77 | 78 | int amf_put_prop(amf_data_t *obj,const char* name,const amf_data_t *data); 79 | amf_data_t *amf_get_prop(amf_data_t *obj,const char* name); 80 | 81 | /*return a amf object null for invalid*/ 82 | amf_data_t * amf_decode(const char *buf,int *len); 83 | 84 | /*return remain length of buf*/ 85 | int amf_encode(amf_data_t *data,char *buf,int maxlen); 86 | 87 | #ifdef HAVE_DEBUG 88 | int amf_dump_data(amf_data_t * data); 89 | #endif 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_array.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | 10 | int array_init(array_t *a, mem_pool_t *pool, uint32_t n, size_t size) 11 | { 12 | a->nelts = 0; 13 | a->size = size; 14 | a->nalloc = n; 15 | a->pool = pool; 16 | 17 | a->elts = mem_palloc(pool, n * size); 18 | if (a->elts == NULL) { 19 | return RTMP_ERROR; 20 | } 21 | 22 | return RTMP_OK; 23 | } 24 | 25 | array_t * 26 | array_create(mem_pool_t *p, uint32_t n, size_t size) 27 | { 28 | array_t *a; 29 | 30 | a = mem_palloc(p, sizeof(array_t)); 31 | if (a == NULL) { 32 | return NULL; 33 | } 34 | 35 | if (array_init(a, p, n, size) != RTMP_OK) { 36 | return NULL; 37 | } 38 | 39 | return a; 40 | } 41 | 42 | 43 | void 44 | array_destroy(array_t *a) 45 | { 46 | mem_pool_t *p; 47 | 48 | p = a->pool; 49 | 50 | if ((u_char *) a->elts + a->size * a->nalloc == p->d.last) { 51 | p->d.last -= a->size * a->nalloc; 52 | } 53 | 54 | if ((u_char *) a + sizeof(array_t) == p->d.last) { 55 | p->d.last = (u_char *) a; 56 | } 57 | } 58 | 59 | 60 | void * 61 | array_push(array_t *a) 62 | { 63 | void *elt, *new; 64 | size_t size; 65 | mem_pool_t *p; 66 | 67 | if (a->nelts == a->nalloc) { 68 | 69 | /* the array is full */ 70 | 71 | size = a->size * a->nalloc; 72 | 73 | p = a->pool; 74 | 75 | if ((u_char *) a->elts + size == p->d.last 76 | && p->d.last + a->size <= p->d.end) 77 | { 78 | /* 79 | * the array allocation is the last in the pool 80 | * and there is space for new allocation 81 | */ 82 | 83 | p->d.last += a->size; 84 | a->nalloc++; 85 | 86 | } else { 87 | /* allocate a new array */ 88 | 89 | new = mem_palloc(p, 2 * size); 90 | if (new == NULL) { 91 | return NULL; 92 | } 93 | 94 | memcpy(new, a->elts, size); 95 | a->elts = new; 96 | a->nalloc *= 2; 97 | } 98 | } 99 | 100 | elt = (u_char *) a->elts + a->size * a->nelts; 101 | a->nelts++; 102 | 103 | return elt; 104 | } 105 | 106 | 107 | void * 108 | array_push_n(array_t *a, uint32_t n) 109 | { 110 | void *elt, *new; 111 | size_t size; 112 | uint32_t nalloc; 113 | mem_pool_t *p; 114 | 115 | size = n * a->size; 116 | 117 | if (a->nelts + n > a->nalloc) { 118 | 119 | /* the array is full */ 120 | 121 | p = a->pool; 122 | 123 | if ((u_char *) a->elts + a->size * a->nalloc == p->d.last 124 | && p->d.last + size <= p->d.end) 125 | { 126 | /* 127 | * the array allocation is the last in the pool 128 | * and there is space for new allocation 129 | */ 130 | 131 | p->d.last += size; 132 | a->nalloc += n; 133 | 134 | } else { 135 | /* allocate a new array */ 136 | 137 | nalloc = 2 * ((n >= a->nalloc) ? n : a->nalloc); 138 | 139 | new = mem_palloc(p, nalloc * a->size); 140 | if (new == NULL) { 141 | return NULL; 142 | } 143 | 144 | memcpy(new, a->elts, a->nelts * a->size); 145 | a->elts = new; 146 | a->nalloc = nalloc; 147 | } 148 | } 149 | 150 | elt = (u_char *) a->elts + a->size * a->nelts; 151 | a->nelts += n; 152 | 153 | return elt; 154 | } 155 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_array.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #ifndef __ARRAY_H_INCLUDED__ 8 | #define __ARRAY_H_INCLUDED__ 9 | 10 | 11 | typedef struct { 12 | void *elts; 13 | uint32_t nelts; 14 | size_t size; 15 | uint32_t nalloc; 16 | mem_pool_t *pool; 17 | } array_t; 18 | 19 | 20 | array_t *array_create(mem_pool_t *p, uint32_t n, size_t size); 21 | void array_destroy(array_t *a); 22 | void *array_push(array_t *a); 23 | void *array_push_n(array_t *a, uint32_t n); 24 | int array_init(array_t *array, mem_pool_t *pool, uint32_t n, size_t size); 25 | 26 | #endif /* __ARRAY_H_INCLUDED__ */ -------------------------------------------------------------------------------- /trunk/src/core/rtmp_bytes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CopyLeft (C) nie950@gmail.com 3 | */ 4 | 5 | #include "rtmp_config.h" 6 | #include "rtmp_core.h" 7 | 8 | #if 0 9 | 10 | static int byte_write_little(const char *in,char *out,int l); 11 | static int byte_write_big(const char *in,char *out,int l); 12 | 13 | int byte_write(const char *in,char *out,int l,int order) 14 | { 15 | if (order == BYTE_LITTLE_ENDIAN) { 16 | return byte_write_little(in,out,l); 17 | } 18 | return byte_write_big(in,out,l); 19 | } 20 | 21 | int byte_write_little(const char *in,char *out,int l) 22 | { 23 | char temp[8]; 24 | 25 | switch (l) { 26 | case 1: 27 | *out = *in; 28 | 29 | break; 30 | 31 | case 2: 32 | memcpy(temp,in,2); 33 | 34 | out[0] = temp[1]; 35 | out[1] = temp[0]; 36 | 37 | break; 38 | 39 | case 4: 40 | memcpy(temp,in,4); 41 | 42 | out[0] = temp[3]; 43 | out[1] = temp[2]; 44 | out[2] = temp[1]; 45 | out[3] = temp[0]; 46 | 47 | break; 48 | 49 | case 8: 50 | memcpy(temp,in,8); 51 | 52 | out[0] = temp[7]; 53 | out[1] = temp[6]; 54 | out[2] = temp[5]; 55 | out[3] = temp[4]; 56 | out[4] = temp[3]; 57 | out[5] = temp[2]; 58 | out[6] = temp[1]; 59 | out[7] = temp[0]; 60 | 61 | break; 62 | 63 | default: 64 | return -1; 65 | } 66 | 67 | return 0; 68 | } 69 | 70 | static int byte_write_big(const char *in,char *out,int l) 71 | { 72 | char temp[8]; 73 | 74 | if (in == out) { 75 | return 0; 76 | } 77 | 78 | switch (l) { 79 | case 1: 80 | *out = *in; 81 | 82 | break; 83 | 84 | case 2: 85 | case 4: 86 | case 8: 87 | memcpy(temp,in,l); 88 | memcpy(out,temp,l); 89 | 90 | break; 91 | 92 | default: 93 | 94 | return -1; 95 | } 96 | 97 | return 0; 98 | } 99 | 100 | #endif 101 | 102 | void byte_fill_random(char *buf,int size) 103 | { 104 | while (size-- > 0) { 105 | buf[size] = (unsigned char)rand(); 106 | } 107 | } 108 | 109 | uint32_t mem_bits_init(mem_bits_t *b,mem_buf_t *buf) 110 | { 111 | b->buf = *buf; 112 | b->offset = 0; 113 | 114 | return RTMP_OK; 115 | } 116 | 117 | uint32_t mem_bits_read(mem_bits_t *b,uint16_t l) 118 | { 119 | uint32_t n,c,i,j; 120 | uint8_t buf[8]; 121 | 122 | c = (uint32_t)(b->buf.last - b->buf.buf); 123 | if ((b->offset + l > c * 8) || (l > 32)) { 124 | return (uint32_t)-1; 125 | } 126 | 127 | memcpy(buf,& b->buf.buf[b->offset/8],(l+7)/8); 128 | j = b->offset % 8; 129 | 130 | n = 0; 131 | for (i = j;i < j + l;i++) { 132 | n = (uint32_t)((buf[i/8] >> (7-i%8)) & 1) | (n << 1); 133 | } 134 | b->offset += l; 135 | 136 | return n; 137 | } 138 | 139 | uint32_t mem_bits_read_golomb(mem_bits_t *b) 140 | { 141 | uint32_t n; 142 | 143 | for (n = 0;mem_bits_read(b,1) == 0;n++) { 144 | if (b->offset >= (uint32_t)(b->buf.last - b->buf.buf) * 8) { 145 | break; 146 | } 147 | } 148 | 149 | return (1 << n) + mem_bits_read(b,n) - 1; 150 | } -------------------------------------------------------------------------------- /trunk/src/core/rtmp_conf.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __CONF_H_INCLUDED__ 7 | #define __CONF_H_INCLUDED__ 8 | 9 | 10 | #define GET_CONF_CURRENT 0 11 | #define GET_CONF_NEXT 1 12 | #define GET_CONF_CHILD 2 13 | 14 | #define CONF_CONFIG_BLOCK_START 0 15 | #define CONF_CONFIG_BLOCK_DONE 1 16 | #define CONF_CONFIG_NEXT 2 17 | #define CONF_CONFIG_ERROR 3 18 | #define CONF_CONFIG_END 4 19 | 20 | #define CONF_ON 1 21 | #define CONF_OFF 0 22 | 23 | typedef struct rtmp_conf_s rtmp_conf_t; 24 | typedef struct rtmp_conf_tree_s rtmp_conf_tree_t; 25 | 26 | struct rtmp_conf_s { 27 | void *data; /*void data*/ 28 | 29 | array_t argv; 30 | 31 | link_t v; /*next: child ; prev : parent*/ 32 | link_t h; 33 | }; 34 | 35 | struct rtmp_conf_tree_s { 36 | rtmp_conf_t *root; 37 | }; 38 | 39 | /*parse file*/ 40 | int32_t rtmp_conf_parse(rtmp_cycle_t *cycle); 41 | rtmp_conf_t *rtmp_get_conf(rtmp_conf_t *conf,char *name,int type); 42 | 43 | #endif -------------------------------------------------------------------------------- /trunk/src/core/rtmp_connection.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | 10 | void drain_connections() 11 | { 12 | return ; 13 | } 14 | 15 | rtmp_connection_t *get_connection(rtmp_listening_t *ls,fd_t s) 16 | { 17 | rtmp_connection_t *c; 18 | rtmp_event_t *rev, *wev; 19 | mem_pool_t *pool; 20 | rtmp_cycle_t *rtmp_cycle; 21 | 22 | rtmp_cycle = ls->cycle; 23 | 24 | c = rtmp_cycle->free_connections; 25 | 26 | if (c == NULL) { 27 | drain_connections(); 28 | c = rtmp_cycle->free_connections; 29 | } 30 | 31 | if (c == NULL) { 32 | rtmp_log(RTMP_LOG_DEBUG,"no enough connections[%d]!",s); 33 | return NULL; 34 | } 35 | 36 | rtmp_cycle->free_connections = c->next; 37 | rev = c->read; 38 | wev = c->write; 39 | pool = c->pool; 40 | 41 | memset(c, 0, sizeof(rtmp_connection_t)); 42 | 43 | c->read = rev; 44 | c->write = wev; 45 | c->fd = s; 46 | c->pool = pool; 47 | 48 | memset(rev, 0 ,sizeof(rtmp_event_t)); 49 | memset(wev, 0, sizeof(rtmp_event_t)); 50 | 51 | rev->data = c; 52 | wev->data = c; 53 | wev->write = 1; 54 | 55 | rev->index = -1; 56 | wev->index = -1; 57 | 58 | rtmp_log(RTMP_LOG_DEBUG,"get connection:%p",c); 59 | 60 | return c; 61 | } 62 | 63 | void close_connection(rtmp_connection_t *c) 64 | { 65 | rtmp_cycle_t *ngx_cycle; 66 | fd_t fd; 67 | 68 | ngx_cycle = c->listening->cycle; 69 | 70 | fd = c->fd; 71 | if (fd == -1) { 72 | rtmp_log(RTMP_LOG_DEBUG,"[%d]already closed socket!",c->fd); 73 | return ; 74 | } 75 | 76 | if (c->read->timer_set) { 77 | rtmp_event_del_timer(c->read); 78 | } 79 | 80 | if (c->write->timer_set) { 81 | rtmp_event_del_timer(c->write); 82 | } 83 | 84 | rtmp_event_delete_conn(c); 85 | 86 | c->fd = -1; 87 | closesocket(fd); 88 | 89 | rtmp_log(RTMP_LOG_DEBUG,"[%d]closed socket",fd); 90 | 91 | c->next = ngx_cycle->free_connections; 92 | ngx_cycle->free_connections = c; 93 | 94 | rtmp_log(RTMP_LOG_DEBUG,"close connection[%p]",c); 95 | 96 | return ; 97 | } 98 | 99 | void free_connection(rtmp_connection_t *c) 100 | { 101 | rtmp_cycle_t *ngx_cycle; 102 | fd_t fd; 103 | 104 | ngx_cycle = c->listening->cycle; 105 | 106 | fd = c->fd; 107 | c->fd = -1; 108 | 109 | if (fd != -1) { 110 | rtmp_log(RTMP_LOG_DEBUG,"close socket",fd); 111 | closesocket(fd); 112 | } 113 | 114 | c->next = ngx_cycle->free_connections; 115 | ngx_cycle->free_connections = c; 116 | 117 | rtmp_log(RTMP_LOG_DEBUG,"free connection:%p",c); 118 | 119 | return ; 120 | } 121 | 122 | int32_t sockaddr_sin_cmp(struct sockaddr *sin1,struct sockaddr *sin2) 123 | { 124 | struct sockaddr_in *s1,*s2; 125 | int32_t family,port,addr; 126 | 127 | s1 = (struct sockaddr_in *)sin1; 128 | s2 = (struct sockaddr_in *)sin2; 129 | 130 | family = s1->sin_family - s2->sin_family; 131 | if (family > 0) { 132 | 133 | family = 0x10; 134 | 135 | } else if (family < 0){ 136 | 137 | family = 0x01; 138 | } 139 | 140 | port = s1->sin_port - s2->sin_port; 141 | if (port > 0) { 142 | 143 | port = 0x10; 144 | 145 | } else if (port < 0){ 146 | 147 | port = 0x01; 148 | } 149 | 150 | addr = s1->sin_addr.s_addr - s1->sin_addr.s_addr; 151 | if (addr > 0) { 152 | 153 | addr = 0x10; 154 | 155 | } else if (addr < 0){ 156 | 157 | addr = 0x01; 158 | } 159 | 160 | return (family << 24) + (port << 16) + addr; 161 | } -------------------------------------------------------------------------------- /trunk/src/core/rtmp_connection.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LISTENING_H_INCLUDED__ 7 | #define __LISTENING_H_INCLUDED__ 8 | 9 | struct rtmp_listening_s { 10 | socket_t fd; 11 | 12 | struct sockaddr sockaddr; 13 | socklen_t socklen; 14 | char sockaddr_text[32]; 15 | connection_handler_pt handler; 16 | 17 | rtmp_connection_t *connection; 18 | rtmp_cycle_t *cycle; 19 | 20 | void *data; 21 | }; 22 | 23 | struct rtmp_connection_s { 24 | void *data; 25 | 26 | fd_t fd; 27 | rtmp_event_t *read; 28 | rtmp_event_t *write; 29 | rtmp_listening_t *listening; 30 | rtmp_connection_t *next; 31 | 32 | /*remote*/ 33 | struct sockaddr sockaddr; 34 | socklen_t socklen; 35 | char addr_text[32]; 36 | 37 | /*local*/ 38 | struct sockaddr local_sockaddr; 39 | socklen_t local_socklen; 40 | char local_addr_text[32]; 41 | 42 | mem_pool_t *pool; 43 | }; 44 | 45 | rtmp_connection_t *get_connection(rtmp_listening_t *ls,fd_t s); 46 | void free_connection(rtmp_connection_t *c); 47 | void close_connection(rtmp_connection_t *c); 48 | 49 | /*[00][00][0000]: family:port:addr*/ 50 | int32_t sockaddr_sin_cmp(struct sockaddr *sin1,struct sockaddr *sin2); 51 | 52 | #endif -------------------------------------------------------------------------------- /trunk/src/core/rtmp_def.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __RTMP_DEF_H_INCLUDED__ 7 | #define __RTMP_DEF_H_INCLUDED__ 8 | 9 | #define rtmp_abs(value) (((value) >= 0) ? (value) : - (value)) 10 | #define rtmp_max(val1, val2) (((val1) < (val2)) ? (val2) : (val1)) 11 | #define rtmp_min(val1, val2) (((val1) > (val2)) ? (val2) : (val1)) 12 | 13 | #define rtmp_array_size(x) (sizeof(x)/sizeof((x)[0])) 14 | #define rtmp_hash(key, c) ((uint32_t) key * 31 + c) 15 | 16 | #define rtmp_invaild_ptr ((void*)(-1)) 17 | 18 | typedef struct rtmp_cycle_s rtmp_cycle_t; 19 | typedef struct rtmp_module_s rtmp_module_t; 20 | typedef struct rtmp_listening_s rtmp_listening_t; 21 | typedef struct rtmp_connection_s rtmp_connection_t; 22 | typedef struct rtmp_session_s rtmp_session_t; 23 | typedef struct rtmp_addr_port_s rtmp_addr_port_t; 24 | typedef struct rtmp_addr_inet_s rtmp_addr_inet_t; 25 | 26 | #define RTMP_VIDEO_KEY_FRAME 1 27 | #define RTMP_VIDEO_INTER_FRAME 2 28 | #define RTMP_VIDEO_DISPOSABLE_FRAME 3 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_error.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | #define ERR_MAX 1000 10 | 11 | char *sys_error_unknown = "Unknown error"; 12 | char **sys_error_list; 13 | int32_t sys_error_len; 14 | char *rtmp_error_list[32]; 15 | 16 | char *rtmp_strncpy(char* dest,const char* src, size_t size) 17 | { 18 | if (!dest || !src) { 19 | return 0; 20 | } 21 | 22 | while (((int32_t)--size > 0) && (*dest++ = *src++)) {} 23 | dest[0] = '\0'; 24 | 25 | return dest; 26 | } 27 | 28 | 29 | char* rtmp_strerror(int32_t err, char *errstr, size_t size) 30 | { 31 | char *msg; 32 | 33 | if (err < 0 && err >= sys_error_len) { 34 | return 0; 35 | } 36 | 37 | msg = sys_error_list[err]; 38 | rtmp_strncpy(errstr,msg,size); 39 | 40 | return errstr; 41 | } 42 | 43 | 44 | int32_t rtmp_strerror_init(void) 45 | { 46 | int32_t err,len; 47 | char * msg,*p; 48 | size_t slen; 49 | 50 | for (err = 0;err < ERR_MAX;err++) { 51 | 52 | errno = 0; 53 | msg = strerror(err); 54 | 55 | if (errno == EINVAL || msg == NULL) { 56 | break; 57 | } 58 | } 59 | 60 | if (err == 0) { 61 | goto failed; 62 | } 63 | 64 | len = err; 65 | sys_error_list = malloc(sizeof(char *)*len); 66 | if (sys_error_list == NULL) { 67 | goto failed; 68 | } 69 | 70 | for (err = 0;err < len;err++) { 71 | 72 | msg = strerror(err); 73 | slen = strlen(msg); 74 | 75 | p = malloc(slen+1); 76 | if (p == NULL) { 77 | goto failed; 78 | } 79 | 80 | memcpy(p,msg,slen); 81 | p[slen] = '\0'; 82 | 83 | sys_error_list[err] = p; 84 | } 85 | 86 | sys_error_len = len; 87 | 88 | return RTMP_OK; 89 | 90 | failed: 91 | 92 | return RTMP_FAILED; 93 | } 94 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_error.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __ERROR_H_INCLUDED__ 7 | #define __ERROR_H_INCLUDED__ 8 | 9 | 10 | #define RTMP_NULL ((void*)0) 11 | #define RTMP_READY ((void*)-1) 12 | 13 | #define RTMP_OK (0) 14 | #define RTMP_ERROR (-1) 15 | #define RTMP_FAILED (-1) 16 | #define RTMP_IGNORE (-2) 17 | #define RTMP_ERROR_MAX (32) 18 | 19 | int32_t rtmp_strerror_init(void ); 20 | char* rtmp_strerror(int32_t err, char *errstr, size_t size); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_link.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | 10 | #define _link_init(n) \ 11 | ((n)->next = (n)->prev = (n)) 12 | 13 | #define _link_remove(n) \ 14 | (n)->next->prev = (n)->prev; \ 15 | (n)->prev->next = (n)->next; 16 | 17 | #define _link_insert(a,b) \ 18 | (b)->prev = (a); \ 19 | (b)->next = (a)->next; \ 20 | (b)->prev->next = (b); \ 21 | (b)->next->prev = (b); 22 | 23 | #define _link_num(l,i) \ 24 | do { \ 25 | const link_t * it; (i)=0; \ 26 | for (it = (l)->next; it != (l); it = it->next, (i)++) {/*void*/} \ 27 | } while (0) 28 | 29 | void list_init(list_t * l) 30 | { 31 | _link_init(l); 32 | } 33 | 34 | void list_insert_tail(list_t * l,link_t * n) 35 | { 36 | _link_insert(l->prev,n); 37 | } 38 | 39 | void list_insert_head(list_t * l,link_t * n) 40 | { 41 | _link_insert(l,n); 42 | } 43 | 44 | void list_remove(link_t * n) 45 | { 46 | _link_remove(n); 47 | } 48 | 49 | int list_empty(list_t *l) 50 | { 51 | return l == l->next; 52 | } 53 | 54 | int list_num(list_t * l) 55 | { 56 | int i; 57 | 58 | _link_num(l,i); 59 | 60 | return i; 61 | } 62 | 63 | link_t * list_find(list_t *l,compare proc,void * u) 64 | { 65 | link_t *it; 66 | 67 | for (it = l->next; it != l; it = it->next) { 68 | if (proc(it,u) == 0) { 69 | return it; 70 | } 71 | } 72 | 73 | return 0; 74 | } 75 | 76 | void queue_init(queue_t * q) 77 | { 78 | _link_init(q); 79 | } 80 | 81 | void queue_push(queue_t * q,link_t *n) 82 | { 83 | _link_insert(q->next,n); 84 | } 85 | 86 | link_t * queue_pop(queue_t * q) 87 | { 88 | link_t * n; 89 | 90 | if (q->next == q) { 91 | return 0; 92 | } 93 | 94 | n = q->next; 95 | 96 | _link_remove(n); 97 | 98 | return n; 99 | } 100 | 101 | link_t * queue_front(queue_t * q) 102 | { 103 | if (q->next == q) { 104 | return 0; 105 | } 106 | 107 | return q->next; 108 | } 109 | 110 | link_t * queue_rear(queue_t * q) 111 | { 112 | if (q->next == q) { 113 | return 0; 114 | } 115 | 116 | return q->prev; 117 | } 118 | 119 | int queue_length(queue_t * q) 120 | { 121 | int i = 0; 122 | 123 | _link_num(q,i); 124 | 125 | return i; 126 | } 127 | 128 | #if 0 129 | 130 | void stack_init(stack_t *st) 131 | { 132 | _link_init(st); 133 | } 134 | 135 | void stack_push(stack_t *st,link_t *n) 136 | { 137 | _link_insert(st->next,n) 138 | } 139 | 140 | link_t * stack_pop(stack_t *st) 141 | { 142 | link_t *n; 143 | 144 | n = st->prev; 145 | 146 | if (n == st) { 147 | return 0; 148 | } 149 | 150 | _link_remove(n); 151 | 152 | return n; 153 | } 154 | 155 | int stack_dept(stack_t *st) 156 | { 157 | int i = 0; 158 | 159 | _link_num(st,i); 160 | 161 | return i; 162 | } 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_link.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LINK_H_INCLUDED__ 7 | #define __LINK_H_INCLUDED__ 8 | 9 | typedef struct link_s link_t; 10 | typedef struct link_s list_t; 11 | typedef struct link_s queue_t; 12 | 13 | #if 0 14 | typedef struct link_s stack_t; 15 | #endif 16 | 17 | struct link_s { 18 | struct link_s * prev; 19 | struct link_s * next; 20 | }; 21 | 22 | #define struct_entry(p,t,m) \ 23 | ((t *)((char *)(p)-(char *)(&((t *)0)->m))) 24 | 25 | typedef int (*compare)(link_t *link,void *data); 26 | 27 | /*list interface*/ 28 | void list_init(list_t * l); 29 | void list_insert_head(list_t * l,link_t * n); 30 | void list_insert_tail(list_t * l,link_t * n); 31 | void list_remove(link_t * n); 32 | int list_empty(list_t *l); 33 | 34 | int list_num(list_t * l); 35 | 36 | link_t * list_find(list_t *l,compare,void *); 37 | 38 | /*queue interface*/ 39 | void queue_init(queue_t * q); 40 | void queue_push(queue_t * q,link_t *n); 41 | link_t * queue_pop(queue_t * q); 42 | 43 | link_t * queue_front(queue_t * q); 44 | link_t * queue_rear(queue_t * q); 45 | 46 | int queue_length(queue_t * q); 47 | 48 | /*stack interface*/ 49 | #if 0 50 | void stack_init(stack_t *st); 51 | void stack_push(stack_t *st,link_t *n); 52 | link_t * stack_pop(stack_t *st); 53 | int stack_dept(stack_t *st); 54 | #endif 55 | 56 | #endif -------------------------------------------------------------------------------- /trunk/src/core/rtmp_log.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __RTMP_LOG_H__INCLUDED__ 7 | #define __RTMP_LOG_H__INCLUDED__ 8 | 9 | #define KB (1024) 10 | #define MB (1024*KB) 11 | 12 | #define RTMP_LOG_ERR 0 13 | #define RTMP_LOG_WARNING 1 14 | #define RTMP_LOG_INFO 2 15 | #define RTMP_LOG_NORMAL 3 16 | #define RTMP_LOG_DEBUG 4 17 | 18 | /* 19 | * func,line,level 20 | */ 21 | #define rtmp_log(l,...) \ 22 | rtmp_log_core(__FUNCTION__,__LINE__,l,__VA_ARGS__) 23 | 24 | /* log core 25 | * format 26 | * [2012-07-19 12:23:08][main():32][debug]hello world! 27 | */ 28 | 29 | int rtmp_log_init(int level,const char *logname); 30 | void rtmp_log_core(const char *,long,int ,const char *,...); 31 | void rtmp_log_set_level(int level); 32 | void rtmp_log_set_maxsize(size_t size); 33 | void rtmp_log_printf(const char *,...); 34 | 35 | #endif -------------------------------------------------------------------------------- /trunk/src/core/rtmp_rbtree.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #ifndef __RBTREE_H__INCLUDED__ 8 | #define __RBTREE_H__INCLUDED__ 9 | 10 | typedef uint64_t rbtree_key_t; 11 | 12 | typedef struct rbnode_s rbnode_t; 13 | typedef struct rbtree_s rbtree_t; 14 | 15 | typedef int (*rbnode_cmp_pt)(rbnode_t *,rbnode_t *); 16 | 17 | #define RBT_RED 0 18 | #define RBT_BLACK 1 19 | 20 | #define rbt_init(T,p) \ 21 | do { \ 22 | (T)->root = &((T)->nil); \ 23 | (T)->nil.c = RBT_BLACK; \ 24 | (T)->cmp = (p); \ 25 | }while(0) 26 | 27 | struct rbnode_s { 28 | rbtree_key_t k; /*key*/ 29 | char c; /*color*/ 30 | rbnode_t *p; /*parent*/ 31 | rbnode_t *l; /*left*/ 32 | rbnode_t *r; /*right*/ 33 | }; 34 | 35 | struct rbtree_s { 36 | rbnode_t *root; 37 | rbnode_t nil; 38 | rbnode_cmp_pt cmp; 39 | }; 40 | 41 | rbnode_t* rbt_parent(rbtree_t *T,rbnode_t *nd); 42 | rbnode_t* rbt_min(rbtree_t *T,rbnode_t *x); 43 | rbnode_t* rbt_max(rbtree_t *T,rbnode_t * x); 44 | rbnode_t* rbt_successor(rbtree_t *T,rbnode_t *x); 45 | rbnode_t* rbt_predecessor(rbtree_t *T,rbnode_t *x); 46 | 47 | int rbt_dept(rbtree_t * T); 48 | int rbt_insert(rbtree_t *T,rbnode_t *z,int ingore); 49 | int rbt_remove(rbtree_t *T,rbnode_t *z); 50 | 51 | void rbt_inorder(rbtree_t * T,void (*visit)(rbnode_t *)); 52 | 53 | #endif -------------------------------------------------------------------------------- /trunk/src/core/rtmp_recv.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | int rtmp_recv_n(int sockfd,u_char *buf,int n) 10 | { 11 | int recvd,rc; 12 | 13 | recvd = 0; 14 | while (n > 0) { 15 | rc = recv(sockfd,(char *)buf+recvd,n,0); 16 | 17 | if (rc <= 0) { 18 | break; 19 | } 20 | 21 | recvd += rc; 22 | n -= recvd; 23 | } 24 | 25 | return recvd; 26 | } -------------------------------------------------------------------------------- /trunk/src/core/rtmp_send.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | int rtmp_send_n(int sockfd,const u_char *buf,int n) 10 | { 11 | int sent,rc; 12 | 13 | sent = 0; 14 | while (n > 0) { 15 | rc = send(sockfd,(const char*)buf+sent,n,0); 16 | 17 | if (rc <= 0) { 18 | break; 19 | } 20 | 21 | sent += rc; 22 | n -= sent; 23 | } 24 | 25 | return sent; 26 | } 27 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_time.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | 10 | volatile uint64_t rtmp_current_msec; 11 | volatile uint32_t rtmp_current_sec; 12 | 13 | 14 | #ifdef HAVE_OS_WIN32 15 | 16 | #define gettimeofday(x,y) rtmp_gettimeofday(x) 17 | 18 | static void rtmp_gettimeofday(struct timeval *tp) 19 | { 20 | uint64_t intervals; 21 | FILETIME ft; 22 | 23 | GetSystemTimeAsFileTime(&ft); 24 | 25 | intervals = ((uint64_t) ft.dwHighDateTime << 32) | ft.dwLowDateTime; 26 | intervals -= 116444736000000000; 27 | 28 | tp->tv_sec = (long) (intervals / 10000000); 29 | tp->tv_usec = (long) ((intervals % 10000000) / 10); 30 | } 31 | 32 | #endif 33 | 34 | void rtmp_time_update(void) 35 | { 36 | struct timeval tv; 37 | uint32_t sec,msec; 38 | 39 | gettimeofday(&tv,NULL); 40 | 41 | sec = tv.tv_sec; 42 | msec = tv.tv_usec / 1000; 43 | 44 | rtmp_current_sec = sec; 45 | rtmp_current_msec = (uint64_t) sec * 1000 + msec; 46 | } 47 | -------------------------------------------------------------------------------- /trunk/src/core/rtmp_time.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __TIME_H_INCLUDED__ 7 | #define __TIME_H_INCLUDED__ 8 | 9 | extern volatile uint64_t rtmp_current_msec; 10 | extern volatile uint32_t rtmp_current_sec; 11 | 12 | void rtmp_time_update(void); 13 | 14 | #endif -------------------------------------------------------------------------------- /trunk/src/event/rtmp_event.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #ifndef __EVENT_H_INCLUDED__ 8 | #define __EVENT_H_INCLUDED__ 9 | 10 | #define EVENT_IO_SELECT (0) /*"select"*/ 11 | #define EVENT_IO_EPOLL (1) /*"epoll"*/ 12 | #define EVENT_IO_IOCP (2) /*"iocp"*/ 13 | #define EVENT_IO_KQUEUE (3) /*"kqueue"*/ 14 | #define EVENT_IO_RSING (4) /*"rsing"*/ 15 | 16 | #define EVENT_READ (0x0001) 17 | #define EVENT_WRITE (0x0002) 18 | #define EVENT_DONE (0xFFFF) 19 | 20 | #define EVENT_UPDATE 0x01 21 | #define EVENT_POST 0x02 22 | 23 | typedef struct rtmp_event_s rtmp_event_t; 24 | typedef struct rtmp_event_io_s rtmp_event_io_t; 25 | 26 | typedef void (*event_handler)(rtmp_event_t *ev); 27 | typedef void (*connection_handler_pt)(rtmp_connection_t *c); 28 | 29 | typedef int32_t (*event_io_init)(rtmp_event_io_t *io); 30 | typedef int32_t (*event_io_add)(rtmp_event_io_t *io,rtmp_event_t *ev,uint32_t flag); 31 | typedef int32_t (*event_io_add_conn)(rtmp_event_io_t *io,rtmp_connection_t *c); 32 | typedef int32_t (*event_io_poll)(rtmp_event_io_t *io,uint32_t msec,uint32_t flag); 33 | typedef int32_t (*event_io_del)(rtmp_event_io_t *io,rtmp_event_t *ev,uint32_t flag); 34 | typedef int32_t (*event_io_del_conn)(rtmp_event_io_t *io,rtmp_connection_t *c); 35 | typedef int32_t (*event_io_done)(rtmp_event_io_t *io); 36 | 37 | struct rtmp_event_s { 38 | void *data; 39 | 40 | unsigned timeout:1; 41 | unsigned accept:1; 42 | unsigned destroy:1; 43 | unsigned timer_set:1; 44 | unsigned write:1; 45 | unsigned active:1; 46 | unsigned ready:1; 47 | int16_t index; 48 | 49 | event_handler handler; 50 | 51 | rbnode_t timer; 52 | link_t link; 53 | }; 54 | 55 | struct rtmp_event_io_s{ 56 | uint32_t type; 57 | char name[16]; 58 | 59 | void *data; 60 | 61 | uint32_t max_conn; 62 | 63 | event_io_init io_init; 64 | event_io_add io_add; 65 | event_io_add_conn io_add_conn; 66 | event_io_poll io_poll; 67 | event_io_del io_del; 68 | event_io_del_conn io_del_conn; 69 | event_io_done io_done; 70 | 71 | /*event queue*/ 72 | queue_t accept; 73 | queue_t posted; 74 | }; 75 | 76 | void rtmp_event_poll(uint32_t msec); 77 | 78 | uint32_t rtmp_event_add(rtmp_event_t *ev,int flag); 79 | uint32_t rtmp_event_add_conn(rtmp_connection_t *c); 80 | uint32_t rtmp_event_delete(rtmp_event_t *ev,int flag); 81 | uint32_t rtmp_event_delete_conn(rtmp_connection_t *c); 82 | uint32_t rtmp_event_add_timer(rtmp_event_t *ev,uint32_t msec); 83 | uint32_t rtmp_event_del_timer(rtmp_event_t *ev); 84 | 85 | #endif -------------------------------------------------------------------------------- /trunk/src/event/rtmp_event_timer.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | extern volatile uint64_t rtmp_current_msec; 10 | 11 | void rtmp_event_timer_expire(rbtree_t *timer) 12 | { 13 | rbnode_t *x; 14 | rtmp_event_t *ev; 15 | 16 | while ((x = rbt_min(timer,timer->root)) != 0) { 17 | 18 | if (x->k > rtmp_current_msec) { 19 | break; 20 | } 21 | 22 | rbt_remove(timer,x); 23 | ev = struct_entry(x,rtmp_event_t,timer); 24 | 25 | ev->timeout = 1; 26 | ev->timer_set = 0; 27 | 28 | if (ev->handler) { 29 | ev->handler(ev); 30 | } 31 | } 32 | 33 | return ; 34 | } 35 | 36 | int rtmp_timer_compare(rbnode_t *a,rbnode_t *b) 37 | { 38 | rtmp_event_t *eva,*evb; 39 | int64_t rc; 40 | 41 | eva = struct_entry(a,rtmp_event_t,timer); 42 | evb = struct_entry(b,rtmp_event_t,timer); 43 | 44 | rc = (eva->timer.k - evb->timer.k); 45 | 46 | if (rc == 0) { 47 | return 0; 48 | } 49 | 50 | if (rc > 0) { 51 | return 1; 52 | } 53 | 54 | return -1; 55 | } -------------------------------------------------------------------------------- /trunk/src/event/rtmp_event_timer.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __TIMER_H_INCLUDED__ 7 | #define __TIMER_H_INCLUDED__ 8 | 9 | void rtmp_event_timer_expire(rbtree_t *timer); 10 | int rtmp_timer_compare(rbnode_t *a,rbnode_t *b); 11 | 12 | #endif -------------------------------------------------------------------------------- /trunk/src/event/rtmp_timer.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) nie950@gmail.com 4 | */ 5 | -------------------------------------------------------------------------------- /trunk/src/event/rtmp_timer.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __TIMER_H_INCLUDED__ 7 | #define __TIMER_H_INCLUDED__ 8 | 9 | 10 | struct _timer_s { 11 | int i; 12 | }; 13 | 14 | 15 | #endif -------------------------------------------------------------------------------- /trunk/src/http/rtmp_hls_module.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | rtmp_module_t rtmp_http_moudle; 10 | rtmp_module_t rtmp_hls_moudle; -------------------------------------------------------------------------------- /trunk/src/http/rtmp_http_module.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | rtmp_module_t rtmp_http_moudle; 10 | rtmp_module_t rtmp_hls_moudle; -------------------------------------------------------------------------------- /trunk/src/librtmp/librtmp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/src/librtmp/librtmp.c -------------------------------------------------------------------------------- /trunk/src/librtmp/librtmp_dump.c: -------------------------------------------------------------------------------- 1 | 2 | #include "librtmp_in.h" 3 | 4 | void *my_malloc(size_t sz,void *u) 5 | { 6 | return malloc(sz); 7 | } 8 | 9 | void my_free(void *p,void *u) 10 | { 11 | if (p != NULL) { 12 | free(p); 13 | } 14 | } 15 | 16 | int main(int argc,char **argv) 17 | { 18 | rtmp_net_conn_t conn; 19 | rtmp_net_stream_t stream; 20 | int rc; 21 | rtmp_message_t msg; 22 | 23 | 24 | #ifdef WIN32 25 | WSADATA wsadata; 26 | 27 | rc = WSAStartup(MAKEWORD(2,2),&wsadata); 28 | 29 | if (rc != 0) { 30 | return -2; 31 | } 32 | 33 | #endif 34 | 35 | rtmp_time_update(); 36 | 37 | rtmp_log_init(RTMP_LOG_DEBUG,"rtmp_core.log"); 38 | 39 | /*NetConnection()*/ 40 | conn = rtmp_conn_create(my_malloc,my_free,NULL); 41 | if (conn == NULL) { 42 | rtmp_log(RTMP_LOG_ERR,"NetConnection() failed!"); 43 | return -1; 44 | } 45 | 46 | /*NetConnection.connect()*/ 47 | rc = rtmp_conn_connect(conn,"rtmp://liveteach.xescdn.com/live_server"); 48 | if (rc != RTMP_ERR_OK) { 49 | rtmp_log(RTMP_LOG_ERR,"NetConnection.connect() failed:[%d]",rc); 50 | return -1; 51 | } 52 | 53 | /*NetStream()*/ 54 | stream = rtmp_stream_create(conn,"mux_4"); 55 | if (stream == NULL) { 56 | rtmp_log(RTMP_LOG_ERR,"NetStream() failed!"); 57 | return -1; 58 | } 59 | 60 | /*NetStream.play()*/ 61 | rc = rtmp_stream_play(stream); 62 | if (rc != RTMP_ERR_OK) { 63 | rtmp_log(RTMP_LOG_ERR,"NetStream.play() failed:[%d]",rc); 64 | return -1; 65 | } 66 | 67 | while (TRUE) { 68 | rc = rtmp_stream_recv(stream,&msg); 69 | 70 | if (rc == RTMP_ERR_OK) { 71 | 72 | rtmp_log(RTMP_LOG_DEBUG,"recv packet : " 73 | "timestamp:[%d] type_id:[%d] length:[%d]", 74 | msg.timestamp,msg.type,msg.body_size); 75 | 76 | } 77 | 78 | if (rc == RTMP_ERR_FAILED) { 79 | break; 80 | } 81 | } 82 | 83 | rtmp_stream_close(stream); 84 | rtmp_conn_destroy(conn); 85 | 86 | return 0; 87 | } 88 | 89 | -------------------------------------------------------------------------------- /trunk/src/librtmp/librtmp_in.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LIB_RTMP_IN_H_INCLUDED__ 7 | #define __LIB_RTMP_IN_H_INCLUDED__ 8 | 9 | #define HAVE_DEBUG 1 10 | 11 | #ifdef WIN32 12 | #define HAVE_WIN32 1 13 | #define _CRT_SECURE_NO_WARNINGS 14 | #else 15 | #endif 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #if HAVE_WIN32 25 | 26 | #include 27 | #include 28 | 29 | #define sock_errno WSAGetLastError() 30 | #define mutex_trylock(x) (InterlockedCompareExchange((long *)x, 1, 0) == 0) 31 | #define sleep(n) Sleep((n)*1000) 32 | #define msleep(n) Sleep(n) 33 | #define EBLOCK WSAEWOULDBLOCK 34 | 35 | typedef SOCKET socket_t; 36 | typedef int socklen_t; 37 | 38 | #else 39 | 40 | #include 41 | #define sock_errno errno 42 | 43 | #define closesocket(fd) close(fd) 44 | #define mutex_trylock(x) __sync_bool_compare_and_swap((long *)x,0,1) 45 | #define msleep(n) usleep(n*1000) 46 | #define EBLOCK EAGAIN 47 | 48 | #endif 49 | 50 | #define mutex_init(x) ((*(x))=0) 51 | #define mutex_lock(x) do {msleep(0);}while(mutex_trylock(x)) 52 | #define mutex_unlock(x) ((*(x))=0) 53 | #define _array_length(a) (sizeof(a)/sizeof((a)[0])) 54 | 55 | #include "librtmp.h" 56 | 57 | #include "rtmp_time.h" 58 | #include "rtmp_link.h" 59 | #include "rtmp_log.h" 60 | #include "rtmp_amf.h" 61 | #include "rtmp_bytes.h" 62 | #include "rtmp_alloc.h" 63 | 64 | #endif -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_alloc.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LIB_RTMP_ALLOC_H_INCLUDED__ 7 | #define __LIB_RTMP_ALLOC_H_INCLUDED__ 8 | 9 | #define MEM_DEFAULT_POOL_SIZE (16 * 1024) 10 | #define MEM_POOL_ALIGNMENT (16) 11 | #define MEM_MAX_ALLOC_FROM_POOL (4096) 12 | 13 | typedef struct mem_pool_s mem_pool_t; 14 | typedef struct mem_pool_large_s mem_pool_large_t; 15 | typedef struct mem_buf_s mem_buf_t; 16 | typedef struct mem_buf_chain_s mem_buf_chain_t; 17 | 18 | struct mem_pool_large_s { 19 | mem_pool_large_t *next; 20 | void *alloc; 21 | }; 22 | 23 | typedef struct { 24 | u_char *last; 25 | u_char *end; 26 | mem_pool_t *next; 27 | uint32_t failed; 28 | } mem_pool_data_t; 29 | 30 | struct mem_pool_s { 31 | mem_pool_data_t d; 32 | size_t max; 33 | mem_pool_t *current; 34 | mem_pool_large_t *large; 35 | mem_buf_chain_t *chain; 36 | }; 37 | 38 | struct mem_buf_s { 39 | u_char *buf; 40 | u_char *last; 41 | u_char *end; 42 | }; 43 | 44 | struct mem_buf_chain_s { 45 | uint8_t *chunk_body; 46 | uint32_t chunk_size; 47 | 48 | mem_buf_t chunk; 49 | int32_t locked; 50 | 51 | mem_buf_chain_t *next; 52 | }; 53 | 54 | #define mem_malloc malloc 55 | #define mem_free free 56 | #define mem_memalign(alignment, size) mem_alloc(size) 57 | 58 | #ifndef MEM_ALIGNMENT 59 | #define MEM_ALIGNMENT sizeof(unsigned long) /* platform word */ 60 | #endif 61 | 62 | #define mem_align(d, a) (((d) + (a - 1)) & ~(a - 1)) 63 | #define mem_align_ptr(p, a) \ 64 | (u_char *)(((uintptr_t)(p) + ((uintptr_t)a - 1)) & ~((uintptr_t)a - 1)) 65 | 66 | void *mem_alloc(size_t size); 67 | void *mem_calloc(size_t size); 68 | 69 | void *mem_prealloc(mem_pool_t *pool,void *ptr,size_t old,size_t new); 70 | void *mem_pcrealloc(mem_pool_t *pool,void *ptr,size_t old,size_t new); 71 | 72 | mem_pool_t *mem_create_pool(size_t size); 73 | void mem_destroy_pool(mem_pool_t *pool); 74 | void mem_reset_pool(mem_pool_t *pool); 75 | 76 | mem_buf_t* mem_buf_palloc(mem_pool_t *pool,mem_buf_t *buf,size_t size); 77 | mem_buf_t* mem_buf_pcalloc(mem_pool_t *pool,mem_buf_t *buf,size_t size); 78 | 79 | mem_buf_t* mem_buf_merge_chain(mem_buf_chain_t *chain,mem_pool_t *temp); 80 | 81 | void *mem_palloc(mem_pool_t *pool, size_t size); 82 | void *mem_pnalloc(mem_pool_t *pool, size_t size); 83 | void *mem_pcalloc(mem_pool_t *pool, size_t size); 84 | void *mem_pmemalign(mem_pool_t *pool, size_t size, size_t alignment); 85 | 86 | mem_buf_chain_t* mem_alloc_chain_link(mem_pool_t *pool); 87 | 88 | #define mem_free_chain_link(pool,cl) \ 89 | cl->next = pool->chain; \ 90 | pool->chain = cl; 91 | 92 | char *mem_dup_str(const char *src,mem_pool_t *pool); 93 | char *mem_dup_str_size(const char *src,size_t s,mem_pool_t *pool); 94 | char *mem_dup_case_str(const char *src,int up,mem_pool_t *pool); 95 | 96 | #endif -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_amf.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LIB_RTMP_AMF_H_INCLUDED__ 7 | #define __LIB_RTMP_AMF_H_INCLUDED__ 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define SCRIPT_AMF0 0 16 | #define SCRIPT_AMF3 3 17 | 18 | /*AMF0 data types*/ 19 | 20 | #define amf_number 0x00 21 | #define amf_boolean 0x01 22 | #define amf_string 0x02 23 | #define amf_object 0x03 24 | #define amf_movieclip 0x04 /* reserved */ 25 | #define amf_null 0x05 26 | #define amf_undefined 0x06 27 | #define amf_reference 0x07 28 | #define amf_ecma_array 0x08 29 | #define amf_object_end 0x09 30 | #define amf_strict_array 0x0a 31 | #define amf_date 0x0b 32 | #define amf_long_string 0x0c 33 | #define amf_unsupported 0x0d 34 | #define amf_recordset 0x0e /* reserved */ 35 | #define amf_xml_document 0x0f 36 | #define amf_typed_object 0x10 37 | #define amf_avmplus_object 0x11 38 | #define amf_invalid 0xff 39 | 40 | /*AMF3 data types*/ 41 | 42 | #define amf3_null 0x01 43 | #define amf3_false 0x02 44 | #define amf3_true 0x03 45 | #define amf3_integer 0x04 46 | #define amf3_double 0x05 47 | #define amf3_string 0x06 48 | #define amf3_xml_doc 0x07 49 | #define amf3_date 0x08 50 | #define amf3_array 0x09 51 | #define amf3_object 0x0a 52 | #define amf3_xml 0x0c 53 | #define amf3_byte_array 0x0d 54 | #define amf3_invalid 0xff 55 | 56 | #define amf_new_bool(b) amf_new(amf_boolean,(uint32_t)b) 57 | #define amf_new_string_c(s) amf_new(amf_string,(const char*)s,strlen(s)) 58 | #define amf_new_string(s,len) amf_new(amf_string,(const char*)s,(int32_t)len) 59 | #define amf_new_number(n) amf_new(amf_number,(double)n) 60 | #define amf_new_date(n,tz) amf_new(amf_date,(double)n,(int32_t)tz) 61 | #define amf_new_object() amf_new(amf_object) 62 | #define amf_new_ecma_array() amf_new(amf_ecma_array) 63 | #define amf_new_null() amf_new(amf_null) 64 | 65 | /*memory*/ 66 | typedef void* (*amf_malloc)(size_t size,void *u); 67 | typedef void (*amf_free)(void *p,void *u); 68 | 69 | /*data types*/ 70 | typedef void amf_data_t; 71 | 72 | uint8_t amf_get_data_type(amf_data_t * data); 73 | 74 | char* amf_get_string(amf_data_t *data); 75 | uint8_t amf_get_bool(amf_data_t *data); 76 | double amf_get_number(amf_data_t *data); 77 | double amf_get_date(amf_data_t *data); 78 | 79 | amf_data_t*amf_get_prop(amf_data_t *obj,const char* name); 80 | int amf_put_prop(amf_data_t *obj,const char* name,const amf_data_t *data); 81 | 82 | amf_data_t* amf_new(uint8_t type,...); 83 | void amf_free_data(amf_data_t * data); 84 | 85 | void amf_set_allocator(amf_malloc m,amf_free f,void *u); 86 | 87 | /*return a amf object or null for invalid*/ 88 | amf_data_t* amf_decode(const char *buf,int *len); 89 | 90 | /*return remain length of buf*/ 91 | int amf_encode(amf_data_t *data,char *buf,int maxlen); 92 | 93 | /*encode object array ,return remain length of buf*/ 94 | int amf_encode_objects(amf_data_t *objs[],int n, char *buf, int maxlen); 95 | 96 | #ifdef HAVE_DEBUG 97 | int amf_dump_data(amf_data_t * data); 98 | #endif 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_link.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "librtmp_in.h" 7 | 8 | void list_init(list_t* l) 9 | { 10 | l->next = l->prev = l; 11 | } 12 | 13 | void list_insert_head(list_t* l,link_t* n) 14 | { 15 | n->next = l->next; 16 | n->prev = l; 17 | 18 | n->prev->next = n; 19 | n->next->prev = n; 20 | } 21 | 22 | void list_insert_tail(list_t* l,link_t* n) 23 | { 24 | n->next = l; 25 | n->prev = l->prev; 26 | 27 | n->prev->next = n; 28 | n->next->prev = n; 29 | } 30 | 31 | void list_remove(link_t* n) 32 | { 33 | n->next->prev = n->prev; 34 | n->prev->next = n->next; 35 | 36 | #ifdef HAVE_DEBUG 37 | n->next = n->prev = n; 38 | #endif 39 | 40 | } -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_link.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LIB_RTMP_LINK_H_INCLUDED__ 7 | #define __LIB_RTMP_LINK_H_INCLUDED__ 8 | 9 | typedef struct link_s link_t; 10 | typedef struct link_s list_t; 11 | 12 | struct link_s { 13 | struct link_s * prev; 14 | struct link_s * next; 15 | }; 16 | 17 | #define struct_entry(p,t,m) \ 18 | ((t *)((char *)(p)-(char *)(&((t *)0)->m))) 19 | 20 | void list_init(list_t* l); 21 | void list_insert_head(list_t* l,link_t* n); 22 | void list_insert_tail(list_t* l,link_t* n); 23 | void list_remove(link_t* n); 24 | 25 | #endif -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_log.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "librtmp_in.h" 7 | 8 | #define RTMP_LOG_ERR ( 0) 9 | #define RTMP_LOG_WARNING ( 1) 10 | #define RTMP_LOG_INFO ( 2) 11 | #define RTMP_LOG_NORMAL ( 3) 12 | #define RTMP_LOG_DEBUG ( 4) 13 | #define RTMP_LOG_MAX (RTMP_LOG_DEBUG+1) 14 | 15 | static const char *log_level_string[] = { 16 | "error", 17 | "warning", 18 | "info", 19 | "normal", 20 | "debug", 21 | "unknown" 22 | }; 23 | 24 | static char log_default_file[256] = "rtmp_core.log"; 25 | static int log_default_level = RTMP_LOG_ERR; 26 | static char log_str[8000]; 27 | 28 | void rtmp_log_core(const char *func,long line, int level, 29 | const char * fmt,...) 30 | { 31 | va_list ap; 32 | time_t t; 33 | struct tm *now; 34 | char ts[128]; 35 | FILE *fp; 36 | 37 | if (level < RTMP_LOG_ERR || level > log_default_level) { 38 | return; 39 | } 40 | 41 | va_start(ap,fmt); 42 | t = (time_t)(rtmp_current_sec); 43 | now = localtime(&t); 44 | 45 | sprintf(ts,"%04d-%02d-%02d %02d:%02d:%02d", 46 | now->tm_year+1900,now->tm_mon+1,now->tm_mday, 47 | now->tm_hour,now->tm_min,now->tm_sec); 48 | 49 | if (_vsnprintf(log_str,_array_length(log_str),fmt,ap) == -1) { 50 | va_end(ap); 51 | return ; 52 | } 53 | 54 | fp = fopen(log_default_file,"a+"); 55 | if (fp == NULL) { 56 | va_end(ap); 57 | return ; 58 | } 59 | 60 | /*#if HAVE_DEBUG*/ 61 | #if 0 62 | fprintf(fp,"[%s][%s():%d][%s]%s\n",ts,func,(int)line, 63 | log_level_string[level],log_str); 64 | #else 65 | fprintf(fp,"[%s][%s]%s\n",ts,log_level_string[level],log_str); 66 | #endif 67 | 68 | va_end(ap); 69 | fclose(fp); 70 | 71 | return; 72 | } 73 | 74 | int rtmp_log_init(int level,const char* logname) 75 | { 76 | log_default_level = level; 77 | strncpy(log_default_file,logname,sizeof(log_default_file)-1); 78 | 79 | return 0; 80 | } -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_log.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LIB_RTMP_LOG_H_INCLUDED__ 7 | #define __LIB_RTMP_LOG_H_INCLUDED__ 8 | 9 | 10 | #define rtmp_log(l,...) \ 11 | rtmp_log_core(__FUNCTION__,__LINE__,l,__VA_ARGS__) 12 | 13 | int rtmp_log_init(int level,const char* logname); 14 | void rtmp_log_core(const char *func,long line, int level, 15 | const char * fmt,...); 16 | 17 | 18 | #endif -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_time.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "librtmp_in.h" 7 | 8 | volatile uint64_t rtmp_current_msec; 9 | volatile uint32_t rtmp_current_sec; 10 | 11 | #ifdef WIN32 12 | 13 | #define gettimeofday(x,y) rtmp_gettimeofday(x) 14 | 15 | static void rtmp_gettimeofday(struct timeval *tp) 16 | { 17 | uint64_t intervals; 18 | FILETIME ft; 19 | 20 | GetSystemTimeAsFileTime(&ft); 21 | 22 | intervals = ((uint64_t) ft.dwHighDateTime << 32) | ft.dwLowDateTime; 23 | intervals -= 116444736000000000; 24 | 25 | tp->tv_sec = (long) (intervals / 10000000); 26 | tp->tv_usec = (long) ((intervals % 10000000) / 10); 27 | } 28 | 29 | #endif 30 | 31 | void rtmp_time_update(void) 32 | { 33 | struct timeval tv; 34 | uint32_t sec,msec; 35 | 36 | gettimeofday(&tv,NULL); 37 | 38 | sec = tv.tv_sec; 39 | msec = tv.tv_usec / 1000; 40 | 41 | rtmp_current_sec = sec; 42 | rtmp_current_msec = (uint64_t) sec * 1000 + msec; 43 | } 44 | -------------------------------------------------------------------------------- /trunk/src/librtmp/rtmp_time.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __LIB_RTMP_TIME_H_INCLUDED__ 7 | #define __LIB_RTMP_TIME_H_INCLUDED__ 8 | 9 | extern volatile uint64_t rtmp_current_msec; 10 | extern volatile uint32_t rtmp_current_sec; 11 | 12 | void rtmp_time_update(void); 13 | 14 | #endif -------------------------------------------------------------------------------- /trunk/src/os/rtmp_alloc.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __ALLOC_H_INCLUDED__ 7 | #define __ALLOC_H_INCLUDED__ 8 | 9 | #define MEM_DEFAULT_POOL_SIZE (16 * 1024) 10 | #define MEM_POOL_ALIGNMENT (16) 11 | #define MEM_MAX_ALLOC_FROM_POOL (mem_pagesize - 1) 12 | 13 | typedef struct mem_pool_s mem_pool_t; 14 | typedef struct mem_pool_large_s mem_pool_large_t; 15 | typedef struct mem_buf_s mem_buf_t; 16 | typedef struct mem_buf_chain_s mem_buf_chain_t; 17 | 18 | struct mem_pool_large_s { 19 | mem_pool_large_t *next; 20 | void *alloc; 21 | }; 22 | 23 | typedef struct { 24 | u_char *last; 25 | u_char *end; 26 | mem_pool_t *next; 27 | uint32_t failed; 28 | } mem_pool_data_t; 29 | 30 | struct mem_pool_s { 31 | mem_pool_data_t d; 32 | size_t max; 33 | mem_pool_t *current; 34 | mem_pool_large_t *large; 35 | mem_buf_chain_t *chain; 36 | }; 37 | 38 | struct mem_buf_s { 39 | u_char *buf; 40 | u_char *last; 41 | u_char *end; 42 | }; 43 | 44 | struct mem_buf_chain_s { 45 | uint8_t *chunk_body; 46 | uint32_t chunk_size; 47 | 48 | mem_buf_t chunk; 49 | int32_t locked; 50 | 51 | mem_buf_chain_t *next; 52 | }; 53 | 54 | #define mem_malloc malloc 55 | #define mem_free free 56 | #define mem_memalign(alignment, size) mem_alloc(size) 57 | 58 | void *mem_alloc(size_t size); 59 | void *mem_calloc(size_t size); 60 | 61 | void *mem_prealloc(mem_pool_t *pool,void *ptr,size_t old,size_t new); 62 | void *mem_pcrealloc(mem_pool_t *pool,void *ptr,size_t old,size_t new); 63 | 64 | mem_pool_t *mem_create_pool(size_t size); 65 | void mem_destroy_pool(mem_pool_t *pool); 66 | void mem_reset_pool(mem_pool_t *pool); 67 | 68 | mem_buf_t* mem_buf_palloc(mem_pool_t *pool,mem_buf_t *buf,size_t size); 69 | mem_buf_t* mem_buf_pcalloc(mem_pool_t *pool,mem_buf_t *buf,size_t size); 70 | 71 | mem_buf_t* mem_buf_merge_chain(mem_buf_chain_t *chain,mem_pool_t *temp); 72 | 73 | void *mem_palloc(mem_pool_t *pool, size_t size); 74 | void *mem_pnalloc(mem_pool_t *pool, size_t size); 75 | void *mem_pcalloc(mem_pool_t *pool, size_t size); 76 | void *mem_pmemalign(mem_pool_t *pool, size_t size, size_t alignment); 77 | int mem_pfree(mem_pool_t *pool, void *p); 78 | 79 | mem_buf_chain_t* mem_alloc_chain_link(mem_pool_t *pool); 80 | 81 | #define mem_free_chain_link(pool,cl) \ 82 | cl->next = pool->chain; \ 83 | pool->chain = cl; 84 | 85 | char *mem_dup_str(char *src,mem_pool_t *pool); 86 | 87 | #endif -------------------------------------------------------------------------------- /trunk/src/os/rtmp_atomic.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * CopyLeft (C) nie950@gmail.com 5 | */ 6 | 7 | 8 | #ifndef __ATOMIC_H_INCLUDED__ 9 | #define __ATOMIC_H_INCLUDED__ 10 | 11 | #define HAVE_ATOMIC_OPS 1 12 | 13 | typedef int32_t atomic_int_t; 14 | typedef uint32_t atomic_uint_t; 15 | typedef volatile atomic_uint_t atomic_t; 16 | 17 | #define ATOMIC_T_LEN (sizeof("-2147483648") - 1) 18 | 19 | 20 | #ifdef HAVE_OS_WIN32 21 | 22 | #if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || ( _MSC_VER >= 1300 ) 23 | 24 | /* the new SDK headers */ 25 | 26 | #define atomic_cmp_set(lock, old, set) \ 27 | ((atomic_uint_t) InterlockedCompareExchange((long *) lock, set, old) \ 28 | == old) 29 | 30 | #else 31 | 32 | /* the old MS VC6.0SP2 SDK headers */ 33 | 34 | #define atomic_cmp_set(lock, old, set) \ 35 | (InterlockedCompareExchange((void **) lock, (void *) set, (void *) old) \ 36 | == (void *) old) 37 | 38 | #define memory_barrier() 39 | 40 | #endif 41 | 42 | #define atomic_fetch_add(p, add) InterlockedExchangeAdd((long *) p, add) 43 | 44 | #else 45 | 46 | #define atomic_cmp_set(lock, old, set) \ 47 | __sync_bool_compare_and_swap(lock, old, set) 48 | 49 | #define atomic_fetch_add(value, add) \ 50 | __sync_fetch_and_add(value, add) 51 | 52 | #endif 53 | 54 | 55 | #if defined( __BORLANDC__ ) || ( __WATCOMC__ < 1230 ) 56 | 57 | /* 58 | * Borland C++ 5.5 (tasm32) and Open Watcom C prior to 1.3 59 | * do not understand the "pause" instruction 60 | */ 61 | 62 | #define cpu_pause() 63 | #else 64 | #define cpu_pause() __asm { pause } 65 | #endif 66 | 67 | 68 | void spinlock_in(atomic_t *lock, atomic_int_t value, uint32_t spin); 69 | 70 | #define spin_trylock(lock) (*(lock) == 0 && atomic_cmp_set(lock, 0, 1)) 71 | #define spin_unlock(lock) *(lock) = 0 72 | #define spin_lock(lock) spinlock_in(lock,1,2048); 73 | 74 | #endif /* _NGX_ATOMIC_H_INCLUDED_ */ 75 | -------------------------------------------------------------------------------- /trunk/src/os/rtmp_config.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | /*HAVE_NDEBUG*/ 7 | #define HAVE_DEBUG 1 8 | 9 | #ifndef MEM_ALIGNMENT 10 | #define MEM_ALIGNMENT sizeof(unsigned long) /* platform word */ 11 | #endif 12 | 13 | #define mem_align(d, a) (((d) + (a - 1)) & ~(a - 1)) 14 | #define mem_align_ptr(p, a) \ 15 | (u_char *) (((uintptr_t) (p) + ((uintptr_t) a - 1)) & ~((uintptr_t) a - 1)) 16 | 17 | #ifdef _WIN32 18 | #include 19 | #else 20 | #include 21 | #endif 22 | 23 | 24 | #include 25 | #include 26 | 27 | #include "rtmp_alloc.h" 28 | -------------------------------------------------------------------------------- /trunk/src/os/rtmp_shmem.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | -------------------------------------------------------------------------------- /trunk/src/os/unix/rtmp_atomic.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | -------------------------------------------------------------------------------- /trunk/src/os/unix/rtmp_linux_config.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #ifndef __LINUX_H_INCLUDED__ 8 | #define __LINUX_H_INCLUDED__ 9 | 10 | #define HAVE_OS_LINUX 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define HAVE_USING_LEDIAN 1 28 | #define HAVE_EVENT_EPOLL 1 29 | 30 | #define SOCK_EAGAIN EAGAIN 31 | #define SOCK_ENFILE ENFILE 32 | #define SOCK_EMFILE EMFILE 33 | #define SOCK_ERROR (-1) 34 | #define SOCK_OK (0) 35 | 36 | #ifndef inline 37 | #define inline __inline 38 | #endif 39 | 40 | #define rtmp_socket(af, type, proto) socket(af,type,proto) 41 | 42 | typedef int fd_t; 43 | typedef int socket_t; 44 | 45 | #define sock_errno errno 46 | #define closesocket(c) close(c) 47 | #define set_nonblocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK) 48 | #define set_blocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK) 49 | int set_tcppush(socket_t s); 50 | 51 | int rtmp_init_signals(); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /trunk/src/os/unix/rtmp_shmem.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | -------------------------------------------------------------------------------- /trunk/src/os/unix/rtmp_signal.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * CopyLeft (C) nie950@gmail.com 5 | */ 6 | 7 | #include "rtmp_config.h" 8 | #include "rtmp_core.h" 9 | 10 | typedef struct { 11 | int signo; 12 | char *signame; 13 | char *name; 14 | void (*handler)(int signo); 15 | }rtmp_signal_t; 16 | 17 | void rtmp_signal_handler(int signo); 18 | 19 | rtmp_signal_t signals[] = { 20 | { SIGALRM, "SIGALRM", "", rtmp_signal_handler }, 21 | { SIGINT, "SIGINT", "", rtmp_signal_handler }, 22 | { SIGIO, "SIGIO", "", rtmp_signal_handler }, 23 | { SIGCHLD, "SIGCHLD", "", rtmp_signal_handler }, 24 | { SIGSYS, "SIGSYS, SIG_IGN", "", SIG_IGN }, 25 | { SIGPIPE, "SIGPIPE, SIG_IGN", "", SIG_IGN }, 26 | { 0, NULL, "", NULL } 27 | }; 28 | 29 | int rtmp_init_signals() 30 | { 31 | rtmp_signal_t *sig; 32 | struct sigaction sa; 33 | 34 | for (sig = signals; sig->signo != 0; sig++) { 35 | memset(&sa, sizeof(struct sigaction),0); 36 | sa.sa_handler = sig->handler; 37 | sigemptyset(&sa.sa_mask); 38 | if (sigaction(sig->signo, &sa, NULL) == -1) { 39 | return -1; 40 | } 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | void rtmp_signal_handler(int signo) 47 | { 48 | return ; 49 | } -------------------------------------------------------------------------------- /trunk/src/os/unix/rtmp_socket.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | int set_tcppush(socket_t s) 10 | { 11 | int tcp_nopush; 12 | 13 | tcp_nopush = 0; 14 | 15 | return setsockopt(s, IPPROTO_TCP, TCP_CORK, 16 | (const void *) &tcp_nopush, sizeof(int)); 17 | } 18 | -------------------------------------------------------------------------------- /trunk/src/os/win32/rtmp_atomic.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | 10 | void spinlock_in(atomic_t *lock, atomic_int_t value, uint32_t spin) 11 | { 12 | uint32_t i, n; 13 | 14 | for ( ;; ) { 15 | 16 | if (*lock == 0 && atomic_cmp_set(lock, 0, value)) { 17 | return; 18 | } 19 | 20 | for (n = 1; n < spin; n <<= 1) { 21 | for (i = 0; i < n; i++) { 22 | cpu_pause(); 23 | } 24 | if (*lock == 0 && atomic_cmp_set(lock, 0, value)) { 25 | return; 26 | } 27 | } 28 | sched_yield(); 29 | } 30 | return ; 31 | } 32 | -------------------------------------------------------------------------------- /trunk/src/os/win32/rtmp_shmem.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | -------------------------------------------------------------------------------- /trunk/src/os/win32/rtmp_socket.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | int set_nonblocking(socket_t s) 10 | { 11 | unsigned long nb = 1; 12 | 13 | return ioctlsocket(s, FIONBIO, &nb); 14 | } 15 | 16 | int set_blocking(socket_t s) 17 | { 18 | unsigned long nb = 0; 19 | 20 | return ioctlsocket(s, FIONBIO, &nb); 21 | } 22 | 23 | int set_tcppush(socket_t s) 24 | { 25 | unsigned long push = 0; 26 | return setsockopt(s,IPPROTO_TCP,TCP_NODELAY, 27 | (const char*)&push,sizeof(push)); 28 | } -------------------------------------------------------------------------------- /trunk/src/os/win32/rtmp_win32_config.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #ifndef __WIN32_H_INCLUDED__ 8 | #define __WIN32_H_INCLUDED__ 9 | 10 | #define _CRT_SECURE_NO_WARNINGS 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #define HAVE_USING_LEDIAN 1 20 | #define HAVE_OS_WIN32 1 21 | #define HAVE_EPOLL_STUB 1 22 | 23 | #define SOCK_EAGAIN WSAEWOULDBLOCK 24 | #define SOCK_ENFILE WSAEMFILE 25 | #define SOCK_EMFILE WSAEMFILE 26 | #define SOCK_ERROR (-1) 27 | #define SOCK_OK (0) 28 | 29 | #ifndef inline 30 | #define inline __inline 31 | #endif 32 | 33 | typedef DWORD pid_t; 34 | typedef DWORD fd_t; 35 | 36 | typedef SOCKET socket_t; 37 | typedef int socklen_t; 38 | 39 | #define rtmp_socket(af,type,proto) socket(af,type,proto) 40 | #define fork() 1 41 | 42 | #define sock_errno WSAGetLastError() 43 | 44 | #define msleep(x) Sleep(x) 45 | 46 | #define sched_yield() SwitchToThread() 47 | 48 | int set_nonblocking(socket_t s); 49 | int set_blocking(socket_t s); 50 | int set_tcppush(socket_t s); 51 | 52 | #endif -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_app.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | rtmp_app_t* rtmp_create_app(mem_pool_t *pool,rtmp_host_t *host) 10 | { 11 | mem_pool_t *chunk_pool; 12 | rtmp_app_t *app; 13 | rtmp_app_conf_t *conf; 14 | rtmp_host_conf_t *hconf; 15 | 16 | hconf = host->hconf; 17 | app = mem_pcalloc(pool,sizeof(rtmp_app_t) + sizeof(rtmp_app_conf_t)); 18 | if (app == NULL) { 19 | return NULL; 20 | } 21 | 22 | chunk_pool = mem_create_pool(MEM_DEFAULT_POOL_SIZE); 23 | if (chunk_pool == NULL) { 24 | return NULL; 25 | } 26 | 27 | conf = (rtmp_app_conf_t*)(app + 1); 28 | app->conf = conf; 29 | app->chunk_pool = chunk_pool; 30 | 31 | conf->ack_size = hconf->ack_size; 32 | conf->ping_timeout = hconf->ping; 33 | conf->chunk_size = hconf->chunk_size; 34 | conf->stream_buckets = 1024; 35 | 36 | list_init(&app->free_lives); 37 | 38 | app->host = host; 39 | 40 | return app; 41 | } 42 | 43 | rtmp_app_t *rtmp_app_conf_find(char *name,array_t *a) 44 | { 45 | uint32_t i; 46 | rtmp_app_t *app; 47 | 48 | app = NULL; 49 | if ((name == NULL) || (a == NULL) || (a->nelts == 0)) { 50 | return app; 51 | } 52 | 53 | for (i = 0;i < a->nelts;i++) { 54 | app = (rtmp_app_t *)((void **)a->elts)[i]; 55 | if (app && strcmp(app->name,name) == 0) { 56 | break; 57 | } 58 | app = NULL; 59 | } 60 | 61 | return app; 62 | } 63 | 64 | rtmp_live_stream_t* rtmp_app_live_find(rtmp_app_t *app, 65 | const char *livestream) 66 | { 67 | rtmp_live_stream_t *live; 68 | list_t *h,*next; 69 | uint32_t k; 70 | 71 | k = rtmp_hash_string(livestream); 72 | h = app->lives + (k % app->conf->stream_buckets); 73 | 74 | next = h->next; 75 | while (next != h) { 76 | 77 | live = struct_entry(next,rtmp_live_stream_t,link); 78 | if (strcmp(livestream,live->name) == 0) { 79 | break; 80 | } 81 | next = next->next; 82 | } 83 | 84 | if (next == h) { 85 | return NULL; 86 | } 87 | 88 | return live; 89 | } 90 | 91 | rtmp_live_stream_t* rtmp_app_live_alloc(rtmp_app_t *app, 92 | const char *livestream) 93 | { 94 | mem_pool_t *pool; 95 | rtmp_live_stream_t *live; 96 | uint32_t k; 97 | list_t *h; 98 | 99 | if (list_empty(&app->free_lives) == 0) { 100 | 101 | live = struct_entry(app->free_lives.next, 102 | rtmp_live_stream_t,link); 103 | 104 | list_remove(&live->link); 105 | } else { 106 | pool = app->host->cycle->pool; 107 | live = mem_pcalloc(pool,sizeof(rtmp_live_stream_t)); 108 | } 109 | 110 | if (live) { 111 | live->epoch = rtmp_current_sec; 112 | live->timestamp = 0; 113 | strncpy(live->name,livestream,63); 114 | 115 | live->publisher = NULL; 116 | live->players = NULL; 117 | 118 | k = rtmp_hash_string(livestream); 119 | h = app->lives + (k % app->conf->stream_buckets); 120 | 121 | list_insert_head(h,&live->link); 122 | } 123 | 124 | return live; 125 | } 126 | 127 | void rtmp_app_live_free(rtmp_app_t *app,rtmp_live_stream_t *live) 128 | { 129 | list_remove(&live->link); 130 | 131 | #ifdef HAVE_DEBUG 132 | memset(live,0,sizeof(rtmp_live_stream_t)); 133 | #endif 134 | 135 | list_insert_head(&app->free_lives,&live->link); 136 | } 137 | 138 | void rtmp_app_live_release(rtmp_live_link_t *link) 139 | { 140 | rtmp_live_stream_t *live; 141 | 142 | live = link->lvst; 143 | 144 | if (live->publisher == link) { 145 | live->publisher = NULL; 146 | } else { 147 | list_remove(&link->link); 148 | if (link == live->players) { 149 | live->players = NULL; 150 | } 151 | } 152 | 153 | if ((live->publisher == NULL) && (live->players == NULL)) { 154 | 155 | rtmp_log(RTMP_LOG_DEBUG,"[%d]free live[%s]", 156 | link->session->sid,live->name); 157 | 158 | rtmp_app_live_free(link->session->app_ctx,live); 159 | } 160 | return ; 161 | } 162 | 163 | rtmp_live_stream_t* rtmp_app_live_get(rtmp_app_t *app, 164 | const char *livestream) 165 | { 166 | rtmp_live_stream_t *live; 167 | 168 | live = rtmp_app_live_find(app,livestream); 169 | if (live == NULL) { 170 | live = rtmp_app_live_alloc(app,livestream); 171 | } 172 | 173 | return live; 174 | } -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_app.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #include "rtmp_config.h" 8 | #include "rtmp_core.h" 9 | 10 | #ifndef __APP_H_INCLUDED__ 11 | #define __APP_H_INCLUDED__ 12 | 13 | typedef struct rtmp_live_stream_s rtmp_live_stream_t; 14 | typedef struct rtmp_live_link_s rtmp_live_link_t; 15 | 16 | struct rtmp_live_link_s { 17 | rtmp_session_t *session; 18 | 19 | uint32_t msgid; 20 | uint32_t paused; 21 | uint32_t timestamp; 22 | 23 | rtmp_live_stream_t *lvst; 24 | link_t link; 25 | }; 26 | 27 | struct rtmp_live_stream_s { 28 | char name[64]; 29 | uint32_t epoch; 30 | uint32_t timestamp; 31 | 32 | mem_buf_chain_t *avc_header; 33 | mem_buf_chain_t *aac_header; 34 | rtmp_live_codec_t *codec; 35 | 36 | mem_buf_chain_t **gop_cache; 37 | rtmp_live_link_t *publisher; 38 | rtmp_live_link_t *players; 39 | 40 | link_t link; 41 | }; 42 | 43 | struct rtmp_app_s { 44 | char name[128]; 45 | rtmp_app_conf_t *conf; 46 | rtmp_host_t *host; 47 | mem_pool_t *chunk_pool; 48 | 49 | list_t *lives; /*lives ptr,len: stream_buckets*/ 50 | list_t free_lives; /*live free list*/ 51 | }; 52 | 53 | rtmp_app_t* rtmp_create_app(mem_pool_t *pool,rtmp_host_t *hconf); 54 | rtmp_app_t* rtmp_app_conf_find(char *name,array_t *a); 55 | 56 | rtmp_live_stream_t* rtmp_app_live_find(rtmp_app_t *app, 57 | const char *livestream); 58 | 59 | rtmp_live_stream_t* rtmp_app_live_alloc(rtmp_app_t *app, 60 | const char *livestream); 61 | 62 | /* 63 | maybe 64 | 65 | static rtmp_live_stream_t *rtmp_app_live_get(rtmp_app_t *app, 66 | const char *livestream) 67 | { 68 | rtmp_live_stream_t *live; 69 | 70 | live = rtmp_app_live_find(app,livestream); 71 | if (live == NULL) { 72 | live = rtmp_app_live_alloc(app,livestream); 73 | } 74 | return live; 75 | } 76 | 77 | */ 78 | rtmp_live_stream_t* rtmp_app_live_get(rtmp_app_t *app, 79 | const char *livestream); 80 | 81 | int32_t rtmp_app_live_publish(rtmp_session_t *session, 82 | rtmp_chunk_header_t *chunk,char *livestream); 83 | 84 | int32_t rtmp_app_live_play(rtmp_session_t *session, 85 | rtmp_chunk_header_t *chunk,const char *livestream); 86 | 87 | void rtmp_app_live_free(rtmp_app_t *app,rtmp_live_stream_t *live); 88 | 89 | void rtmp_app_live_release(rtmp_live_link_t *link); 90 | 91 | #endif -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_chunk.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | uint8_t* rtmp_chunk_read(mem_buf_t *buf,rtmp_chunk_header_t *h) 10 | { 11 | uint32_t csid; 12 | uint8_t *p,*last; 13 | 14 | memset(h,0,sizeof(rtmp_chunk_header_t)); 15 | 16 | p = buf->buf; 17 | last = buf->last; 18 | 19 | if (last == p) { 20 | return 0; 21 | } 22 | 23 | /*Basic Header*/ 24 | 25 | h->fmt = (*p >> 6) & 0x03; 26 | csid = *p++ & 0x3f; 27 | 28 | if (csid == 0) { 29 | 30 | if (last - p < 1) { 31 | return 0; 32 | } 33 | csid = 64; 34 | csid += *(uint8_t*)p++; 35 | 36 | } else if (csid == 1){ 37 | 38 | if (last - p < 2) { 39 | return 0; 40 | } 41 | csid = 64; 42 | csid += *p++; 43 | csid += (uint32_t)*p++ << 8; /*p * 256*/ 44 | } 45 | h->csid = csid; 46 | 47 | /*Message Header*/ 48 | 49 | switch (h->fmt) { 50 | 51 | case 0: 52 | 53 | if (last - p < 11) { 54 | return 0; 55 | } 56 | 57 | h->dtime = byte_make_ulong3(p); 58 | p += 3; 59 | 60 | h->msglen = byte_make_ulong3(p); 61 | p += 3; 62 | 63 | h->msgtid = *p++; 64 | h->msgsid = byte_make_ulong4_l(p); 65 | p += 4; 66 | 67 | break; 68 | 69 | case 1: 70 | 71 | if (last - p < 7) { 72 | return 0; 73 | } 74 | 75 | h->dtime = byte_make_ulong3(p); 76 | p += 3; 77 | 78 | h->msglen = byte_make_ulong3(p); 79 | p += 3; 80 | 81 | h->msgtid = *p++; 82 | 83 | break; 84 | 85 | case 2: 86 | 87 | if (last - p < 3) { 88 | return 0; 89 | } 90 | 91 | h->dtime = byte_make_ulong3(p); 92 | p += 3; 93 | 94 | break; 95 | } 96 | 97 | /*Extern Timestamp*/ 98 | 99 | if (h->dtime == 0x00ffffff) { 100 | 101 | if (last - p < 4) { 102 | return 0; 103 | } 104 | 105 | h->extend = byte_make_ulong4(p); 106 | p += 4; 107 | } 108 | 109 | return p; 110 | } 111 | 112 | int32_t rtmp_chunk_write(mem_buf_t *buf,rtmp_chunk_header_t *h) 113 | { 114 | uint32_t csid; 115 | uint8_t *p,*end; 116 | 117 | p = buf->buf; 118 | end = buf->end; 119 | 120 | if (end == p) { 121 | return -1; 122 | } 123 | 124 | /*Basic Header*/ 125 | 126 | *p = (h->fmt << 6) & 0xc0; 127 | csid = h->csid; 128 | 129 | if ((csid < 2) || (csid > 65566)) { 130 | rtmp_log(RTMP_LOG_ERR,"invalid csid: [%d]",csid); 131 | return -1; 132 | } 133 | 134 | if (csid <= 63) { 135 | 136 | *p++ |= (uint8_t)csid; 137 | 138 | } else if (csid <= 319) { 139 | 140 | if (end - p < 1) { 141 | return -1; 142 | } 143 | 144 | *p++ &= 0xc0; 145 | *p++ = (csid - 64); 146 | 147 | } else { 148 | 149 | if (end - p < 2) { 150 | return -1; 151 | } 152 | 153 | csid -= 64; 154 | *p++ |= 0x3f; 155 | 156 | *p++ = csid & 0xff; 157 | *p++ = csid >> 8; 158 | } 159 | 160 | /*Message Header*/ 161 | 162 | switch (h->fmt) { 163 | 164 | case 0: 165 | 166 | if (end - p < 11) { 167 | return -1; 168 | } 169 | 170 | ulong_make_byte3(p,h->dtime); 171 | p += 3; 172 | 173 | ulong_make_byte3(p,h->msglen); 174 | p += 3; 175 | 176 | *p++ = h->msgtid; 177 | 178 | ulong_make_byte4_l(p,h->msgsid); 179 | p += 4; 180 | 181 | break; 182 | 183 | case 1: 184 | 185 | if (end - p < 7) { 186 | return -1; 187 | } 188 | 189 | ulong_make_byte3(p,h->dtime); 190 | p += 3; 191 | 192 | ulong_make_byte3(p,h->msglen); 193 | p += 3; 194 | 195 | *p++ = h->msgtid; 196 | 197 | break; 198 | 199 | case 2: 200 | 201 | if (end - p < 3) { 202 | return -1; 203 | } 204 | 205 | ulong_make_byte3(p,h->dtime); 206 | p += 3; 207 | 208 | break; 209 | } 210 | 211 | /*Extern Timestamp*/ 212 | 213 | if (h->dtime == 0x00ffffff) { 214 | 215 | if (end - p < 4) { 216 | return -1; 217 | } 218 | 219 | ulong_make_byte4_l(p,h->extend); 220 | p += 4; 221 | } 222 | 223 | buf->last = p; 224 | 225 | return 0; 226 | } 227 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_chunk.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #include "rtmp_config.h" 8 | #include "rtmp_core.h" 9 | 10 | #ifndef __CHUNK_H_INCLUDED__ 11 | #define __CHUNK_H_INCLUDED__ 12 | 13 | #define RTMP_DEFAULT_IN_CHUNKSIZE 128 14 | #define RTMP_DEFAULT_OUT_CHUNKSIZE 4096 15 | #define RTMP_MAX_CHUNK_HEADER 18 16 | 17 | /* 18 | +--------------+----------------+--------------------+--------------+ 19 | | Basic Header | Message Header | Extended Timestamp | Chunk Data | 20 | +--------------+----------------+--------------------+--------------+ 21 | | | 22 | |<------------------- Chunk Header ----------------->| 23 | 24 | 25 | Basic Header: (1,2,3 Byte) 26 | 27 | 0 1 2 3 4 5 6 7 28 | +-+-+-+-+-+-+-+-+ 29 | |fmt| cs id | 30 | +-+-+-+-+-+-+-+-+ 31 | 32 | Message Header: (11,7,3,0 Byte) 33 | 34 | 0 1 2 3 35 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 36 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 | | timestamp |message length | 38 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 | | message length (cont) |message type id| msg stream id | 40 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 | | message stream id (cont) | 42 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 | 44 | 45 | Extended Timestamp: (4,0 Byte) 46 | 47 | 0 1 2 3 48 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 49 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 50 | | timestamp |message length | 51 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 52 | */ 53 | 54 | typedef struct rtmp_chunk_header_s rtmp_chunk_header_t; 55 | typedef struct rtmp_chunk_stream_s rtmp_chunk_stream_t; 56 | 57 | /*chunk header*/ 58 | struct rtmp_chunk_header_s{ 59 | uint32_t fmt:2; 60 | uint32_t csid:24; 61 | 62 | uint32_t dtime:24; /*timestamp (delta)*/ 63 | uint32_t msglen:24; 64 | uint32_t msgtid:8; 65 | uint32_t msgsid; 66 | 67 | uint32_t extend; 68 | uint32_t chunk_time; 69 | }; 70 | 71 | struct rtmp_chunk_stream_s { 72 | rtmp_chunk_header_t hdr; 73 | uint32_t recvlen; 74 | mem_buf_chain_t *chain; 75 | mem_buf_chain_t *last; 76 | }; 77 | 78 | uint8_t* rtmp_chunk_read(mem_buf_t *buf,rtmp_chunk_header_t *h); 79 | int32_t rtmp_chunk_write(mem_buf_t *buf,rtmp_chunk_header_t *h); 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_codec.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #define RTMP_STREAM_LIVE 0 7 | #define RTMP_STREAM_RECORD 1 8 | #define RTMP_STREAM_APPEND 2 9 | 10 | typedef struct rtmp_live_codec_s rtmp_live_codec_t; 11 | 12 | struct rtmp_live_codec_s { 13 | /*video codec*/ 14 | uint32_t video_codec_id; 15 | uint32_t width; 16 | uint32_t height; 17 | uint32_t duration; 18 | uint32_t frame_rate; 19 | uint32_t video_data_rate; 20 | uint32_t avc_version; 21 | uint32_t avc_profile; 22 | uint32_t avc_compat; 23 | uint32_t avc_level; 24 | uint32_t avc_nal_bytes; 25 | uint32_t avc_ref_frames; 26 | 27 | 28 | 29 | 30 | /*audio codec*/ 31 | uint32_t audio_codec_id; 32 | uint32_t audio_data_rate; 33 | uint32_t aac_profile; 34 | uint32_t aac_chan_conf; 35 | uint32_t aac_sbr; 36 | uint32_t aac_ps; 37 | uint32_t sample_rate; 38 | uint32_t sample_size; 39 | uint32_t audio_channels; 40 | 41 | u_char profile[32]; 42 | u_char level[32]; 43 | 44 | /*meta data*/ 45 | mem_buf_chain_t *meta; 46 | }; -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_core.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __RTMP_CORE_H_INCLUDED__ 7 | #define __RTMP_CORE_H_INCLUDED__ 8 | 9 | #include "rtmp_def.h" 10 | #include "rtmp_array.h" 11 | #include "rtmp_amf.h" 12 | #include "rtmp_link.h" 13 | #include "rtmp_bytes.h" 14 | #include "rtmp_rbtree.h" 15 | 16 | #include "rtmp_atomic.h" 17 | #include "rtmp_log.h" 18 | #include "rtmp_time.h" 19 | #include "rtmp_error.h" 20 | 21 | #include "rtmp_conf.h" 22 | #include "rtmp_event.h" 23 | #include "rtmp_event_timer.h" 24 | #include "rtmp_core_conf.h" 25 | #include "rtmp_chunk.h" 26 | #include "rtmp_message.h" 27 | #include "rtmp_host.h" 28 | #include "rtmp_codec.h" 29 | #include "rtmp_app.h" 30 | #include "rtmp_protocol.h" 31 | #include "rtmp_handshake.h" 32 | #include "rtmp_session.h" 33 | #include "rtmp_connection.h" 34 | #include "rtmp_handler.h" 35 | 36 | struct rtmp_cycle_s { 37 | mem_pool_t *pool; 38 | mem_pool_t *temp_pool; 39 | rtmp_conf_t *conf; 40 | char *conf_file; 41 | 42 | uint32_t daemon; 43 | uint32_t workers; 44 | uint32_t max_conn; 45 | uint32_t out_queue; 46 | 47 | rtmp_connection_t *free_connections; 48 | rtmp_connection_t *connections; 49 | 50 | rtmp_event_t *read_events; 51 | rtmp_event_t *write_events; 52 | 53 | array_t ports; /*rtmp_addr_port_t*/ 54 | array_t listening; /*rtmp_listening_t*/ 55 | array_t server_list; /*rtmp_host_t*/ 56 | array_t msg_handler; /*rtmp_msg_handler_pt*/ 57 | }; 58 | 59 | struct rtmp_addr_port_s { 60 | uint16_t family; 61 | uint16_t port; 62 | array_t addr_in; /*rtmp_addr_inet_t*/ 63 | }; 64 | 65 | struct rtmp_addr_inet_s { 66 | struct sockaddr_in addr; 67 | array_t hosts; /* rtmp_host_t ** */ 68 | rtmp_addr_port_t *port; 69 | }; 70 | 71 | struct rtmp_module_s{ 72 | int32_t index; 73 | 74 | char *name; 75 | 76 | void *ctx; 77 | 78 | void* (*create_module)(rtmp_cycle_t *cycle); 79 | int32_t (*init_cycle)(rtmp_cycle_t *cycle,rtmp_module_t *m); 80 | int32_t (*init_forking)(rtmp_cycle_t *cycle,rtmp_module_t *m); 81 | int32_t (*eixt_cycle)(rtmp_cycle_t *cycle,rtmp_module_t *m); 82 | }; 83 | 84 | rtmp_cycle_t* rtmp_init_cycle(); 85 | void rtmp_run_cycle(rtmp_cycle_t *); 86 | 87 | int32_t rtmp_server_handshake(rtmp_session_t *session); 88 | int32_t rtmp_client_handshake(rtmp_session_t *session); 89 | 90 | int32_t rtmp_server_handshake_done(rtmp_session_t *session); 91 | int32_t rtmp_client_handshake_done(rtmp_session_t *session); 92 | 93 | mem_buf_chain_t* rtmp_core_alloc_chain(rtmp_session_t *session, 94 | mem_pool_t *pool,int32_t chunk_size); 95 | 96 | void rtmp_core_lock_chain(mem_buf_chain_t *chain); 97 | 98 | void rtmp_core_lock_chains(mem_buf_chain_t *chain); 99 | 100 | void rtmp_core_free_chain(rtmp_session_t *session, 101 | mem_pool_t *pool,mem_buf_chain_t *chain); 102 | 103 | void rtmp_core_free_chains(rtmp_session_t *session, 104 | mem_pool_t *pool,mem_buf_chain_t *chain); 105 | 106 | int32_t rtmp_recv_buf(int sockfd,mem_buf_t *buf,int32_t *n); 107 | int32_t rtmp_send_buf(int sockfd,mem_buf_t *buf,int32_t *n); 108 | 109 | void rtmp_chain_send(rtmp_event_t *ev); 110 | 111 | int32_t rtmp_handler_init(rtmp_cycle_t *cycle); 112 | 113 | mem_buf_t* rtmp_prepare_amf_buffer(mem_pool_t *temp_pool, 114 | amf_data_t **amf,uint32_t num); 115 | 116 | uint32_t rtmp_hash_key(const u_char *data, size_t len); 117 | uint32_t rtmp_hash_string(const char *data); 118 | 119 | extern rtmp_module_t rtmp_core_moudle; 120 | extern rtmp_module_t rtmp_host_moudle; 121 | extern rtmp_module_t rtmp_event_module; 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_core_conf.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __RTMP_CORE_CONF_H_INCLUDED__ 7 | #define __RTMP_CORE_CONF_H_INCLUDED__ 8 | 9 | 10 | #define RTMP_DEFAULT_PORT 1935 11 | #define RTMP_DEFAULT_ACK 5000000 12 | #define RTMP_DEFAULT_PING 5000 /*ms*/ 13 | 14 | #define RTMP_IPT_TYPE_PUBLISH 0x0001 15 | #define RTMP_IPT_TYPE_PLAY 0x0002 16 | 17 | typedef struct rtmp_app_conf_s rtmp_app_conf_t; 18 | typedef struct rtmp_app_s rtmp_app_t; 19 | 20 | typedef struct rtmp_host_conf_s rtmp_host_conf_t; 21 | typedef struct rtmp_host_s rtmp_host_t; 22 | 23 | typedef struct rtmp_ip_table_s rtmp_ip_table_t; 24 | 25 | struct rtmp_ip_table_s { 26 | uint32_t in_addr; 27 | uint32_t mask; 28 | link_t link; 29 | }; 30 | 31 | struct rtmp_app_conf_s { 32 | uint32_t push:1; 33 | uint32_t pull:1; 34 | 35 | /*0 for play,1 for publish*/ 36 | link_t allow_list[2]; 37 | link_t deny_list[2]; 38 | 39 | uint32_t chunk_size; 40 | uint32_t ack_size; 41 | uint32_t ping_timeout; 42 | uint32_t stream_buckets; 43 | }; 44 | 45 | struct rtmp_host_conf_s { 46 | 47 | struct sockaddr sock; 48 | socklen_t socklen; 49 | 50 | uint32_t default_server; 51 | 52 | uint32_t ping; 53 | uint32_t chunk_size; 54 | uint32_t ack_size; 55 | 56 | /*0 for play,1 for publish*/ 57 | link_t allow_list[2]; 58 | link_t deny_list[2]; 59 | 60 | link_t allow_play_list; 61 | link_t deny_play_list; 62 | }; 63 | 64 | int32_t rtmp_host_conf_block(rtmp_cycle_t *c,rtmp_conf_t *conf); 65 | int32_t rtmp_app_conf_block(rtmp_conf_t *conf,rtmp_app_t *app); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_handshake.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #ifndef __HANDSHAKE_H_INCLUDED__ 8 | #define __HANDSHAKE_H_INCLUDED__ 9 | 10 | 11 | #define HANDSHAKE_BUF_LEN 1537 12 | #define HANDSHAKE_KEY_LEN 32 13 | 14 | typedef struct rtmp_handshake_s{ 15 | 16 | mem_buf_t rbuf; 17 | mem_buf_t wbuf; 18 | 19 | u_char *digest; 20 | 21 | uint32_t stage:4; 22 | 23 | uint32_t epoch; 24 | uint32_t peer_epoch; 25 | char peer_version[4]; 26 | } rtmp_handshake_t; 27 | 28 | void rtmp_core_handshake_init(); 29 | void rtmp_handshake_recv(rtmp_event_t *ev); 30 | void rtmp_handshake_send(rtmp_event_t *ev); 31 | rtmp_handshake_t* rtmp_handshake_alloc(mem_pool_t *); 32 | 33 | #endif -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_host.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #include "rtmp_config.h" 8 | #include "rtmp_core.h" 9 | 10 | #ifndef __HOST_H_INCLUDED__ 11 | #define __HOST_H_INCLUDED__ 12 | 13 | #define RTMP_HOSTNAME_DEF "__defualt_host__" 14 | #define RTMP_APPNAME_DEF "__defualt_app__" 15 | 16 | extern rtmp_module_t rtmp_hosts_moudle; 17 | 18 | struct rtmp_host_s { 19 | char name[128]; 20 | rtmp_host_conf_t *hconf; 21 | array_t apps; 22 | rtmp_cycle_t *cycle; 23 | }; 24 | 25 | rtmp_host_t *rtmp_host_conf_find(char *name,array_t *a); 26 | 27 | #endif -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_host_module.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | static void *rtmp_host_create_module(rtmp_cycle_t *cycle); 10 | static int32_t rtmp_host_init_cycle(rtmp_cycle_t *cycle,rtmp_module_t *module); 11 | static int32_t rtmp_host_init_process(rtmp_cycle_t *cycle,rtmp_module_t *module); 12 | static int32_t rtmp_host_eixt_cycle(rtmp_cycle_t *cycle,rtmp_module_t *module); 13 | 14 | rtmp_module_t rtmp_host_moudle = { 15 | 0, 16 | "rtmp_host_module", 17 | 0, 18 | rtmp_host_create_module, 19 | rtmp_host_init_cycle, 20 | rtmp_host_init_process, 21 | rtmp_host_eixt_cycle 22 | }; 23 | 24 | static void *rtmp_host_create_module(rtmp_cycle_t *cycle) 25 | { 26 | return (void *)(-1); 27 | } 28 | 29 | static int32_t rtmp_host_init_cycle(rtmp_cycle_t *cycle, 30 | rtmp_module_t *module) 31 | { 32 | int32_t rc; 33 | rtmp_conf_t *conf,*it,*sconf; 34 | char **word; 35 | 36 | conf = rtmp_get_conf(cycle->conf,"rtmp",GET_CONF_CURRENT); 37 | if (conf == NULL) { 38 | return RTMP_FAILED; 39 | } 40 | 41 | sconf = rtmp_get_conf(conf,"out_queue",GET_CONF_CHILD); 42 | if (sconf == NULL) { 43 | rtmp_log(RTMP_LOG_WARNING,"no workers!"); 44 | } 45 | 46 | if (sconf && sconf->argv.nelts > 1) { 47 | uint32_t n; 48 | 49 | word = sconf->argv.elts; 50 | n = atoi(word[1]); 51 | if (n > 0) { 52 | cycle->out_queue = (uint32_t)n; 53 | } 54 | } 55 | 56 | conf = rtmp_get_conf(conf,"server",GET_CONF_CHILD); 57 | if (conf == NULL) { 58 | return RTMP_FAILED; 59 | } 60 | 61 | it = conf; 62 | do { 63 | rc = rtmp_host_conf_block(cycle,it); 64 | 65 | if (rc != RTMP_OK) { 66 | rtmp_log(RTMP_LOG_WARNING,"host conf failed [%d]!",rc); 67 | continue; 68 | } 69 | 70 | it = rtmp_get_conf(it,"server",GET_CONF_NEXT); 71 | } while (it && it != conf); 72 | 73 | return RTMP_OK; 74 | } 75 | 76 | static int32_t rtmp_host_init_process(rtmp_cycle_t *cycle, 77 | rtmp_module_t *module) 78 | { 79 | return RTMP_OK; 80 | } 81 | 82 | static int32_t rtmp_host_eixt_cycle(rtmp_cycle_t *cycle, 83 | rtmp_module_t *module) 84 | { 85 | return RTMP_OK; 86 | } 87 | 88 | rtmp_host_t *rtmp_host_conf_find(char *name,array_t *a) 89 | { 90 | uint32_t i; 91 | rtmp_host_t *host; 92 | 93 | host = NULL; 94 | if ((name == NULL) || (a == NULL) || (a->nelts == 0)) { 95 | return host; 96 | } 97 | 98 | for (i = 0;i < a->nelts;i++) { 99 | host = (rtmp_host_t *)((void **)a->elts)[i]; 100 | if (host && strcmp(host->name,name) == 0) { 101 | break; 102 | } 103 | host = NULL; 104 | } 105 | 106 | return host; 107 | } -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_live.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | 10 | static int32_t rtmp_live_send_avdata(rtmp_live_link_t *client, 11 | rtmp_chunk_header_t *chunk,mem_buf_chain_t *chain); 12 | 13 | static uint8_t rtmp_get_video_frame_type(mem_buf_chain_t *chain) 14 | { 15 | return (chain->chunk.buf[0] & 0xf0) >> 4; 16 | } 17 | 18 | static int32_t rtmp_live_send_avdata(rtmp_live_link_t *client, 19 | rtmp_chunk_header_t *hdr,mem_buf_chain_t *chain) 20 | { 21 | rtmp_session_t *session; 22 | 23 | session = client->session; 24 | if (rtmp_append_message_chain(session,chain,hdr) != RTMP_OK) { 25 | rtmp_core_free_chains(session,session->chunk_pool,chain); 26 | rtmp_log(RTMP_LOG_DEBUG,"[%d] drop message",session->sid); 27 | 28 | return RTMP_ERROR; 29 | } 30 | 31 | rtmp_core_lock_chains(chain); 32 | 33 | rtmp_chain_send(client->session->c->write); 34 | return RTMP_OK; 35 | } 36 | 37 | int32_t rtmp_handler_audio(rtmp_session_t *s,rtmp_chunk_header_t *hdr, 38 | mem_buf_chain_t *chain) 39 | { 40 | return rtmp_handler_avdata(s,hdr,chain); 41 | } 42 | 43 | int32_t rtmp_handler_video(rtmp_session_t *s,rtmp_chunk_header_t *hdr, 44 | mem_buf_chain_t *chain) 45 | { 46 | return rtmp_handler_avdata(s,hdr,chain); 47 | } 48 | 49 | int32_t rtmp_handler_avdata(rtmp_session_t *session,rtmp_chunk_header_t *chunk, 50 | mem_buf_chain_t *in_chain) 51 | { 52 | rtmp_live_stream_t *live; 53 | rtmp_live_link_t *link,*client; 54 | link_t *next; 55 | int32_t rc; 56 | mem_buf_chain_t *chain; 57 | uint8_t keyframe; 58 | 59 | if (chunk->msgtid == RTMP_MSG_VIDEO) { 60 | keyframe = rtmp_get_video_frame_type(in_chain); 61 | } 62 | 63 | if ((chunk->msgsid == 0) || (chunk->msgsid >= session->max_lives)) { 64 | rtmp_log(RTMP_LOG_ERR,"[%d]invalid message stream id[%d]!", 65 | session->sid,chunk->msgsid); 66 | return RTMP_FAILED; 67 | } 68 | 69 | link = session->lives[chunk->msgsid]; 70 | if (link == RTMP_NULL || link == RTMP_READY) { 71 | rtmp_log(RTMP_LOG_ERR,"[%d]invalid message stream status[%p]!", 72 | session->sid,link); 73 | return RTMP_FAILED; 74 | } 75 | 76 | if (link->lvst == NULL) { 77 | rtmp_log(RTMP_LOG_ERR,"[%d]invalid live (null)!",session->sid); 78 | return RTMP_FAILED; 79 | } 80 | 81 | if (link != link->lvst->publisher) { 82 | rtmp_log(RTMP_LOG_WARNING,"[%d]not publisher!",session->sid); 83 | return RTMP_OK; 84 | } 85 | 86 | chain = rtmp_copy_chain_to_chain(session,in_chain); 87 | live = link->lvst; 88 | 89 | /*broad cast*/ 90 | if (live->players) { 91 | 92 | next = &live->players->link; 93 | do { 94 | client = struct_entry(next,rtmp_live_link_t,link); 95 | next = client->link.next; 96 | 97 | if (client->session == NULL) { 98 | 99 | list_remove(&client->link); 100 | rtmp_log(RTMP_LOG_WARNING,"[%d]invalid session!", 101 | session->sid); 102 | 103 | if (client == live->players) { 104 | live->players = NULL; 105 | 106 | break; 107 | } 108 | 109 | continue; 110 | } 111 | 112 | rc = rtmp_live_send_avdata(client,chunk,chain); 113 | 114 | if (rc != RTMP_OK) { 115 | rtmp_log(RTMP_LOG_WARNING,"[%d]send avdata[%d]", 116 | client->session->sid,rc); 117 | continue; 118 | } 119 | 120 | rtmp_log(RTMP_LOG_DEBUG,"[%d]send av data", 121 | client->session->sid); 122 | }while (next != &live->players->link); 123 | } 124 | 125 | rtmp_core_free_chains(session,session->chunk_pool,chain); 126 | 127 | return RTMP_OK; 128 | } 129 | 130 | 131 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_message.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __MESSAGE_H_INCLUDED__ 7 | #define __MESSAGE_H_INCLUDED__ 8 | 9 | typedef struct rtmp_message_s rtmp_message_t; 10 | struct rtmp_message_s { 11 | rtmp_chunk_header_t hdr; 12 | mem_buf_t head; 13 | mem_buf_chain_t *chain; 14 | uint8_t head_buf[RTMP_MAX_CHUNK_HEADER]; 15 | }; 16 | 17 | typedef mem_buf_chain_t* (*rtmp_create_proctol_message_ptr) 18 | (rtmp_session_t *session, 19 | rtmp_chunk_header_t *ih,rtmp_chunk_header_t *oh); 20 | 21 | mem_buf_chain_t* rtmp_create_ack_size(rtmp_session_t *session, 22 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 23 | 24 | mem_buf_chain_t* rtmp_create_ack(rtmp_session_t *session, 25 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 26 | 27 | mem_buf_chain_t* rtmp_create_peer_bandwidth_size(rtmp_session_t *session, 28 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 29 | 30 | mem_buf_chain_t* rtmp_create_set_chunk_size(rtmp_session_t *session, 31 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 32 | 33 | mem_buf_chain_t* rtmp_create_user_begin(rtmp_session_t *session, 34 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 35 | 36 | mem_buf_chain_t* rtmp_create_play_reset(rtmp_session_t *session, 37 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 38 | 39 | mem_buf_chain_t* rtmp_create_play_start(rtmp_session_t *session, 40 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 41 | 42 | mem_buf_chain_t* rtmp_create_publish_start(rtmp_session_t *session, 43 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 44 | 45 | mem_buf_chain_t* rtmp_create_publish_badname(rtmp_session_t *session, 46 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 47 | 48 | mem_buf_chain_t* rtmp_create_sample_access(rtmp_session_t *session, 49 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 50 | 51 | mem_buf_chain_t* rtmp_create_play_not_found(rtmp_session_t *session, 52 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 53 | 54 | mem_buf_chain_t* rtmp_create_publish_not_found(rtmp_session_t *session, 55 | rtmp_chunk_header_t *h,rtmp_chunk_header_t *oh); 56 | 57 | mem_buf_chain_t* rtmp_create_ping_request(rtmp_session_t *session, 58 | uint32_t timestamp,rtmp_chunk_header_t *oh); 59 | 60 | mem_buf_chain_t* rtmp_create_ping_response(rtmp_session_t *session, 61 | uint32_t timestamp,rtmp_chunk_header_t *oh); 62 | 63 | 64 | int32_t rtmp_create_append_chain(rtmp_session_t *session, 65 | rtmp_create_proctol_message_ptr ptr,rtmp_chunk_header_t *h); 66 | 67 | int32_t rtmp_append_message_chain(rtmp_session_t *session, 68 | mem_buf_chain_t *chain,rtmp_chunk_header_t *h); 69 | 70 | mem_buf_t* rtmp_copy_chain_to_buf(mem_buf_chain_t *chain_in, 71 | mem_pool_t *temp_pool); 72 | 73 | mem_buf_chain_t *rtmp_copy_buf_to_chain(rtmp_session_t *session, 74 | mem_buf_t *buf); 75 | 76 | mem_buf_chain_t *rtmp_copy_chain_to_chain(rtmp_session_t *session, 77 | mem_buf_chain_t *in_chain); 78 | 79 | #endif -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_play.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #include "rtmp_config.h" 8 | #include "rtmp_core.h" 9 | 10 | static int32_t rtmp_app_live_play_send(rtmp_session_t *session, 11 | rtmp_chunk_header_t *h,const char *livestream) 12 | { 13 | int32_t rc; 14 | 15 | rc = rtmp_create_append_chain(session,rtmp_create_set_chunk_size,h); 16 | if (rc != RTMP_OK) { 17 | rtmp_log(RTMP_LOG_WARNING,"[%d]append set chunk size " 18 | "message failed!",session->sid); 19 | return RTMP_FAILED; 20 | } 21 | 22 | rc = rtmp_create_append_chain(session,rtmp_create_user_begin,h); 23 | if (rc != RTMP_OK) { 24 | rtmp_log(RTMP_LOG_WARNING,"[%d]append user begin " 25 | "message failed!",session->sid); 26 | return RTMP_FAILED; 27 | } 28 | 29 | rc = rtmp_create_append_chain(session,rtmp_create_play_reset,h); 30 | if (rc != RTMP_OK) { 31 | rtmp_log(RTMP_LOG_WARNING,"[%d]append play rest " 32 | "message failed!",session->sid); 33 | return RTMP_FAILED; 34 | } 35 | 36 | rc = rtmp_create_append_chain(session,rtmp_create_play_start,h); 37 | if (rc != RTMP_OK) { 38 | rtmp_log(RTMP_LOG_WARNING,"[%d]append play start " 39 | "message failed!",session->sid); 40 | return RTMP_FAILED; 41 | } 42 | 43 | rc = rtmp_create_append_chain(session,rtmp_create_sample_access,h); 44 | if (rc != RTMP_OK) { 45 | rtmp_log(RTMP_LOG_WARNING,"[%d]append sample access " 46 | "message failed!",session->sid); 47 | return RTMP_FAILED; 48 | } 49 | 50 | rtmp_chain_send(session->c->write); 51 | 52 | return RTMP_OK; 53 | } 54 | 55 | int32_t rtmp_app_live_play(rtmp_session_t *session,rtmp_chunk_header_t *chunk, 56 | const char *livestream) 57 | { 58 | rtmp_app_t *app; 59 | rtmp_live_stream_t *live; 60 | rtmp_live_link_t *lvid; 61 | int32_t rc; 62 | rtmp_chunk_header_t *h; 63 | 64 | h = chunk; 65 | app = session->app_ctx; 66 | 67 | if ((h->msgsid == 0) || (h->msgsid >= session->max_lives) 68 | || (session->lives[h->msgsid] == RTMP_NULL)) 69 | { 70 | rc = rtmp_create_append_chain(session,rtmp_create_play_not_found,h); 71 | if (rc != RTMP_OK) { 72 | rtmp_log(RTMP_LOG_WARNING,"[%d]append play not found " 73 | "message failed!",session->sid); 74 | 75 | return RTMP_FAILED; 76 | } 77 | 78 | rtmp_log(RTMP_LOG_ERR,"[%d]\"%s\" stream not found!", 79 | session->sid,livestream); 80 | 81 | rtmp_chain_send(session->c->write); 82 | 83 | return RTMP_OK; 84 | } 85 | 86 | lvid = mem_palloc(session->pool,sizeof(rtmp_live_link_t)); 87 | if (lvid == NULL) { 88 | rtmp_log(RTMP_LOG_ERR,"[%d]\"%s\" alloc live link failed!", 89 | session->sid,livestream); 90 | return RTMP_FAILED; 91 | } 92 | 93 | live = rtmp_app_live_get(app,livestream); 94 | if (live == NULL) { 95 | rtmp_log(RTMP_LOG_ERR,"[%d]\"%s\" get stream failed!", 96 | session->sid,livestream); 97 | return RTMP_FAILED; 98 | } 99 | 100 | rc = rtmp_app_live_play_send(session,h,livestream); 101 | if (rc == RTMP_OK) { 102 | 103 | session->lives[h->msgsid] = lvid; 104 | lvid->msgid = h->msgsid; 105 | lvid->session = session; 106 | lvid->lvst = live; 107 | 108 | if (live->players == NULL) { 109 | list_init(&lvid->link); 110 | live->players = lvid; 111 | } else { 112 | list_insert_head(&live->players->link,&lvid->link); 113 | } 114 | } 115 | 116 | rtmp_log(RTMP_LOG_DEBUG,"[%d]play start[%d]",session->sid,rc); 117 | 118 | return RTMP_OK; 119 | } 120 | 121 | /* 122 | string "play" 123 | double 0.000000 124 | null 125 | string "cameraFeed" 126 | */ 127 | int32_t rtmp_amf_cmd_play(rtmp_session_t *s, 128 | rtmp_chunk_header_t *chunk,amf_data_t *amf[],uint32_t num) 129 | { 130 | char *livestream,*arg; 131 | 132 | if (num < 4 || amf[3] == NULL) { 133 | rtmp_log(RTMP_LOG_ERR,"[%d]amf num error[%d]!",s->sid,num); 134 | return RTMP_FAILED; 135 | } 136 | 137 | livestream = amf_get_string(amf[3]); 138 | arg = strchr(livestream,'?'); 139 | if (arg != NULL) { 140 | *arg++ = 0; 141 | rtmp_log(RTMP_LOG_INFO,"publish args=\"%s\"", 142 | arg,(*arg ? arg:"null")); 143 | } 144 | 145 | return rtmp_app_live_play(s,chunk,livestream); 146 | } -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_protocol.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | * CopyLeft (C) nie950@gmail.com 5 | */ 6 | 7 | #ifndef __RTMP_PROTOCOL_H_INCLUDED__ 8 | #define __RTMP_PROTOCOL_H_INCLUDED__ 9 | 10 | /* 11 | *define protocol const value 12 | */ 13 | 14 | /* 15 | 16 | C -----> C0 C1 ----> S 17 | | <----- S0 S1 <---- | 18 | | <----- S2 <-----| 19 | | -----> C2 ----> | 20 | 21 | */ 22 | 23 | #define RTMP_HANDSHAKE_FAILED 0 /*handshake failed*/ 24 | 25 | #define RTMP_HANDSHAKE_SERVER_INIT 1 /*prepare*/ 26 | #define RTMP_HANDSHAKE_SERVER_C0C1 2 /*recv c0c1*/ 27 | #define RTMP_HANDSHAKE_SERVER_S0S1 3 /*send s0s1*/ 28 | #define RTMP_HANDSHAKE_SERVER_S2 4 /*send s2*/ 29 | #define RTMP_HANDSHAKE_SERVER_C2 5 /*recv c2*/ 30 | #define RTMP_HANDSHAKE_SERVER_DONE 6 31 | 32 | #define RTMP_HANDSHAKE_CLIENT_INIT 7 /*prepare c0c1*/ 33 | #define RTMP_HANDSHAKE_CLIENT_C0C1 8 /*send c0c1*/ 34 | #define RTMP_HANDSHAKE_CLIENT_S0S1 9 /*recv s0s1*/ 35 | #define RTMP_HANDSHAKE_CLIENT_S2 10 /*recv s2*/ 36 | #define RTMP_HANDSHAKE_CLIENT_C2 11 /*send c2*/ 37 | #define RTMP_HANDSHAKE_CLIENT_DONE 12 38 | 39 | 40 | #define rtmp_sig_fms_ver "4,5,6,5012" 41 | #define rtmp_sig_amf0_ver 0 42 | #define rtmp_sig_client_id "ASAICiss" 43 | 44 | #define rtmp_status_level "level" 45 | #define rtmp_status_code "code" 46 | #define rtmp_status_desc "description" 47 | #define rtmp_status_details "details" 48 | #define rtmp_status_clientid "clientid" 49 | 50 | 51 | #define rtmp_status_level_status "status" 52 | #define rtmp_status_level_error "error" 53 | 54 | #define rtmp_status_code_conn_success "NetConnection.Connect.Success" 55 | #define rtmp_status_code_conn_rejected "NetConnection.Connect.Rejected" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_publish.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #include "rtmp_config.h" 8 | #include "rtmp_core.h" 9 | 10 | int32_t rtmp_app_live_publish(rtmp_session_t *session, 11 | rtmp_chunk_header_t *chunk,char *livestream) 12 | { 13 | rtmp_app_t *app; 14 | rtmp_live_stream_t *live; 15 | rtmp_live_link_t *lvid; 16 | int32_t rc; 17 | rtmp_chunk_header_t *h; 18 | 19 | h = chunk; 20 | app = session->app_ctx; 21 | 22 | if ((h->msgsid == 0) || (h->msgsid >= session->max_lives) 23 | || (session->lives[h->msgsid] == RTMP_NULL)) 24 | { 25 | rc = rtmp_create_append_chain(session,rtmp_create_publish_not_found,h); 26 | if (rc != RTMP_OK) { 27 | rtmp_log(RTMP_LOG_WARNING,"[%d]append publish not found " 28 | "message failed!",session->sid); 29 | 30 | return RTMP_FAILED; 31 | } 32 | 33 | rtmp_log(RTMP_LOG_ERR,"[%d]\"%s\" stream not found!", 34 | session->sid,livestream); 35 | 36 | rtmp_chain_send(session->c->write); 37 | 38 | return RTMP_OK; 39 | } 40 | lvid = session->lives[h->msgsid]; 41 | 42 | live = rtmp_app_live_find(app,livestream); 43 | if ((lvid != RTMP_READY) || (live && live->publisher)){ 44 | 45 | rc = rtmp_create_append_chain(session,rtmp_create_publish_badname,h); 46 | if (rc != RTMP_OK) { 47 | rtmp_log(RTMP_LOG_WARNING,"[%d]append publish badname " 48 | "message failed!",session->sid); 49 | return RTMP_FAILED; 50 | } 51 | 52 | rtmp_log(RTMP_LOG_ERR,"[%d]\"%s\" already publish!", 53 | session->sid,livestream); 54 | 55 | rtmp_chain_send(session->c->write); 56 | 57 | return RTMP_OK; 58 | } 59 | 60 | lvid = mem_palloc(session->pool,sizeof(rtmp_live_link_t)); 61 | if (lvid == NULL) { 62 | 63 | rtmp_log(RTMP_LOG_ERR,"[%d]\"%s\" alloc live link failed!", 64 | session->sid,livestream); 65 | 66 | return RTMP_FAILED; 67 | } 68 | 69 | if (live == NULL) { 70 | live = rtmp_app_live_alloc(app,livestream); 71 | if (live == NULL) { 72 | rtmp_log(RTMP_LOG_ERR,"[%d]alloc live failed!",session->sid); 73 | return RTMP_FAILED; 74 | } 75 | } 76 | 77 | rc = rtmp_create_append_chain(session,rtmp_create_set_chunk_size,h); 78 | if (rc != RTMP_OK) { 79 | rtmp_log(RTMP_LOG_WARNING,"[%d]append set chunk size " 80 | "message failed!",session->sid); 81 | 82 | return RTMP_FAILED; 83 | } 84 | 85 | rc = rtmp_create_append_chain(session,rtmp_create_publish_start,h); 86 | if (rc != RTMP_OK) { 87 | rtmp_log(RTMP_LOG_WARNING,"[%d]append publish start " 88 | "message failed!",session->sid); 89 | 90 | return RTMP_FAILED; 91 | } 92 | 93 | lvid->session = session; 94 | lvid->lvst = live; 95 | lvid->msgid = h->msgsid; 96 | 97 | session->lives[h->msgsid] = lvid; 98 | live->publisher = lvid; 99 | 100 | rtmp_log(RTMP_LOG_DEBUG,"[%d]\"%s\" publish starting!", 101 | session->sid,livestream); 102 | 103 | rtmp_chain_send(session->c->write); 104 | 105 | return RTMP_OK; 106 | } 107 | 108 | /* 109 | string "publish" 110 | double 0.000000 111 | null 112 | string "cameraFeed" 113 | string "live" 114 | */ 115 | int32_t rtmp_amf_cmd_publish(rtmp_session_t *s, 116 | rtmp_chunk_header_t *chunk,amf_data_t *amf[],uint32_t num) 117 | { 118 | char *livestream,*streamtype,*arg; 119 | 120 | if (num < 5) { 121 | rtmp_log(RTMP_LOG_ERR,"[%d]amf num error[%d]!",s->sid,num); 122 | return RTMP_FAILED; 123 | } 124 | 125 | if (amf[3] == NULL || amf[4] == NULL) { 126 | rtmp_log(RTMP_LOG_ERR,"[%d]amf null error[%p][%p]!", 127 | s->sid,amf[3],amf[4]); 128 | return RTMP_FAILED; 129 | } 130 | 131 | streamtype = amf_get_string(amf[4]); 132 | if ((streamtype == NULL) || (strcmp(streamtype,"live"))) { 133 | rtmp_log(RTMP_LOG_ERR,"[%d]stream type[%s]!", 134 | s->sid,streamtype ? streamtype:"null"); 135 | return RTMP_FAILED; 136 | } 137 | 138 | livestream = amf_get_string(amf[3]); 139 | arg = strchr(livestream,'?'); 140 | if (arg != NULL) { 141 | *arg++ = 0; 142 | rtmp_log(RTMP_LOG_INFO,"publish args=\"%s\"", 143 | arg,(*arg ? arg:"null")); 144 | } 145 | 146 | return rtmp_app_live_publish(s,chunk,livestream); 147 | } -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_push_module.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/src/rtmp/rtmp_push_module.c -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_recv.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | int32_t rtmp_recv_n(int sockfd,u_char *buf,int n) 10 | { 11 | int recvd,rc; 12 | 13 | recvd = 0; 14 | while (n > 0) { 15 | rc = recv(sockfd,(char *)buf+recvd,n,0); 16 | 17 | if (rc <= 0) { 18 | break; 19 | } 20 | 21 | recvd += rc; 22 | n -= recvd; 23 | } 24 | 25 | return recvd; 26 | } 27 | 28 | int32_t rtmp_recv_buf(int sockfd,mem_buf_t *rbuf,int32_t *sz) 29 | { 30 | int32_t r,n; 31 | 32 | if (sz != NULL) { 33 | *sz = 0; 34 | } 35 | 36 | while (rbuf->last != rbuf->end) { 37 | 38 | n = rbuf->end - rbuf->last; 39 | r = recv(sockfd,(char *)rbuf->last,n,0); 40 | 41 | if (r > 0 && sz != NULL) { 42 | *sz = r; 43 | } 44 | 45 | if (r == -1 || r == 0) { 46 | if (sock_errno == SOCK_EAGAIN) { 47 | return SOCK_EAGAIN; 48 | } 49 | return SOCK_ERROR; 50 | } 51 | 52 | rbuf->last += r; 53 | } 54 | return SOCK_OK; 55 | } -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_rtmp_module.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | 10 | static void *rtmp_core_create_module(rtmp_cycle_t *cycle); 11 | static int32_t rtmp_core_init_cycle(rtmp_cycle_t *cycle); 12 | static int32_t rtmp_core_init_process(rtmp_cycle_t *cycle); 13 | static int32_t rtmp_core_eixt_cycle(rtmp_cycle_t *cycle); 14 | 15 | extern int rtmp_daemon_mode; 16 | 17 | rtmp_module_t rtmp_core_moudle = { 18 | 0, 19 | "rtmp_core_module", 20 | 0, 21 | rtmp_core_create_module, 22 | rtmp_core_init_cycle, 23 | rtmp_core_init_process, 24 | rtmp_core_eixt_cycle 25 | }; 26 | 27 | static void *rtmp_core_create_module(rtmp_cycle_t *cycle) 28 | { 29 | rtmp_core_conf_t *conf; 30 | 31 | conf = mem_pcalloc(cycle->pool,sizeof(rtmp_core_conf_t)); 32 | if (conf == NULL) { 33 | rtmp_log(RTMP_LOG_ERR,"create conf failed"); 34 | } 35 | 36 | return conf; 37 | } 38 | 39 | static int32_t rtmp_core_init_cycle(rtmp_cycle_t *cycle) 40 | { 41 | rtmp_conf_t *conf; 42 | char **word; 43 | rtmp_core_conf_t *cconf; 44 | 45 | conf = rtmp_get_conf(cycle->conf,"daemon",GET_CONF_NEXT); 46 | cconf = rtmp_core_moudle.conf; 47 | 48 | cconf->daemon = CONF_OFF; 49 | 50 | #ifndef HAVE_OS_WIN32 /*win32 doesn't support daemon*/ 51 | 52 | if (conf && (conf->argv.nelts > 1)) { 53 | word = conf->argv.elts; 54 | if ((word[1][0] == 'o') && (word[1][1] == 'n')) { 55 | cconf->daemon = CONF_ON; 56 | } 57 | } 58 | 59 | #endif 60 | 61 | rtmp_daemon_mode = cconf->daemon; 62 | 63 | cconf->workers = 1; 64 | if (cconf->daemon == CONF_ON) { 65 | conf = rtmp_get_conf(cycle->conf,"workers",GET_CONF_NEXT); 66 | 67 | if (conf && (conf->argv.nelts > 1)) { 68 | word = conf->argv.elts; 69 | cconf->workers = atoi(word[1]); 70 | } 71 | 72 | if (cconf->workers == 0) { 73 | cconf->workers = 1; 74 | } 75 | } 76 | 77 | return RTMP_OK; 78 | } 79 | 80 | static int32_t rtmp_core_init_process(rtmp_cycle_t *cycle) 81 | { 82 | return RTMP_OK; 83 | } 84 | 85 | static int32_t rtmp_core_eixt_cycle(rtmp_cycle_t *cycle) 86 | { 87 | return RTMP_OK; 88 | } -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_send.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | int rtmp_send_n(int sockfd,const u_char *buf,int n) 10 | { 11 | int sent,rc; 12 | 13 | sent = 0; 14 | while (n > 0) { 15 | rc = send(sockfd,(const char*)buf+sent,n,0); 16 | 17 | if (rc <= 0) { 18 | break; 19 | } 20 | 21 | sent += rc; 22 | n -= sent; 23 | } 24 | 25 | return sent; 26 | } 27 | 28 | 29 | int32_t rtmp_send_buf(int sockfd,mem_buf_t *wbuf,int32_t *sz) 30 | { 31 | int32_t r,n; 32 | 33 | if ( sz != NULL) { 34 | *sz = 0; 35 | } 36 | 37 | while (wbuf->last != wbuf->end) { 38 | 39 | n = wbuf->end - wbuf->last; 40 | r = send(sockfd,(char *)wbuf->last,n,0); 41 | 42 | if (r > 0 && sz != NULL) { 43 | *sz += r; 44 | } 45 | 46 | if (r == -1 || r == 0) { 47 | if (sock_errno == SOCK_EAGAIN) { 48 | return SOCK_EAGAIN; 49 | } 50 | return SOCK_ERROR; 51 | } 52 | wbuf->last += r; 53 | } 54 | return SOCK_OK; 55 | } 56 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_session.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #include "rtmp_config.h" 7 | #include "rtmp_core.h" 8 | 9 | rtmp_session_t *rtmp_session_create(rtmp_connection_t *c) 10 | { 11 | mem_pool_t *pool; 12 | rtmp_session_t *session; 13 | socklen_t socklen; 14 | struct sockaddr_in *addr_in; 15 | uint32_t ssz,lsz,i; 16 | mem_pool_t *temp_pool; 17 | rtmp_message_t *msg; 18 | 19 | /*get local address*/ 20 | socklen = sizeof(c->local_sockaddr); 21 | if (getsockname(c->fd, (struct sockaddr *) &c->local_sockaddr, 22 | &socklen) == -1) 23 | { 24 | rtmp_log(RTMP_LOG_WARNING,"getsockname() failed!"); 25 | return NULL; 26 | } 27 | 28 | switch(c->local_sockaddr.sa_family) { 29 | case AF_INET: 30 | addr_in = (struct sockaddr_in *)&c->local_sockaddr; 31 | sprintf(c->local_addr_text,"%s",inet_ntoa(addr_in->sin_addr)); 32 | 33 | break; 34 | case AF_UNIX: 35 | break; 36 | } 37 | 38 | if (c->pool == NULL) { 39 | c->pool = mem_create_pool(MEM_DEFAULT_POOL_SIZE); 40 | if (c->pool == NULL) { 41 | return NULL; 42 | } 43 | } 44 | 45 | temp_pool = c->listening->cycle->temp_pool; 46 | 47 | rtmp_core_handshake_init(); 48 | 49 | pool = c->pool; 50 | 51 | ssz = RTMP_DEFAULT_MAX_STREAMS * sizeof(rtmp_chunk_stream_t *); 52 | lsz = (RTMP_DEFAULT_MAX_LIVES + 1) * sizeof(rtmp_live_stream_t *); 53 | 54 | session = mem_pcalloc(pool,sizeof(rtmp_session_t) + ssz + lsz); 55 | if (session == NULL) { 56 | return NULL; 57 | } 58 | 59 | session->chunk_streams = (rtmp_chunk_stream_t **)((char *)session 60 | + sizeof(rtmp_session_t)); 61 | session->max_streams = RTMP_DEFAULT_MAX_STREAMS; 62 | 63 | session->lives = (rtmp_live_link_t**)((char *)session->chunk_streams + ssz); 64 | session->max_lives = RTMP_DEFAULT_MAX_LIVES; 65 | for (i = 0;i < session->max_lives;i++) { 66 | session->lives[i] = RTMP_NULL; 67 | } 68 | 69 | session->handshake = rtmp_handshake_alloc(pool); 70 | if (session->handshake == NULL) { 71 | return NULL; 72 | } 73 | 74 | session->ack_window = RTMP_DEFAULT_ACK; 75 | session->ping_timeout = RTMP_DEFAULT_PING; 76 | 77 | session->in_chunk_size = RTMP_DEFAULT_IN_CHUNKSIZE; 78 | session->in_chain = NULL; 79 | 80 | session->out_chunk_size = RTMP_DEFAULT_OUT_CHUNKSIZE; 81 | session->out_queue = c->listening->cycle->out_queue; 82 | 83 | msg = mem_pcalloc(pool,session->out_queue * sizeof(rtmp_message_t)); 84 | if (msg == NULL) { 85 | return NULL; 86 | } 87 | 88 | session->out_message = msg; 89 | for (i = 0;i < session->out_queue;i++) { 90 | msg[i].head.buf = msg[i].head_buf; 91 | msg[i].head.end = msg[i].head_buf + sizeof(msg[i].head_buf); 92 | msg[i].head.last = msg[i].head.end; 93 | } 94 | 95 | session->c = c; 96 | session->pool = c->pool; 97 | session->sid = c->fd; 98 | 99 | session->temp_pool = temp_pool; 100 | session->chunk_time = -1; 101 | 102 | rtmp_log(RTMP_LOG_INFO,"[%d]create session",session->sid); 103 | 104 | return session; 105 | } 106 | 107 | int32_t rtmp_session_destroy(rtmp_session_t * session) 108 | { 109 | uint32_t i; 110 | rtmp_connection_t *c; 111 | rtmp_live_link_t **lives; 112 | 113 | if (session == NULL) { 114 | return RTMP_FAILED; 115 | } 116 | 117 | rtmp_log(RTMP_LOG_INFO,"[%d]destroy session",session->sid); 118 | c = session->c; 119 | 120 | /*free chains*/ 121 | for (i = 0;i < session->out_queue;i++) { 122 | if (session->out_message[i].chain != NULL) { 123 | rtmp_core_free_chains(session,session->chunk_pool, 124 | session->out_message[i].chain); 125 | } 126 | } 127 | 128 | /*clear live streams*/ 129 | lives = session->lives; 130 | for (i = 1;i < session->max_lives;i++) { 131 | if ((lives[i] != RTMP_NULL) && (lives[i] != RTMP_READY)) { 132 | rtmp_app_live_release(lives[i]); 133 | } 134 | } 135 | 136 | if (c) { 137 | if (c->pool) { 138 | mem_reset_pool(c->pool); 139 | } 140 | 141 | close_connection(session->c); 142 | } 143 | 144 | return RTMP_OK; 145 | } -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_session.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | #ifndef __RTMP_SESSION_H_INCLUDED__ 7 | #define __RTMP_SESSION_H_INCLUDED__ 8 | 9 | #define RTMP_DEFAULT_MAX_STREAMS 32 10 | #define RTMP_DEFAULT_MAX_LIVES 8 11 | #define RTMP_CONN_APPNAME_SIZE_MAX 256 12 | #define RTMP_CONN_URL_SIZE_MAX 256 13 | #define RTMP_CONN_ARGS_SIZE_MAX 256 14 | #define RTMP_CONN_VER_SIZE_MAX 32 15 | 16 | typedef struct rtmp_session_connect_s rtmp_session_connect_t; 17 | struct rtmp_session_connect_s { 18 | char *app; 19 | char *args; 20 | char *flashver; 21 | char *swf_url; 22 | char *tc_url; 23 | char *page_url; 24 | char *vhost; 25 | double trans; 26 | double acodecs; 27 | double vcodecs; 28 | double object_encoding; 29 | }; 30 | 31 | struct rtmp_session_s { 32 | uint32_t sid; /*session id*/ 33 | 34 | /*handshake*/ 35 | rtmp_handshake_t *handshake; 36 | rtmp_session_connect_t *conn; 37 | 38 | /*chunk info*/ 39 | rtmp_chunk_stream_t **chunk_streams; 40 | uint32_t chunk_time; 41 | uint32_t max_streams; 42 | 43 | /*lives info*/ 44 | rtmp_live_link_t **lives; /*0 is reserved*/ 45 | uint32_t max_lives; 46 | 47 | /*chain in*/ 48 | uint32_t in_chunk_size; 49 | mem_buf_chain_t *in_chain; 50 | 51 | /*chain out*/ 52 | rtmp_message_t *out_message; /*out message*/ 53 | uint32_t out_front; /*queue front*/ 54 | uint32_t out_rear; /*queue rear*/ 55 | uint32_t out_queue; /*queue capacity*/ 56 | mem_buf_chain_t *out_chunk; /*current chunk in current chain*/ 57 | uint8_t *out_last; /*last out position*/ 58 | uint32_t out_chunk_size; 59 | 60 | /*connection info*/ 61 | rtmp_connection_t *c; 62 | mem_pool_t *pool; 63 | mem_pool_t *temp_pool; 64 | mem_pool_t *chunk_pool; 65 | rtmp_host_t *host_ctx; 66 | rtmp_app_t *app_ctx; 67 | uint32_t ping_timeout; 68 | uint32_t ping_sent : 1; 69 | uint32_t ack_window; 70 | uint32_t in_bytes; 71 | uint32_t in_last_ack; 72 | }; 73 | 74 | rtmp_session_t *rtmp_session_create(rtmp_connection_t *); 75 | int32_t rtmp_session_destroy(rtmp_session_t *); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /trunk/src/rtmp/rtmp_stream.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * CopyLeft (C) nie950@gmail.com 4 | */ 5 | 6 | 7 | #include "rtmp_config.h" 8 | #include "rtmp_core.h" 9 | 10 | int32_t rtmp_amf_cmd_createstream(rtmp_session_t *session, 11 | rtmp_chunk_header_t *hdr,amf_data_t *amf[],uint32_t num) 12 | { 13 | amf_data_t *amf_response[4]; 14 | mem_buf_t *buf; 15 | mem_buf_chain_t *chain; 16 | uint32_t lsid; 17 | rtmp_chunk_header_t h; 18 | 19 | h = *hdr; 20 | 21 | if (num != 3) { 22 | rtmp_log(RTMP_LOG_ERR,"[%d]amf number[%d] error!",session->sid,num); 23 | return RTMP_FAILED; 24 | } 25 | 26 | if (session->app_ctx == NULL) { 27 | rtmp_log(RTMP_LOG_WARNING,"[%d]connect failed!",session->sid); 28 | return RTMP_FAILED; 29 | } 30 | 31 | for (lsid = 1;lsid < session->max_lives;lsid++) { 32 | if (session->lives[lsid] == RTMP_NULL) { 33 | break; 34 | } 35 | } 36 | 37 | if (lsid == session->max_lives) { 38 | rtmp_log(RTMP_LOG_WARNING,"[%d]get empty stream id failed!", 39 | session->sid); 40 | return RTMP_FAILED; 41 | } 42 | 43 | session->lives[lsid] = RTMP_READY; 44 | 45 | amf_response[0] = amf_new_string("_result",0); 46 | amf_response[1] = amf[1]; 47 | amf_response[2] = amf_new_null(); 48 | amf_response[3] = amf_new_number(lsid); 49 | 50 | buf = rtmp_prepare_amf_buffer(session->temp_pool,amf_response,4); 51 | if (buf == NULL) { 52 | return RTMP_FAILED; 53 | } 54 | 55 | if (h.msgtid == RTMP_MSG_AMF3_CMD) { 56 | h.msgtid = RTMP_MSG_AMF_CMD; 57 | } 58 | 59 | chain = rtmp_copy_buf_to_chain(session,buf); 60 | 61 | if (chain == NULL) { 62 | rtmp_log(RTMP_LOG_WARNING,"[%d]prepare connect app message failed!", 63 | session->sid); 64 | return RTMP_FAILED; 65 | } 66 | 67 | h.msglen = buf->last - buf->buf; 68 | h.fmt = 0; 69 | 70 | if (rtmp_append_message_chain(session,chain,&h) == -1) { 71 | rtmp_log(RTMP_LOG_WARNING,"[%d]append connect app message failed!", 72 | session->sid); 73 | return RTMP_FAILED; 74 | } 75 | 76 | rtmp_chain_send(session->c->write); 77 | return RTMP_OK; 78 | } 79 | 80 | int32_t rtmp_amf_cmd_releasestream(rtmp_session_t *session, 81 | rtmp_chunk_header_t *chunk,amf_data_t *amf[],uint32_t num) 82 | { 83 | return RTMP_OK; 84 | } 85 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/applink.c: -------------------------------------------------------------------------------- 1 | #define APPLINK_STDIN 1 2 | #define APPLINK_STDOUT 2 3 | #define APPLINK_STDERR 3 4 | #define APPLINK_FPRINTF 4 5 | #define APPLINK_FGETS 5 6 | #define APPLINK_FREAD 6 7 | #define APPLINK_FWRITE 7 8 | #define APPLINK_FSETMOD 8 9 | #define APPLINK_FEOF 9 10 | #define APPLINK_FCLOSE 10 /* should not be used */ 11 | 12 | #define APPLINK_FOPEN 11 /* solely for completeness */ 13 | #define APPLINK_FSEEK 12 14 | #define APPLINK_FTELL 13 15 | #define APPLINK_FFLUSH 14 16 | #define APPLINK_FERROR 15 17 | #define APPLINK_CLEARERR 16 18 | #define APPLINK_FILENO 17 /* to be used with below */ 19 | 20 | #define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */ 21 | #define APPLINK_READ 19 22 | #define APPLINK_WRITE 20 23 | #define APPLINK_LSEEK 21 24 | #define APPLINK_CLOSE 22 25 | #define APPLINK_MAX 22 /* always same as last macro */ 26 | 27 | #ifndef APPMACROS_ONLY 28 | #include 29 | #include 30 | #include 31 | 32 | static void *app_stdin(void) { return stdin; } 33 | static void *app_stdout(void) { return stdout; } 34 | static void *app_stderr(void) { return stderr; } 35 | static int app_feof(FILE *fp) { return feof(fp); } 36 | static int app_ferror(FILE *fp) { return ferror(fp); } 37 | static void app_clearerr(FILE *fp) { clearerr(fp); } 38 | static int app_fileno(FILE *fp) { return _fileno(fp); } 39 | static int app_fsetmod(FILE *fp,char mod) 40 | { return _setmode (_fileno(fp),mod=='b'?_O_BINARY:_O_TEXT); } 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | __declspec(dllexport) 47 | void ** 48 | #if defined(__BORLANDC__) 49 | __stdcall /* __stdcall appears to be the only way to get the name 50 | * decoration right with Borland C. Otherwise it works 51 | * purely incidentally, as we pass no parameters. */ 52 | #else 53 | __cdecl 54 | #endif 55 | OPENSSL_Applink(void) 56 | { static int once=1; 57 | static void *OPENSSL_ApplinkTable[APPLINK_MAX+1]={(void *)APPLINK_MAX}; 58 | 59 | if (once) 60 | { OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; 61 | OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; 62 | OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; 63 | OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; 64 | OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; 65 | OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; 66 | OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; 67 | OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; 68 | OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; 69 | OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; 70 | 71 | OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen; 72 | OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek; 73 | OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell; 74 | OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush; 75 | OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror; 76 | OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr; 77 | OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno; 78 | 79 | OPENSSL_ApplinkTable[APPLINK_OPEN] = _open; 80 | OPENSSL_ApplinkTable[APPLINK_READ] = _read; 81 | OPENSSL_ApplinkTable[APPLINK_WRITE] = _write; 82 | OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek; 83 | OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close; 84 | 85 | once = 0; 86 | } 87 | 88 | return OPENSSL_ApplinkTable; 89 | } 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | #endif 95 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/cmac.h: -------------------------------------------------------------------------------- 1 | /* crypto/cmac/cmac.h */ 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 | * project. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * licensing@OpenSSL.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | */ 53 | 54 | 55 | #ifndef HEADER_CMAC_H 56 | #define HEADER_CMAC_H 57 | 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | #include 63 | 64 | /* Opaque */ 65 | typedef struct CMAC_CTX_st CMAC_CTX; 66 | 67 | CMAC_CTX *CMAC_CTX_new(void); 68 | void CMAC_CTX_cleanup(CMAC_CTX *ctx); 69 | void CMAC_CTX_free(CMAC_CTX *ctx); 70 | EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); 71 | int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); 72 | 73 | int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, 74 | const EVP_CIPHER *cipher, ENGINE *impl); 75 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); 76 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); 77 | int CMAC_resume(CMAC_CTX *ctx); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif 83 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/comp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef HEADER_COMP_H 3 | #define HEADER_COMP_H 4 | 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct comp_ctx_st COMP_CTX; 12 | 13 | typedef struct comp_method_st 14 | { 15 | int type; /* NID for compression library */ 16 | const char *name; /* A text string to identify the library */ 17 | int (*init)(COMP_CTX *ctx); 18 | void (*finish)(COMP_CTX *ctx); 19 | int (*compress)(COMP_CTX *ctx, 20 | unsigned char *out, unsigned int olen, 21 | unsigned char *in, unsigned int ilen); 22 | int (*expand)(COMP_CTX *ctx, 23 | unsigned char *out, unsigned int olen, 24 | unsigned char *in, unsigned int ilen); 25 | /* The following two do NOTHING, but are kept for backward compatibility */ 26 | long (*ctrl)(void); 27 | long (*callback_ctrl)(void); 28 | } COMP_METHOD; 29 | 30 | struct comp_ctx_st 31 | { 32 | COMP_METHOD *meth; 33 | unsigned long compress_in; 34 | unsigned long compress_out; 35 | unsigned long expand_in; 36 | unsigned long expand_out; 37 | 38 | CRYPTO_EX_DATA ex_data; 39 | }; 40 | 41 | 42 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); 43 | void COMP_CTX_free(COMP_CTX *ctx); 44 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 45 | unsigned char *in, int ilen); 46 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 47 | unsigned char *in, int ilen); 48 | COMP_METHOD *COMP_rle(void ); 49 | COMP_METHOD *COMP_zlib(void ); 50 | void COMP_zlib_cleanup(void); 51 | 52 | #ifdef HEADER_BIO_H 53 | #ifdef ZLIB 54 | BIO_METHOD *BIO_f_zlib(void); 55 | #endif 56 | #endif 57 | 58 | /* BEGIN ERROR CODES */ 59 | /* The following lines are auto generated by the script mkerr.pl. Any changes 60 | * made after this point may be overwritten when the script is next run. 61 | */ 62 | void ERR_load_COMP_strings(void); 63 | 64 | /* Error codes for the COMP functions. */ 65 | 66 | /* Function codes. */ 67 | #define COMP_F_BIO_ZLIB_FLUSH 99 68 | #define COMP_F_BIO_ZLIB_NEW 100 69 | #define COMP_F_BIO_ZLIB_READ 101 70 | #define COMP_F_BIO_ZLIB_WRITE 102 71 | 72 | /* Reason codes. */ 73 | #define COMP_R_ZLIB_DEFLATE_ERROR 99 74 | #define COMP_R_ZLIB_INFLATE_ERROR 100 75 | #define COMP_R_ZLIB_NOT_SUPPORTED 101 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | #endif 81 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/conf_api.h: -------------------------------------------------------------------------------- 1 | /* conf_api.h */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_CONF_API_H 60 | #define HEADER_CONF_API_H 61 | 62 | #include 63 | #include 64 | 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | /* Up until OpenSSL 0.9.5a, this was new_section */ 70 | CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); 71 | /* Up until OpenSSL 0.9.5a, this was get_section */ 72 | CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); 73 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ 74 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, 75 | const char *section); 76 | 77 | int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); 78 | char *_CONF_get_string(const CONF *conf, const char *section, 79 | const char *name); 80 | long _CONF_get_number(const CONF *conf, const char *section, const char *name); 81 | 82 | int _CONF_new_data(CONF *conf); 83 | void _CONF_free_data(CONF *conf); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/ebcdic.h: -------------------------------------------------------------------------------- 1 | /* crypto/ebcdic.h */ 2 | 3 | #ifndef HEADER_EBCDIC_H 4 | #define HEADER_EBCDIC_H 5 | 6 | #include 7 | 8 | /* Avoid name clashes with other applications */ 9 | #define os_toascii _openssl_os_toascii 10 | #define os_toebcdic _openssl_os_toebcdic 11 | #define ebcdic2ascii _openssl_ebcdic2ascii 12 | #define ascii2ebcdic _openssl_ascii2ebcdic 13 | 14 | extern const unsigned char os_toascii[256]; 15 | extern const unsigned char os_toebcdic[256]; 16 | void *ebcdic2ascii(void *dest, const void *srce, size_t count); 17 | void *ascii2ebcdic(void *dest, const void *srce, size_t count); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/mdc2.h: -------------------------------------------------------------------------------- 1 | /* crypto/mdc2/mdc2.h */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_MDC2_H 60 | #define HEADER_MDC2_H 61 | 62 | #include 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | #ifdef OPENSSL_NO_MDC2 69 | #error MDC2 is disabled. 70 | #endif 71 | 72 | #define MDC2_BLOCK 8 73 | #define MDC2_DIGEST_LENGTH 16 74 | 75 | typedef struct mdc2_ctx_st 76 | { 77 | unsigned int num; 78 | unsigned char data[MDC2_BLOCK]; 79 | DES_cblock h,hh; 80 | int pad_type; /* either 1 or 2, default 1 */ 81 | } MDC2_CTX; 82 | 83 | 84 | #ifdef OPENSSL_FIPS 85 | int private_MDC2_Init(MDC2_CTX *c); 86 | #endif 87 | int MDC2_Init(MDC2_CTX *c); 88 | int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); 89 | int MDC2_Final(unsigned char *md, MDC2_CTX *c); 90 | unsigned char *MDC2(const unsigned char *d, size_t n, 91 | unsigned char *md); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/opensslv.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OPENSSLV_H 2 | #define HEADER_OPENSSLV_H 3 | 4 | /* Numeric release version identifier: 5 | * MNNFFPPS: major minor fix patch status 6 | * The status nibble has one of the values 0 for development, 1 to e for betas 7 | * 1 to 14, and f for release. The patch level is exactly that. 8 | * For example: 9 | * 0.9.3-dev 0x00903000 10 | * 0.9.3-beta1 0x00903001 11 | * 0.9.3-beta2-dev 0x00903002 12 | * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) 13 | * 0.9.3 0x0090300f 14 | * 0.9.3a 0x0090301f 15 | * 0.9.4 0x0090400f 16 | * 1.2.3z 0x102031af 17 | * 18 | * For continuity reasons (because 0.9.5 is already out, and is coded 19 | * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level 20 | * part is slightly different, by setting the highest bit. This means 21 | * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start 22 | * with 0x0090600S... 23 | * 24 | * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) 25 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 26 | * major minor fix final patch/beta) 27 | */ 28 | #define OPENSSL_VERSION_NUMBER 0x1000103fL 29 | #ifdef OPENSSL_FIPS 30 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1c-fips 10 May 2012" 31 | #else 32 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1c 10 May 2012" 33 | #endif 34 | #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 35 | 36 | 37 | /* The macros below are to be used for shared library (.so, .dll, ...) 38 | * versioning. That kind of versioning works a bit differently between 39 | * operating systems. The most usual scheme is to set a major and a minor 40 | * number, and have the runtime loader check that the major number is equal 41 | * to what it was at application link time, while the minor number has to 42 | * be greater or equal to what it was at application link time. With this 43 | * scheme, the version number is usually part of the file name, like this: 44 | * 45 | * libcrypto.so.0.9 46 | * 47 | * Some unixen also make a softlink with the major verson number only: 48 | * 49 | * libcrypto.so.0 50 | * 51 | * On Tru64 and IRIX 6.x it works a little bit differently. There, the 52 | * shared library version is stored in the file, and is actually a series 53 | * of versions, separated by colons. The rightmost version present in the 54 | * library when linking an application is stored in the application to be 55 | * matched at run time. When the application is run, a check is done to 56 | * see if the library version stored in the application matches any of the 57 | * versions in the version string of the library itself. 58 | * This version string can be constructed in any way, depending on what 59 | * kind of matching is desired. However, to implement the same scheme as 60 | * the one used in the other unixen, all compatible versions, from lowest 61 | * to highest, should be part of the string. Consecutive builds would 62 | * give the following versions strings: 63 | * 64 | * 3.0 65 | * 3.0:3.1 66 | * 3.0:3.1:3.2 67 | * 4.0 68 | * 4.0:4.1 69 | * 70 | * Notice how version 4 is completely incompatible with version, and 71 | * therefore give the breach you can see. 72 | * 73 | * There may be other schemes as well that I haven't yet discovered. 74 | * 75 | * So, here's the way it works here: first of all, the library version 76 | * number doesn't need at all to match the overall OpenSSL version. 77 | * However, it's nice and more understandable if it actually does. 78 | * The current library version is stored in the macro SHLIB_VERSION_NUMBER, 79 | * which is just a piece of text in the format "M.m.e" (Major, minor, edit). 80 | * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, 81 | * we need to keep a history of version numbers, which is done in the 82 | * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and 83 | * should only keep the versions that are binary compatible with the current. 84 | */ 85 | #define SHLIB_VERSION_HISTORY "" 86 | #define SHLIB_VERSION_NUMBER "1.0.0" 87 | 88 | 89 | #endif /* HEADER_OPENSSLV_H */ 90 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/pem2.h: -------------------------------------------------------------------------------- 1 | /* ==================================================================== 2 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. All advertising materials mentioning features or use of this 17 | * software must display the following acknowledgment: 18 | * "This product includes software developed by the OpenSSL Project 19 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 20 | * 21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 22 | * endorse or promote products derived from this software without 23 | * prior written permission. For written permission, please contact 24 | * licensing@OpenSSL.org. 25 | * 26 | * 5. Products derived from this software may not be called "OpenSSL" 27 | * nor may "OpenSSL" appear in their names without prior written 28 | * permission of the OpenSSL Project. 29 | * 30 | * 6. Redistributions of any form whatsoever must retain the following 31 | * acknowledgment: 32 | * "This product includes software developed by the OpenSSL Project 33 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 34 | * 35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 46 | * OF THE POSSIBILITY OF SUCH DAMAGE. 47 | * ==================================================================== 48 | * 49 | * This product includes cryptographic software written by Eric Young 50 | * (eay@cryptsoft.com). This product includes software written by Tim 51 | * Hudson (tjh@cryptsoft.com). 52 | * 53 | */ 54 | 55 | /* 56 | * This header only exists to break a circular dependency between pem and err 57 | * Ben 30 Jan 1999. 58 | */ 59 | 60 | #ifdef __cplusplus 61 | extern "C" { 62 | #endif 63 | 64 | #ifndef HEADER_PEM_H 65 | void ERR_load_PEM_strings(void); 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/pqueue.h: -------------------------------------------------------------------------------- 1 | /* crypto/pqueue/pqueue.h */ 2 | /* 3 | * DTLS implementation written by Nagendra Modadugu 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 5 | */ 6 | /* ==================================================================== 7 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in 18 | * the documentation and/or other materials provided with the 19 | * distribution. 20 | * 21 | * 3. All advertising materials mentioning features or use of this 22 | * software must display the following acknowledgment: 23 | * "This product includes software developed by the OpenSSL Project 24 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 25 | * 26 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27 | * endorse or promote products derived from this software without 28 | * prior written permission. For written permission, please contact 29 | * openssl-core@OpenSSL.org. 30 | * 31 | * 5. Products derived from this software may not be called "OpenSSL" 32 | * nor may "OpenSSL" appear in their names without prior written 33 | * permission of the OpenSSL Project. 34 | * 35 | * 6. Redistributions of any form whatsoever must retain the following 36 | * acknowledgment: 37 | * "This product includes software developed by the OpenSSL Project 38 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51 | * OF THE POSSIBILITY OF SUCH DAMAGE. 52 | * ==================================================================== 53 | * 54 | * This product includes cryptographic software written by Eric Young 55 | * (eay@cryptsoft.com). This product includes software written by Tim 56 | * Hudson (tjh@cryptsoft.com). 57 | * 58 | */ 59 | 60 | #ifndef HEADER_PQUEUE_H 61 | #define HEADER_PQUEUE_H 62 | 63 | #include 64 | #include 65 | #include 66 | 67 | typedef struct _pqueue *pqueue; 68 | 69 | typedef struct _pitem 70 | { 71 | unsigned char priority[8]; /* 64-bit value in big-endian encoding */ 72 | void *data; 73 | struct _pitem *next; 74 | } pitem; 75 | 76 | typedef struct _pitem *piterator; 77 | 78 | pitem *pitem_new(unsigned char *prio64be, void *data); 79 | void pitem_free(pitem *item); 80 | 81 | pqueue pqueue_new(void); 82 | void pqueue_free(pqueue pq); 83 | 84 | pitem *pqueue_insert(pqueue pq, pitem *item); 85 | pitem *pqueue_peek(pqueue pq); 86 | pitem *pqueue_pop(pqueue pq); 87 | pitem *pqueue_find(pqueue pq, unsigned char *prio64be); 88 | pitem *pqueue_iterator(pqueue pq); 89 | pitem *pqueue_next(piterator *iter); 90 | 91 | void pqueue_print(pqueue pq); 92 | int pqueue_size(pqueue pq); 93 | 94 | #endif /* ! HEADER_PQUEUE_H */ 95 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/rc4.h: -------------------------------------------------------------------------------- 1 | /* crypto/rc4/rc4.h */ 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_RC4_H 60 | #define HEADER_RC4_H 61 | 62 | #include /* OPENSSL_NO_RC4, RC4_INT */ 63 | #ifdef OPENSSL_NO_RC4 64 | #error RC4 is disabled. 65 | #endif 66 | 67 | #include 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | typedef struct rc4_key_st 74 | { 75 | RC4_INT x,y; 76 | RC4_INT data[256]; 77 | } RC4_KEY; 78 | 79 | 80 | const char *RC4_options(void); 81 | void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 82 | void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 83 | void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, 84 | unsigned char *outdata); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/ssl23.h: -------------------------------------------------------------------------------- 1 | /* ssl/ssl23.h */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_SSL23_H 60 | #define HEADER_SSL23_H 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /*client */ 67 | /* write to server */ 68 | #define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT) 69 | #define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT) 70 | /* read from server */ 71 | #define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT) 72 | #define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT) 73 | 74 | /* server */ 75 | /* read from client */ 76 | #define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT) 77 | #define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT) 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif 83 | 84 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/ui_compat.h: -------------------------------------------------------------------------------- 1 | /* crypto/ui/ui.h -*- mode:C; c-file-style: "eay" -*- */ 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL 3 | * project 2001. 4 | */ 5 | /* ==================================================================== 6 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * 3. All advertising materials mentioning features or use of this 21 | * software must display the following acknowledgment: 22 | * "This product includes software developed by the OpenSSL Project 23 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 24 | * 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 | * endorse or promote products derived from this software without 27 | * prior written permission. For written permission, please contact 28 | * openssl-core@openssl.org. 29 | * 30 | * 5. Products derived from this software may not be called "OpenSSL" 31 | * nor may "OpenSSL" appear in their names without prior written 32 | * permission of the OpenSSL Project. 33 | * 34 | * 6. Redistributions of any form whatsoever must retain the following 35 | * acknowledgment: 36 | * "This product includes software developed by the OpenSSL Project 37 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 38 | * 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. 51 | * ==================================================================== 52 | * 53 | * This product includes cryptographic software written by Eric Young 54 | * (eay@cryptsoft.com). This product includes software written by Tim 55 | * Hudson (tjh@cryptsoft.com). 56 | * 57 | */ 58 | 59 | #ifndef HEADER_UI_COMPAT_H 60 | #define HEADER_UI_COMPAT_H 61 | 62 | #include 63 | #include 64 | 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | /* The following functions were previously part of the DES section, 70 | and are provided here for backward compatibility reasons. */ 71 | 72 | #define des_read_pw_string(b,l,p,v) \ 73 | _ossl_old_des_read_pw_string((b),(l),(p),(v)) 74 | #define des_read_pw(b,bf,s,p,v) \ 75 | _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) 76 | 77 | int _ossl_old_des_read_pw_string(char *buf,int length,const char *prompt,int verify); 78 | int _ossl_old_des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #endif 84 | -------------------------------------------------------------------------------- /trunk/vs2010/include/openssl/whrlpool.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_WHRLPOOL_H 2 | #define HEADER_WHRLPOOL_H 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define WHIRLPOOL_DIGEST_LENGTH (512/8) 12 | #define WHIRLPOOL_BBLOCK 512 13 | #define WHIRLPOOL_COUNTER (256/8) 14 | 15 | typedef struct { 16 | union { 17 | unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; 18 | /* double q is here to ensure 64-bit alignment */ 19 | double q[WHIRLPOOL_DIGEST_LENGTH/sizeof(double)]; 20 | } H; 21 | unsigned char data[WHIRLPOOL_BBLOCK/8]; 22 | unsigned int bitoff; 23 | size_t bitlen[WHIRLPOOL_COUNTER/sizeof(size_t)]; 24 | } WHIRLPOOL_CTX; 25 | 26 | #ifndef OPENSSL_NO_WHIRLPOOL 27 | #ifdef OPENSSL_FIPS 28 | int private_WHIRLPOOL_Init(WHIRLPOOL_CTX *c); 29 | #endif 30 | int WHIRLPOOL_Init (WHIRLPOOL_CTX *c); 31 | int WHIRLPOOL_Update (WHIRLPOOL_CTX *c,const void *inp,size_t bytes); 32 | void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *inp,size_t bits); 33 | int WHIRLPOOL_Final (unsigned char *md,WHIRLPOOL_CTX *c); 34 | unsigned char *WHIRLPOOL(const void *inp,size_t bytes,unsigned char *md); 35 | #endif 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /trunk/vs2010/lib/libeay32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/vs2010/lib/libeay32.dll -------------------------------------------------------------------------------- /trunk/vs2010/lib/libeay32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/vs2010/lib/libeay32.lib -------------------------------------------------------------------------------- /trunk/vs2010/lib/ssleay32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/vs2010/lib/ssleay32.dll -------------------------------------------------------------------------------- /trunk/vs2010/lib/ssleay32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niesongsong/tiny-rtmp-server/2595e2be799c2b471e61f60bc1621ed448bf45e3/trunk/vs2010/lib/ssleay32.lib -------------------------------------------------------------------------------- /trunk/vs2010/librtmp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "librtmp", "librtmp\librtmp.vcxproj", "{7E4F968C-1058-4D99-9E35-8B899715052C}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {7E4F968C-1058-4D99-9E35-8B899715052C}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {7E4F968C-1058-4D99-9E35-8B899715052C}.Debug|Win32.Build.0 = Debug|Win32 14 | {7E4F968C-1058-4D99-9E35-8B899715052C}.Release|Win32.ActiveCfg = Release|Win32 15 | {7E4F968C-1058-4D99-9E35-8B899715052C}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /trunk/vs2010/librtmp/librtmp.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 41 | 42 | 源文件 43 | 44 | 45 | 源文件 46 | 47 | 48 | 源文件 49 | 50 | 51 | 源文件 52 | 53 | 54 | 源文件 55 | 56 | 57 | 源文件 58 | 59 | 60 | 源文件 61 | 62 | 63 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rtmpd", "rtmpd\rtmpd.vcxproj", "{514969DE-2DE6-412C-83CC-58A1F340D837}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {514969DE-2DE6-412C-83CC-58A1F340D837}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {514969DE-2DE6-412C-83CC-58A1F340D837}.Debug|Win32.Build.0 = Debug|Win32 14 | {514969DE-2DE6-412C-83CC-58A1F340D837}.Release|Win32.ActiveCfg = Release|Win32 15 | {514969DE-2DE6-412C-83CC-58A1F340D837}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/fastcgi.conf: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param HTTPS $https if_not_empty; 14 | 15 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 16 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 17 | 18 | fastcgi_param REMOTE_ADDR $remote_addr; 19 | fastcgi_param REMOTE_PORT $remote_port; 20 | fastcgi_param SERVER_ADDR $server_addr; 21 | fastcgi_param SERVER_PORT $server_port; 22 | fastcgi_param SERVER_NAME $server_name; 23 | 24 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 25 | fastcgi_param REDIRECT_STATUS 200; 26 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/fastcgi.conf.default: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param HTTPS $https if_not_empty; 14 | 15 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 16 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 17 | 18 | fastcgi_param REMOTE_ADDR $remote_addr; 19 | fastcgi_param REMOTE_PORT $remote_port; 20 | fastcgi_param SERVER_ADDR $server_addr; 21 | fastcgi_param SERVER_PORT $server_port; 22 | fastcgi_param SERVER_NAME $server_name; 23 | 24 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 25 | fastcgi_param REDIRECT_STATUS 200; 26 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/fastcgi_params: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | fastcgi_param HTTPS $https if_not_empty; 13 | 14 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 15 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 16 | 17 | fastcgi_param REMOTE_ADDR $remote_addr; 18 | fastcgi_param REMOTE_PORT $remote_port; 19 | fastcgi_param SERVER_ADDR $server_addr; 20 | fastcgi_param SERVER_PORT $server_port; 21 | fastcgi_param SERVER_NAME $server_name; 22 | 23 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 24 | fastcgi_param REDIRECT_STATUS 200; 25 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/fastcgi_params.default: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | fastcgi_param HTTPS $https if_not_empty; 13 | 14 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 15 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 16 | 17 | fastcgi_param REMOTE_ADDR $remote_addr; 18 | fastcgi_param REMOTE_PORT $remote_port; 19 | fastcgi_param SERVER_ADDR $server_addr; 20 | fastcgi_param SERVER_PORT $server_port; 21 | fastcgi_param SERVER_NAME $server_name; 22 | 23 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 24 | fastcgi_param REDIRECT_STATUS 200; 25 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/koi-utf: -------------------------------------------------------------------------------- 1 | 2 | # This map is not a full koi8-r <> utf8 map: it does not contain 3 | # box-drawing and some other characters. Besides this map contains 4 | # several koi8-u and Byelorussian letters which are not in koi8-r. 5 | # If you need a full and standard map, use contrib/unicode2nginx/koi-utf 6 | # map instead. 7 | 8 | charset_map koi8-r utf-8 { 9 | 10 | 80 E282AC ; # euro 11 | 12 | 95 E280A2 ; # bullet 13 | 14 | 9A C2A0 ; #   15 | 16 | 9E C2B7 ; # · 17 | 18 | A3 D191 ; # small yo 19 | A4 D194 ; # small Ukrainian ye 20 | 21 | A6 D196 ; # small Ukrainian i 22 | A7 D197 ; # small Ukrainian yi 23 | 24 | AD D291 ; # small Ukrainian soft g 25 | AE D19E ; # small Byelorussian short u 26 | 27 | B0 C2B0 ; # ° 28 | 29 | B3 D081 ; # capital YO 30 | B4 D084 ; # capital Ukrainian YE 31 | 32 | B6 D086 ; # capital Ukrainian I 33 | B7 D087 ; # capital Ukrainian YI 34 | 35 | B9 E28496 ; # numero sign 36 | 37 | BD D290 ; # capital Ukrainian soft G 38 | BE D18E ; # capital Byelorussian short U 39 | 40 | BF C2A9 ; # (C) 41 | 42 | C0 D18E ; # small yu 43 | C1 D0B0 ; # small a 44 | C2 D0B1 ; # small b 45 | C3 D186 ; # small ts 46 | C4 D0B4 ; # small d 47 | C5 D0B5 ; # small ye 48 | C6 D184 ; # small f 49 | C7 D0B3 ; # small g 50 | C8 D185 ; # small kh 51 | C9 D0B8 ; # small i 52 | CA D0B9 ; # small j 53 | CB D0BA ; # small k 54 | CC D0BB ; # small l 55 | CD D0BC ; # small m 56 | CE D0BD ; # small n 57 | CF D0BE ; # small o 58 | 59 | D0 D0BF ; # small p 60 | D1 D18F ; # small ya 61 | D2 D180 ; # small r 62 | D3 D181 ; # small s 63 | D4 D182 ; # small t 64 | D5 D183 ; # small u 65 | D6 D0B6 ; # small zh 66 | D7 D0B2 ; # small v 67 | D8 D18C ; # small soft sign 68 | D9 D18B ; # small y 69 | DA D0B7 ; # small z 70 | DB D188 ; # small sh 71 | DC D18D ; # small e 72 | DD D189 ; # small shch 73 | DE D187 ; # small ch 74 | DF D18A ; # small hard sign 75 | 76 | E0 D0AE ; # capital YU 77 | E1 D090 ; # capital A 78 | E2 D091 ; # capital B 79 | E3 D0A6 ; # capital TS 80 | E4 D094 ; # capital D 81 | E5 D095 ; # capital YE 82 | E6 D0A4 ; # capital F 83 | E7 D093 ; # capital G 84 | E8 D0A5 ; # capital KH 85 | E9 D098 ; # capital I 86 | EA D099 ; # capital J 87 | EB D09A ; # capital K 88 | EC D09B ; # capital L 89 | ED D09C ; # capital M 90 | EE D09D ; # capital N 91 | EF D09E ; # capital O 92 | 93 | F0 D09F ; # capital P 94 | F1 D0AF ; # capital YA 95 | F2 D0A0 ; # capital R 96 | F3 D0A1 ; # capital S 97 | F4 D0A2 ; # capital T 98 | F5 D0A3 ; # capital U 99 | F6 D096 ; # capital ZH 100 | F7 D092 ; # capital V 101 | F8 D0AC ; # capital soft sign 102 | F9 D0AB ; # capital Y 103 | FA D097 ; # capital Z 104 | FB D0A8 ; # capital SH 105 | FC D0AD ; # capital E 106 | FD D0A9 ; # capital SHCH 107 | FE D0A7 ; # capital CH 108 | FF D0AA ; # capital hard sign 109 | } 110 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/koi-win: -------------------------------------------------------------------------------- 1 | 2 | charset_map koi8-r windows-1251 { 3 | 4 | 80 88 ; # euro 5 | 6 | 95 95 ; # bullet 7 | 8 | 9A A0 ; #   9 | 10 | 9E B7 ; # · 11 | 12 | A3 B8 ; # small yo 13 | A4 BA ; # small Ukrainian ye 14 | 15 | A6 B3 ; # small Ukrainian i 16 | A7 BF ; # small Ukrainian yi 17 | 18 | AD B4 ; # small Ukrainian soft g 19 | AE A2 ; # small Byelorussian short u 20 | 21 | B0 B0 ; # ° 22 | 23 | B3 A8 ; # capital YO 24 | B4 AA ; # capital Ukrainian YE 25 | 26 | B6 B2 ; # capital Ukrainian I 27 | B7 AF ; # capital Ukrainian YI 28 | 29 | B9 B9 ; # numero sign 30 | 31 | BD A5 ; # capital Ukrainian soft G 32 | BE A1 ; # capital Byelorussian short U 33 | 34 | BF A9 ; # (C) 35 | 36 | C0 FE ; # small yu 37 | C1 E0 ; # small a 38 | C2 E1 ; # small b 39 | C3 F6 ; # small ts 40 | C4 E4 ; # small d 41 | C5 E5 ; # small ye 42 | C6 F4 ; # small f 43 | C7 E3 ; # small g 44 | C8 F5 ; # small kh 45 | C9 E8 ; # small i 46 | CA E9 ; # small j 47 | CB EA ; # small k 48 | CC EB ; # small l 49 | CD EC ; # small m 50 | CE ED ; # small n 51 | CF EE ; # small o 52 | 53 | D0 EF ; # small p 54 | D1 FF ; # small ya 55 | D2 F0 ; # small r 56 | D3 F1 ; # small s 57 | D4 F2 ; # small t 58 | D5 F3 ; # small u 59 | D6 E6 ; # small zh 60 | D7 E2 ; # small v 61 | D8 FC ; # small soft sign 62 | D9 FB ; # small y 63 | DA E7 ; # small z 64 | DB F8 ; # small sh 65 | DC FD ; # small e 66 | DD F9 ; # small shch 67 | DE F7 ; # small ch 68 | DF FA ; # small hard sign 69 | 70 | E0 DE ; # capital YU 71 | E1 C0 ; # capital A 72 | E2 C1 ; # capital B 73 | E3 D6 ; # capital TS 74 | E4 C4 ; # capital D 75 | E5 C5 ; # capital YE 76 | E6 D4 ; # capital F 77 | E7 C3 ; # capital G 78 | E8 D5 ; # capital KH 79 | E9 C8 ; # capital I 80 | EA C9 ; # capital J 81 | EB CA ; # capital K 82 | EC CB ; # capital L 83 | ED CC ; # capital M 84 | EE CD ; # capital N 85 | EF CE ; # capital O 86 | 87 | F0 CF ; # capital P 88 | F1 DF ; # capital YA 89 | F2 D0 ; # capital R 90 | F3 D1 ; # capital S 91 | F4 D2 ; # capital T 92 | F5 D3 ; # capital U 93 | F6 C6 ; # capital ZH 94 | F7 C2 ; # capital V 95 | F8 DC ; # capital soft sign 96 | F9 DB ; # capital Y 97 | FA C7 ; # capital Z 98 | FB D8 ; # capital SH 99 | FC DD ; # capital E 100 | FD D9 ; # capital SHCH 101 | FE D7 ; # capital CH 102 | FF DA ; # capital hard sign 103 | } 104 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/mime.types: -------------------------------------------------------------------------------- 1 | 2 | types { 3 | text/html html htm shtml; 4 | text/css css; 5 | text/xml xml; 6 | image/gif gif; 7 | image/jpeg jpeg jpg; 8 | application/javascript js; 9 | application/atom+xml atom; 10 | application/rss+xml rss; 11 | 12 | text/mathml mml; 13 | text/plain txt; 14 | text/vnd.sun.j2me.app-descriptor jad; 15 | text/vnd.wap.wml wml; 16 | text/x-component htc; 17 | 18 | image/png png; 19 | image/tiff tif tiff; 20 | image/vnd.wap.wbmp wbmp; 21 | image/x-icon ico; 22 | image/x-jng jng; 23 | image/x-ms-bmp bmp; 24 | image/svg+xml svg svgz; 25 | image/webp webp; 26 | 27 | application/font-woff woff; 28 | application/java-archive jar war ear; 29 | application/mac-binhex40 hqx; 30 | application/msword doc; 31 | application/pdf pdf; 32 | application/postscript ps eps ai; 33 | application/rtf rtf; 34 | application/vnd.ms-excel xls; 35 | application/vnd.ms-fontobject eot; 36 | application/vnd.ms-powerpoint ppt; 37 | application/vnd.wap.wmlc wmlc; 38 | application/vnd.google-earth.kml+xml kml; 39 | application/vnd.google-earth.kmz kmz; 40 | application/x-7z-compressed 7z; 41 | application/x-cocoa cco; 42 | application/x-java-archive-diff jardiff; 43 | application/x-java-jnlp-file jnlp; 44 | application/x-makeself run; 45 | application/x-perl pl pm; 46 | application/x-pilot prc pdb; 47 | application/x-rar-compressed rar; 48 | application/x-redhat-package-manager rpm; 49 | application/x-sea sea; 50 | application/x-shockwave-flash swf; 51 | application/x-stuffit sit; 52 | application/x-tcl tcl tk; 53 | application/x-x509-ca-cert der pem crt; 54 | application/x-xpinstall xpi; 55 | application/xhtml+xml xhtml; 56 | application/zip zip; 57 | 58 | application/octet-stream bin exe dll; 59 | application/octet-stream deb; 60 | application/octet-stream dmg; 61 | application/octet-stream iso img; 62 | application/octet-stream msi msp msm; 63 | 64 | application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; 65 | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; 66 | application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; 67 | 68 | audio/midi mid midi kar; 69 | audio/mpeg mp3; 70 | audio/ogg ogg; 71 | audio/x-m4a m4a; 72 | audio/x-realaudio ra; 73 | 74 | video/3gpp 3gpp 3gp; 75 | video/mp4 mp4; 76 | video/mpeg mpeg mpg; 77 | video/quicktime mov; 78 | video/webm webm; 79 | video/x-flv flv; 80 | video/x-m4v m4v; 81 | video/x-mng mng; 82 | video/x-ms-asf asx asf; 83 | video/x-ms-wmv wmv; 84 | video/x-msvideo avi; 85 | } 86 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/mime.types.default: -------------------------------------------------------------------------------- 1 | 2 | types { 3 | text/html html htm shtml; 4 | text/css css; 5 | text/xml xml; 6 | image/gif gif; 7 | image/jpeg jpeg jpg; 8 | application/javascript js; 9 | application/atom+xml atom; 10 | application/rss+xml rss; 11 | 12 | text/mathml mml; 13 | text/plain txt; 14 | text/vnd.sun.j2me.app-descriptor jad; 15 | text/vnd.wap.wml wml; 16 | text/x-component htc; 17 | 18 | image/png png; 19 | image/tiff tif tiff; 20 | image/vnd.wap.wbmp wbmp; 21 | image/x-icon ico; 22 | image/x-jng jng; 23 | image/x-ms-bmp bmp; 24 | image/svg+xml svg svgz; 25 | image/webp webp; 26 | 27 | application/font-woff woff; 28 | application/java-archive jar war ear; 29 | application/mac-binhex40 hqx; 30 | application/msword doc; 31 | application/pdf pdf; 32 | application/postscript ps eps ai; 33 | application/rtf rtf; 34 | application/vnd.ms-excel xls; 35 | application/vnd.ms-fontobject eot; 36 | application/vnd.ms-powerpoint ppt; 37 | application/vnd.wap.wmlc wmlc; 38 | application/vnd.google-earth.kml+xml kml; 39 | application/vnd.google-earth.kmz kmz; 40 | application/x-7z-compressed 7z; 41 | application/x-cocoa cco; 42 | application/x-java-archive-diff jardiff; 43 | application/x-java-jnlp-file jnlp; 44 | application/x-makeself run; 45 | application/x-perl pl pm; 46 | application/x-pilot prc pdb; 47 | application/x-rar-compressed rar; 48 | application/x-redhat-package-manager rpm; 49 | application/x-sea sea; 50 | application/x-shockwave-flash swf; 51 | application/x-stuffit sit; 52 | application/x-tcl tcl tk; 53 | application/x-x509-ca-cert der pem crt; 54 | application/x-xpinstall xpi; 55 | application/xhtml+xml xhtml; 56 | application/zip zip; 57 | 58 | application/octet-stream bin exe dll; 59 | application/octet-stream deb; 60 | application/octet-stream dmg; 61 | application/octet-stream iso img; 62 | application/octet-stream msi msp msm; 63 | 64 | application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; 65 | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; 66 | application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; 67 | 68 | audio/midi mid midi kar; 69 | audio/mpeg mp3; 70 | audio/ogg ogg; 71 | audio/x-m4a m4a; 72 | audio/x-realaudio ra; 73 | 74 | video/3gpp 3gpp 3gp; 75 | video/mp4 mp4; 76 | video/mpeg mpeg mpg; 77 | video/quicktime mov; 78 | video/webm webm; 79 | video/x-flv flv; 80 | video/x-m4v m4v; 81 | video/x-mng mng; 82 | video/x-ms-asf asx asf; 83 | video/x-ms-wmv wmv; 84 | video/x-msvideo avi; 85 | } 86 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | daemon on; 2 | workers 12; 3 | 4 | event { 5 | use select; 6 | work_connections 2048; 7 | } 8 | 9 | rtmp { 10 | server { 11 | 12 | listen 1935 default; 13 | 14 | server_name www.test.com; 15 | 16 | ping 5000; 17 | acknowledgement 2500000; 18 | chunk_size 1024; 19 | 20 | app myapp { 21 | 22 | push rtmp://192.168.9.253:1936/$app/$stream; 23 | 24 | allow publish 192.168.9.25/24; 25 | deny play 192.168.9.24/32; 26 | 27 | } 28 | } 29 | 30 | server { 31 | 32 | listen 127.0.0.1:1935; 33 | listen 0.0.0.0:1935 default; 34 | 35 | server_name www.example.com; 36 | ping 5000; 37 | acknowledgement 2500000; 38 | chunk_size 1024; 39 | 40 | app myapp { 41 | 42 | push rtmp://192.168.9.254:1936/$app/$stream; 43 | 44 | allow publish 192.168.9.25/24; 45 | deny play 192.168.9.24/32; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/nginx.conf.default: -------------------------------------------------------------------------------- 1 | 2 | #user nobody; 3 | worker_processes 1; 4 | 5 | #error_log logs/error.log; 6 | #error_log logs/error.log notice; 7 | #error_log logs/error.log info; 8 | 9 | #pid logs/nginx.pid; 10 | 11 | 12 | events { 13 | worker_connections 1024; 14 | } 15 | 16 | 17 | http { 18 | include mime.types; 19 | default_type application/octet-stream; 20 | 21 | #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 22 | # '$status $body_bytes_sent "$http_referer" ' 23 | # '"$http_user_agent" "$http_x_forwarded_for"'; 24 | 25 | #access_log logs/access.log main; 26 | 27 | sendfile on; 28 | #tcp_nopush on; 29 | 30 | #keepalive_timeout 0; 31 | keepalive_timeout 65; 32 | 33 | #gzip on; 34 | 35 | server { 36 | listen 80; 37 | server_name localhost; 38 | 39 | #charset koi8-r; 40 | 41 | #access_log logs/host.access.log main; 42 | 43 | location / { 44 | root html; 45 | index index.html index.htm; 46 | } 47 | 48 | #error_page 404 /404.html; 49 | 50 | # redirect server error pages to the static page /50x.html 51 | # 52 | error_page 500 502 503 504 /50x.html; 53 | location = /50x.html { 54 | root html; 55 | } 56 | 57 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80 58 | # 59 | #location ~ \.php$ { 60 | # proxy_pass http://127.0.0.1; 61 | #} 62 | 63 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 64 | # 65 | #location ~ \.php$ { 66 | # root html; 67 | # fastcgi_pass 127.0.0.1:9000; 68 | # fastcgi_index index.php; 69 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 70 | # include fastcgi_params; 71 | #} 72 | 73 | # deny access to .htaccess files, if Apache's document root 74 | # concurs with nginx's one 75 | # 76 | #location ~ /\.ht { 77 | # deny all; 78 | #} 79 | } 80 | 81 | 82 | # another virtual host using mix of IP-, name-, and port-based configuration 83 | # 84 | #server { 85 | # listen 8000; 86 | # listen somename:8080; 87 | # server_name somename alias another.alias; 88 | 89 | # location / { 90 | # root html; 91 | # index index.html index.htm; 92 | # } 93 | #} 94 | 95 | 96 | # HTTPS server 97 | # 98 | #server { 99 | # listen 443 ssl; 100 | # server_name localhost; 101 | 102 | # ssl_certificate cert.pem; 103 | # ssl_certificate_key cert.key; 104 | 105 | # ssl_session_cache shared:SSL:1m; 106 | # ssl_session_timeout 5m; 107 | 108 | # ssl_ciphers HIGH:!aNULL:!MD5; 109 | # ssl_prefer_server_ciphers on; 110 | 111 | # location / { 112 | # root html; 113 | # index index.html index.htm; 114 | # } 115 | #} 116 | 117 | } 118 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/scgi_params: -------------------------------------------------------------------------------- 1 | 2 | scgi_param REQUEST_METHOD $request_method; 3 | scgi_param REQUEST_URI $request_uri; 4 | scgi_param QUERY_STRING $query_string; 5 | scgi_param CONTENT_TYPE $content_type; 6 | 7 | scgi_param DOCUMENT_URI $document_uri; 8 | scgi_param DOCUMENT_ROOT $document_root; 9 | scgi_param SCGI 1; 10 | scgi_param SERVER_PROTOCOL $server_protocol; 11 | scgi_param HTTPS $https if_not_empty; 12 | 13 | scgi_param REMOTE_ADDR $remote_addr; 14 | scgi_param REMOTE_PORT $remote_port; 15 | scgi_param SERVER_PORT $server_port; 16 | scgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/scgi_params.default: -------------------------------------------------------------------------------- 1 | 2 | scgi_param REQUEST_METHOD $request_method; 3 | scgi_param REQUEST_URI $request_uri; 4 | scgi_param QUERY_STRING $query_string; 5 | scgi_param CONTENT_TYPE $content_type; 6 | 7 | scgi_param DOCUMENT_URI $document_uri; 8 | scgi_param DOCUMENT_ROOT $document_root; 9 | scgi_param SCGI 1; 10 | scgi_param SERVER_PROTOCOL $server_protocol; 11 | scgi_param HTTPS $https if_not_empty; 12 | 13 | scgi_param REMOTE_ADDR $remote_addr; 14 | scgi_param REMOTE_PORT $remote_port; 15 | scgi_param SERVER_PORT $server_port; 16 | scgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/uwsgi_params: -------------------------------------------------------------------------------- 1 | 2 | uwsgi_param QUERY_STRING $query_string; 3 | uwsgi_param REQUEST_METHOD $request_method; 4 | uwsgi_param CONTENT_TYPE $content_type; 5 | uwsgi_param CONTENT_LENGTH $content_length; 6 | 7 | uwsgi_param REQUEST_URI $request_uri; 8 | uwsgi_param PATH_INFO $document_uri; 9 | uwsgi_param DOCUMENT_ROOT $document_root; 10 | uwsgi_param SERVER_PROTOCOL $server_protocol; 11 | uwsgi_param HTTPS $https if_not_empty; 12 | 13 | uwsgi_param REMOTE_ADDR $remote_addr; 14 | uwsgi_param REMOTE_PORT $remote_port; 15 | uwsgi_param SERVER_PORT $server_port; 16 | uwsgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/uwsgi_params.default: -------------------------------------------------------------------------------- 1 | 2 | uwsgi_param QUERY_STRING $query_string; 3 | uwsgi_param REQUEST_METHOD $request_method; 4 | uwsgi_param CONTENT_TYPE $content_type; 5 | uwsgi_param CONTENT_LENGTH $content_length; 6 | 7 | uwsgi_param REQUEST_URI $request_uri; 8 | uwsgi_param PATH_INFO $document_uri; 9 | uwsgi_param DOCUMENT_ROOT $document_root; 10 | uwsgi_param SERVER_PROTOCOL $server_protocol; 11 | uwsgi_param HTTPS $https if_not_empty; 12 | 13 | uwsgi_param REMOTE_ADDR $remote_addr; 14 | uwsgi_param REMOTE_PORT $remote_port; 15 | uwsgi_param SERVER_PORT $server_port; 16 | uwsgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /trunk/vs2010/rtmpd/conf/win-utf: -------------------------------------------------------------------------------- 1 | 2 | # This map is not a full windows-1251 <> utf8 map: it does not 3 | # contain Serbian and Macedonian letters. If you need a full map, 4 | # use contrib/unicode2nginx/win-utf map instead. 5 | 6 | charset_map windows-1251 utf-8 { 7 | 8 | 82 E2809A ; # single low-9 quotation mark 9 | 10 | 84 E2809E ; # double low-9 quotation mark 11 | 85 E280A6 ; # ellipsis 12 | 86 E280A0 ; # dagger 13 | 87 E280A1 ; # double dagger 14 | 88 E282AC ; # euro 15 | 89 E280B0 ; # per mille 16 | 17 | 91 E28098 ; # left single quotation mark 18 | 92 E28099 ; # right single quotation mark 19 | 93 E2809C ; # left double quotation mark 20 | 94 E2809D ; # right double quotation mark 21 | 95 E280A2 ; # bullet 22 | 96 E28093 ; # en dash 23 | 97 E28094 ; # em dash 24 | 25 | 99 E284A2 ; # trade mark sign 26 | 27 | A0 C2A0 ; #   28 | A1 D18E ; # capital Byelorussian short U 29 | A2 D19E ; # small Byelorussian short u 30 | 31 | A4 C2A4 ; # currency sign 32 | A5 D290 ; # capital Ukrainian soft G 33 | A6 C2A6 ; # borken bar 34 | A7 C2A7 ; # section sign 35 | A8 D081 ; # capital YO 36 | A9 C2A9 ; # (C) 37 | AA D084 ; # capital Ukrainian YE 38 | AB C2AB ; # left-pointing double angle quotation mark 39 | AC C2AC ; # not sign 40 | AD C2AD ; # soft hypen 41 | AE C2AE ; # (R) 42 | AF D087 ; # capital Ukrainian YI 43 | 44 | B0 C2B0 ; # ° 45 | B1 C2B1 ; # plus-minus sign 46 | B2 D086 ; # capital Ukrainian I 47 | B3 D196 ; # small Ukrainian i 48 | B4 D291 ; # small Ukrainian soft g 49 | B5 C2B5 ; # micro sign 50 | B6 C2B6 ; # pilcrow sign 51 | B7 C2B7 ; # · 52 | B8 D191 ; # small yo 53 | B9 E28496 ; # numero sign 54 | BA D194 ; # small Ukrainian ye 55 | BB C2BB ; # right-pointing double angle quotation mark 56 | 57 | BF D197 ; # small Ukrainian yi 58 | 59 | C0 D090 ; # capital A 60 | C1 D091 ; # capital B 61 | C2 D092 ; # capital V 62 | C3 D093 ; # capital G 63 | C4 D094 ; # capital D 64 | C5 D095 ; # capital YE 65 | C6 D096 ; # capital ZH 66 | C7 D097 ; # capital Z 67 | C8 D098 ; # capital I 68 | C9 D099 ; # capital J 69 | CA D09A ; # capital K 70 | CB D09B ; # capital L 71 | CC D09C ; # capital M 72 | CD D09D ; # capital N 73 | CE D09E ; # capital O 74 | CF D09F ; # capital P 75 | 76 | D0 D0A0 ; # capital R 77 | D1 D0A1 ; # capital S 78 | D2 D0A2 ; # capital T 79 | D3 D0A3 ; # capital U 80 | D4 D0A4 ; # capital F 81 | D5 D0A5 ; # capital KH 82 | D6 D0A6 ; # capital TS 83 | D7 D0A7 ; # capital CH 84 | D8 D0A8 ; # capital SH 85 | D9 D0A9 ; # capital SHCH 86 | DA D0AA ; # capital hard sign 87 | DB D0AB ; # capital Y 88 | DC D0AC ; # capital soft sign 89 | DD D0AD ; # capital E 90 | DE D0AE ; # capital YU 91 | DF D0AF ; # capital YA 92 | 93 | E0 D0B0 ; # small a 94 | E1 D0B1 ; # small b 95 | E2 D0B2 ; # small v 96 | E3 D0B3 ; # small g 97 | E4 D0B4 ; # small d 98 | E5 D0B5 ; # small ye 99 | E6 D0B6 ; # small zh 100 | E7 D0B7 ; # small z 101 | E8 D0B8 ; # small i 102 | E9 D0B9 ; # small j 103 | EA D0BA ; # small k 104 | EB D0BB ; # small l 105 | EC D0BC ; # small m 106 | ED D0BD ; # small n 107 | EE D0BE ; # small o 108 | EF D0BF ; # small p 109 | 110 | F0 D180 ; # small r 111 | F1 D181 ; # small s 112 | F2 D182 ; # small t 113 | F3 D183 ; # small u 114 | F4 D184 ; # small f 115 | F5 D185 ; # small kh 116 | F6 D186 ; # small ts 117 | F7 D187 ; # small ch 118 | F8 D188 ; # small sh 119 | F9 D189 ; # small shch 120 | FA D18A ; # small hard sign 121 | FB D18B ; # small y 122 | FC D18C ; # small soft sign 123 | FD D18D ; # small e 124 | FE D18E ; # small yu 125 | FF D18F ; # small ya 126 | } 127 | --------------------------------------------------------------------------------