Agents 1.4.0
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::media Namespace Reference

Media envelope namespace. More...

Functions

bool hasString (const JsonObject &j, const char *key)
 Check if a key exists and is a string.
bool hasObject (const JsonObject &j, const char *key)
 Check if a key exists and is an object.
bool eqType (const JsonObject &j, const char *value)
 Check if a key exists and is a specific type.
bool isKnownType (const std::string &v)
 Check if the media type is known.
bool hasKnownType (const JsonObject &j)
 Check if the media type is known.
bool isMediaPart (const JsonObject &j)
 Quick probe to see if JSONObject looks like a media envelope (canonical or compatible).
JsonObject normalizeMediaPart (JsonObject j)
 Normalize various accepted shapes into the canonical envelope, validating constraints.
std::string getMime (const JsonObject &j)
 Extract MIME type (returns empty string if not present).
bool hasUri (const JsonObject &j)
 Returns true if the envelope carries a URI reference.
bool hasData (const JsonObject &j)
 Returns true if the envelope carries inline base64 data.
std::string mimeFromDataUrl (const std::string &data_url)
 Best-effort parse of a Data URL to extract MIME type (empty if not parsable).
std::optional< JsonObjecttryParseEnvelopeFromString (const std::string &content)
 Parse a string into a media envelope if possible; returns nullopt if not media.
JsonObject text (const std::string &s)
 Create a text media envelope.
JsonObject imageUri (const std::string &uri, const std::string &mime, JsonObject meta={})
 Create an image media envelope.
JsonObject imageData (const std::string &base64, const std::string &mime, JsonObject meta={})
 Create an image media envelope with base64 data.
JsonObject audioUri (const std::string &uri, const std::string &mime, JsonObject meta={})
 Create an audio media envelope.
JsonObject audioData (const std::string &base64, const std::string &mime, JsonObject meta={})
 Create an audio media envelope with base64 data.
JsonObject videoUri (const std::string &uri, const std::string &mime, JsonObject meta={})
 Create a video media envelope.
JsonObject videoData (const std::string &base64, const std::string &mime, JsonObject meta={})
 Create a video media envelope with base64 data.
JsonObject documentUri (const std::string &uri, const std::string &mime, JsonObject meta={})
 Create a document media envelope.
JsonObject documentData (const std::string &base64, const std::string &mime, JsonObject meta={})
 Create a document media envelope with base64 data.

Detailed Description

Media envelope namespace.

Function Documentation

◆ audioData()

JsonObject agents::media::audioData ( const std::string & base64,
const std::string & mime,
JsonObject meta = {} )
inline

Create an audio media envelope with base64 data.

Parameters
base64The base64 data
mimeThe audio MIME type
metaThe audio metadata
Returns
The media envelope

◆ audioUri()

JsonObject agents::media::audioUri ( const std::string & uri,
const std::string & mime,
JsonObject meta = {} )
inline

Create an audio media envelope.

Parameters
uriThe audio URI
mimeThe audio MIME type
metaThe audio metadata
Returns
The media envelope

◆ documentData()

JsonObject agents::media::documentData ( const std::string & base64,
const std::string & mime,
JsonObject meta = {} )
inline

Create a document media envelope with base64 data.

Parameters
base64The base64 data
mimeThe document MIME type
metaThe document metadata
Returns
The media envelope

◆ documentUri()

JsonObject agents::media::documentUri ( const std::string & uri,
const std::string & mime,
JsonObject meta = {} )
inline

Create a document media envelope.

Parameters
uriThe document URI
mimeThe document MIME type
metaThe document metadata
Returns
The media envelope

◆ eqType()

bool agents::media::eqType ( const JsonObject & j,
const char * value )

Check if a key exists and is a specific type.

Parameters
jThe JSON object
keyThe key to check
valueThe type to compare against
Returns
bool true if key exists and is of the specified type, else false

◆ hasKnownType()

bool agents::media::hasKnownType ( const JsonObject & j)

Check if the media type is known.

Parameters
jThe JSON object
Returns
bool true if type is known, else false

◆ hasObject()

bool agents::media::hasObject ( const JsonObject & j,
const char * key )

Check if a key exists and is an object.

Parameters
jThe JSON object
keyThe key to check
Returns
bool true if key exists and is an object, else false

◆ hasString()

bool agents::media::hasString ( const JsonObject & j,
const char * key )

Check if a key exists and is a string.

Parameters
jThe JSON object
keyThe key to check
Returns
bool true if key exists and is a string, else false

◆ imageData()

JsonObject agents::media::imageData ( const std::string & base64,
const std::string & mime,
JsonObject meta = {} )
inline

Create an image media envelope with base64 data.

Parameters
base64The base64 data
mimeThe image MIME type
metaThe image metadata
Returns
The media envelope

◆ imageUri()

JsonObject agents::media::imageUri ( const std::string & uri,
const std::string & mime,
JsonObject meta = {} )
inline

Create an image media envelope.

Parameters
uriThe image URI
mimeThe image MIME type
metaThe image metadata
Returns
The media envelope

◆ isKnownType()

bool agents::media::isKnownType ( const std::string & v)

Check if the media type is known.

Parameters
vThe media type string
Returns
bool true if type is known, else false

◆ normalizeMediaPart()

JsonObject agents::media::normalizeMediaPart ( JsonObject j)

Normalize various accepted shapes into the canonical envelope, validating constraints.

Exceptions
std::invalid_argumentif the input cannot be normalized to a valid envelope

◆ text()

JsonObject agents::media::text ( const std::string & s)
inline

Create a text media envelope.

Media envelope builders

Parameters
sThe text content
Returns
The media envelope

◆ videoData()

JsonObject agents::media::videoData ( const std::string & base64,
const std::string & mime,
JsonObject meta = {} )
inline

Create a video media envelope with base64 data.

Parameters
base64The base64 data
mimeThe video MIME type
metaThe video metadata
Returns
The media envelope

◆ videoUri()

JsonObject agents::media::videoUri ( const std::string & uri,
const std::string & mime,
JsonObject meta = {} )
inline

Create a video media envelope.

Parameters
uriThe video URI
mimeThe video MIME type
metaThe video metadata
Returns
The media envelope