mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
update research, flv ingester, support atc time flv.
This commit is contained in:
parent
30d48905b3
commit
3292136f70
2 changed files with 18 additions and 12 deletions
|
@ -39,8 +39,8 @@ int connect_oc(srs_rtmp_t ortmp);
|
||||||
|
|
||||||
#define RE_PULSE_MS 300
|
#define RE_PULSE_MS 300
|
||||||
int64_t re_create();
|
int64_t re_create();
|
||||||
void re_update(int64_t re, u_int32_t time);
|
void re_update(int64_t re, int32_t starttime, u_int32_t time);
|
||||||
void re_cleanup(int64_t re, u_int32_t time);
|
void re_cleanup(int64_t re, int32_t starttime, u_int32_t time);
|
||||||
|
|
||||||
int64_t tools_main_entrance_startup_time;
|
int64_t tools_main_entrance_startup_time;
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
@ -109,7 +109,7 @@ int main(int argc, char** argv)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, u_int32_t* ptimestamp)
|
int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u_int32_t* ptimestamp)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -147,8 +147,12 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, u_int32_t* ptimestamp)
|
||||||
}
|
}
|
||||||
srs_lib_verbose("ortmp sent packet: type=%s, time=%d, size=%d",
|
srs_lib_verbose("ortmp sent packet: type=%s, time=%d, size=%d",
|
||||||
srs_type2string(type), *ptimestamp, size);
|
srs_type2string(type), *ptimestamp, size);
|
||||||
|
|
||||||
|
if (*pstarttime < 0) {
|
||||||
|
*pstarttime = *ptimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
re_update(re, *ptimestamp);
|
re_update(re, *pstarttime, *ptimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -158,6 +162,7 @@ int proxy(srs_flv_t flv, srs_rtmp_t ortmp)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
u_int32_t timestamp = 0;
|
u_int32_t timestamp = 0;
|
||||||
|
int32_t starttime = -1;
|
||||||
|
|
||||||
char header[13];
|
char header[13];
|
||||||
if ((ret = srs_flv_read_header(flv, header)) != 0) {
|
if ((ret = srs_flv_read_header(flv, header)) != 0) {
|
||||||
|
@ -169,10 +174,10 @@ int proxy(srs_flv_t flv, srs_rtmp_t ortmp)
|
||||||
|
|
||||||
int64_t re = re_create();
|
int64_t re = re_create();
|
||||||
|
|
||||||
ret = do_proxy(flv, ortmp, re, ×tamp);
|
ret = do_proxy(flv, ortmp, re, &starttime, ×tamp);
|
||||||
|
|
||||||
// for the last pulse, always sleep.
|
// for the last pulse, always sleep.
|
||||||
re_cleanup(re, timestamp);
|
re_cleanup(re, starttime, timestamp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -223,23 +228,24 @@ int64_t re_create()
|
||||||
|
|
||||||
return re;
|
return re;
|
||||||
}
|
}
|
||||||
void re_update(int64_t re, u_int32_t time)
|
void re_update(int64_t re, int32_t starttime, u_int32_t time)
|
||||||
{
|
{
|
||||||
// send by pulse algorithm.
|
// send by pulse algorithm.
|
||||||
int64_t now = srs_get_time_ms();
|
int64_t now = srs_get_time_ms();
|
||||||
int64_t diff = time - (now -re);
|
int64_t diff = time - starttime - (now -re);
|
||||||
if (diff > RE_PULSE_MS) {
|
if (diff > RE_PULSE_MS) {
|
||||||
usleep(diff * 1000);
|
usleep(diff * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void re_cleanup(int64_t re, u_int32_t time)
|
void re_cleanup(int64_t re, int32_t starttime, u_int32_t time)
|
||||||
{
|
{
|
||||||
// for the last pulse, always sleep.
|
// for the last pulse, always sleep.
|
||||||
// for the virtual live encoder long time publishing.
|
// for the virtual live encoder long time publishing.
|
||||||
int64_t now = srs_get_time_ms();
|
int64_t now = srs_get_time_ms();
|
||||||
int64_t diff = time - (now -re);
|
int64_t diff = time - starttime - (now -re);
|
||||||
if (diff > 0) {
|
if (diff > 0) {
|
||||||
srs_lib_trace("re_cleanup sleep for the last pulse for %d ms", (int)diff);
|
srs_lib_trace("re_cleanup, diff=%d, start=%d, last=%d ms",
|
||||||
|
(int)diff, starttime, time);
|
||||||
usleep(diff * 1000);
|
usleep(diff * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ int __srs_write_h264_sps_pps(Context* context, u_int32_t dts, u_int32_t pts)
|
||||||
|
|
||||||
// @see: Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205
|
// @see: Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205
|
||||||
// Baseline profile profile_idc is 66(0x42).
|
// Baseline profile profile_idc is 66(0x42).
|
||||||
// Baseline profile profile_idc is 77(0x4d).
|
// Main profile profile_idc is 77(0x4d).
|
||||||
// Extended profile profile_idc is 88(0x58).
|
// Extended profile profile_idc is 88(0x58).
|
||||||
u_int8_t profile_idc = frame[1];
|
u_int8_t profile_idc = frame[1];
|
||||||
//u_int8_t constraint_set = frame[2];
|
//u_int8_t constraint_set = frame[2];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue