Skip to content

Commit

Permalink
Set default sample rate for all cams
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Jan 6, 2024
1 parent dd58ca5 commit ff514dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/wyzecam/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@


# known 2k cameras
PRO_CAMS = {"HL_CAM3P", "HL_PANP", "HL_CAM4", "HL_DB2"}
PRO_CAMS = {"HL_CAM3P", "HL_PANP", "HL_CAM4", "HL_DB2", "HL_CFL2"}

PAN_CAMS = {"WYZECP1_JEF", "HL_PAN2", "HL_PAN3", "HL_PANP"}

BATTERY_CAMS = {"WVOD1", "HL_WCO2", "AN_RSCW"}

AUDIO_16k = {"WYZE_CAKP2JFUS", "HL_CAM3P", "MODEL_HL_PANP"}
# Doorbells
DOORBELL = {"WYZEDB3", "HL_DB2"}
VERTICAL_CAMS = {"WYZEDB3", "GW_BE1", "AN_RDB1"}
Expand Down Expand Up @@ -160,6 +161,10 @@ def webrtc_support(self) -> bool:
def is_2k(self) -> bool:
return self.product_model in PRO_CAMS or self.model_name.endswith("Pro")

@property
def default_sample_rate(self) -> int:
return 16000 if self.product_model in AUDIO_16k else 8000

@property
def is_gwell(self) -> bool:
return self.product_model.startswith("GW_")
Expand Down
6 changes: 2 additions & 4 deletions app/wyzecam/iotc.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,11 @@ def _audio_frame_slow(self, frame_info) -> Optional[bool]:

def get_audio_sample_rate(self) -> int:
"""Attempt to get the audio sample rate."""
default_rate = 16000 if self.camera.product_model == "WYZE_CAKP2JFUS" else 8000

if self.camera.camera_info and "audioParm" in self.camera.camera_info:
audio_param = self.camera.camera_info["audioParm"]
return int(audio_param.get("sampleRate", default_rate))
return int(audio_param.get("sampleRate", self.camera.default_sample_rate))

return default_rate
return self.camera.default_sample_rate

def get_audio_codec_from_codec_id(self, codec_id: int) -> tuple[str, int]:
sample_rate = self.get_audio_sample_rate()
Expand Down

0 comments on commit ff514dd

Please sign in to comment.