@@ -5,15 +5,15 @@ use crate::error::Result;
5
5
use chrono:: prelude:: * ;
6
6
use std:: time:: { Duration , UNIX_EPOCH } ;
7
7
8
- #[ tokio :: test]
9
- async fn test_packetizer ( ) -> Result < ( ) > {
8
+ #[ test]
9
+ fn test_packetizer ( ) -> Result < ( ) > {
10
10
let multiple_payload = Bytes :: from_static ( & [ 0 ; 128 ] ) ;
11
11
let g722 = Box :: new ( g7xx:: G722Payloader { } ) ;
12
12
let seq = Box :: new ( new_random_sequencer ( ) ) ;
13
13
14
14
//use the G722 payloader here, because it's very simple and all 0s is valid G722 data.
15
15
let mut packetizer = new_packetizer ( 100 , 98 , 0x1234ABCD , g722, seq, 90000 ) ;
16
- let packets = packetizer. packetize ( & multiple_payload, 2000 ) . await ?;
16
+ let packets = packetizer. packetize ( & multiple_payload, 2000 ) ?;
17
17
18
18
if packets. len ( ) != 2 {
19
19
let mut packet_lengths = String :: new ( ) ;
@@ -31,22 +31,18 @@ async fn test_packetizer() -> Result<()> {
31
31
Ok ( ( ) )
32
32
}
33
33
34
- #[ tokio :: test]
35
- async fn test_packetizer_abs_send_time ( ) -> Result < ( ) > {
34
+ #[ test]
35
+ fn test_packetizer_abs_send_time ( ) -> Result < ( ) > {
36
36
let g722 = Box :: new ( g7xx:: G722Payloader { } ) ;
37
37
let sequencer = Box :: new ( new_fixed_sequencer ( 1234 ) ) ;
38
38
39
- let time_gen: Option < FnTimeGen > = Some ( Arc :: new (
40
- || -> Pin < Box < dyn Future < Output = SystemTime > + Send + ' static > > {
41
- Box :: pin ( async move {
42
- let loc = FixedOffset :: west_opt ( 5 * 60 * 60 ) . unwrap ( ) ; // UTC-5
43
- let t = loc. with_ymd_and_hms ( 1985 , 6 , 23 , 4 , 0 , 0 ) . unwrap ( ) ;
44
- UNIX_EPOCH
45
- . checked_add ( Duration :: from_nanos ( t. timestamp_nanos ( ) as u64 ) )
46
- . unwrap_or ( UNIX_EPOCH )
47
- } )
48
- } ,
49
- ) ) ;
39
+ let time_gen: Option < FnTimeGen > = Some ( Arc :: new ( || -> SystemTime {
40
+ let loc = FixedOffset :: west_opt ( 5 * 60 * 60 ) . unwrap ( ) ; // UTC-5
41
+ let t = loc. with_ymd_and_hms ( 1985 , 6 , 23 , 4 , 0 , 0 ) . unwrap ( ) ;
42
+ UNIX_EPOCH
43
+ . checked_add ( Duration :: from_nanos ( t. timestamp_nanos ( ) as u64 ) )
44
+ . unwrap_or ( UNIX_EPOCH )
45
+ } ) ) ;
50
46
51
47
//use the G722 payloader here, because it's very simple and all 0s is valid G722 data.
52
48
let mut pktizer = PacketizerImpl {
@@ -63,7 +59,7 @@ async fn test_packetizer_abs_send_time() -> Result<()> {
63
59
pktizer. enable_abs_send_time ( 1 ) ;
64
60
65
61
let payload = Bytes :: from_static ( & [ 0x11 , 0x12 , 0x13 , 0x14 ] ) ;
66
- let packets = pktizer. packetize ( & payload, 2000 ) . await ?;
62
+ let packets = pktizer. packetize ( & payload, 2000 ) ?;
67
63
68
64
let expected = Packet {
69
65
header : Header {
@@ -94,17 +90,17 @@ async fn test_packetizer_abs_send_time() -> Result<()> {
94
90
Ok ( ( ) )
95
91
}
96
92
97
- #[ tokio :: test]
98
- async fn test_packetizer_timestamp_rollover_does_not_panic ( ) -> Result < ( ) > {
93
+ #[ test]
94
+ fn test_packetizer_timestamp_rollover_does_not_panic ( ) -> Result < ( ) > {
99
95
let g722 = Box :: new ( g7xx:: G722Payloader { } ) ;
100
96
let seq = Box :: new ( new_random_sequencer ( ) ) ;
101
97
102
98
let payload = Bytes :: from_static ( & [ 0 ; 128 ] ) ;
103
99
let mut packetizer = new_packetizer ( 100 , 98 , 0x1234ABCD , g722, seq, 90000 ) ;
104
100
105
- packetizer. packetize ( & payload, 10 ) . await ?;
101
+ packetizer. packetize ( & payload, 10 ) ?;
106
102
107
- packetizer. packetize ( & payload, u32:: MAX ) . await ?;
103
+ packetizer. packetize ( & payload, u32:: MAX ) ?;
108
104
109
105
packetizer. skip_samples ( u32:: MAX ) ;
110
106
0 commit comments