Class: SafetyKit::Resources::Streams
- Inherits:
-
Object
- Object
- SafetyKit::Resources::Streams
- Defined in:
- lib/safety_kit/resources/streams.rb
Overview
Ingest and monitor livestream content.
Instance Method Summary collapse
-
#add(namespace, id:, stream_url:, request_options: {}) ⇒ SafetyKit::Models::StreamAddResponse
Monitor the livestream at the given stream URL.
-
#add_frame(namespace, image_data_uri:, stream_id:, timestamp:, request_options: {}) ⇒ SafetyKit::Models::StreamAddFrameResponse
Some parameter documentations has been truncated, see Models::StreamAddFrameParams for more details.
-
#add_transcript(namespace, stream_id:, text:, timestamp:, request_options: {}) ⇒ SafetyKit::Models::StreamAddTranscriptResponse
Ingest a single transcript segment for a livestream using a relative timestamp in milliseconds.
-
#initialize(client:) ⇒ Streams
constructor
private
A new instance of Streams.
Constructor Details
#initialize(client:) ⇒ Streams
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Streams.
108 109 110 |
# File 'lib/safety_kit/resources/streams.rb', line 108 def initialize(client:) @client = client end |
Instance Method Details
#add(namespace, id:, stream_url:, request_options: {}) ⇒ SafetyKit::Models::StreamAddResponse
Monitor the livestream at the given stream URL. This method returns immediately.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/safety_kit/resources/streams.rb', line 22 def add(namespace, params) parsed, = SafetyKit::StreamAddParams.dump_request(params) @client.request( method: :post, path: ["v1/streams/%1$s", namespace], body: parsed, model: SafetyKit::Models::StreamAddResponse, options: ) end |
#add_frame(namespace, image_data_uri:, stream_id:, timestamp:, request_options: {}) ⇒ SafetyKit::Models::StreamAddFrameResponse
Some parameter documentations has been truncated, see Models::StreamAddFrameParams for more details.
Ingest a single livestream frame as an image data URI plus relative timestamp in milliseconds. The stream does not need to be created beforehand. Only image/jpeg, image/png, and image/webp are accepted. The decoded bytes must match the declared mime type, decode as a valid image, stay within 5 MB, and stay within 4096x4096 / 16,000,000 total pixels. Timestamps are relative milliseconds from stream start and must be unique and strictly increasing within a stream. Duplicate or out-of-order frame timestamps are accepted at the API boundary but ignored by downstream processing. This method returns immediately after the frame has been accepted for processing.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/safety_kit/resources/streams.rb', line 61 def add_frame(namespace, params) parsed, = SafetyKit::StreamAddFrameParams.dump_request(params) @client.request( method: :post, path: ["v1/streams/%1$s/frames", namespace], body: parsed, model: SafetyKit::Models::StreamAddFrameResponse, options: ) end |
#add_transcript(namespace, stream_id:, text:, timestamp:, request_options: {}) ⇒ SafetyKit::Models::StreamAddTranscriptResponse
Ingest a single transcript segment for a livestream using a relative timestamp in milliseconds. The stream does not need to be created beforehand. Transcript timestamps are relative milliseconds from stream start and should be monotonically increasing within a stream so transcript context lines up correctly with later frames. This method returns immediately after the transcript has been accepted for processing.
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/safety_kit/resources/streams.rb', line 94 def add_transcript(namespace, params) parsed, = SafetyKit::StreamAddTranscriptParams.dump_request(params) @client.request( method: :post, path: ["v1/streams/%1$s/transcripts", namespace], body: parsed, model: SafetyKit::Models::StreamAddTranscriptResponse, options: ) end |