Asterisk - The Open Source Telephony Project GIT-master-66c01d8
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Data Structures | Macros | Enumerations | Functions
Stasis topics, and their messages.

This group contains the topics, messages and corresponding message types found within Asterisk. More...

Data Structures

struct  ast_channel_blob
 Blob of data associated with a channel. More...
 
struct  ast_channel_snapshot
 Structure representing a snapshot of channel state. More...
 
struct  ast_channel_snapshot_base
 Structure containing base information for a channel snapshot. More...
 
struct  ast_channel_snapshot_bridge
 Structure containing bridge information for a channel snapshot. More...
 
struct  ast_channel_snapshot_caller
 Structure containing caller information for a channel snapshot. More...
 
struct  ast_channel_snapshot_connected
 Structure containing connected information for a channel snapshot. More...
 
struct  ast_channel_snapshot_dialplan
 Structure containing dialplan information for a channel snapshot. More...
 
struct  ast_channel_snapshot_hangup
 Structure containing hangup information for a channel snapshot. More...
 
struct  ast_channel_snapshot_peer
 Structure containing peer information for a channel snapshot. More...
 
struct  ast_channel_snapshot_update
 Structure representing a change of snapshot of channel state. More...
 
struct  ast_endpoint_blob
 Blob of data associated with an endpoint. More...
 
struct  ast_endpoint_snapshot
 A snapshot of an endpoint's state. More...
 
struct  stasis_cache_update
 Cache update message. More...
 
struct  stasis_subscription_change
 Holds details about changes to subscriptions for the specified topic. More...
 

Macros

#define STASIS_UMOS_MAX   (STASIS_UMOS_ENDPOINT + 1)
 Number of snapshot types. More...
 

Enumerations

enum  ast_channel_snapshot_segment_invalidation {
  AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE = (1 << 1) , AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN = (1 << 2) , AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED = (1 << 3) , AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER = (1 << 4) ,
  AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP = (1 << 5) , AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER = (1 << 6) , AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE = (1 << 7)
}
 Channel snapshot invalidation flags, used to force generation of segments. More...
 
enum  stasis_user_multi_object_snapshot_type { STASIS_UMOS_CHANNEL = 0 , STASIS_UMOS_BRIDGE , STASIS_UMOS_ENDPOINT }
 Object type code for multi user object snapshots. More...
 

Functions

struct stasis_message_typeast_channel_agent_login_type (void)
 Message type for agent login on a channel. More...
 
struct stasis_message_typeast_channel_agent_logoff_type (void)
 Message type for agent logoff on a channel. More...
 
