@@ -490,6 +490,13 @@ ngx_rtmp_play_seek(ngx_rtmp_session_t *s, ngx_rtmp_seek_t *v)
490
490
goto next ;
491
491
}
492
492
493
+ if (!ctx -> opened ) {
494
+ ctx -> post_seek = v -> offset ;
495
+ ngx_log_debug1 (NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
496
+ "play: post seek=%ui" , ctx -> post_seek );
497
+ goto next ;
498
+ }
499
+
493
500
if (ngx_rtmp_send_stream_eof (s , NGX_RTMP_MSID ) != NGX_OK ) {
494
501
return NGX_ERROR ;
495
502
}
@@ -522,6 +529,12 @@ ngx_rtmp_play_pause(ngx_rtmp_session_t *s, ngx_rtmp_pause_t *v)
522
529
goto next ;
523
530
}
524
531
532
+ if (!ctx -> opened ) {
533
+ ngx_log_debug0 (NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
534
+ "play: pause ignored" );
535
+ goto next ;
536
+ }
537
+
525
538
ngx_log_debug2 (NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
526
539
"play: pause=%i timestamp=%f" ,
527
540
(ngx_int_t ) v -> pause , v -> position );
@@ -676,6 +689,7 @@ ngx_rtmp_play_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
676
689
677
690
ctx -> file .fd = NGX_INVALID_FILE ;
678
691
ctx -> nentry = NGX_CONF_UNSET_UINT ;
692
+ ctx -> post_seek = NGX_CONF_UNSET_UINT ;
679
693
680
694
sfx = & ctx -> fmt -> sfx ;
681
695
@@ -780,6 +794,7 @@ ngx_rtmp_play_open(ngx_rtmp_session_t *s, double start)
780
794
{
781
795
ngx_rtmp_play_ctx_t * ctx ;
782
796
ngx_event_t * e ;
797
+ ngx_uint_t timestamp ;
783
798
784
799
ctx = ngx_rtmp_get_module_ctx (s , ngx_rtmp_play_module );
785
800
@@ -809,14 +824,19 @@ ngx_rtmp_play_open(ngx_rtmp_session_t *s, double start)
809
824
return NGX_ERROR ;
810
825
}
811
826
812
- if (ngx_rtmp_play_do_seek (s , start < 0 ? 0 : start ) != NGX_OK ) {
827
+ timestamp = ctx -> post_seek != NGX_CONF_UNSET_UINT ? ctx -> post_seek :
828
+ (start < 0 ? 0 : (ngx_uint_t ) start );
829
+
830
+ if (ngx_rtmp_play_do_seek (s , timestamp ) != NGX_OK ) {
813
831
return NGX_ERROR ;
814
832
}
815
833
816
834
if (ngx_rtmp_play_do_start (s ) != NGX_OK ) {
817
835
return NGX_ERROR ;
818
836
}
819
837
838
+ ctx -> opened = 1 ;
839
+
820
840
return NGX_OK ;
821
841
}
822
842
0 commit comments