mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-11-24 12:25:20 +01:00
Add sample_bytes to media player supported format and a test (#955)
This commit is contained in:
parent
5a120d7293
commit
a2a0bbfb4b
@ -1145,6 +1145,7 @@ message MediaPlayerSupportedFormat {
|
||||
uint32 sample_rate = 2;
|
||||
uint32 num_channels = 3;
|
||||
MediaPlayerFormatPurpose purpose = 4;
|
||||
uint32 sample_bytes = 5;
|
||||
}
|
||||
message ListEntitiesMediaPlayerResponse {
|
||||
option (id) = 63;
|
||||
|
File diff suppressed because one or more lines are too long
@ -835,6 +835,7 @@ class MediaPlayerSupportedFormat(APIModelBase):
|
||||
default=MediaPlayerFormatPurpose.DEFAULT,
|
||||
converter=MediaPlayerFormatPurpose.convert,
|
||||
)
|
||||
sample_bytes: int = 0
|
||||
|
||||
@classmethod
|
||||
def convert_list(cls, value: list[Any]) -> list[MediaPlayerSupportedFormat]:
|
||||
|
@ -45,6 +45,7 @@ from aioesphomeapi.api_pb2 import (
|
||||
ListEntitiesValveResponse,
|
||||
LockStateResponse,
|
||||
MediaPlayerStateResponse,
|
||||
MediaPlayerSupportedFormat,
|
||||
NumberStateResponse,
|
||||
SelectStateResponse,
|
||||
SensorStateResponse,
|
||||
@ -651,3 +652,32 @@ async def test_bluetooth_gatt_services_from_dict() -> None:
|
||||
assert BluetoothGATTDescriptorModel.from_dict(
|
||||
{"uuid": [1, 3], "handle": 3},
|
||||
) == BluetoothGATTDescriptorModel(uuid=[1, 3], handle=3)
|
||||
|
||||
|
||||
def test_media_player_supported_format_convert_list() -> None:
|
||||
"""Test list conversion for MediaPlayerSupportedFormat."""
|
||||
assert MediaPlayerInfo.from_dict(
|
||||
{
|
||||
"supports_pause": False,
|
||||
"supported_formats": [
|
||||
{
|
||||
"format": "flac",
|
||||
"sample_rate": 48000,
|
||||
"num_channels": 2,
|
||||
"purpose": 1,
|
||||
"sample_bytes": 2,
|
||||
}
|
||||
],
|
||||
}
|
||||
) == MediaPlayerInfo(
|
||||
supports_pause=False,
|
||||
supported_formats=[
|
||||
MediaPlayerSupportedFormat(
|
||||
format="flac",
|
||||
sample_rate=48000,
|
||||
num_channels=2,
|
||||
purpose=1,
|
||||
sample_bytes=2,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user