struct stasis_messageast_channel_blob_create (struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
 Creates a ast_channel_blob message. More...
 
struct stasis_messageast_channel_blob_create_from_cache (const char *uniqueid, struct stasis_message_type *type, struct ast_json *blob)
 Create a ast_channel_blob message, pulling channel state from the cache. More...
 
struct ao2_containerast_channel_cache_all (void)
 
struct ao2_containerast_channel_cache_by_name (void)
 Secondary channel cache, indexed by name. More...
 
struct stasis_message_typeast_channel_chanspy_start_type (void)
 Message type for when a channel starts spying on another channel. More...
 
struct stasis_message_typeast_channel_chanspy_stop_type (void)
 Message type for when a channel stops spying on another channel. More...
 
struct stasis_message_typeast_channel_dial_type (void)
 Message type for when a channel dials another channel. More...
 
struct stasis_message_typeast_channel_dtmf_begin_type (void)
 Message type for when DTMF begins on a channel. More...
 
struct stasis_message_typeast_channel_dtmf_end_type (void)
 Message type for when DTMF ends on a channel. More...
 
struct stasis_message_typeast_channel_fax_type (void)
 Message type for a fax operation. More...
 
struct stasis_message_typeast_channel_flash_type (void)
 Message type for when a hook flash occurs on a channel. More...
 
struct stasis_message_typeast_channel_hangup_handler_type (void)
 Message type for hangup handler related actions. More...
 
struct stasis_message_typeast_channel_hangup_request_type (void)
 Message type for when a hangup is requested on a channel. More...
 
struct stasis_message_typeast_channel_hold_type (void)
 Message type for when a channel is placed on hold. More...
 
struct stasis_message_typeast_channel_masquerade_type (void)
 Message type for when a channel is being masqueraded. More...
 
struct stasis_message_typeast_channel_mixmonitor_mute_type (void)
 Message type for muting or unmuting mixmonitor on a channel. More...
 
struct stasis_message_typeast_channel_mixmonitor_start_type (void)
 Message type for starting mixmonitor on a channel. More...
 
struct stasis_message_typeast_channel_mixmonitor_stop_type (void)
 Message type for stopping mixmonitor on a channel. More...
 
struct stasis_message_typeast_channel_moh_start_type (void)
 Message type for starting music on hold on a channel. More...
 
struct stasis_message_typeast_channel_moh_stop_type (void)
 Message type for stopping music on hold on a channel. More...
 
void ast_channel_publish_blob (struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
 Publish a channel blob message. More...
 
void ast_channel_publish_cached_blob (struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
 Publish a channel blob message using the latest snapshot from the cache. More...
 
void ast_channel_publish_dial (struct ast_channel *caller, struct ast_channel *peer, const char *dialstring, const char *dialstatus)
 Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels involved in a dial operation. More...
 
void ast_channel_publish_dial_forward (struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
 Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels involved in a dial operation that is forwarded. More...
 
void ast_channel_publish_final_snapshot (struct ast_channel *chan)
 Send the final channel snapshot for a channel, thus removing it from cache. More...
 
void ast_channel_publish_snapshot (struct ast_channel *chan)
 Publish a ast_channel_snapshot for a channel. More...
 
void ast_channel_publish_varset (struct ast_channel *chan, const char *variable, const char *value)
 Publish a ast_channel_publish_varset for a channel. More...
 
struct ast_channel_snapshotast_channel_snapshot_create (struct ast_channel *chan)
 Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate. More...
 
struct ast_channel_snapshotast_channel_snapshot_get_latest (const char *uniqueid)
 Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object, so use ao2_cleanup() to deallocate. More...
 
struct ast_channel_snapshotast_channel_snapshot_get_latest_by_name (const char *name)
 Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object, so use ao2_cleanup() to deallocate. More...
 
void ast_channel_snapshot_invalidate_segment (struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
 Invalidate a channel snapshot segment from being reused. More...
 
struct stasis_message_typeast_channel_snapshot_type (void)
 Message type for ast_channel_snapshot_update. More...
 
void ast_channel_stage_snapshot (struct ast_channel *chan)
 Set flag to indicate channel snapshot is being staged. More...
 
void ast_channel_stage_snapshot_done (struct ast_channel *chan)
 Clear flag to indicate channel snapshot is being staged, and publish snapshot. More...
 
struct stasis_message_typeast_channel_talking_start (void)
 Message type for a channel starting talking. More...
 
struct stasis_message_typeast_channel_talking_stop (void)
 Message type for a channel stopping talking. More...
 
struct stasis_message_typeast_channel_tone_detect (void)
 Message type for a channel tone detection. More...
 
struct stasis_topicast_channel_topic_all (void)
 A topic which publishes the events for all channels. More...
 
struct stasis_message_typeast_channel_transfer_request_type (void)
 
struct stasis_message_typeast_channel_unhold_type (void)
 Message type for when a channel is removed from hold. More...
 
struct stasis_message_typeast_channel_varset_type (void)
 Message type for when a variable is set on a channel. More...
 
struct stasis_message_typeast_channel_wink_type (void)
 Message type for when a wink occurs on a channel. More...
 
struct stasis_messageast_endpoint_blob_create (struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
 Creates a ast_endpoint_blob message. More...
 
void ast_endpoint_blob_publish (struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
 Creates and publishes a ast_endpoint_blob message. More...
 
struct stasis_cacheast_endpoint_cache (void)
 Backend cache for ast_endpoint_topic_all_cached(). More...
 
struct stasis_cp_allast_endpoint_cache_all (void)
 
struct stasis_message_typeast_endpoint_contact_state_type (void)
 Message type for endpoint contact state changes. More...
 
struct ast_endpoint_snapshotast_endpoint_latest_snapshot (const char *tech, const char *resource)
 Retrieve the most recent snapshot for the endpoint with the given name. More...
 
struct ast_endpoint_snapshotast_endpoint_snapshot_create (struct ast_endpoint *endpoint)
 Create a snapshot of an endpoint. More...
 
struct stasis_message_typeast_endpoint_snapshot_type (void)
 Message type for ast_endpoint_snapshot. More...
 
struct stasis_message_typeast_endpoint_state_type (void)
 Message type for endpoint state changes. More...
 
struct stasis_topicast_endpoint_topic (struct ast_endpoint *endpoint)
 Returns the topic for a specific endpoint. More...
 
struct stasis_topicast_endpoint_topic_all (void)
 Topic for all endpoint related messages. More...
 
struct stasis_topicast_endpoint_topic_all_cached (void)
 Cached topic for all endpoint related messages. More...
 
struct stasis_topicast_endpoint_topic_cached (struct ast_endpoint *endpoint)
 Returns the topic for a specific endpoint. More...
 
void ast_multi_channel_blob_add_channel (struct ast_multi_channel_blob *obj, const char *role, struct ast_channel_snapshot *snapshot)
 Add a ast_channel_snapshot to a ast_multi_channel_blob object. More...
 
struct ast_multi_channel_blobast_multi_channel_blob_create (struct ast_json *blob)
 Create a ast_multi_channel_blob suitable for a stasis_message. More...
 
struct ast_channel_snapshotast_multi_channel_blob_get_channel (struct ast_multi_channel_blob *obj, const char *role)
 Retrieve a channel snapshot associated with a specific role from a ast_multi_channel_blob. More...
 
struct ao2_containerast_multi_channel_blob_get_channels (struct ast_multi_channel_blob *obj, const char *role)
 Retrieve all channel snapshots associated with a specific role from a ast_multi_channel_blob. More...
 
struct ast_jsonast_multi_channel_blob_get_json (struct ast_multi_channel_blob *obj)
 Retrieve the JSON blob from a ast_multi_channel_blob. Returned ast_json is still owned by obj. More...
 
void ast_multi_object_blob_add (struct ast_multi_object_blob *multi, enum stasis_user_multi_object_snapshot_type type, void *object)
 Add an object to a multi object blob previously created. More...
 
struct ast_multi_object_blobast_multi_object_blob_create (struct ast_json *blob)
 Create a stasis multi object blob. More...
 
void ast_multi_object_blob_single_channel_publish (struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
 Create and publish a stasis message blob on a channel with it's snapshot. More...
 
struct stasis_message_typeast_multi_user_event_type (void)
 Message type for custom user defined events with multi object blobs. More...
 
struct stasis_message_typeast_parked_call_type (void)
 accessor for the parked call stasis message type More...
 
struct stasis_topicast_parking_topic (void)
 accessor for the parking stasis topic More...
 
struct stasis_message_typeast_rtp_rtcp_received_type (void)
 Message type for an RTCP message received from some external source. More...
 
struct stasis_message_typeast_rtp_rtcp_sent_type (void)
 Message type for an RTCP message sent from this Asterisk instance. More...
 
struct stasis_message_typestasis_cache_clear_type (void)
 Message type for clearing a message from a stasis cache. More...
 
struct stasis_message_typestasis_cache_update_type (void)
 Message type for cache update messages. More...
 
struct stasis_message_typestasis_subscription_change_type (void)
 Gets the message type for subscription change notices. More...
 
struct stasis_messagestasis_test_message_create (void)
 Creates a test message. More...
 
struct stasis_message_typestasis_test_message_type (void)
 Gets the type of messages created by stasis_test_message_create(). More...
 

Detailed Description

This group contains the topics, messages and corresponding message types found within Asterisk.

Macro Definition Documentation

◆ STASIS_UMOS_MAX

#define STASIS_UMOS_MAX   (STASIS_UMOS_ENDPOINT + 1)

Number of snapshot types.

Definition at line 1360 of file stasis.h.

Enumeration Type Documentation

◆ ast_channel_snapshot_segment_invalidation

Channel snapshot invalidation flags, used to force generation of segments.

Since
17
Enumerator
AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE 

Invalidate the bridge segment

AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN 

Invalidate the dialplan segment

AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED 

Invalidate the connected segment

AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER 

Invalidate the caller segment

AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP 

Invalidate the hangup segment

AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER 

Invalidate the peer segment

AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE 

Invalidate the base segment

Definition at line 36 of file stasis_channels.h.

36 {
37 /*! Invalidate the bridge segment */
39 /*! Invalidate the dialplan segment */
41 /*! Invalidate the connected segment */
43 /*! Invalidate the caller segment */
45 /*! Invalidate the hangup segment */
47 /*! Invalidate the peer segment */
49 /*! Invalidate the base segment */
51};
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED
@ AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN

◆ stasis_user_multi_object_snapshot_type

Object type code for multi user object snapshots.

Enumerator
STASIS_UMOS_CHANNEL 

Channel Snapshots

STASIS_UMOS_BRIDGE 

Bridge Snapshots

STASIS_UMOS_ENDPOINT 

Endpoint Snapshots

Definition at line 1353 of file stasis.h.

1353 {
1354 STASIS_UMOS_CHANNEL = 0, /*!< Channel Snapshots */
1355 STASIS_UMOS_BRIDGE, /*!< Bridge Snapshots */
1356 STASIS_UMOS_ENDPOINT, /*!< Endpoint Snapshots */
1357};
@ STASIS_UMOS_ENDPOINT
Definition: stasis.h:1356
@ STASIS_UMOS_BRIDGE
Definition: stasis.h:1355
@ STASIS_UMOS_CHANNEL
Definition: stasis.h:1354

Function Documentation

◆ ast_channel_agent_login_type()

struct stasis_message_type * ast_channel_agent_login_type ( void  )

Message type for agent login on a channel.

Since
18.0.0
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), load_module(), queue_agent_cb(), send_agent_login(), and stasis_channels_cleanup().

◆ ast_channel_agent_logoff_type()

struct stasis_message_type * ast_channel_agent_logoff_type ( void  )

Message type for agent logoff on a channel.

Since
12.0.0
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), load_module(), queue_agent_cb(), send_agent_logoff(), and stasis_channels_cleanup().

◆ ast_channel_blob_create()

struct stasis_message * ast_channel_blob_create ( struct ast_channel chan,
struct stasis_message_type type,
struct ast_json blob 
)

Creates a ast_channel_blob message.

Since
12

The given blob should be treated as immutable and not modified after it is put into the message.

Precondition
chan is locked
Parameters
chanChannel blob is associated with, or NULL for global/all channels.
typeMessage type for this blob.
blobJSON object representing the data, or NULL for no data. If NULL, ast_json_null() is put into the object.
Returns
ast_channel_blob message.
Return values
NULLon error

Definition at line 814 of file stasis_channels.c.

816{
817 struct ast_channel_snapshot *snapshot;
818 struct stasis_message *msg;
819
820 if (!type) {
821 return NULL;
822 }
823
824 snapshot = chan ? ao2_bump(ast_channel_snapshot(chan)) : NULL;
825 msg = create_channel_blob_message(snapshot, type, blob);
826 ao2_cleanup(snapshot);
827 return msg;
828}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
static const char type[]
Definition: chan_ooh323.c:109
struct ast_channel_snapshot * ast_channel_snapshot(const struct ast_channel *chan)
#define NULL
Definition: resample.c:96
static struct stasis_message * create_channel_blob_message(struct ast_channel_snapshot *snapshot, struct stasis_message_type *type, struct ast_json *blob)
Structure representing a snapshot of channel state.

References ao2_bump, ao2_cleanup, ast_channel_snapshot(), create_channel_blob_message(), NULL, and type.

Referenced by app_send_end_msg(), ast_channel_publish_blob(), AST_TEST_DEFINE(), and meetme_stasis_generate_msg().

◆ ast_channel_blob_create_from_cache()

struct stasis_message * ast_channel_blob_create_from_cache ( const char *  uniqueid,
struct stasis_message_type type,
struct ast_json blob 
)

Create a ast_channel_blob message, pulling channel state from the cache.

Since
12
Parameters
uniqueidUniqueid of the channel.
typeMessage type for this blob.
blobJSON object representing the data, or NULL for no data. If NULL, ast_json_null() is put into the object.
Returns
ast_channel_blob message.
Return values
NULLon error

Definition at line 797 of file stasis_channels.c.

800{
801 struct ast_channel_snapshot *snapshot;
802 struct stasis_message *msg;
803
804 if (!type) {
805 return NULL;
806 }
807
808 snapshot = ast_channel_snapshot_get_latest(channel_id);
809 msg = create_channel_blob_message(snapshot, type, blob);
810 ao2_cleanup(snapshot);
811 return msg;
812}
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...

References ao2_cleanup, ast_channel_snapshot_get_latest(), create_channel_blob_message(), NULL, and type.

Referenced by ast_cel_publish_event(), ast_channel_publish_cached_blob(), detect_callback(), manager_mute_mixmonitor(), mixmonitor_exec(), moh_post_start(), moh_post_stop(), playback_publish(), recording_publish(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), stop_mixmonitor_full(), and talk_detect_audiohook_cb().

◆ ast_channel_cache_all()

struct ao2_container * ast_channel_cache_all ( void  )

Definition at line 144 of file stasis_channels.c.

145{
146 return ao2_bump(channel_cache);
147}
static struct ao2_container * channel_cache

References ao2_bump, and channel_cache.

Referenced by ast_ari_channels_list(), ast_complete_channels(), and channels_scrape_cb().

◆ ast_channel_cache_by_name()

struct ao2_container * ast_channel_cache_by_name ( void  )

Secondary channel cache, indexed by name.

Since
12
Returns
Cache of ast_channel_snapshot.

Definition at line 154 of file stasis_channels.c.

155{
157}
static struct ao2_container * channel_cache_by_name

References ao2_bump, and channel_cache_by_name.

Referenced by action_coreshowchannels(), get_container(), and handle_chanlist().

◆ ast_channel_chanspy_start_type()

struct stasis_message_type * ast_channel_chanspy_start_type ( void  )

Message type for when a channel starts spying on another channel.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), publish_chanspy_message(), and stasis_channels_cleanup().

◆ ast_channel_chanspy_stop_type()

struct stasis_message_type * ast_channel_chanspy_stop_type ( void  )

Message type for when a channel stops spying on another channel.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), publish_chanspy_message(), and stasis_channels_cleanup().

◆ ast_channel_dial_type()

struct stasis_message_type * ast_channel_dial_type ( void  )

Message type for when a channel dials another channel.

Since
12
Returns
A stasis message type

Referenced by ast_channel_publish_dial_internal(), ast_stasis_channels_init(), create_routes(), load_module(), manager_channels_init(), and stasis_channels_cleanup().

◆ ast_channel_dtmf_begin_type()

struct stasis_message_type * ast_channel_dtmf_begin_type ( void  )

Message type for when DTMF begins on a channel.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), send_dtmf_begin_event(), and stasis_channels_cleanup().

◆ ast_channel_dtmf_end_type()

struct stasis_message_type * ast_channel_dtmf_end_type ( void  )

Message type for when DTMF ends on a channel.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), send_dtmf_end_event(), and stasis_channels_cleanup().

◆ ast_channel_fax_type()

struct stasis_message_type * ast_channel_fax_type ( void  )

Message type for a fax operation.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), and stasis_channels_cleanup().

◆ ast_channel_flash_type()

struct stasis_message_type * ast_channel_flash_type ( void  )

Message type for when a hook flash occurs on a channel.

Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), send_flash_event(), and stasis_channels_cleanup().

◆ ast_channel_hangup_handler_type()

struct stasis_message_type * ast_channel_hangup_handler_type ( void  )

Message type for hangup handler related actions.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), publish_hangup_handler_message(), and stasis_channels_cleanup().

◆ ast_channel_hangup_request_type()

struct stasis_message_type * ast_channel_hangup_request_type ( void  )

Message type for when a hangup is requested on a channel.

