streaming.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # streaming.py/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro).
  2. # This copyright was auto-generated on Thu May 15 16:57:28 UTC 2025
  3. """Streaming models and entities."""
  4. import enum
  5. from dataclasses import dataclass
  6. from pathlib import Path
  7. from pydantic import Field
  8. from open_gopro.domain.enum import GoProEnum, GoProIntEnum
  9. from open_gopro.models.bases import CustomBaseModel
  10. from open_gopro.models.general import SupportedOption
  11. from open_gopro.models.proto import EnumLens, EnumWindowSize
  12. class StreamType(enum.Enum):
  13. """Enum for the different types of streams."""
  14. WEBCAM = enum.auto()
  15. LIVE = enum.auto()
  16. PREVIEW = enum.auto()
  17. class WebcamResolution(GoProIntEnum):
  18. """Possible Webcam Resolutions"""
  19. NOT_APPLICABLE = 0
  20. RES_480 = 4
  21. RES_720 = 7
  22. RES_1080 = 12
  23. class WebcamFOV(GoProIntEnum):
  24. """Possible Webcam FOVs"""
  25. WIDE = 0
  26. NARROW = 2
  27. SUPERVIEW = 3
  28. LINEAR = 4
  29. class WebcamProtocol(GoProEnum):
  30. """Possible Webcam Protocols"""
  31. TS = "TS"
  32. RTSP = "RTSP"
  33. class WebcamStatus(GoProIntEnum):
  34. """Webcam Statuses / states"""
  35. OFF = 0
  36. IDLE = 1
  37. HIGH_POWER_PREVIEW = 2
  38. LOW_POWER_PREVIEW = 3
  39. class WebcamError(GoProIntEnum):
  40. """Errors common among Webcam commands"""
  41. SUCCESS = 0
  42. SET_PRESET = 1
  43. SET_WINDOW_SIZE = 2
  44. EXEC_STREAM = 3
  45. SHUTTER = 4
  46. COM_TIMEOUT = 5
  47. INVALID_PARAM = 6
  48. UNAVAILABLE = 7
  49. EXIT = 8
  50. class WebcamResponse(CustomBaseModel):
  51. """Common Response from Webcam Commands"""
  52. status: WebcamStatus | None = Field(default=None)
  53. error: WebcamError
  54. setting_id: str | None = Field(default=None)
  55. supported_options: list[SupportedOption] | None = Field(default=None)
  56. @dataclass
  57. class LivestreamOptions:
  58. """Livestream-specific stream setup options"""
  59. url: str
  60. minimum_bitrate: int = 1000
  61. maximum_bitrate: int = 1000
  62. starting_bitrate: int = 1000
  63. encode: bool = True
  64. resolution: EnumWindowSize.ValueType | None = None
  65. fov: EnumLens.ValueType | None = None
  66. certs: list[Path] | None = None
  67. @dataclass
  68. class PreviewStreamOptions:
  69. """Preview stream-specific stream setup options"""
  70. port: int | None = None
  71. @dataclass
  72. class WebcamStreamOptions:
  73. """Webcam stream-specific stream setup options"""
  74. resolution: WebcamResolution | None = None
  75. protocol: WebcamProtocol | None = None
  76. fov: WebcamFOV | None = None
  77. port: int | None = None