1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

donot install tools when ffmpeg is not open, 0.9.108

This commit is contained in:
winlin 2014-05-20 18:11:33 +08:00
parent 5bb6e657c3
commit 2265173c4d
5 changed files with 125 additions and 85 deletions

View file

@ -70,6 +70,7 @@ function Ubuntu_prepare()
echo "install patch success"
fi
if [ $SRS_FFMPEG_TOOL = YES ]; then
autoconf --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install autoconf"
require_sudoer "sudo apt-get install -y --force-yes autoconf"
@ -104,6 +105,7 @@ function Ubuntu_prepare()
sudo apt-get install -y --force-yes libfreetype6-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install libfreetype6-dev success"
fi
fi
# for arm, install the cross build tool chain.
if [ $SRS_ARM_UBUNTU12 = YES ]; then
@ -168,6 +170,7 @@ function Centos_prepare()
echo "install patch success"
fi
if [ $SRS_FFMPEG_TOOL = YES ]; then
automake --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then
echo "install automake"
require_sudoer "sudo yum install -y automake"
@ -209,6 +212,7 @@ function Centos_prepare()
sudo yum install -y freetype-devel; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi
echo "install freetype-devel success"
fi
fi
# for arm, install the cross build tool chain.
if [ $SRS_EMBEDED_CPU = YES ]; then

View file

@ -43,13 +43,18 @@ void close_flv_file(int flv_fd);
int flv_open_ic(int flv_fd);
int flv_read_packet(int flv_fd, int* type, u_int32_t* timestamp, char** data, int* size);
#define RE_PULSE_MS 300
int64_t re_create();
int64_t re_update(int64_t re, u_int32_t time);
void re_update(int64_t re, u_int32_t time);
int64_t tools_main_entrance_startup_time;
int main(int argc, char** argv)
{
int ret = 0;
// main function
tools_main_entrance_startup_time = srs_get_time_ms();
// user option parse index.
int opt = 0;
// user options.
@ -118,8 +123,6 @@ int proxy(int flv_fd, srs_rtmp_t ortmp)
int type, size;
u_int32_t timestamp = 0;
char* data = NULL;
// re
int64_t re = re_create();
if ((ret = flv_open_ic(flv_fd)) != 0) {
return ret;
@ -128,6 +131,9 @@ int proxy(int flv_fd, srs_rtmp_t ortmp)
return ret;
}
// re
int64_t re = re_create();
trace("start ingest flv to RTMP stream");
for (;;) {
if ((ret = flv_read_packet(flv_fd, &type, &timestamp, &data, &size)) != 0) {
@ -144,7 +150,7 @@ int proxy(int flv_fd, srs_rtmp_t ortmp)
verbose("ortmp sent packet: type=%s, time=%d, size=%d",
srs_type2string(type), timestamp, size);
re = re_update(re, timestamp);
re_update(re, timestamp);
}
return ret;
@ -177,17 +183,35 @@ int connect_oc(srs_rtmp_t ortmp)
int64_t re_create()
{
return 0;
}
int64_t re_update(int64_t re, u_int32_t time)
{
if (time - re > 500) {
usleep((time - re) * 1000);
return time;
// if not very precise, we can directly use this as re.
int64_t re = srs_get_time_ms();
// use the starttime to get the deviation
int64_t deviation = re - tools_main_entrance_startup_time;
trace("deviation is %d ms, pulse is %d ms", (int)(deviation), (int)(RE_PULSE_MS));
// so, we adjust time to max(0, deviation - pulse/4)
// because the last pulse, we never sleep, so we use pulse/4,
// for example, when EOF at the 120ms of last pulse,
// these bytes is additional data and to fill the deviation.
int adjust = (int)(deviation - (RE_PULSE_MS / 4));
if (adjust > 0) {
trace("adjust re time, sub %d ms", adjust);
re -= adjust;
} else {
trace("no need to adjust re time");
}
return re;
}
void re_update(int64_t re, u_int32_t time)
{
int64_t now = srs_get_time_ms();
int64_t diff = time - (now -re);
if (diff > RE_PULSE_MS) {
usleep(diff * 1000);
}
}
int open_flv_file(char* in_flv_file)
{

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "107"
#define VERSION_REVISION "108"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"

View file

@ -35,6 +35,7 @@ using namespace std;
#include <srs_protocol_utility.hpp>
#include <srs_core_autofree.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_kernel_utility.hpp>
// if user want to define log, define the folowing macro.
#ifndef SRS_RTMP_USER_DEFINED_LOG
@ -399,6 +400,12 @@ int srs_version_revision()
return ::atoi(VERSION_REVISION);
}
int64_t srs_get_time_ms()
{
srs_update_system_time_ms();
return srs_get_system_time_ms();
}
#ifdef __cplusplus
}
#endif

View file

@ -154,6 +154,11 @@ int srs_version_major();
int srs_version_minor();
int srs_version_revision();
/**
* utilities
*/
extern int64_t srs_get_time_ms();
#ifdef __cplusplus
}
#endif