Since
12
Returns
A stasis message type

Referenced by ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_softhangup(), ast_stasis_channels_init(), manager_channels_init(), setup_stasis_subs(), and stasis_channels_cleanup().

◆ ast_channel_hold_type()

struct stasis_message_type * ast_channel_hold_type ( void  )

Message type for when a channel is placed on hold.

Since
12
Returns
A stasis message type

Referenced by ast_bridge_channel_write_hold(), ast_queue_hold(), ast_stasis_channels_init(), hold_intercept_framehook(), manager_channels_init(), and stasis_channels_cleanup().

◆ ast_channel_masquerade_type()

struct stasis_message_type * ast_channel_masquerade_type ( void  )

Message type for when a channel is being masqueraded.

Since
16
Returns
A stasis message type

Referenced by ast_channel_move(), ast_stasis_channels_init(), setup_stasis_subs(), and stasis_channels_cleanup().

◆ ast_channel_mixmonitor_mute_type()

struct stasis_message_type * ast_channel_mixmonitor_mute_type ( void  )

Message type for muting or unmuting mixmonitor on a channel.

Since
18
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), manager_mute_mixmonitor(), and stasis_channels_cleanup().

◆ ast_channel_mixmonitor_start_type()

struct stasis_message_type * ast_channel_mixmonitor_start_type ( void  )

Message type for starting mixmonitor on a channel.

Since
18
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), mixmonitor_exec(), and stasis_channels_cleanup().

◆ ast_channel_mixmonitor_stop_type()

struct stasis_message_type * ast_channel_mixmonitor_stop_type ( void  )

Message type for stopping mixmonitor on a channel.

Since
18
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), stasis_channels_cleanup(), and stop_mixmonitor_full().

◆ ast_channel_moh_start_type()

struct stasis_message_type * ast_channel_moh_start_type ( void  )

Message type for starting music on hold on a channel.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), moh_post_start(), and stasis_channels_cleanup().

◆ ast_channel_moh_stop_type()

struct stasis_message_type * ast_channel_moh_stop_type ( void  )

Message type for stopping music on hold on a channel.

Since
12
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), moh_post_stop(), and stasis_channels_cleanup().

◆ ast_channel_publish_blob()

void ast_channel_publish_blob ( struct ast_channel chan,
struct stasis_message_type type,
struct ast_json blob 
)

Publish a channel blob message.

Since
12.0.0
Precondition
chan is locked
Parameters
chanChannel publishing the blob.
typeType of stasis message.
blobThe blob being published. (NULL if no blob)
Note
This will use the current snapshot on the channel and will not generate a new one.

Definition at line 1159 of file stasis_channels.c.

1160{
1161 struct stasis_message *message;
1162
1163 if (!blob) {
1164 blob = ast_json_null();
1165 }
1166
1167 message = ast_channel_blob_create(chan, type, blob);
1168 if (message) {
1170 ao2_ref(message, -1);
1171 }
1172}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
struct stasis_message * ast_channel_blob_create(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Creates a ast_channel_blob message.
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition: json.c:248
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1538

References ao2_ref, ast_channel_blob_create(), ast_channel_topic(), ast_json_null(), stasis_publish(), and type.

Referenced by ast_channel_move(), ast_channel_publish_varset(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_queue_unhold(), ast_softhangup(), publish_dahdichannel(), publish_hangup_handler_message(), send_agent_login(), send_agent_logoff(), send_dtmf_begin_event(), send_dtmf_end_event(), send_flash_event(), and send_wink_event().

◆ ast_channel_publish_cached_blob()

void ast_channel_publish_cached_blob ( struct ast_channel chan,
struct stasis_message_type type,
struct ast_json blob 
)

Publish a channel blob message using the latest snapshot from the cache.

Since
12.4.0
Parameters
chanChannel publishing the blob.
typeType of stasis message.
blobThe blob being published. (NULL if no blob)
Note
As this only accesses the uniqueid and topic of the channel - neither of which should ever be changed on a channel anyhow - a channel does not have to be locked when calling this function.

Definition at line 1144 of file stasis_channels.c.

1145{
1146 struct stasis_message *message;
1147
1148 if (!blob) {
1149 blob = ast_json_null();
1150 }
1151
1153 if (message) {
1155 ao2_ref(message, -1);
1156 }
1157}
const char * ast_channel_uniqueid(const struct ast_channel *chan)
struct stasis_message * ast_channel_blob_create_from_cache(const char *channel_id, struct stasis_message_type *type, struct ast_json *blob)
Create a ast_channel_blob message, pulling channel state from the cache.

References ao2_ref, ast_channel_blob_create_from_cache(), ast_channel_topic(), ast_channel_uniqueid(), ast_json_null(), stasis_publish(), and type.

Referenced by agi_handle_command(), ast_bridge_channel_write_hold(), ast_bridge_channel_write_unhold(), hold_intercept_framehook(), join_queue(), launch_asyncagi(), leave_queue(), publish_async_exec_end(), and record_abandoned().

◆ ast_channel_publish_dial()

void ast_channel_publish_dial ( struct ast_channel caller,
struct ast_channel peer,
const char *  dialstring,
const char *  dialstatus 
)

Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels involved in a dial operation.

Since
12
Parameters
callerThe channel performing the dial operation
peerThe channel being dialed
dialstringWhen beginning a dial, the information passed to the dialing application
dialstatusThe current status of the dial operation (NULL if no status is known)

Definition at line 765 of file stasis_channels.c.

767{
768 ast_channel_publish_dial_forward(caller, peer, NULL, dialstring, dialstatus, NULL);
769}
void ast_channel_publish_dial_forward(struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels in...

References ast_channel_publish_dial_forward(), ast_channel_snapshot::caller, NULL, and ast_channel_snapshot::peer.

Referenced by app_control_dial(), AST_TEST_DEFINE(), begin_dial_channel(), bridge_handle_trip(), dial_exec_full(), do_forward(), findmeexec(), handle_frame(), hangupcalls(), monitor_dial(), publish_dial_end_event(), ring_entry(), try_calling(), wait_for_answer(), and wait_for_winner().

◆ ast_channel_publish_dial_forward()

void ast_channel_publish_dial_forward ( struct ast_channel caller,
struct ast_channel peer,
struct ast_channel forwarded,
const char *  dialstring,
const char *  dialstatus,
const char *  forward 
)

Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels involved in a dial operation that is forwarded.

Since
12
Parameters
callerThe channel performing the dial operation
peerThe channel being dialed
forwardedThe channel created as a result of the call forwarding
dialstringThe information passed to the dialing application when beginning a dial
dialstatusThe current status of the dial operation
forwardThe call forward string provided by the dialed channel

Definition at line 715 of file stasis_channels.c.

718{
719 ast_assert(peer != NULL);
720
721 /* XXX With an early bridge the below dial masquerade datastore code could, theoretically,
722 * go away as the act of changing the channel during dialing would be done using the bridge
723 * API itself and not a masquerade.
724 */
725
726 if (caller) {
727 /*
728 * Lock two or three channels.
729 *
730 * We need to hold the locks to hold off a potential masquerade
731 * messing up the stasis dial event ordering.
732 */
733 for (;; ast_channel_unlock(caller), sched_yield()) {
734 ast_channel_lock(caller);
735 if (ast_channel_trylock(peer)) {
736 continue;
737 }
738 if (forwarded && ast_channel_trylock(forwarded)) {
739 ast_channel_unlock(peer);
740 continue;
741 }
742 break;
743 }
744
745 if (ast_strlen_zero(dialstatus)) {
746 set_dial_masquerade(caller, peer, dialstring);
747 } else {
749 }
750 }
751
752 ast_channel_publish_dial_internal(caller, peer, forwarded, dialstring, dialstatus,
753 forward);
754
755 if (caller) {
756 if (forwarded) {
757 ast_channel_unlock(forwarded);
758 }
759 ast_channel_unlock(peer);
761 ast_channel_unlock(caller);
762 }
763}
#define ast_channel_lock(chan)
Definition: channel.h:2970
#define ast_channel_trylock(chan)
Definition: channel.h:2972
#define ast_channel_unlock(chan)
Definition: channel.h:2971
static int set_dial_masquerade(struct ast_channel *caller, struct ast_channel *peer, const char *dialstring)
static void ast_channel_publish_dial_internal(struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
static void remove_dial_masquerade_caller(struct ast_channel *caller)
static void remove_dial_masquerade(struct ast_channel *peer)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_assert(a)
Definition: utils.h:739

References ast_assert, ast_channel_lock, ast_channel_publish_dial_internal(), ast_channel_trylock, ast_channel_unlock, ast_strlen_zero(), ast_channel_snapshot::caller, NULL, ast_channel_snapshot::peer, remove_dial_masquerade(), remove_dial_masquerade_caller(), and set_dial_masquerade().

Referenced by ast_channel_publish_dial(), bridge_handle_trip(), do_forward(), handle_call_forward(), and wait_for_answer().

◆ ast_channel_publish_final_snapshot()

void ast_channel_publish_final_snapshot ( struct ast_channel chan)

Send the final channel snapshot for a channel, thus removing it from cache.

Since
17
Precondition
chan is locked
Parameters
chanThe channel to send the final channel snapshot for
Note
This will also remove the cached snapshot from the channel itself

Definition at line 943 of file stasis_channels.c.

944{
946 struct stasis_message *message;
947
949 return;
950 }
951
953 if (!update) {
954 return;
955 }
956
958 /* In the success path message holds a reference to update so it will be valid
959 * for the lifetime of this function until the end.
960 */
961 ao2_ref(update, -1);
962 if (!message) {
963 return;
964 }
965
968
970
972 ao2_ref(message, -1);
973}
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_UNLINK
Definition: astobj2.h:1039
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition: codec_g726.c:367
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
static struct ast_channel_snapshot_update * channel_snapshot_update_create(struct ast_channel *chan)
Structure representing a change of snapshot of channel state.

References ao2_find, ao2_ref, ast_channel_name(), ast_channel_snapshot_set(), ast_channel_snapshot_type(), ast_channel_topic(), ast_channel_uniqueid(), channel_cache, channel_cache_by_name, channel_snapshot_update_create(), NULL, OBJ_NODATA, OBJ_SEARCH_KEY, OBJ_UNLINK, stasis_message_create(), stasis_publish(), and update().

Referenced by ast_channel_destructor().

◆ ast_channel_publish_snapshot()

void ast_channel_publish_snapshot ( struct ast_channel chan)

Publish a ast_channel_snapshot for a channel.

Since
12
Precondition
chan is locked
Parameters
chanChannel to publish.

Definition at line 1081 of file stasis_channels.c.

1082{
1084 struct stasis_message *message;
1085
1087 return;
1088 }
1089
1091 return;
1092 }
1093
1095 if (!update) {
1096 return;
1097 }
1098
1099 /* If an old snapshot exists and is the same as this newly created one don't bother
1100 * raising a message as it hasn't changed.
1101 */
1102 if (update->old_snapshot && !memcmp(update->old_snapshot, update->new_snapshot, sizeof(struct ast_channel_snapshot))) {
1103 ao2_ref(update, -1);
1104 return;
1105 }
1106
1108 /* In the success path message holds a reference to update so it will be valid
1109 * for the lifetime of this function until the end.
1110 */
1111 ao2_ref(update, -1);
1112 if (!message) {
1113 return;
1114 }
1115
1116 /* We lock these ourselves so that the update is atomic and there isn't time where a
1117 * snapshot is not in the cache.
1118 */
1121
1124
1125 /* The same applies here. */
1128
1131
1132 ast_channel_snapshot_set(chan, update->new_snapshot);
1133
1134 /* As this is now the new snapshot any existing invalidated segments have been
1135 * created fresh and are up to date.
1136 */
1138
1141 ao2_ref(message, -1);
1142}
#define ao2_wrlock(a)
Definition: astobj2.h:719
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
Definition: astobj2.h:1554
#define ao2_unlock(a)
Definition: astobj2.h:729
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
Definition: astobj2.h:1063
struct ast_flags * ast_channel_snapshot_segment_flags(struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
@ AST_FLAG_SNAPSHOT_STAGE
Definition: channel.h:1070
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define AST_FLAGS_ALL
Definition: utils.h:196

References ao2_find, ao2_link_flags, ao2_ref, ao2_unlock, ao2_wrlock, ast_assert, ast_channel_flags(), ast_channel_name(), ast_channel_snapshot_segment_flags(), ast_channel_snapshot_set(), ast_channel_snapshot_type(), ast_channel_topic(), ast_channel_uniqueid(), ast_clear_flag, AST_FLAG_SNAPSHOT_STAGE, AST_FLAGS_ALL, ast_test_flag, channel_cache, channel_cache_by_name, channel_snapshot_update_create(), NULL, OBJ_NODATA, OBJ_NOLOCK, OBJ_SEARCH_KEY, OBJ_UNLINK, stasis_message_create(), stasis_publish(), and update().

Referenced by ast_channel_amaflags_set(), ast_channel_internal_bridge_set(), ast_channel_internal_copy_linkedid(), ast_channel_publish_varset(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_channel_stage_snapshot_done(), ast_pbx_exec_application(), ast_set_callerid(), ast_setstate(), AST_TEST_DEFINE(), channel_do_masquerade(), do_forward(), onCallEstablished(), pbx_exec(), and realtime_exec().

◆ ast_channel_publish_varset()

void ast_channel_publish_varset ( struct ast_channel chan,
const char *  variable,
const char *  value 
)

Publish a ast_channel_publish_varset for a channel.

Since
12
Precondition
chan is locked
Parameters
chanChannel to publish the event for, or NULL for 'none'.
variableName of the variable being set
valueValue.

If there are manager variables, force a cache update

Definition at line 1174 of file stasis_channels.c.

1175{
1176 struct ast_json *blob;
1178 char *new_value = NULL;
1179 size_t new_value_size = 0;
1180
1181 ast_assert(name != NULL);
1182 ast_assert(value != NULL);
1183
1184 /*
1185 * Call with new-value == NULL to just check for invalid UTF-8
1186 * sequences and get size of buffer needed.
1187 */
1188 result = ast_utf8_replace_invalid_chars(new_value, &new_value_size,
1189 value, strlen(value));
1190
1192 /*
1193 * If there were no invalid sequences, we can use
1194 * the value directly.
1195 */
1196 new_value = (char *)value;
1197 } else {
1198 /*
1199 * If there were invalid sequences, we need to replace
1200 * them with the UTF-8 U+FFFD replacement character.
1201 */
1202 new_value = ast_alloca(new_value_size);
1203
1204 result = ast_utf8_replace_invalid_chars(new_value, &new_value_size,
1205 value, strlen(value));
1206
1207 ast_log(LOG_WARNING, "%s: The contents of variable '%s' had invalid UTF-8 sequences which were replaced",
1208 chan ? ast_channel_name(chan) : "GLOBAL", name);
1209 }
1210
1211 blob = ast_json_pack("{s: s, s: s}",
1212 "variable", name,
1213 "value", new_value);
1214 if (!blob) {
1215 ast_log(LOG_ERROR, "Error creating message\n");
1216 return;
1217 }
1218
1219 /*! If there are manager variables, force a cache update */
1220 if (chan && ast_channel_has_manager_vars()) {
1222 }
1223
1224 /* This function is NULL safe for global variables */
1226 ast_json_unref(blob);
1227}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define ast_log
Definition: astobj2.c:42
static PGresult * result
Definition: cel_pgsql.c:84
int ast_channel_has_manager_vars(void)
Return whether or not any manager variables have been set.
Definition: channel.c:7881
static const char name[]
Definition: format_mp3.c:68
struct stasis_message_type * ast_channel_varset_type(void)
Message type for when a variable is set on a channel.
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
#define LOG_ERROR
#define LOG_WARNING
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
Abstract JSON element (object, array, string, int, ...).
int value
Definition: syslog.c:37
ast_utf8_replace_result
Definition: utf8.h:70
@ AST_UTF8_REPLACE_VALID
Source contained fully valid UTF-8.
Definition: utf8.h:76
enum ast_utf8_replace_result ast_utf8_replace_invalid_chars(char *dst, size_t *dst_size, const char *src, size_t src_len)
Copy a string safely replacing any invalid UTF-8 sequences.
Definition: utf8.c:173

References ast_alloca, ast_assert, ast_channel_has_manager_vars(), ast_channel_name(), ast_channel_publish_blob(), ast_channel_publish_snapshot(), ast_channel_varset_type(), ast_json_pack(), ast_json_unref(), ast_log, ast_utf8_replace_invalid_chars(), AST_UTF8_REPLACE_VALID, LOG_ERROR, LOG_WARNING, name, NULL, result, and value.

Referenced by ast_channel_inherit_variables(), ast_unreal_call_setup(), frame_set_var(), pbx_builtin_setvar_helper(), and shared_write().

◆ ast_channel_snapshot_create()

struct ast_channel_snapshot * ast_channel_snapshot_create ( struct ast_channel chan)

Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate.

Since
12
Precondition
chan is locked
Parameters
chanThe channel from which to generate a snapshot
Returns
pointer on success (must be unreffed)
Return values
NULLon error

Definition at line 477 of file stasis_channels.c.

478{
479 struct ast_channel_snapshot *old_snapshot;
480 struct ast_channel_snapshot *snapshot;
481
482 /* no snapshots for dummy channels */
483 if (!ast_channel_tech(chan)) {
484 return NULL;
485 }
486
487 snapshot = ao2_alloc_options(sizeof(*snapshot), channel_snapshot_dtor,
489 if (!snapshot) {
490 return NULL;
491 }
492
493 old_snapshot = ast_channel_snapshot(chan);
494
495 /* Channels automatically have all segments invalidated on them initially so a check for an old
496 * snapshot existing before usage is not done here, as it can not happen. If the stored snapshot
497 * on the channel is updated as a result of this then all segments marked as invalidated will be
498 * cleared.
499 */
501 /* The base information has changed so update our snapshot */
502 snapshot->base = channel_snapshot_base_create(chan);
503 if (!snapshot->base) {
504 ao2_ref(snapshot, -1);
505 return NULL;
506 }
507 } else {
508 snapshot->base = ao2_bump(old_snapshot->base);
509 }
510
512 /* The peer information has changed so update our snapshot */
513 snapshot->peer = channel_snapshot_peer_create(chan);
514 if (!snapshot->peer) {
515 ao2_ref(snapshot, -1);
516 return NULL;
517 }
518 } else {
519 snapshot->peer = ao2_bump(old_snapshot->peer);
520 }
521
522 /* Unfortunately both caller and connected information do not have an enforced contract with
523 * the channel API. This has allowed consumers to directly get the caller or connected structure
524 * and manipulate it. Until such time as there is an enforced contract (which is being tracked under
525 * ASTERISK-28164) they are each regenerated every time a channel snapshot is created.
526 */
527 snapshot->caller = channel_snapshot_caller_create(chan);
528 if (!snapshot->caller) {
529 ao2_ref(snapshot, -1);
530 return NULL;
531 }
532
534 if (!snapshot->connected) {
535 ao2_ref(snapshot, -1);
536 return NULL;
537 }
538
540 /* The bridge has changed so update our snapshot */
541 snapshot->bridge = channel_snapshot_bridge_create(chan);
542 if (!snapshot->bridge) {
543 ao2_ref(snapshot, -1);
544 return NULL;
545 }
546 } else {
547 snapshot->bridge = ao2_bump(old_snapshot->bridge);
548 }
549
551 /* The dialplan information has changed so update our snapshot */
553 if (!snapshot->dialplan) {
554 ao2_ref(snapshot, -1);
555 return NULL;
556 }
557 } else {
558 snapshot->dialplan = ao2_bump(old_snapshot->dialplan);
559 }
560
562 /* The hangup information has changed so update our snapshot */
563 snapshot->hangup = channel_snapshot_hangup_create(chan);
564 if (!snapshot->hangup) {
565 ao2_ref(snapshot, -1);
566 return NULL;
567 }
568 } else {
569 snapshot->hangup = ao2_bump(old_snapshot->hangup);
570 }
571
572 snapshot->state = ast_channel_state(chan);
573 snapshot->amaflags = ast_channel_amaflags(chan);
574 ast_copy_flags(&snapshot->flags, ast_channel_flags(chan), 0xFFFFFFFF);
576
577 /* These have to be recreated as they may have changed, unfortunately */
579 snapshot->ari_vars = ast_channel_get_ari_vars(chan);
580
581 return snapshot;
582}
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition: astobj2.h:367
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:404
struct varshead * ast_channel_get_manager_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
Definition: channel.c:8009
struct varshead * ast_channel_get_ari_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
Definition: channel.c:8014
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
ast_channel_state
ast_channel states
Definition: channelstate.h:35
static struct ast_channel_snapshot_caller * channel_snapshot_caller_create(struct ast_channel *chan)
static struct ast_channel_snapshot_base * channel_snapshot_base_create(struct ast_channel *chan)
static struct ast_channel_snapshot_peer * channel_snapshot_peer_create(struct ast_channel *chan)
static struct ast_channel_snapshot_connected * channel_snapshot_connected_create(struct ast_channel *chan)
static struct ast_channel_snapshot_dialplan * channel_snapshot_dialplan_create(struct ast_channel *chan)
static struct ast_channel_snapshot_hangup * channel_snapshot_hangup_create(struct ast_channel *chan)
static void channel_snapshot_dtor(void *obj)
static struct ast_channel_snapshot_bridge * channel_snapshot_bridge_create(struct ast_channel *chan)
struct ast_channel_snapshot_connected * connected
struct varshead * manager_vars
struct varshead * ari_vars
struct ast_channel_snapshot_dialplan * dialplan
struct ast_channel_snapshot_peer * peer
struct ast_channel_snapshot_bridge * bridge
struct ast_channel_snapshot_base * base
enum ast_channel_state state
struct ast_flags softhangup_flags
struct ast_channel_snapshot_caller * caller
struct ast_flags flags
struct ast_channel_snapshot_hangup * hangup
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define ast_copy_flags(dest, src, flagz)
Definition: utils.h:84

References ast_channel_snapshot::amaflags, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ao2_ref, ast_channel_snapshot::ari_vars, ast_channel_amaflags(), ast_channel_flags(), ast_channel_get_ari_vars(), ast_channel_get_manager_vars(), ast_channel_snapshot(), AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE, AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE, AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN, AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP, AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER, ast_channel_snapshot_segment_flags(), ast_channel_softhangup_internal_flag(), ast_channel_tech(), ast_copy_flags, ast_set_flag, ast_test_flag, ast_channel_snapshot::base, ast_channel_snapshot::bridge, ast_channel_snapshot::caller, channel_snapshot_base_create(), channel_snapshot_bridge_create(), channel_snapshot_caller_create(), channel_snapshot_connected_create(), channel_snapshot_dialplan_create(), channel_snapshot_dtor(), channel_snapshot_hangup_create(), channel_snapshot_peer_create(), ast_channel_snapshot::connected, ast_channel_snapshot::dialplan, ast_channel_snapshot::flags, ast_channel_snapshot::hangup, ast_channel_snapshot::manager_vars, NULL, ast_channel_snapshot::peer, ast_channel_snapshot::softhangup_flags, and ast_channel_snapshot::state.

Referenced by action_agents(), append_expected_event(), ast_channel_publish_dial_internal(), ast_do_pickup(), ast_multi_object_blob_single_channel_publish(), AST_TEST_DEFINE(), channel_snapshot_update_create(), parked_call_app_exec(), parked_call_payload_from_failure(), parked_call_payload_from_parked_user(), queue_publish_multi_channel_blob(), and send_start_msg().

◆ ast_channel_snapshot_get_latest()

struct ast_channel_snapshot * ast_channel_snapshot_get_latest ( const char *  uniqueid)

Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object, so use ao2_cleanup() to deallocate.

Since
12
Parameters
uniqueidThe channel's unique ID
Returns
A ast_channel_snapshot on success
Return values
NULLon error

Definition at line 929 of file stasis_channels.c.

930{
931 ast_assert(!ast_strlen_zero(uniqueid));
932
933 return ao2_find(channel_cache, uniqueid, OBJ_SEARCH_KEY);
934}

References ao2_find, ast_assert, ast_strlen_zero(), channel_cache, and OBJ_SEARCH_KEY.

Referenced by __test_cel_generate_peer_str(), action_confbridgelist_item(), ari_channels_handle_originate_with_id(), ari_channels_handle_snoop_channel(), ast_ari_channels_create(), ast_ari_channels_get(), ast_ari_channels_redirect(), ast_attended_transfer_message_add_app(), ast_attended_transfer_message_add_link(), ast_attended_transfer_message_create(), ast_blind_transfer_message_create(), ast_bridge_blob_create(), ast_bridge_transfer_blind(), ast_channel_blob_create_from_cache(), ast_channel_publish_dial_internal(), ast_do_pickup(), ast_rtp_publish_rtcp_message(), ast_sip_for_each_channel_snapshot(), blind_transfer_bridge(), bridge_channel_snapshot_pair_init(), bridge_parking_push(), bridge_show_specific_print_channel(), bridge_stasis_push_peek(), cel_generate_peer_str(), chan_pjsip_devicestate(), channel_id_sanitizer(), channel_replaced_cb(), conf_send_event_to_participants(), coreshowchannelmap_add_connected_channels(), find_channel_control(), generate_status(), handle_attended_transfer(), handle_blind_transfer(), handle_hangup(), local_channel_optimization_blob(), local_optimization_started_cb(), mwi_state_create_message(), notify_new_message(), pack_channel_into_message(), publish_chanspy_message(), publish_local_bridge_message(), send_bridge_info_item_cb(), stasis_app_control_get_snapshot(), stasis_app_exec(), stasis_app_user_event(), and test_cel_generate_peer_str().

◆ ast_channel_snapshot_get_latest_by_name()

struct ast_channel_snapshot * ast_channel_snapshot_get_latest_by_name ( const char *  name)

Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object, so use ao2_cleanup() to deallocate.

Since
12
Parameters
nameThe channel's name
Returns
A ast_channel_snapshot on success
Return values
NULLon error

Definition at line 936 of file stasis_channels.c.

References ao2_find, ast_assert, ast_strlen_zero(), channel_cache_by_name, name, and OBJ_SEARCH_KEY.

Referenced by action_coreshowchannelmap(), cli_channel_retrieve_by_id(), coreshowchannelmap_add_connected_channels(), and handle_channelstatus().

◆ ast_channel_snapshot_invalidate_segment()

void ast_channel_snapshot_invalidate_segment ( struct ast_channel chan,
enum ast_channel_snapshot_segment_invalidation  segment 
)

◆ ast_channel_snapshot_type()

struct stasis_message_type * ast_channel_snapshot_type ( void  )

◆ ast_channel_stage_snapshot()

void ast_channel_stage_snapshot ( struct ast_channel chan)

◆ ast_channel_stage_snapshot_done()

void ast_channel_stage_snapshot_done ( struct ast_channel chan)

◆ ast_channel_talking_start()

struct stasis_message_type * ast_channel_talking_start ( void  )

Message type for a channel starting talking.

Since
12.4.0
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), stasis_channels_cleanup(), and talk_detect_audiohook_cb().

◆ ast_channel_talking_stop()

struct stasis_message_type * ast_channel_talking_stop ( void  )

Message type for a channel stopping talking.

Since
12.4.0
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), stasis_channels_cleanup(), and talk_detect_audiohook_cb().

◆ ast_channel_tone_detect()

struct stasis_message_type * ast_channel_tone_detect ( void  )

Message type for a channel tone detection.

Since
22.0.0
Returns
A stasis message type

Referenced by ast_stasis_channels_init(), detect_callback(), and stasis_channels_cleanup().

◆ ast_channel_topic_all()

struct stasis_topic * ast_channel_topic_all ( void  )

A topic which publishes the events for all channels.

Since
12
Returns
Topic for all channel events.

Definition at line 149 of file stasis_channels.c.

150{
151 return channel_topic_all;
152}
static struct stasis_topic * channel_topic_all

References channel_topic_all.

Referenced by ast_channel_internal_setup_topics(), ast_channel_topic(), create_subscriptions(), forwards_create_channel(), load_module(), manager_channels_init(), manager_confbridge_init(), meetme_stasis_init(), publish_message_for_channel_topics(), and setup_stasis_subs().

◆ ast_channel_transfer_request_type()

struct stasis_message_type * ast_channel_transfer_request_type ( void  )

◆ ast_channel_unhold_type()

struct stasis_message_type * ast_channel_unhold_type ( void  )

Message type for when a channel is removed from hold.

Since
12
Returns
A stasis message type

Referenced by ast_bridge_channel_write_unhold(), ast_queue_unhold(), ast_stasis_channels_init(), hold_intercept_framehook(), manager_channels_init(), and stasis_channels_cleanup().

◆ ast_channel_varset_type()

struct stasis_message_type * ast_channel_varset_type ( void  )

Message type for when a variable is set on a channel.

Since
12
Returns
A stasis message type

Referenced by ast_channel_publish_varset(), ast_stasis_channels_init(), and stasis_channels_cleanup().

◆ ast_channel_wink_type()

struct stasis_message_type * ast_channel_wink_type ( void  )

Message type for when a wink occurs on a channel.

Returns
A stasis message type

Referenced by ast_stasis_channels_init(), manager_channels_init(), send_wink_event(), and stasis_channels_cleanup().

◆ ast_endpoint_blob_create()

struct stasis_message * ast_endpoint_blob_create ( struct ast_endpoint endpoint,
struct stasis_message_type type,
struct ast_json blob 
)

Creates a ast_endpoint_blob message.

Since
12

The given blob should be treated as immutable and not modified after it is put into the message.

Parameters
endpointEndpoint blob is associated with.
typeMessage type for this blob.
blobJSON object representing the data, or NULL for no data. If NULL, ast_json_null() is put into the object.
Returns
ast_endpoint_blob message.
Return values
NULLon error

Definition at line 299 of file stasis_endpoints.c.

