From 56e78bdf6f3699b61086843cb2e64b43a70df773 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 19 Oct 2013 09:00:17 +0800 Subject: [PATCH] add comments. refine naming --- trunk/src/core/srs_core.hpp | 8 ++++++-- trunk/src/core/srs_core_auto_free.hpp | 8 ++++---- trunk/src/core/srs_core_buffer.cpp | 9 +++++++++ trunk/src/core/srs_core_buffer.hpp | 12 ++++++++++++ trunk/src/core/srs_core_client.hpp | 4 ++++ trunk/src/core/srs_core_conn.cpp | 2 +- trunk/src/core/srs_core_protocol.hpp | 5 +++++ trunk/src/core/srs_core_rtmp.hpp | 8 +++++++- trunk/src/core/srs_core_server.cpp | 2 +- trunk/src/core/srs_core_socket.hpp | 5 ++++- 10 files changed, 53 insertions(+), 10 deletions(-) diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index ab4327437..9f352bf0f 100755 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -28,7 +28,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include */ -// user must include the srs_core.hpp before any header. +/** +* the core provides the common defined macros, utilities, +* user must include the srs_core.hpp before any header, or maybe +* build failed. +*/ // for int64_t print using PRId64 format. #ifndef __STDC_FORMAT_MACROS @@ -36,6 +40,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #include -#define SrsAssert(expression) assert(expression) +#define srs_assert(expression) assert(expression) #endif \ No newline at end of file diff --git a/trunk/src/core/srs_core_auto_free.hpp b/trunk/src/core/srs_core_auto_free.hpp index e11f83c6b..7409af55d 100755 --- a/trunk/src/core/srs_core_auto_free.hpp +++ b/trunk/src/core/srs_core_auto_free.hpp @@ -36,10 +36,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * auto free the instance in the current scope. */ #define SrsAutoFree(className, instance, is_array) \ - c__SrsAutoFree _auto_free_##instance(&instance, is_array) + __SrsAutoFree _auto_free_##instance(&instance, is_array) template -class c__SrsAutoFree +class __SrsAutoFree { private: T** ptr; @@ -49,12 +49,12 @@ public: * auto delete the ptr. * @is_array a bool value indicates whether the ptr is a array. */ - c__SrsAutoFree(T** _ptr, bool _is_array){ + __SrsAutoFree(T** _ptr, bool _is_array){ ptr = _ptr; is_array = _is_array; } - virtual ~c__SrsAutoFree(){ + virtual ~__SrsAutoFree(){ if (ptr == NULL || *ptr == NULL) { return; } diff --git a/trunk/src/core/srs_core_buffer.cpp b/trunk/src/core/srs_core_buffer.cpp index 1dc4683b6..d87130528 100755 --- a/trunk/src/core/srs_core_buffer.cpp +++ b/trunk/src/core/srs_core_buffer.cpp @@ -22,3 +22,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include + +SrsBuffer::SrsBuffer() +{ +} + +SrsBuffer::~SrsBuffer() +{ +} + diff --git a/trunk/src/core/srs_core_buffer.hpp b/trunk/src/core/srs_core_buffer.hpp index 42996d66b..babdf9601 100755 --- a/trunk/src/core/srs_core_buffer.hpp +++ b/trunk/src/core/srs_core_buffer.hpp @@ -30,4 +30,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +/** +* the buffer provices bytes cache for protocol. generally, +* protocol recv data from socket, put into buffer, decode to RTMP message. +* protocol encode RTMP message to bytes, put into buffer, send to socket. +*/ +class SrsBuffer +{ +public: + SrsBuffer(); + virtual ~SrsBuffer(); +}; + #endif \ No newline at end of file diff --git a/trunk/src/core/srs_core_client.hpp b/trunk/src/core/srs_core_client.hpp index c4d9fce10..279692234 100755 --- a/trunk/src/core/srs_core_client.hpp +++ b/trunk/src/core/srs_core_client.hpp @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include class SrsRtmp; + +/** +* the client provides the main logic control for RTMP clients. +*/ class SrsClient : public SrsConnection { private: diff --git a/trunk/src/core/srs_core_conn.cpp b/trunk/src/core/srs_core_conn.cpp index ba0e4d3f4..4c99b9922 100755 --- a/trunk/src/core/srs_core_conn.cpp +++ b/trunk/src/core/srs_core_conn.cpp @@ -83,7 +83,7 @@ void SrsConnection::cycle() void* SrsConnection::cycle_thread(void* arg) { SrsConnection* conn = (SrsConnection*)arg; - SrsAssert(conn != NULL); + srs_assert(conn != NULL); conn->cycle(); diff --git a/trunk/src/core/srs_core_protocol.hpp b/trunk/src/core/srs_core_protocol.hpp index 7f8cf1460..43d7de56b 100755 --- a/trunk/src/core/srs_core_protocol.hpp +++ b/trunk/src/core/srs_core_protocol.hpp @@ -32,6 +32,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +/** +* the protocol provides the rtmp-message-protocol services, +* to recv RTMP message from RTMP chunk stream, +* and to send out RTMP message over RTMP chunk stream. +*/ class SrsProtocol { private: diff --git a/trunk/src/core/srs_core_rtmp.hpp b/trunk/src/core/srs_core_rtmp.hpp index c4a19a1e4..b0602e499 100755 --- a/trunk/src/core/srs_core_rtmp.hpp +++ b/trunk/src/core/srs_core_rtmp.hpp @@ -34,13 +34,19 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +class SrsProtocol; + struct SrsApp { std::string vhost; std::string app; }; -class SrsProtocol; +/** +* the rtmp provices rtmp-command-protocol services, +* a high level protocol, media stream oriented services, +* such as connect to vhost/app, play stream, get audio/video data. +*/ class SrsRtmp { private: diff --git a/trunk/src/core/srs_core_server.cpp b/trunk/src/core/srs_core_server.cpp index 032f455b5..4454d514a 100755 --- a/trunk/src/core/srs_core_server.cpp +++ b/trunk/src/core/srs_core_server.cpp @@ -203,7 +203,7 @@ void SrsServer::listen_cycle() void* SrsServer::listen_thread(void* arg) { SrsServer* server = (SrsServer*)arg; - SrsAssert(server != NULL); + srs_assert(server != NULL); server->listen_cycle(); diff --git a/trunk/src/core/srs_core_socket.hpp b/trunk/src/core/srs_core_socket.hpp index f2933f510..a575b88da 100755 --- a/trunk/src/core/srs_core_socket.hpp +++ b/trunk/src/core/srs_core_socket.hpp @@ -32,7 +32,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -// the socket base on st. +/** +* the socket provides TCP socket over st, +* that is, the sync socket mechanism. +*/ class Socket { private: