55
66
77class RTStreamSceneIndex :
8+ """RTStreamSceneIndex class to interact with the rtstream scene index
9+
10+ :ivar str rtstream_index_id: Unique identifier for the rtstream scene index
11+ :ivar str rtstream_id: ID of the rtstream this scene index belongs to
12+ :ivar str extraction_type: Type of extraction
13+ :ivar dict extraction_config: Configuration for extraction
14+ :ivar str prompt: Prompt for scene extraction
15+ :ivar str name: Name of the scene index
16+ :ivar str status: Status of the scene index
17+ """
18+
819 def __init__ (
920 self , _connection , rtstream_index_id : str , rtstream_id , ** kwargs
1021 ) -> None :
@@ -21,6 +32,7 @@ def __repr__(self) -> str:
2132 return (
2233 f"RTStreamSceneIndex("
2334 f"rtstream_index_id={ self .rtstream_index_id } , "
35+ f"rtstream_id={ self .rtstream_id } , "
2436 f"extraction_type={ self .extraction_type } , "
2537 f"extraction_config={ self .extraction_config } , "
2638 f"prompt={ self .prompt } , "
@@ -29,6 +41,15 @@ def __repr__(self) -> str:
2941 )
3042
3143 def get_scenes (self , start : int = None , end : int = None , page = 1 , page_size = 100 ):
44+ """Get rtstream scene index scenes.
45+
46+ :param int start: Start time of the scenes
47+ :param int end: End time of the scenes
48+ :param int page: Page number
49+ :param int page_size: Number of scenes per page
50+ :return: List of scenes
51+ :rtype: List[dict]
52+ """
3253 params = {"page" : page , "page_size" : page_size }
3354 if start and end :
3455 params ["start" ] = start
@@ -46,20 +67,37 @@ def get_scenes(self, start: int = None, end: int = None, page=1, page_size=100):
4667 }
4768
4869 def start (self ):
70+ """Start the scene index.
71+
72+ :return: None
73+ :rtype: None
74+ """
4975 self ._connection .patch (
5076 f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ ApiPath .scene } /{ self .rtstream_index_id } /{ ApiPath .status } " ,
5177 data = {"action" : "start" },
5278 )
5379 self .status = "connected"
5480
5581 def stop (self ):
82+ """Stop the scene index.
83+
84+ :return: None
85+ :rtype: None
86+ """
5687 self ._connection .patch (
5788 f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ ApiPath .scene } /{ self .rtstream_index_id } /{ ApiPath .status } " ,
5889 data = {"action" : "stop" },
5990 )
6091 self .status = "stopped"
6192
6293 def create_alert (self , event_id , callback_url ) -> str :
94+ """Create an event alert.
95+
96+ :param str event_id: ID of the event
97+ :param str callback_url: URL to receive the alert callback
98+ :return: Alert ID
99+ :rtype: str
100+ """
63101 alert_data = self ._connection .post (
64102 f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } " ,
65103 data = {
@@ -70,25 +108,52 @@ def create_alert(self, event_id, callback_url) -> str:
70108 return alert_data .get ("alert_id" , None )
71109
72110 def list_alerts (self ):
111+ """List all alerts for the rtstream scene index.
112+
113+ :return: List of alerts
114+ :rtype: List[dict]
115+ """
73116 alert_data = self ._connection .get (
74117 f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } "
75118 )
76119 return alert_data .get ("alerts" , [])
77120
78121 def enable_alert (self , alert_id ):
122+ """Enable an alert.
123+
124+ :param str alert_id: ID of the alert
125+ :return: None
126+ :rtype: None
127+ """
79128 self ._connection .patch (
80129 f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } /{ alert_id } /{ ApiPath .status } " ,
81130 data = {"action" : "enable" },
82131 )
83132
84133 def disable_alert (self , alert_id ):
134+ """Disable an alert.
135+
136+ :param str alert_id: ID of the alert
137+ :return: None
138+ :rtype: None
139+ """
85140 self ._connection .patch (
86141 f"{ ApiPath .rtstream } /{ self .rtstream_id } /{ ApiPath .index } /{ self .rtstream_index_id } /{ ApiPath .alert } /{ alert_id } /{ ApiPath .status } " ,
87142 data = {"action" : "disable" },
88143 )
89144
90145
91146class RTStream :
147+ """RTStream class to interact with the RTStream
148+
149+ :ivar str id: Unique identifier for the rtstream
150+ :ivar str name: Name of the rtstream
151+ :ivar str collection_id: ID of the collection this rtstream belongs to
152+ :ivar str created_at: Timestamp of the rtstream creation
153+ :ivar int sample_rate: Sample rate of the rtstream
154+ :ivar str status: Status of the rtstream
155+ """
156+
92157 def __init__ (self , _connection , id : str , ** kwargs ) -> None :
93158 self ._connection = _connection
94159 self .id = id
@@ -110,20 +175,37 @@ def __repr__(self) -> str:
110175 )
111176
112177 def start (self ):
178+ """Connect to the rtstream.
179+
180+ :return: None
181+ :rtype: None
182+ """
113183 self ._connection .patch (
114184 f"{ ApiPath .rtstream } /{ self .id } /{ ApiPath .status } " ,
115185 data = {"action" : "start" },
116186 )
117187 self .status = "connected"
118188
119189 def stop (self ):
190+ """Disconnect from the rtstream.
191+
192+ :return: None
193+ :rtype: None
194+ """
120195 self ._connection .patch (
121196 f"{ ApiPath .rtstream } /{ self .id } /{ ApiPath .status } " ,
122197 data = {"action" : "stop" },
123198 )
124199 self .status = "stopped"
125200
126201 def generate_stream (self , start , end ):
202+ """Generate a stream from the rtstream.
203+
204+ :param int start: Start time of the stream
205+ :param int end: End time of the stream
206+ :return: Stream URL
207+ :rtype: str
208+ """
127209 stream_data = self ._connection .get (
128210 f"{ ApiPath .rtstream } /{ self .id } /{ ApiPath .stream } " ,
129211 params = {"start" : start , "end" : end },
@@ -139,6 +221,17 @@ def index_scenes(
139221 model_config = {},
140222 name = None ,
141223 ):
224+ """Index scenes from the rtstream.
225+
226+ :param str extraction_type: Type of extraction
227+ :param dict extraction_config: Configuration for extraction
228+ :param str prompt: Prompt for scene extraction
229+ :param str model_name: Name of the model
230+ :param dict model_config: Configuration for the model
231+ :param str name: Name of the scene index
232+ :return: Scene index, :class:`RTStreamSceneIndex <RTStreamSceneIndex>` object
233+ :rtype: :class:`videodb.rtstream.RTStreamSceneIndex`
234+ """
142235 index_data = self ._connection .post (
143236 f"{ ApiPath .rtstream } /{ self .id } /{ ApiPath .index } /{ ApiPath .scene } " ,
144237 data = {
@@ -164,6 +257,11 @@ def index_scenes(
164257 )
165258
166259 def list_scene_indexes (self ):
260+ """List all scene indexes for the rtstream.
261+
262+ :return: List of :class:`RTStreamSceneIndex <RTStreamSceneIndex>` objects
263+ :rtype: List[:class:`videodb.rtstream.RTStreamSceneIndex`]
264+ """
167265 index_data = self ._connection .get (
168266 f"{ ApiPath .rtstream } /{ self .id } /{ ApiPath .index } /{ ApiPath .scene } "
169267 )
@@ -182,6 +280,12 @@ def list_scene_indexes(self):
182280 ]
183281
184282 def get_scene_index (self , index_id : str ) -> RTStreamSceneIndex :
283+ """Get a scene index by its ID.
284+
285+ :param str index_id: ID of the scene index
286+ :return: Scene index, :class:`RTStreamSceneIndex <RTStreamSceneIndex>` object
287+ :rtype: :class:`videodb.rtstream.RTStreamSceneIndex`
288+ """
185289 index_data = self ._connection .get (
186290 f"{ ApiPath .rtstream } /{ self .id } /{ ApiPath .index } /{ index_id } "
187291 )
0 commit comments