301{
302 struct ast_endpoint_blob *obj;
303 struct stasis_message *msg;
304
305 if (!type) {
306 return NULL;
307 }
308 if (!blob) {
309 blob = ast_json_null();
310 }
311
312 if (!(obj = ao2_alloc(sizeof(*obj), endpoint_blob_dtor))) {
313 return NULL;
314 }
315
316 if (endpoint) {
317 if (!(obj->snapshot = ast_endpoint_snapshot_create(endpoint))) {
318 ao2_ref(obj, -1);
319
320 return NULL;
321 }
322 }
323
324 obj->blob = ast_json_ref(blob);
325 msg = stasis_message_create(type, obj);
326 ao2_ref(obj, -1);
327
328 return msg;
329}
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
struct ast_endpoint_snapshot * ast_endpoint_snapshot_create(struct ast_endpoint *endpoint)
Create a snapshot of an endpoint.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
static void endpoint_blob_dtor(void *obj)
Blob of data associated with an endpoint.
struct ast_endpoint_snapshot * snapshot
struct ast_json * blob

References ao2_alloc, ao2_ref, ast_endpoint_snapshot_create(), ast_json_null(), ast_json_ref(), ast_endpoint_blob::blob, endpoint_blob_dtor(), NULL, ast_endpoint_blob::snapshot, stasis_message_create(), and type.

Referenced by ast_endpoint_blob_publish().

◆ ast_endpoint_blob_publish()

void ast_endpoint_blob_publish ( struct ast_endpoint endpoint,
struct stasis_message_type type,
struct ast_json blob 
)

Creates and publishes a ast_endpoint_blob message.

Since
12

The given blob should be treated as immutable and not modified after it is put into the message.

Parameters
endpointEndpoint blob is associated with.
typeMessage type for this blob.
blobJSON object representing the data, or NULL for no data. If NULL, ast_json_null() is put into the object.

Definition at line 331 of file stasis_endpoints.c.

