Skip to content

Commit 92ada7c

Browse files
committed
Make audio/stream pure
1 parent ef999f7 commit 92ada7c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from av.packet cimport Packet
1+
import cython
2+
from cython.cimports.av.audio.frame import AudioFrame
3+
from cython.cimports.av.packet import Packet
24

3-
from .frame cimport AudioFrame
45

5-
6-
cdef class AudioStream(Stream):
6+
@cython.cclass
7+
class AudioStream(Stream):
78
def __repr__(self):
89
form = self.format.name if self.format else None
910
return (
@@ -14,7 +15,8 @@ def __repr__(self):
1415
def __getattr__(self, name):
1516
return getattr(self.codec_context, name)
1617

17-
cpdef encode(self, AudioFrame frame=None):
18+
@cython.ccall
19+
def encode(self, frame: AudioFrame | None = None):
1820
"""
1921
Encode an :class:`.AudioFrame` and return a list of :class:`.Packet`.
2022
@@ -24,14 +26,15 @@ def __getattr__(self, name):
2426
"""
2527

2628
packets = self.codec_context.encode(frame)
27-
cdef Packet packet
29+
packet: Packet
2830
for packet in packets:
2931
packet._stream = self
3032
packet.ptr.stream_index = self.ptr.index
3133

3234
return packets
3335

34-
cpdef decode(self, Packet packet=None):
36+
@cython.ccall
37+
def decode(self, packet: Packet | None = None):
3538
"""
3639
Decode a :class:`.Packet` and return a list of :class:`.AudioFrame`.
3740

0 commit comments

Comments
 (0)