2018-09-26 09:49:55 +02:00
|
|
|
"""Collection of helper methods.
|
|
|
|
|
|
|
|
All containing methods are legacy helpers that should not be used by new
|
|
|
|
components. Instead call the service directly.
|
|
|
|
"""
|
2024-03-08 14:50:25 +01:00
|
|
|
|
2021-08-10 19:33:06 -05:00
|
|
|
from unittest.mock import Mock
|
|
|
|
|
|
|
|
EMPTY_8_6_JPEG = b"empty_8_6"
|
2022-02-08 14:32:02 -08:00
|
|
|
WEBRTC_ANSWER = "a=sendonly"
|
2021-08-10 19:33:06 -05:00
|
|
|
|
2018-09-26 09:49:55 +02:00
|
|
|
|
2021-08-10 19:33:06 -05:00
|
|
|
def mock_turbo_jpeg(
|
|
|
|
first_width=None, second_width=None, first_height=None, second_height=None
|
|
|
|
):
|
|
|
|
"""Mock a TurboJPEG instance."""
|
|
|
|
mocked_turbo_jpeg = Mock()
|
|
|
|
mocked_turbo_jpeg.decode_header.side_effect = [
|
|
|
|
(first_width, first_height, 0, 0),
|
|
|
|
(second_width, second_height, 0, 0),
|
|
|
|
]
|
|
|
|
mocked_turbo_jpeg.scale_with_quality.return_value = EMPTY_8_6_JPEG
|
2021-12-23 00:24:53 +08:00
|
|
|
mocked_turbo_jpeg.encode.return_value = EMPTY_8_6_JPEG
|
2021-08-10 19:33:06 -05:00
|
|
|
return mocked_turbo_jpeg
|