11use {
2- super :: { define:: FlvDemuxerData , errors:: MediaError , m3u8:: M3u8 } ,
3- bytes:: BytesMut ,
4- xflv:: {
2+ super :: { define:: FlvDemuxerData , errors:: MediaError , m3u8:: M3u8 } , bytes:: BytesMut , config:: HlsConfig , xflv:: {
53 define:: { frame_type, FlvData } ,
64 demuxer:: { FlvAudioTagDemuxer , FlvVideoTagDemuxer } ,
75 } ,
86 streamhub:: { define:: { StreamHubEventSender , StreamHubEvent } , stream:: StreamIdentifier } ,
97 xmpegts:: {
108 define:: { epsi_stream_type, MPEG_FLAG_IDR_FRAME } ,
119 ts:: TsMuxer ,
12- } ,
10+ }
1311} ;
1412
1513pub struct Flv2HlsRemuxer {
@@ -40,13 +38,10 @@ pub struct Flv2HlsRemuxer {
4038
4139impl Flv2HlsRemuxer {
4240 pub fn new (
43- duration : i64 ,
4441 app_name : String ,
4542 stream_name : String ,
46- need_record : bool ,
43+ hls_config : Option < HlsConfig > ,
4744 event_producer : Option < StreamHubEventSender > ,
48- path : String ,
49- aof_ratio : i64 ,
5045 ) -> Self {
5146 let mut ts_muxer = TsMuxer :: new ( ) ;
5247 let audio_pid = ts_muxer
@@ -55,7 +50,17 @@ impl Flv2HlsRemuxer {
5550 let video_pid = ts_muxer
5651 . add_stream ( epsi_stream_type:: PSI_STREAM_H264 , BytesMut :: new ( ) )
5752 . unwrap ( ) ;
58-
53+
54+ let duration = hls_config
55+ . as_ref ( )
56+ . and_then ( |config| config. fragment )
57+ . unwrap_or ( 5 ) ;
58+
59+ let aof_ratio = hls_config
60+ . as_ref ( )
61+ . and_then ( |config| config. aof_ratio )
62+ . unwrap_or ( 5 ) ;
63+
5964 Self {
6065 video_demuxer : FlvVideoTagDemuxer :: new ( ) ,
6166 audio_demuxer : FlvAudioTagDemuxer :: new ( ) ,
@@ -74,7 +79,7 @@ impl Flv2HlsRemuxer {
7479 video_pid,
7580 audio_pid,
7681
77- m3u8_handler : M3u8 :: new ( duration, 6 , app_name. clone ( ) , stream_name. clone ( ) , need_record , path ) ,
82+ m3u8_handler : M3u8 :: new ( duration, app_name. clone ( ) , stream_name. clone ( ) , hls_config ) ,
7883 event_producer,
7984 app_name,
8085 stream_name,
0 commit comments