mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Compare commits
8 commits
3.0release
...
v2.0-r11
Author | SHA1 | Date | |
---|---|---|---|
|
9851a988fa | ||
|
dca3158b5d | ||
|
c8871413e4 | ||
|
bf6e8592d4 | ||
|
114a1c2897 | ||
|
008034615e | ||
|
e6cf8bf22b | ||
|
f1db22f261 |
18 changed files with 1749 additions and 15 deletions
|
@ -295,6 +295,9 @@ Remark:
|
|||
|
||||
## Releases
|
||||
|
||||
* 2021-08-14, [Release v2.0-r11](https://github.com/ossrs/srs/releases/tag/v2.0-r11), 2.0 release11, 2.0.276, 89013 lines.
|
||||
* 2021-07-04, [Release v2.0-r10](https://github.com/ossrs/srs/releases/tag/v2.0-r10), 2.0 release10, 2.0.274, 87575 lines.
|
||||
* 2021-06-26, [Release v2.0-r9](https://github.com/ossrs/srs/releases/tag/v2.0-r9), 2.0 release9, 2.0.273, 87552 lines.
|
||||
* 2020-01-25, [Release v2.0-r8][r2.0r8], 2.0 release8, 2.0.272, 87292 lines.
|
||||
* 2018-11-29, [Release v2.0-r7][r2.0r7], 2.0 release7, 2.0.265, 86994 lines.
|
||||
* 2018-10-28, [Release v2.0-r6][r2.0r6], 2.0 release6, 2.0.263, 86994 lines.
|
||||
|
@ -339,6 +342,11 @@ Remark:
|
|||
|
||||
## History
|
||||
|
||||
* <strong>v2.0, 2021-08-14, [2.0 release11(2.0.276)](https://github.com/ossrs/srs/releases/tag/v2.0-r11) released. 89013 lines.</strong>
|
||||
* <strong>v2.0, 2021-07-04, [2.0 release10(2.0.274)](https://github.com/ossrs/srs/releases/tag/v2.0-r10) released. 87575 lines.</strong>
|
||||
* v2.0, 2021-07-04, For [#2424](https://github.com/ossrs/srs/issues/2424), use srandom/random to generate. 2.0.274
|
||||
* <strong>v2.0, 2021-06-26, [2.0 release9(2.0.273)](https://github.com/ossrs/srs/releases/tag/v2.0-r9) released. 87552 lines.</strong>
|
||||
* v2.0, 2021-06-25, For [#2424](https://github.com/ossrs/srs/issues/2424), query the latest available version. 2.0.273
|
||||
* <strong>v2.0, 2020-01-25, [2.0 release8(2.0.272)][r2.0r8] released. 87292 lines.</strong>
|
||||
* v2.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 2.0.272
|
||||
* v2.0, 2020-01-05, Merge [#1551][bug #1551], fix memory leak in RTSP stack. 2.0.270
|
||||
|
|
|
@ -63,6 +63,11 @@ work_dir ./;
|
|||
# default: off
|
||||
asprocess off;
|
||||
|
||||
# Query the latest available version of SRS, write a log to notice user to upgrade.
|
||||
# @see https://github.com/ossrs/srs/issues/2424
|
||||
# Default: on
|
||||
query_latest_version on;
|
||||
|
||||
#############################################################################################
|
||||
# heartbeat/stats sections
|
||||
#############################################################################################
|
||||
|
|
2
trunk/configure
vendored
2
trunk/configure
vendored
|
@ -179,7 +179,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
|||
"srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_http_static"
|
||||
"srs_app_recv_thread" "srs_app_security" "srs_app_statistic" "srs_app_hds"
|
||||
"srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call"
|
||||
"srs_app_caster_flv")
|
||||
"srs_app_caster_flv" "srs_app_latest_version" "srs_app_uuid")
|
||||
DEFINES=""
|
||||
# add each modules for app
|
||||
for SRS_MODULE in ${SRS_MODULES[*]}; do
|
||||
|
|
|
@ -2212,6 +2212,18 @@ bool SrsConfig::get_asprocess()
|
|||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::whether_query_latest_version()
|
||||
{
|
||||
static bool DEFAULT = true;
|
||||
|
||||
SrsConfDirective* conf = root->get("query_latest_version");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_TRUE(conf->arg0());
|
||||
}
|
||||
|
||||
vector<SrsConfDirective*> SrsConfig::get_stream_casters()
|
||||
{
|
||||
srs_assert(root);
|
||||
|
|
|
@ -386,6 +386,8 @@ public:
|
|||
virtual std::string get_work_dir();
|
||||
// whether use asprocess mode.
|
||||
virtual bool get_asprocess();
|
||||
// Whether query the latest available version of SRS.
|
||||
virtual bool whether_query_latest_version();
|
||||
// stream_caster section
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -35,6 +35,7 @@ using namespace std;
|
|||
#include <srs_app_pithy_print.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
#include <srs_app_utility.hpp>
|
||||
#include <srs_rtmp_utility.hpp>
|
||||
|
||||
// when error, ingester sleep for a while and retry.
|
||||
// ingest never sleep a long time, for we must start the stream ASAP.
|
||||
|
@ -436,7 +437,7 @@ void SrsIngester::show_ingest_log_message()
|
|||
}
|
||||
|
||||
// random choose one ingester to report.
|
||||
int index = rand() % (int)ingesters.size();
|
||||
int index = srs_random() % (int)ingesters.size();
|
||||
SrsIngesterFFMPEG* ingester = ingesters.at(index);
|
||||
|
||||
// reportable
|
||||
|
|
182
trunk/src/app/srs_app_latest_version.cpp
Normal file
182
trunk/src/app/srs_app_latest_version.cpp
Normal file
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2015 SRS(ossrs)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <srs_app_latest_version.hpp>
|
||||
|
||||
#include <srs_core_autofree.hpp>
|
||||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_kernel_log.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
#include <srs_protocol_json.hpp>
|
||||
#include <srs_rtmp_utility.hpp>
|
||||
#include <srs_app_config.hpp>
|
||||
#include <srs_app_http_conn.hpp>
|
||||
#include <srs_app_http_client.hpp>
|
||||
#include <srs_app_utility.hpp>
|
||||
#include <srs_app_uuid.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
SrsLatestVersion::SrsLatestVersion()
|
||||
{
|
||||
trd_ = new SrsEndlessThread("signal", this);
|
||||
}
|
||||
|
||||
SrsLatestVersion::~SrsLatestVersion()
|
||||
{
|
||||
srs_freep(trd_);
|
||||
}
|
||||
|
||||
int SrsLatestVersion::start()
|
||||
{
|
||||
if (!_srs_config->whether_query_latest_version()) {
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
if (true) {
|
||||
uuid_t uuid;
|
||||
uuid_generate_time(uuid);
|
||||
|
||||
char buf[32];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
snprintf(buf + i * 2, sizeof(buf), "%02x", uuid[i]);
|
||||
}
|
||||
server_id_ = string(buf, sizeof(buf));
|
||||
}
|
||||
|
||||
return trd_->start();
|
||||
}
|
||||
|
||||
int SrsLatestVersion::cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
uint64_t first_random_wait = 0;
|
||||
srs_random_generate((char*)&first_random_wait, 8);
|
||||
first_random_wait = (first_random_wait + srs_update_system_time_ms() + getpid()) % (5 * 60); // in s.
|
||||
|
||||
// Only report after 5+ minutes.
|
||||
first_random_wait += 5 * 60;
|
||||
|
||||
srs_trace("Startup query id=%s, eip=%s, wait=%ds", server_id_.c_str(), srs_get_public_internet_address().c_str(), (int)first_random_wait);
|
||||
st_usleep(first_random_wait * 1000 * 1000);
|
||||
|
||||
while (true) {
|
||||
int64_t starttime = srs_update_system_time_ms();
|
||||
ret = query_latest_version(); // Ignore any error.
|
||||
srs_trace("Finish query id=%s, eip=%s, match=%s, stable=%s, cost=%dms, ret=%d", server_id_.c_str(), srs_get_public_internet_address().c_str(), match_version_.c_str(), stable_version_.c_str(), (int)(srs_update_system_time_ms() - starttime), ret);
|
||||
|
||||
st_usleep(3600 * 1000 * 1000LL); // Every an hour.
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsLatestVersion::query_latest_version()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// Generate uri and parse to object.
|
||||
stringstream ss;
|
||||
ss << "http://api.ossrs.net/service/v1/releases?"
|
||||
<< "version=v" << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_REVISION
|
||||
<< "&id=" << server_id_
|
||||
<< "&eip=" << srs_get_public_internet_address()
|
||||
<< "&ts=" << srs_get_system_time_ms()
|
||||
<< "&alive=" << (srs_get_system_time_ms() - srs_get_system_startup_time_ms()) / 1000;
|
||||
string url = ss.str();
|
||||
|
||||
SrsHttpUri uri;
|
||||
if ((ret = uri.initialize(url)) != ERROR_SUCCESS) {
|
||||
srs_error("http: post failed. url=%s, ret=%d", url.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Start HTTP request and read response.
|
||||
SrsHttpClient http;
|
||||
if ((ret = http.initialize(uri.get_host(), uri.get_port())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Path with query.
|
||||
string path = uri.get_path();
|
||||
path += "?";
|
||||
path += uri.get_query();
|
||||
|
||||
ISrsHttpMessage* msg = NULL;
|
||||
if ((ret = http.get(path, "", &msg)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
SrsAutoFree(ISrsHttpMessage, msg);
|
||||
|
||||
string res;
|
||||
int code = msg->status_code();
|
||||
if ((ret = msg->body_read_all(res)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Check the response code and content.
|
||||
if (code != SRS_CONSTS_HTTP_OK) {
|
||||
ret = ERROR_HTTP_STATUS_INVALID;
|
||||
srs_error("invalid response status=%d. ret=%d", code, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (res.empty()) {
|
||||
ret = ERROR_HTTP_DATA_INVALID;
|
||||
srs_error("invalid empty response. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Response in json object.
|
||||
SrsJsonAny* jres = SrsJsonAny::loads((char*)res.c_str());
|
||||
if (!jres || !jres->is_object()) {
|
||||
ret = ERROR_HTTP_DATA_INVALID;
|
||||
srs_error("invalid response %s. ret=%d", res.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
SrsAutoFree(SrsJsonAny, jres);
|
||||
|
||||
SrsJsonObject* obj = jres->to_object();
|
||||
SrsJsonAny* prop = NULL;
|
||||
|
||||
// Parse fields of response.
|
||||
if ((prop = obj->ensure_property_string("match_version")) == NULL) {
|
||||
ret = ERROR_RESPONSE_CODE;
|
||||
srs_error("invalid response without match_version, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
match_version_ = prop->to_str();
|
||||
|
||||
if ((prop = obj->ensure_property_string("stable_version")) == NULL) {
|
||||
ret = ERROR_RESPONSE_CODE;
|
||||
srs_error("invalid response without stable_version, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
stable_version_ = prop->to_str();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
58
trunk/src/app/srs_app_latest_version.hpp
Normal file
58
trunk/src/app/srs_app_latest_version.hpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2015 SRS(ossrs)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_APP_LATEST_VERSION_HPP
|
||||
#define SRS_APP_LATEST_VERSION_HPP
|
||||
|
||||
/*
|
||||
#include <srs_app_latest_version.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <srs_app_thread.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
class SrsLatestVersion : public ISrsEndlessThreadHandler
|
||||
{
|
||||
private:
|
||||
SrsEndlessThread* trd_;
|
||||
std::string server_id_;
|
||||
private:
|
||||
std::string match_version_;
|
||||
std::string stable_version_;
|
||||
public:
|
||||
SrsLatestVersion();
|
||||
virtual ~SrsLatestVersion();
|
||||
public:
|
||||
virtual int start();
|
||||
// interface ISrsEndlessThreadHandler.
|
||||
public:
|
||||
virtual int cycle();
|
||||
private:
|
||||
int query_latest_version();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -48,6 +48,7 @@ using namespace std;
|
|||
#include <srs_app_statistic.hpp>
|
||||
#include <srs_app_caster_flv.hpp>
|
||||
#include <srs_core_mem_watch.hpp>
|
||||
#include <srs_app_latest_version.hpp>
|
||||
|
||||
// signal defines.
|
||||
#define SIGNAL_RELOAD SIGHUP
|
||||
|
@ -486,6 +487,7 @@ SrsServer::SrsServer()
|
|||
pid_fd = -1;
|
||||
|
||||
signal_manager = NULL;
|
||||
latest_version_ = new SrsLatestVersion();
|
||||
|
||||
handler = NULL;
|
||||
ppid = ::getppid();
|
||||
|
@ -540,6 +542,7 @@ void SrsServer::destroy()
|
|||
}
|
||||
|
||||
srs_freep(signal_manager);
|
||||
srs_freep(latest_version_);
|
||||
}
|
||||
|
||||
void SrsServer::dispose()
|
||||
|
@ -652,7 +655,18 @@ int SrsServer::initialize_st()
|
|||
|
||||
int SrsServer::initialize_signal()
|
||||
{
|
||||
return signal_manager->initialize();
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if ((ret = signal_manager->initialize()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Start the version query coroutine.
|
||||
if ((ret = latest_version_->start()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsServer::acquire_pid_file()
|
||||
|
|
|
@ -55,6 +55,7 @@ class SrsTcpListener;
|
|||
#ifdef SRS_AUTO_STREAM_CASTER
|
||||
class SrsAppCasterFlv;
|
||||
#endif
|
||||
class SrsLatestVersion;
|
||||
|
||||
// listener type for server to identify the connection,
|
||||
// that is, use different type to process the connection.
|
||||
|
@ -267,6 +268,8 @@ private:
|
|||
* signal manager which convert gignal to io message.
|
||||
*/
|
||||
SrsSignalManager* signal_manager;
|
||||
// To query the latest available version of SRS.
|
||||
SrsLatestVersion* latest_version_;
|
||||
/**
|
||||
* handle in server cycle.
|
||||
*/
|
||||
|
|
1320
trunk/src/app/srs_app_uuid.cpp
Normal file
1320
trunk/src/app/srs_app_uuid.cpp
Normal file
File diff suppressed because it is too large
Load diff
112
trunk/src/app/srs_app_uuid.hpp
Normal file
112
trunk/src/app/srs_app_uuid.hpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
//
|
||||
// libuuid BSD License @see https://sourceforge.net/projects/libuuid/
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
//
|
||||
#include <srs_core.hpp>
|
||||
|
||||
/*
|
||||
* Public include file for the UUID library
|
||||
*
|
||||
* Copyright (C) 1996, 1997, 1998 Theodore Ts'o.
|
||||
*
|
||||
* %Begin-Header%
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, and the entire permission notice in its entirety,
|
||||
* including the disclaimer of warranties.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
|
||||
* WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
#ifndef _UUID_UUID_H
|
||||
#define _UUID_UUID_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
typedef unsigned char uuid_t[16];
|
||||
|
||||
/* UUID Variant definitions */
|
||||
#define UUID_VARIANT_NCS 0
|
||||
#define UUID_VARIANT_DCE 1
|
||||
#define UUID_VARIANT_MICROSOFT 2
|
||||
#define UUID_VARIANT_OTHER 3
|
||||
|
||||
/* UUID Type definitions */
|
||||
#define UUID_TYPE_DCE_TIME 1
|
||||
#define UUID_TYPE_DCE_RANDOM 4
|
||||
|
||||
/* Allow UUID constants to be defined */
|
||||
#ifdef __GNUC__
|
||||
#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
|
||||
static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
|
||||
#else
|
||||
#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
|
||||
static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* clear.c */
|
||||
void uuid_clear(uuid_t uu);
|
||||
|
||||
/* compare.c */
|
||||
int uuid_compare(const uuid_t uu1, const uuid_t uu2);
|
||||
|
||||
/* copy.c */
|
||||
void uuid_copy(uuid_t dst, const uuid_t src);
|
||||
|
||||
/* gen_uuid.c */
|
||||
void uuid_generate(uuid_t out);
|
||||
void uuid_generate_random(uuid_t out);
|
||||
void uuid_generate_time(uuid_t out);
|
||||
int uuid_generate_time_safe(uuid_t out);
|
||||
|
||||
/* isnull.c */
|
||||
int uuid_is_null(const uuid_t uu);
|
||||
|
||||
/* parse.c */
|
||||
int uuid_parse(const char *in, uuid_t uu);
|
||||
|
||||
/* unparse.c */
|
||||
void uuid_unparse(const uuid_t uu, char *out);
|
||||
void uuid_unparse_lower(const uuid_t uu, char *out);
|
||||
void uuid_unparse_upper(const uuid_t uu, char *out);
|
||||
|
||||
/* uuid_time.c */
|
||||
time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
|
||||
int uuid_type(const uuid_t uu);
|
||||
int uuid_variant(const uuid_t uu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _UUID_UUID_H */
|
||||
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// current release version
|
||||
#define VERSION_MAJOR 2
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 272
|
||||
#define VERSION_REVISION 276
|
||||
|
||||
// generated by configure, only macros.
|
||||
#include <srs_auto_headers.hpp>
|
||||
|
|
|
@ -110,9 +110,17 @@ int64_t srs_get_system_startup_time_ms()
|
|||
if (_srs_system_time_startup_time <= 0) {
|
||||
srs_update_system_time_ms();
|
||||
}
|
||||
|
||||
|
||||
return _srs_system_time_startup_time / 1000;
|
||||
}
|
||||
int64_t srs_get_system_startup_time_us()
|
||||
{
|
||||
if (_srs_system_time_startup_time <= 0) {
|
||||
srs_update_system_time_ms();
|
||||
}
|
||||
|
||||
return _srs_system_time_startup_time;
|
||||
}
|
||||
int64_t srs_update_system_time_ms()
|
||||
{
|
||||
timeval now;
|
||||
|
|
|
@ -46,6 +46,7 @@ extern int srs_avc_nalu_read_bit(SrsBitStream* stream, int8_t& v);
|
|||
// get current system time in ms, use cache to avoid performance problem
|
||||
extern int64_t srs_get_system_time_ms();
|
||||
extern int64_t srs_get_system_startup_time_ms();
|
||||
extern int64_t srs_get_system_startup_time_us();
|
||||
// the deamon st-thread will update it.
|
||||
extern int64_t srs_update_system_time_ms();
|
||||
|
||||
|
|
|
@ -484,7 +484,7 @@ namespace _srs_internal
|
|||
|
||||
key_block::key_block()
|
||||
{
|
||||
offset = (int32_t)rand();
|
||||
offset = (int32_t)srs_random();
|
||||
random0 = NULL;
|
||||
random1 = NULL;
|
||||
|
||||
|
@ -566,7 +566,7 @@ namespace _srs_internal
|
|||
|
||||
digest_block::digest_block()
|
||||
{
|
||||
offset = (int32_t)rand();
|
||||
offset = (int32_t)srs_random();
|
||||
random0 = NULL;
|
||||
random1 = NULL;
|
||||
|
||||
|
|
|
@ -116,19 +116,25 @@ void srs_vhost_resolve(string& vhost, string& app, string& param)
|
|||
|
||||
void srs_random_generate(char* bytes, int size)
|
||||
{
|
||||
static bool _random_initialized = false;
|
||||
if (!_random_initialized) {
|
||||
srand(0);
|
||||
_random_initialized = true;
|
||||
srs_trace("srand initialized the random.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
// the common value in [0x0f, 0xf0]
|
||||
bytes[i] = 0x0f + (rand() % (256 - 0x0f - 0x0f));
|
||||
bytes[i] = 0x0f + (srs_random() % (256 - 0x0f - 0x0f));
|
||||
}
|
||||
}
|
||||
|
||||
long srs_random()
|
||||
{
|
||||
static bool _random_initialized = false;
|
||||
if (!_random_initialized) {
|
||||
_random_initialized = true;
|
||||
|
||||
srandom((unsigned int)srs_get_system_startup_time_us());
|
||||
srs_trace("srandom initialized the random.");
|
||||
}
|
||||
|
||||
return random();
|
||||
}
|
||||
|
||||
string srs_generate_tc_url(string ip, string vhost, string app, string port, string param)
|
||||
{
|
||||
string tcUrl = "rtmp://";
|
||||
|
|
|
@ -80,6 +80,8 @@ extern void srs_vhost_resolve(
|
|||
* generate ramdom data for handshake.
|
||||
*/
|
||||
extern void srs_random_generate(char* bytes, int size);
|
||||
// Generate random value, use srandom(now_us) to init seed if not initialized.
|
||||
extern long srs_random();
|
||||
|
||||
/**
|
||||
* generate the tcUrl.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue