Skip to content

Commit 2d6007a

Browse files
committed
plugins - added is_empty() to accompany video_bytes() or audio_bytes()
1 parent 0d9d6d1 commit 2d6007a

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/ffmpegio/plugins/hookspecs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,13 @@ def device_sink_api() -> tuple[str, dict[str, Callable]]:
132132
133133
Partial definition is OK
134134
"""
135+
...
136+
137+
138+
@hookspec(firstresult=True)
139+
def is_empty(obj: object) -> bool:
140+
"""True if data blob object has no data
141+
142+
:param obj: object containing media data
143+
"""
144+
...

src/ffmpegio/plugins/rawdata_bytes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,12 @@ def bytes_to_audio(
172172
}
173173
except:
174174
return None
175+
176+
177+
@hookimpl
178+
def is_empty(obj: BytesRawDataBlob) -> bool:
179+
"""True if data blob object has no data
180+
181+
:param obj: object containing media data
182+
"""
183+
return not bool(obj["buffer"])

src/ffmpegio/plugins/rawdata_mpl.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,12 @@ def video_bytes(obj: Figure) -> memoryview:
4343
return io_buf.getvalue()
4444
except:
4545
None
46+
47+
48+
@hookimpl
49+
def is_empty(obj: Figure) -> bool:
50+
"""True if data blob object has no data
51+
52+
:param obj: object containing media data
53+
"""
54+
return False

src/ffmpegio/plugins/rawdata_numpy.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,12 @@ def bytes_to_audio(
147147
return x.squeeze() if squeeze else x
148148
except:
149149
return None
150+
151+
152+
@hookimpl
153+
def is_empty(obj: bytes) -> bool:
154+
"""True if data blob object has no data
155+
156+
:param obj: object containing media data
157+
"""
158+
return not bool(obj)

0 commit comments

Comments
 (0)