mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine all research tools, remove the public header, add log to srs_librtmp.h
This commit is contained in:
parent
7ba07c6f49
commit
f92303c764
10 changed files with 129 additions and 168 deletions
|
@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_librtmp.hpp>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
@ -32,7 +33,6 @@ using namespace std;
|
|||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_protocol_rtmp.hpp>
|
||||
#include <srs_lib_simple_socket.hpp>
|
||||
#include <srs_kernel_log.hpp>
|
||||
#include <srs_protocol_utility.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
#include <srs_protocol_stack.hpp>
|
||||
|
@ -531,6 +531,33 @@ int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp)
|
|||
return context->rtmp->get_recv_bytes();
|
||||
}
|
||||
|
||||
const char* srs_format_time()
|
||||
{
|
||||
struct timeval tv;
|
||||
static char buf[23];
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
// clock time
|
||||
if (gettimeofday(&tv, NULL) == -1) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
// to calendar time
|
||||
struct tm* tm;
|
||||
if ((tm = localtime(&tv.tv_sec)) == NULL) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
"%d-%02d-%02d %02d:%02d:%02d.%03d",
|
||||
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec,
|
||||
(int)(tv.tv_usec / 1000));
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
struct FlvContext
|
||||
{
|
||||
SrsFileReader reader;
|
||||
|
|
|
@ -234,7 +234,14 @@ extern int srs_version_revision();
|
|||
extern int64_t srs_get_time_ms();
|
||||
extern int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp);
|
||||
extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
|
||||
|
||||
// log to console.
|
||||
extern const char* srs_format_time();
|
||||
#ifndef srs_trace
|
||||
#define srs_trace(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
||||
#endif
|
||||
#ifndef srs_verbose
|
||||
#define srs_verbose(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
||||
#endif
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
|
|
|
@ -137,7 +137,6 @@ file
|
|||
..\..\research\librtmp\srs_ingest_rtmp.c,
|
||||
..\..\research\librtmp\srs_play.c,
|
||||
..\..\research\librtmp\srs_publish.c,
|
||||
..\..\research\librtmp\srs_research_public.h,
|
||||
..\..\research\hls\ts_info.cc;
|
||||
|
||||
mainconfig
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue