winlin

for #151, #268, refine the pcr start at 0, dts/pts plus delay. 1.0.25

@@ -240,7 +240,7 @@ public: @@ -240,7 +240,7 @@ public:
240 *p++ = 7; // size 240 *p++ = 7; // size
241 *p++ = 0x50; // random access + PCR 241 *p++ = 0x50; // random access + PCR
242 // about the pcr, read https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-71352511 242 // about the pcr, read https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-71352511
243 - p = write_pcr(p, frame->dts - SRS_AUTO_HLS_DELAY); 243 + p = write_pcr(p, frame->dts);
244 } 244 }
245 245
246 // PES header 246 // PES header
@@ -296,11 +296,11 @@ public: @@ -296,11 +296,11 @@ public:
296 *p++ = header_size; 296 *p++ = header_size;
297 297
298 // pts; // 33bits 298 // pts; // 33bits
299 - p = write_pts(p, flags >> 6, frame->pts); 299 + p = write_pts(p, flags >> 6, frame->pts + SRS_AUTO_HLS_DELAY);
300 300
301 // dts; // 33bits 301 // dts; // 33bits
302 if (frame->dts != frame->pts) { 302 if (frame->dts != frame->pts) {
303 - p = write_pts(p, 1, frame->dts); 303 + p = write_pts(p, 1, frame->dts + SRS_AUTO_HLS_DELAY);
304 } 304 }
305 } 305 }
306 306
@@ -371,10 +371,12 @@ private: @@ -371,10 +371,12 @@ private:
371 } 371 }
372 static char* write_pcr(char* p, int64_t pcr) 372 static char* write_pcr(char* p, int64_t pcr)
373 { 373 {
374 - // the pcr=dts-delay  
375 - // and the pcr maybe negative 374 + // the pcr=dts-delay, where dts = frame->dts + delay
  375 + // and the pcr should never be negative
376 // @see https://github.com/winlinvip/simple-rtmp-server/issues/268 376 // @see https://github.com/winlinvip/simple-rtmp-server/issues/268
377 - int64_t v = srs_max(0, pcr); 377 + srs_assert(pcr >= 0);
  378 +
  379 + int64_t v = pcr;
378 380
379 *p++ = (char) (v >> 25); 381 *p++ = (char) (v >> 25);
380 *p++ = (char) (v >> 17); 382 *p++ = (char) (v >> 17);
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 1 32 #define VERSION_MAJOR 1
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 24 34 +#define VERSION_REVISION 25
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"