1
1
use std:: {
2
+ collections:: VecDeque ,
2
3
fs:: File ,
3
4
io:: { BufWriter , Seek , SeekFrom , Write } ,
4
5
num:: NonZeroU32 ,
@@ -17,11 +18,12 @@ use shiguredo_mp4::{
17
18
} ;
18
19
19
20
use crate :: {
20
- audio:: { AudioData , AudioDataReceiver } ,
21
+ audio:: AudioData ,
21
22
layout:: { Layout , Resolution } ,
23
+ media:: MediaStreamId ,
22
24
mixer_audio:: MIXED_AUDIO_DATA_DURATION ,
23
25
stats:: { Mp4WriterStats , Seconds } ,
24
- video:: { VideoFrame , VideoFrameReceiver } ,
26
+ video:: VideoFrame ,
25
27
} ;
26
28
27
29
// Hisui では出力 MP4 のタイムスケールはマイクロ秒固定にする
@@ -42,8 +44,10 @@ pub struct Mp4Writer {
42
44
video_chunks : Vec < Chunk > ,
43
45
audio_sample_entry : Option < SampleEntry > ,
44
46
video_sample_entry : Option < SampleEntry > ,
45
- input_audio_rx : Option < AudioDataReceiver > ,
46
- input_video_rx : Option < VideoFrameReceiver > ,
47
+ input_audio_stream_id : Option < MediaStreamId > ,
48
+ input_video_stream_id : Option < MediaStreamId > ,
49
+ input_audio_queue : VecDeque < AudioData > ,
50
+ input_video_queue : VecDeque < VideoFrame > ,
47
51
finalize_time : Mp4FileTime ,
48
52
appending_video_chunk : bool ,
49
53
stats : Mp4WriterStats ,
@@ -54,8 +58,8 @@ impl Mp4Writer {
54
58
pub fn new < P : AsRef < Path > > (
55
59
path : P ,
56
60
layout : & Layout ,
57
- input_audio_rx : AudioDataReceiver ,
58
- input_video_rx : VideoFrameReceiver ,
61
+ input_audio_stream_id : Option < MediaStreamId > ,
62
+ input_video_stream_id : Option < MediaStreamId > ,
59
63
) -> orfail:: Result < Self > {
60
64
let file = std:: fs:: OpenOptions :: new ( )
61
65
. create ( true )
@@ -74,8 +78,10 @@ impl Mp4Writer {
74
78
audio_sample_entry : None ,
75
79
video_sample_entry : None ,
76
80
finalize_time : Mp4FileTime :: from_unix_time ( Duration :: ZERO ) ,
77
- input_audio_rx : layout. has_audio ( ) . then_some ( input_audio_rx) ,
78
- input_video_rx : layout. has_video ( ) . then_some ( input_video_rx) ,
81
+ input_audio_stream_id,
82
+ input_video_stream_id,
83
+ input_audio_queue : VecDeque :: new ( ) ,
84
+ input_video_queeu : VecDeque :: new ( ) ,
79
85
appending_video_chunk : true ,
80
86
stats : Mp4WriterStats :: default ( ) ,
81
87
} ;
0 commit comments