333{
334 struct stasis_message *message;
335
336 if (!blob) {
337 return;
338 }
339
340 message = ast_endpoint_blob_create(endpoint, type, blob);
341 if (message) {
343 ao2_ref(message, -1);
344 }
345}
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
struct stasis_message * ast_endpoint_blob_create(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates a ast_endpoint_blob message.

References ao2_ref, ast_endpoint_blob_create(), ast_endpoint_topic(), stasis_publish(), and type.

Referenced by __expire_registry(), __iax2_poke_noanswer(), ast_sip_persistent_endpoint_publish_contact_state(), ast_sip_persistent_endpoint_update_state(), socket_process_helper(), and update_registry().

◆ ast_endpoint_cache()

struct stasis_cache * ast_endpoint_cache ( void  )

Backend cache for ast_endpoint_topic_all_cached().

Returns
Cache of ast_endpoint_snapshot.
Since
12

Definition at line 117 of file stasis_endpoints.c.

118{
120}
struct stasis_cache * stasis_cp_all_cache(struct stasis_cp_all *all)
Get the cache.
static struct stasis_cp_all * endpoint_cache_all

References endpoint_cache_all, and stasis_cp_all_cache().

Referenced by ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_endpoint_latest_snapshot(), endpoints_scrape_cb(), load_module(), and unload_module().

◆ ast_endpoint_cache_all()

struct stasis_cp_all * ast_endpoint_cache_all ( void  )

Definition at line 112 of file stasis_endpoints.c.

113{
114 return endpoint_cache_all;
115}

References endpoint_cache_all.

Referenced by endpoint_internal_create().

◆ ast_endpoint_contact_state_type()

struct stasis_message_type * ast_endpoint_contact_state_type ( void  )

◆ ast_endpoint_latest_snapshot()

struct ast_endpoint_snapshot * ast_endpoint_latest_snapshot ( const char *  tech,
const char *  resource 
)

Retrieve the most recent snapshot for the endpoint with the given name.

Parameters
techName of the endpoint's technology.
resourceResource name of the endpoint.
Returns
Snapshot of the endpoint with the given name.
Return values
NULLif endpoint is not found, or on error.
Since
12

Definition at line 347 of file stasis_endpoints.c.

349{
350 char *id = NULL;
351 struct stasis_message *msg;
352 struct ast_endpoint_snapshot *snapshot;
353
354 if (ast_strlen_zero(name)) {
355 ast_asprintf(&id, "%s", tech);
356 } else {
357 ast_asprintf(&id, "%s/%s", tech, name);
358 }
359 if (!id) {
360 return NULL;
361 }
363
365 ast_free(id);
366 if (!msg) {
367 return NULL;
368 }
369
370 snapshot = stasis_message_data(msg);
371 ast_assert(snapshot != NULL);
372
373 ao2_ref(snapshot, +1);
374 ao2_ref(msg, -1);
375
376 return snapshot;
377}
#define ast_free(a)
Definition: astmm.h:180
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
struct stasis_cache * ast_endpoint_cache(void)
Backend cache for ast_endpoint_topic_all_cached().
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_cache_get(struct stasis_cache *cache, struct stasis_message_type *type, const char *id)
Retrieve an item from the cache for the ast_eid_default entity.
Definition: stasis_cache.c:686
char * ast_tech_to_upper(char *dev_str)
Convert the tech portion of a device string to upper case.
Definition: strings.h:1236
A snapshot of an endpoint's state.
const ast_string_field tech

References ao2_ref, ast_asprintf, ast_assert, ast_endpoint_cache(), ast_endpoint_snapshot_type(), ast_free, ast_strlen_zero(), ast_tech_to_upper(), name, NULL, stasis_cache_get(), stasis_message_data(), and ast_endpoint_snapshot::tech.

Referenced by ast_ari_endpoints_get(), ast_ari_endpoints_refer_to_endpoint(), ast_ari_endpoints_send_message_to_endpoint(), ast_sip_get_endpoint_snapshot(), chan_pjsip_devicestate(), message_received_handler(), and stasis_app_user_event().

◆ ast_endpoint_snapshot_create()

struct ast_endpoint_snapshot * ast_endpoint_snapshot_create ( struct ast_endpoint endpoint)

Create a snapshot of an endpoint.

Parameters
endpointEndpoint to snap a shot of.
Returns
Snapshot of the endpoint.
Return values
NULLon error.
Since
12

Definition at line 445 of file main/endpoints.c.

447{
448 struct ast_endpoint_snapshot *snapshot;
449 int channel_count;
450 struct ao2_iterator i;
451 void *obj;
452 SCOPED_AO2LOCK(lock, endpoint);
453
454 ast_assert(endpoint != NULL);
456
457 channel_count = ao2_container_count(endpoint->channel_ids);
458
459 snapshot = ao2_alloc_options(
460 sizeof(*snapshot) + channel_count * sizeof(char *),
463
464 if (!snapshot || ast_string_field_init(snapshot, 80) != 0) {
465 ao2_cleanup(snapshot);
466 return NULL;
467 }
468
469 ast_string_field_build(snapshot, id, "%s/%s", endpoint->tech,
470 endpoint->resource);
471 ast_string_field_set(snapshot, tech, endpoint->tech);
472 ast_string_field_set(snapshot, resource, endpoint->resource);
473
474 snapshot->state = endpoint->state;
475 snapshot->max_channels = endpoint->max_channels;
476
477 i = ao2_iterator_init(endpoint->channel_ids, 0);
478 while ((obj = ao2_iterator_next(&i))) {
479 /* The reference is kept so the channel id does not go away until the snapshot is gone */
480 snapshot->channel_ids[snapshot->num_channels++] = obj;
481 }
483
484 return snapshot;
485}
ast_mutex_t lock
Definition: app_sla.c:337
#define ao2_iterator_next(iter)
Definition: astobj2.h:1911
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
Definition: lock.h:608
static void endpoint_snapshot_dtor(void *obj)
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
Definition: stringfields.h:555
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821
enum ast_endpoint_state state
struct ao2_container * channel_ids
const ast_string_field tech
enum ast_endpoint_state state
int max_channels
Max channels for this endpoint. -1 means unlimited or unknown.
const ast_string_field resource

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_assert, ast_string_field_build, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), ast_endpoint_snapshot::channel_ids, ast_endpoint::channel_ids, endpoint_snapshot_dtor(), lock, ast_endpoint_snapshot::max_channels, ast_endpoint::max_channels, NULL, ast_endpoint_snapshot::num_channels, ast_endpoint::resource, SCOPED_AO2LOCK, ast_endpoint_snapshot::state, ast_endpoint::state, and ast_endpoint::tech.

Referenced by ast_endpoint_blob_create(), AST_TEST_DEFINE(), create_endpoint_snapshot_message(), and endpoint_publish_snapshot().

◆ ast_endpoint_snapshot_type()

struct stasis_message_type * ast_endpoint_snapshot_type ( void  )

◆ ast_endpoint_state_type()

struct stasis_message_type * ast_endpoint_state_type ( void  )

◆ ast_endpoint_topic()

struct stasis_topic * ast_endpoint_topic ( struct ast_endpoint endpoint)

Returns the topic for a specific endpoint.

Parameters
endpointThe endpoint.
Returns
The topic for the given endpoint.
ast_endpoint_topic_all() if endpoint is NULL.
Since
12

Definition at line 93 of file main/endpoints.c.

94{
95 if (!endpoint) {
97 }
98 return stasis_cp_single_topic(endpoint->topics);
99}
struct stasis_topic * ast_endpoint_topic_all(void)
Topic for all endpoint related messages.
struct stasis_topic * stasis_cp_single_topic(struct stasis_cp_single *one)
Get the topic for this instance.
struct stasis_cp_single * topics

References ast_endpoint_topic_all(), stasis_cp_single_topic(), and ast_endpoint::topics.

Referenced by ast_channel_forward_endpoint(), ast_endpoint_blob_publish(), ast_endpoint_shutdown(), AST_TEST_DEFINE(), endpoint_internal_create(), endpoint_publish_snapshot(), and forwards_create_endpoint().

◆ ast_endpoint_topic_all()

struct stasis_topic * ast_endpoint_topic_all ( void  )

Topic for all endpoint related messages.

Since
12

Definition at line 122 of file stasis_endpoints.c.

123{
125}
struct stasis_topic * stasis_cp_all_topic(struct stasis_cp_all *all)
Get the aggregate topic.

References endpoint_cache_all, and stasis_cp_all_topic().

Referenced by ast_endpoint_topic().

◆ ast_endpoint_topic_all_cached()

struct stasis_topic * ast_endpoint_topic_all_cached ( void  )

Cached topic for all endpoint related messages.

Since
12

Definition at line 127 of file stasis_endpoints.c.

128{
130}
struct stasis_topic * stasis_cp_all_topic_cached(struct stasis_cp_all *all)
Get the caching topic.

References endpoint_cache_all, and stasis_cp_all_topic_cached().

Referenced by ast_endpoint_topic_cached(), AST_TEST_DEFINE(), forwards_create_endpoint(), load_module(), and manager_endpoints_init().

◆ ast_endpoint_topic_cached()

struct stasis_topic * ast_endpoint_topic_cached ( struct ast_endpoint endpoint)

Returns the topic for a specific endpoint.

ast_endpoint_snapshot messages are replaced with stasis_cache_update

Parameters
endpointThe endpoint.
Returns
The topic for the given endpoint.
ast_endpoint_topic_all() if endpoint is NULL.
Since
12

Definition at line 101 of file main/endpoints.c.

102{
103 if (!endpoint) {
105 }
106 return stasis_cp_single_topic_cached(endpoint->topics);
107}
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
struct stasis_topic * stasis_cp_single_topic_cached(struct stasis_cp_single *one)
Get the caching topic for this instance.

References ast_endpoint_topic_all_cached(), stasis_cp_single_topic_cached(), and ast_endpoint::topics.

Referenced by forwards_create_endpoint().

◆ ast_multi_channel_blob_add_channel()

void ast_multi_channel_blob_add_channel ( struct ast_multi_channel_blob obj,
const char *  role,
struct ast_channel_snapshot snapshot 
)

Add a ast_channel_snapshot to a ast_multi_channel_blob object.

Since
12
Note
This will increase the reference count by 1 for the channel snapshot. It is assumed that the ast_multi_channel_blob will own a reference to the object.
Parameters
objThe ast_multi_channel_blob object that will reference the snapshot
roleA role that the snapshot has in the multi channel relationship
snapshotThe ast_channel_snapshot being added to the ast_multi_channel_blob object

Definition at line 982 of file stasis_channels.c.

983{
984 struct channel_role_snapshot *role_snapshot;
985 int role_len = strlen(role) + 1;
986
987 if (!obj || ast_strlen_zero(role) || !snapshot) {
988 return;
989 }
990
991 role_snapshot = ao2_alloc_options(sizeof(*role_snapshot) + role_len,
993 if (!role_snapshot) {
994 return;
995 }
996 ast_copy_string(role_snapshot->role, role, role_len);
997 role_snapshot->snapshot = snapshot;
998 ao2_ref(role_snapshot->snapshot, +1);
999 ao2_link(obj->channel_snapshots, role_snapshot);
1000 ao2_ref(role_snapshot, -1);
1001}
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
static void channel_role_snapshot_dtor(void *obj)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
struct ao2_container * channel_snapshots
A channel snapshot wrapper object used in ast_multi_channel_blob objects.
struct ast_channel_snapshot * snapshot

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_link, ao2_ref, ast_copy_string(), ast_strlen_zero(), channel_role_snapshot_dtor(), ast_multi_channel_blob::channel_snapshots, channel_role_snapshot::role, and channel_role_snapshot::snapshot.

Referenced by ast_channel_publish_dial_internal(), AST_TEST_DEFINE(), local_channel_optimization_blob(), local_optimization_started_cb(), pack_channel_into_message(), publish_chanspy_message(), publish_local_bridge_message(), queue_publish_multi_channel_snapshot_blob(), and send_call_pickup_stasis_message().

◆ ast_multi_channel_blob_create()

struct ast_multi_channel_blob * ast_multi_channel_blob_create ( struct ast_json blob)

Create a ast_multi_channel_blob suitable for a stasis_message.

Since
12

The given blob should be treated as immutable and not modified after it is put into the message.

Parameters
blobThe JSON blob that defines the data of this ast_multi_channel_blob
Returns
ast_multi_channel_blob object
Return values
NULLon error

Definition at line 907 of file stasis_channels.c.

908{
909 struct ast_multi_channel_blob *obj;
910
911 ast_assert(blob != NULL);
912
913 obj = ao2_alloc(sizeof(*obj), multi_channel_blob_dtor);
914 if (!obj) {
915 return NULL;
916 }
917
920 if (!obj->channel_snapshots) {
921 ao2_ref(obj, -1);
922 return NULL;
923 }
924
925 obj->blob = ast_json_ref(blob);
926 return obj;
927}
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
static int channel_role_cmp_cb(void *obj, void *arg, int flags)
#define NUM_MULTI_CHANNEL_BLOB_BUCKETS
static int channel_role_hash_cb(const void *obj, const int flags)
static void multi_channel_blob_dtor(void *obj)
A multi channel blob data structure for multi_channel_blob stasis messages.
struct ast_json * blob

References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, ast_assert, ast_json_ref(), ast_multi_channel_blob::blob, channel_role_cmp_cb(), channel_role_hash_cb(), ast_multi_channel_blob::channel_snapshots, multi_channel_blob_dtor(), NULL, and NUM_MULTI_CHANNEL_BLOB_BUCKETS.

Referenced by ast_channel_publish_dial_internal(), AST_TEST_DEFINE(), local_channel_optimization_blob(), publish_chanspy_message(), publish_local_bridge_message(), queue_publish_multi_channel_snapshot_blob(), and send_call_pickup_stasis_message().

◆ ast_multi_channel_blob_get_channel()

struct ast_channel_snapshot * ast_multi_channel_blob_get_channel ( struct ast_multi_channel_blob obj,
const char *  role 
)

Retrieve a channel snapshot associated with a specific role from a ast_multi_channel_blob.

Since
12
Note
The reference count of the ast_channel_snapshot returned from this function is not changed. The caller of this function does not own the reference to the snapshot.
Parameters
objThe ast_multi_channel_blob containing the channel snapshot to retrieve
roleThe role associated with the channel snapshot
Returns
ast_channel_snapshot matching the role on success
Return values
NULLon error or not found for the role specified

Definition at line 1003 of file stasis_channels.c.

1004{
1005 struct channel_role_snapshot *role_snapshot;
1006 struct ast_channel_snapshot *snapshot;
1007
1008 if (!obj || ast_strlen_zero(role)) {
1009 return NULL;
1010 }
1011 role_snapshot = ao2_find(obj->channel_snapshots, role, OBJ_SEARCH_KEY);
1012 /* Note that this function does not increase the ref count on snapshot */
1013 if (!role_snapshot) {
1014 return NULL;
1015 }
1016 snapshot = role_snapshot->snapshot;
1017 ao2_ref(role_snapshot, -1);
1018 return snapshot;
1019}

References ao2_find, ao2_ref, ast_strlen_zero(), ast_multi_channel_blob::channel_snapshots, NULL, OBJ_SEARCH_KEY, and channel_role_snapshot::snapshot.

Referenced by AST_TEST_DEFINE(), call_forwarded_handler(), call_pickup_to_ami(), cel_dial_cb(), cel_local_optimization_cb_helper(), cel_pickup_cb(), channel_chanspy_start_cb(), channel_chanspy_stop_cb(), channel_dial_cb(), dial_to_json(), handle_dial_message(), handle_local_optimization_begin(), handle_local_optimization_end(), local_message_to_ami(), and queue_multi_channel_to_ami().

◆ ast_multi_channel_blob_get_channels()

struct ao2_container * ast_multi_channel_blob_get_channels ( struct ast_multi_channel_blob obj,
const char *  role 
)

Retrieve all channel snapshots associated with a specific role from a ast_multi_channel_blob.

Since
12
Note
Because this function returns an ao2_container (hashed by channel name) of all channel snapshots that matched the passed in role, the reference of the snapshots is increased by this function. The caller of this function must release the reference to the snapshots by disposing of the container appropriately.
Parameters
objThe ast_multi_channel_blob containing the channel snapshots to retrieve
roleThe role associated with the channel snapshots
Returns
A container containing all ast_channel_snapshot objects matching the role on success.
Return values
NULLon error or not found for the role specified

Definition at line 1021 of file stasis_channels.c.

1022{
1023 struct ao2_container *ret_container;
1024 struct ao2_iterator *it_role_snapshots;
1025 struct channel_role_snapshot *role_snapshot;
1026 char *arg;
1027
1028 if (!obj || ast_strlen_zero(role)) {
1029 return NULL;
1030 }
1031
1035 if (!ret_container) {
1036 return NULL;
1037 }
1038
1039 arg = ast_strdupa(role);
1040 it_role_snapshots = ao2_callback(obj->channel_snapshots,
1042 if (!it_role_snapshots) {
1043 ao2_ref(ret_container, -1);
1044 return NULL;
1045 }
1046
1047 while ((role_snapshot = ao2_iterator_next(it_role_snapshots))) {
1048 ao2_link(ret_container, role_snapshot->snapshot);
1049 ao2_ref(role_snapshot, -1);
1050 }
1051 ao2_iterator_destroy(it_role_snapshots);
1052
1053 return ret_container;
1054}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
@ OBJ_MULTIPLE
Definition: astobj2.h:1049
static int channel_snapshot_cmp_cb(void *obj, void *arg, int flags)
static int channel_snapshot_hash_cb(const void *obj, const int flags)
Generic container type.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_callback, ao2_container_alloc_hash, ao2_iterator_destroy(), ao2_iterator_next, ao2_link, ao2_ref, ast_strdupa, ast_strlen_zero(), channel_role_cmp_cb(), channel_snapshot_cmp_cb(), channel_snapshot_hash_cb(), ast_multi_channel_blob::channel_snapshots, NULL, NUM_MULTI_CHANNEL_BLOB_BUCKETS, OBJ_MULTIPLE, OBJ_SEARCH_KEY, channel_role_snapshot::role, and channel_role_snapshot::snapshot.

Referenced by AST_TEST_DEFINE().

◆ ast_multi_channel_blob_get_json()

struct ast_json * ast_multi_channel_blob_get_json ( struct ast_multi_channel_blob obj)

Retrieve the JSON blob from a ast_multi_channel_blob. Returned ast_json is still owned by obj.

Since
12
Parameters
objChannel blob object.
Returns
Type field value from the blob.
Return values
NULLon error.

Definition at line 1056 of file stasis_channels.c.

1057{
1058 if (!obj) {
1059 return NULL;
1060 }
1061 return obj->blob;
1062}

References ast_multi_channel_blob::blob, and NULL.

Referenced by AST_TEST_DEFINE(), channel_dial_cb(), dial_to_json(), get_blob_variable(), handle_dial_message(), handle_local_optimization_begin(), handle_local_optimization_end(), local_message_to_ami(), and queue_multi_channel_to_ami().

◆ ast_multi_object_blob_add()

void ast_multi_object_blob_add ( struct ast_multi_object_blob multi,
enum stasis_user_multi_object_snapshot_type  type,
void *  object 
)

Add an object to a multi object blob previously created.

Since
12.3.0
Parameters
multiThe multi object blob previously created
typeType code for the object such as channel, bridge, etc.
objectSnapshot object of the type supplied to typename

Add an object to a multi object blob previously created.

Definition at line 2028 of file stasis.c.

2030{
2031 if (!multi || !object || AST_VECTOR_APPEND(&multi->snapshots[type], object)) {
2032 ao2_cleanup(object);
2033 }
2034}
struct ast_multi_object_blob::@398 snapshots[STASIS_UMOS_MAX]
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256

References ao2_cleanup, AST_VECTOR_APPEND, ast_multi_object_blob::snapshots, and type.

Referenced by ast_multi_object_blob_single_channel_publish(), and stasis_app_user_event().

◆ ast_multi_object_blob_create()

struct ast_multi_object_blob * ast_multi_object_blob_create ( struct ast_json blob)

Create a stasis multi object blob.

Since
12.3.0

Multi object blob can store a combination of arbitrary json values (the blob) and also snapshots of various other system objects (such as channels, bridges, etc) for delivery through a stasis message. The multi object blob is first created, then optionally objects are added to it, before being attached to a message and delivered to stasis topic.

Parameters
blobJson blob
Note
When used for an ast_multi_user_event_type message, the json blob should contain at minimum {eventname: name}.
Return values
ast_multi_object_blob*if succeeded
NULLif creation failed

Create a stasis multi object blob.

Definition at line 2002 of file stasis.c.

2003{
2004 int type;
2005 struct ast_multi_object_blob *multi;
2006
2007 ast_assert(blob != NULL);
2008
2009 multi = ao2_alloc(sizeof(*multi), multi_object_blob_dtor);
2010 if (!multi) {
2011 return NULL;
2012 }
2013
2014 for (type = 0; type < STASIS_UMOS_MAX; ++type) {
2015 if (AST_VECTOR_INIT(&multi->snapshots[type], 0)) {
2016 ao2_ref(multi, -1);
2017
2018 return NULL;
2019 }
2020 }
2021
2022 multi->blob = ast_json_ref(blob);
2023
2024 return multi;
2025}
#define STASIS_UMOS_MAX
Number of snapshot types.
Definition: stasis.h:1360
static void multi_object_blob_dtor(void *obj)
Definition: stasis.c:1986
A multi object blob data structure to carry user event stasis messages.
Definition: stasis.c:1977
struct ast_json * blob
Definition: stasis.c:1978
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113

References ao2_alloc, ao2_ref, ast_assert, ast_json_ref(), AST_VECTOR_INIT, ast_multi_object_blob::blob, multi_object_blob_dtor(), NULL, ast_multi_object_blob::snapshots, STASIS_UMOS_MAX, and type.

Referenced by ast_multi_object_blob_single_channel_publish(), and stasis_app_user_event().

◆ ast_multi_object_blob_single_channel_publish()

void ast_multi_object_blob_single_channel_publish ( struct ast_channel chan,
struct stasis_message_type type,
struct ast_json blob 
)

Create and publish a stasis message blob on a channel with it's snapshot.

Since
12.3.0

For compatibility with app_userevent, this creates a multi object blob message, attaches the channel snapshot to it, and publishes it to the channel's topic.

Parameters
chanThe channel to snapshot and publish event to
typeThe message type
blobA json blob to publish with the snapshot

Create and publish a stasis message blob on a channel with it's snapshot.

Definition at line 2037 of file stasis.c.

2039{
2040 struct stasis_message *message;
2041 struct ast_channel_snapshot *channel_snapshot;
2042 struct ast_multi_object_blob *multi;
2043
2044 if (!type) {
2045 return;
2046 }
2047
2049 if (!multi) {
2050 return;
2051 }
2052
2053 channel_snapshot = ast_channel_snapshot_create(chan);
2054 if (!channel_snapshot) {
2055 ao2_ref(multi, -1);
2056 return;
2057 }
2058
2059 /* this call steals the channel_snapshot reference */
2060 ast_multi_object_blob_add(multi, STASIS_UMOS_CHANNEL, channel_snapshot);
2061
2063 ao2_ref(multi, -1);
2064 if (message) {
2065 /* app_userevent still publishes to channel */
2067 ao2_ref(message, -1);
2068 }
2069}
void ast_multi_object_blob_add(struct ast_multi_object_blob *multi, enum stasis_user_multi_object_snapshot_type type, void *object)
Add an object (snapshot) to the blob.
Definition: stasis.c:2028
struct ast_channel_snapshot * ast_channel_snapshot_create(struct ast_channel *chan)
Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate.
struct ast_multi_object_blob * ast_multi_object_blob_create(struct ast_json *blob)
Create a stasis user event multi object blob.
Definition: stasis.c:2002
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1538

References ao2_ref, ast_channel_snapshot_create(), ast_channel_topic(), ast_multi_object_blob_add(), ast_multi_object_blob_create(), ast_multi_object_blob::blob, stasis_message_create(), stasis_publish(), STASIS_UMOS_CHANNEL, and type.

Referenced by userevent_exec().

◆ ast_multi_user_event_type()

struct stasis_message_type * ast_multi_user_event_type ( void  )

Message type for custom user defined events with multi object blobs.

Returns
The stasis_message_type for user event
Since
12.3.0

Referenced by stasis_app_user_event(), stasis_cleanup(), stasis_init(), and userevent_exec().

◆ ast_parked_call_type()

struct stasis_message_type * ast_parked_call_type ( void  )

accessor for the parked call stasis message type

Since
12
Return values
NULLif the parking topic hasn't been created or has been canceled
Returns
a pointer to the parked call message type

Referenced by ast_parking_stasis_init(), create_parked_subscription_full(), create_routes(), load_module(), park_and_announce_app_exec(), park_announce_update_cb(), parker_update_cb(), parking_event_cb(), parking_manager_enable_stasis(), parking_stasis_cleanup(), publish_parked_call(), and publish_parked_call_failure().

◆ ast_parking_topic()

struct stasis_topic * ast_parking_topic ( void  )

accessor for the parking stasis topic

Since
12
Return values
NULLif the parking topic hasn't been created or has been disabled
Returns
a pointer to the parking topic

Definition at line 67 of file parking.c.

68{
69 return parking_topic;
70}
static struct stasis_topic * parking_topic
Topic for parking lots.
Definition: parking.c:41

References parking_topic.

Referenced by create_parked_subscription_full(), create_subscriptions(), park_and_announce_app_exec(), parking_manager_enable_stasis(), publish_parked_call(), and publish_parked_call_failure().

◆ ast_rtp_rtcp_received_type()

struct stasis_message_type * ast_rtp_rtcp_received_type ( void  )

Message type for an RTCP message received from some external source.

Since
12
Returns
A stasis message type

Referenced by ast_rtcp_interpret(), ast_rtp_engine_init(), load_module(), rtcp_report_to_ami(), rtcp_report_to_json(), rtp_engine_shutdown(), and rtp_topic_handler().

◆ ast_rtp_rtcp_sent_type()

struct stasis_message_type * ast_rtp_rtcp_sent_type ( void  )

Message type for an RTCP message sent from this Asterisk instance.

Since
12
Returns
A stasis message type

Referenced by ast_rtcp_calculate_sr_rr_statistics(), ast_rtp_engine_init(), load_module(), rtp_engine_shutdown(), and rtp_topic_handler().

◆ stasis_cache_clear_type()

struct stasis_message_type * stasis_cache_clear_type ( void  )

Message type for clearing a message from a stasis cache.

Since
12

Referenced by caching_topic_exec(), stasis_cache_cleanup(), stasis_cache_clear_create(), stasis_cache_init(), and stasis_caching_accept_message_type().

◆ stasis_cache_update_type()

struct stasis_message_type * stasis_cache_update_type ( void  )

Message type for cache update messages.

Returns
Message type for cache update messages.
Since
12

Referenced by AST_TEST_DEFINE(), cache_update(), find_route(), load_module(), stasis_cache_cleanup(), stasis_cache_init(), stasis_message_router_add_cache_update(), sub_endpoint_update_handler(), and update_create().

◆ stasis_subscription_change_type()

struct stasis_message_type * stasis_subscription_change_type ( void  )

◆ stasis_test_message_create()

struct stasis_message * stasis_test_message_create ( void  )

Creates a test message.

Definition at line 236 of file res_stasis_test.c.

237{
238 RAII_VAR(void *, data, NULL, ao2_cleanup);
239
241 return NULL;
242 }
243
244 /* We just need the unique pointer; don't care what's in it */
245 data = ao2_alloc(1, NULL);
246 if (!data) {
247 return NULL;
248 }
249
251}
struct stasis_message_type * stasis_test_message_type(void)
Gets the type of messages created by stasis_test_message_create().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References ao2_alloc, ao2_cleanup, stasis_message::data, NULL, RAII_VAR, stasis_message_create(), and stasis_test_message_type().

◆ stasis_test_message_type()

struct stasis_message_type * stasis_test_message_type ( void  )

Gets the type of messages created by stasis_test_message_create().

Referenced by load_module(), stasis_test_message_create(), and unload_module().