胡斌

adjust the start time of files read from recordinfo,

because the time offset is not begin from the recordinfo file,but maybe from the last recordinfo file with same uid.
... ... @@ -55,7 +55,7 @@ int CAVTranscoder::add(media_info & info)
if (_start_time == INT64_MAX) {
_start_time = info.start_time_ms;
_cur_v_time = _start_time;
_cur_a_time = _start_time;
_cur_a_time = (double)_start_time;
}
vector < CAVDecoder *>::iterator it = _decoders.begin();
for (; it != _decoders.end(); it++) {
... ... @@ -139,7 +139,7 @@ int CAVTranscoder::close()
#if USE_AACBSF
av_bitstream_filter_close(aacbsfc);
#endif
int i;
unsigned int i;
for (i = 0; i<2; i++)
{
if (_ofmt_ctx && _ofmt_ctx->nb_streams > i && _ofmt_ctx->streams[i] && _ofmt_ctx->streams[i]->codec)
... ... @@ -205,7 +205,7 @@ int CAVTranscoder::open_output_file(const char *filename)
enc_ctx->max_qdiff = 4;
enc_ctx->qmin = 10;
enc_ctx->qmax = 30;
enc_ctx->qcompress = 0.6;
enc_ctx->qcompress = 0.6f;
enc_ctx->framerate.den = 20;
enc_ctx->framerate.num = 1;
... ... @@ -289,7 +289,7 @@ int CAVTranscoder::open_output_file(const char *filename)
for (; it != decoders_got_frame.end(); it++) {
AVFrame * pFrame = (*it)->_cur_a_frame;
if (pFrame) {
#if LIBAVCODEC_VERSION_MAJOR < 57
#ifdef PCM_USING_FLTP_FOR_AAC_ENCODE
int16_t * psrc = (int16_t *)pFrame->extended_data[0];
int16_t * pdst = (int16_t *)pDstFrame->extended_data[0];
#else
... ... @@ -319,7 +319,7 @@ int CAVTranscoder::open_output_file(const char *filename)
int CAVTranscoder::mix_and_output_one2many_vframe(vector<CAVDecoder *> & decoders_got_frame)
{
int idxTeacher = -1;
for (int i = 0; i < decoders_got_frame.size(); i++){
for (unsigned int i = 0; i < decoders_got_frame.size(); i++){
if (decoders_got_frame[i]->_media_role == mr_teacher) {
idxTeacher = i;
break;
... ... @@ -349,7 +349,7 @@ int CAVTranscoder::open_output_file(const char *filename)
}
int imageIdx = 0;
for (int i = 0; i < decoders_got_frame.size(); i++){
for (unsigned int i = 0; i < decoders_got_frame.size(); i++){
if (i != idxTeacher) {
//scale eacher frame
CAVDecoder * pDecoder = decoders_got_frame[i];
... ...
... ... @@ -83,6 +83,9 @@ typedef struct FilteringContext {
#define VFRAME_DURATION_MS 50
#if LIBAVCODEC_VERSION_MAJOR < 57
#define PCM_USING_FLTP_FOR_AAC_ENCODE
#endif
#ifdef PCM_USING_FLTP_FOR_AAC_ENCODE
#define PCM_FORMAT_FOR_AAC_ENCODE AV_SAMPLE_FMT_S16
#else
#define PCM_FORMAT_FOR_AAC_ENCODE AV_SAMPLE_FMT_FLTP
... ...
... ... @@ -126,7 +126,7 @@ void addinfo(float t, string name, bool bstart,media_role role,unsigned int uid)
}
}
void addinfo(const char * t, const char * name, const char * rotation){
void addinfo(const char * name, const char * rotation){
int i = 0;
for (; i < media_files.size(); i++) {
if (media_files[i].name == name) {
... ... @@ -739,14 +739,15 @@ void save_out_info(float start_time, char * outputfile)
}
}
// parse the filename like 4165000_20180203013327202.aac
#define get_sub_str_to_x(x , source, len, result) strncpy(x, source, len); x[len] = 0; source += len; result = atoi(x);
time_t time_sec_1970_base = 0;
float get_uid_start_time_from_filename(const char * filename, unsigned int &uid)
{
int year, month, day, hour, min, sec, minsec;
char buf[5];
const char * start = strstr(filename, "_");
//const char * start = strstr(filename, "_"); // used for parsing file name like uid_138471401_20181109095932880.txt
const char * start = filename; //used for parsing file name like 138471401_20181109095932789.aac
const char * end = strstr(start + 1, "_");
if (end) {//get the next
*(char *)end = 0;
... ... @@ -797,7 +798,8 @@ int readfile(const char * filename, media_role role)
}
unsigned int uid = 0;
float start_time = get_uid_start_time_from_filename(filename , uid);
float start_time = 0.0f;
float start_time_offset = 0.0f;
const int LINE_LENGTH = 1000;
char str[LINE_LENGTH];
... ... @@ -807,16 +809,20 @@ int readfile(const char * filename, media_role role)
split(str, " ", res);
if (res.size() >= 3) {
if (res[2] == "create"){
addinfo(start_time + atof(res[0].c_str()), res[1], true, role, uid);
if (!uid){
start_time = get_uid_start_time_from_filename(res[1].c_str(), uid);
start_time_offset = atof(res[0].c_str());
}
addinfo(start_time + atof(res[0].c_str()) - start_time_offset, res[1], true, role, uid);
}
else if (res[2] == "close") {
addinfo(start_time + atof(res[0].c_str()), res[1], false, role, uid);
addinfo(start_time + atof(res[0].c_str()) - start_time_offset, res[1], false, role, uid);
}
else if (res[2] == "info") {
if (res.size() > 5) {
const char * pInfo = res[5].c_str();
if (!strncmp(pInfo, "rotation=", 9)){
addinfo(res[0].c_str(), res[1].c_str(), pInfo + 9);
addinfo(res[1].c_str(), pInfo + 9);
}
}
}
... ...