winlin

update research, flv ingester, support atc time flv.

@@ -39,8 +39,8 @@ int connect_oc(srs_rtmp_t ortmp); @@ -39,8 +39,8 @@ int connect_oc(srs_rtmp_t ortmp);
39 39
40 #define RE_PULSE_MS 300 40 #define RE_PULSE_MS 300
41 int64_t re_create(); 41 int64_t re_create();
42 -void re_update(int64_t re, u_int32_t time);  
43 -void re_cleanup(int64_t re, u_int32_t time); 42 +void re_update(int64_t re, int32_t starttime, u_int32_t time);
  43 +void re_cleanup(int64_t re, int32_t starttime, u_int32_t time);
44 44
45 int64_t tools_main_entrance_startup_time; 45 int64_t tools_main_entrance_startup_time;
46 int main(int argc, char** argv) 46 int main(int argc, char** argv)
@@ -109,7 +109,7 @@ int main(int argc, char** argv) @@ -109,7 +109,7 @@ int main(int argc, char** argv)
109 return ret; 109 return ret;
110 } 110 }
111 111
112 -int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, u_int32_t* ptimestamp) 112 +int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u_int32_t* ptimestamp)
113 { 113 {
114 int ret = 0; 114 int ret = 0;
115 115
@@ -147,8 +147,12 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, u_int32_t* ptimestamp) @@ -147,8 +147,12 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, u_int32_t* ptimestamp)
147 } 147 }
148 srs_lib_verbose("ortmp sent packet: type=%s, time=%d, size=%d", 148 srs_lib_verbose("ortmp sent packet: type=%s, time=%d, size=%d",
149 srs_type2string(type), *ptimestamp, size); 149 srs_type2string(type), *ptimestamp, size);
  150 +
  151 + if (*pstarttime < 0) {
  152 + *pstarttime = *ptimestamp;
  153 + }
150 154
151 - re_update(re, *ptimestamp); 155 + re_update(re, *pstarttime, *ptimestamp);
152 } 156 }
153 157
154 return ret; 158 return ret;
@@ -158,6 +162,7 @@ int proxy(srs_flv_t flv, srs_rtmp_t ortmp) @@ -158,6 +162,7 @@ int proxy(srs_flv_t flv, srs_rtmp_t ortmp)
158 { 162 {
159 int ret = 0; 163 int ret = 0;
160 u_int32_t timestamp = 0; 164 u_int32_t timestamp = 0;
  165 + int32_t starttime = -1;
161 166
162 char header[13]; 167 char header[13];
163 if ((ret = srs_flv_read_header(flv, header)) != 0) { 168 if ((ret = srs_flv_read_header(flv, header)) != 0) {
@@ -169,10 +174,10 @@ int proxy(srs_flv_t flv, srs_rtmp_t ortmp) @@ -169,10 +174,10 @@ int proxy(srs_flv_t flv, srs_rtmp_t ortmp)
169 174
170 int64_t re = re_create(); 175 int64_t re = re_create();
171 176
172 - ret = do_proxy(flv, ortmp, re, &timestamp); 177 + ret = do_proxy(flv, ortmp, re, &starttime, &timestamp);
173 178
174 // for the last pulse, always sleep. 179 // for the last pulse, always sleep.
175 - re_cleanup(re, timestamp); 180 + re_cleanup(re, starttime, timestamp);
176 181
177 return ret; 182 return ret;
178 } 183 }
@@ -223,23 +228,24 @@ int64_t re_create() @@ -223,23 +228,24 @@ int64_t re_create()
223 228
224 return re; 229 return re;
225 } 230 }
226 -void re_update(int64_t re, u_int32_t time) 231 +void re_update(int64_t re, int32_t starttime, u_int32_t time)
227 { 232 {
228 // send by pulse algorithm. 233 // send by pulse algorithm.
229 int64_t now = srs_get_time_ms(); 234 int64_t now = srs_get_time_ms();
230 - int64_t diff = time - (now -re); 235 + int64_t diff = time - starttime - (now -re);
231 if (diff > RE_PULSE_MS) { 236 if (diff > RE_PULSE_MS) {
232 usleep(diff * 1000); 237 usleep(diff * 1000);
233 } 238 }
234 } 239 }
235 -void re_cleanup(int64_t re, u_int32_t time) 240 +void re_cleanup(int64_t re, int32_t starttime, u_int32_t time)
236 { 241 {
237 // for the last pulse, always sleep. 242 // for the last pulse, always sleep.
238 // for the virtual live encoder long time publishing. 243 // for the virtual live encoder long time publishing.
239 int64_t now = srs_get_time_ms(); 244 int64_t now = srs_get_time_ms();
240 - int64_t diff = time - (now -re); 245 + int64_t diff = time - starttime - (now -re);
241 if (diff > 0) { 246 if (diff > 0) {
242 - srs_lib_trace("re_cleanup sleep for the last pulse for %d ms", (int)diff); 247 + srs_lib_trace("re_cleanup, diff=%d, start=%d, last=%d ms",
  248 + (int)diff, starttime, time);
243 usleep(diff * 1000); 249 usleep(diff * 1000);
244 } 250 }
245 } 251 }
@@ -1159,7 +1159,7 @@ int __srs_write_h264_sps_pps(Context* context, u_int32_t dts, u_int32_t pts) @@ -1159,7 +1159,7 @@ int __srs_write_h264_sps_pps(Context* context, u_int32_t dts, u_int32_t pts)
1159 1159
1160 // @see: Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205 1160 // @see: Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205
1161 // Baseline profile profile_idc is 66(0x42). 1161 // Baseline profile profile_idc is 66(0x42).
1162 - // Baseline profile profile_idc is 77(0x4d). 1162 + // Main profile profile_idc is 77(0x4d).
1163 // Extended profile profile_idc is 88(0x58). 1163 // Extended profile profile_idc is 88(0x58).
1164 u_int8_t profile_idc = frame[1]; 1164 u_int8_t profile_idc = frame[1];
1165 //u_int8_t constraint_set = frame[2]; 1165 //u_int8_t constraint_set = frame[2];