Asterisk - The Open Source Telephony Project  21.4.1
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.
 

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_topicast_channel_topic_all (void)
 A topic which publishes the events for all channels. More...
 
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.
 
struct stasis_message_typestasis_test_message_type (void)
 Gets the type of messages created by stasis_test_message_create().
 

Detailed Description

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

Enumeration Type Documentation

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 35 of file stasis_channels.h.

35  {
36  /*! Invalidate the bridge segment */
38  /*! Invalidate the dialplan segment */
40  /*! Invalidate the connected segment */
42  /*! Invalidate the caller segment */
44  /*! Invalidate the hangup segment */
46  /*! Invalidate the peer segment */
48  /*! Invalidate the base segment */
50 };

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 };

Function Documentation

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(), and load_module().

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(), and load_module().

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 793 of file stasis_channels.c.

References ao2_bump.

Referenced by app_send_end_msg(), and ast_channel_publish_blob().

795 {
796  struct ast_channel_snapshot *snapshot;
797  struct stasis_message *msg;
798 
799  if (!type) {
800  return NULL;
801  }
802 
803  snapshot = chan ? ao2_bump(ast_channel_snapshot(chan)) : NULL;
804  msg = create_channel_blob_message(snapshot, type, blob);
805  ao2_cleanup(snapshot);
806  return msg;
807 }
Structure representing a snapshot of channel state.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
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 776 of file stasis_channels.c.

References ast_channel_snapshot_get_latest().

Referenced by ast_cel_publish_event(), ast_channel_publish_cached_blob(), manager_mute_mixmonitor(), report_fax_status(), report_receive_fax_status(), and report_send_fax_status().

779 {
780  struct ast_channel_snapshot *snapshot;
781  struct stasis_message *msg;
782 
783  if (!type) {
784  return NULL;
785  }
786 
787  snapshot = ast_channel_snapshot_get_latest(channel_id);
788  msg = create_channel_blob_message(snapshot, type, blob);
789  ao2_cleanup(snapshot);
790  return msg;
791 }
Structure representing a snapshot of channel state.
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...
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 134 of file stasis_channels.c.

References ao2_bump.

Referenced by action_coreshowchannels().

135 {
136  return ao2_bump(channel_cache_by_name);
137 }
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
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(), and manager_channels_init().

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(), and manager_channels_init().

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_stasis_channels_init(), create_routes(), and manager_channels_init().

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(), and manager_channels_init().

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(), and manager_channels_init().

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(), and report_send_fax_status().

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(), and manager_channels_init().

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(), and manager_channels_init().

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(), and manager_channels_init().

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(), and manager_channels_init().

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(), and ast_stasis_channels_init().

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(), and manager_mute_mixmonitor().

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(), and manager_channels_init().

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(), and manager_channels_init().

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(), and manager_channels_init().

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(), and manager_channels_init().

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 1138 of file stasis_channels.c.

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

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(), and publish_dahdichannel().

1139 {
1140  struct stasis_message *message;
1141 
1142  if (!blob) {
1143  blob = ast_json_null();
1144  }
1145 
1146  message = ast_channel_blob_create(chan, type, blob);
1147  if (message) {
1148  stasis_publish(ast_channel_topic(chan), message);
1149  ao2_ref(message, -1);
1150  }
1151 }
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition: json.c:248
#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.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
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 1123 of file stasis_channels.c.

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

Referenced by ast_bridge_channel_write_hold(), ast_bridge_channel_write_unhold(), hold_intercept_framehook(), leave_queue(), and record_abandoned().

1124 {
1125  struct stasis_message *message;
1126 
1127  if (!blob) {
1128  blob = ast_json_null();
1129  }
1130 
1131  message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan), type, blob);
1132  if (message) {
1133  stasis_publish(ast_channel_topic(chan), message);
1134  ao2_ref(message, -1);
1135  }
1136 }
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition: json.c:248
#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.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
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.
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 744 of file stasis_channels.c.

References ast_channel_publish_dial_forward().

Referenced by begin_dial_channel(), dial_exec_full(), do_forward(), handle_frame(), hangupcalls(), monitor_dial(), ring_entry(), and wait_for_answer().

746 {
747  ast_channel_publish_dial_forward(caller, peer, NULL, dialstring, dialstatus, NULL);
748 }
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...
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 694 of file stasis_channels.c.

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

697 {
698  ast_assert(peer != NULL);
699 
700  /* XXX With an early bridge the below dial masquerade datastore code could, theoretically,
701  * go away as the act of changing the channel during dialing would be done using the bridge
702  * API itself and not a masquerade.
703  */
704 
705  if (caller) {
706  /*
707  * Lock two or three channels.
708  *
709  * We need to hold the locks to hold off a potential masquerade
710  * messing up the stasis dial event ordering.
711  */
712  for (;; ast_channel_unlock(caller), sched_yield()) {
713  ast_channel_lock(caller);
714  if (ast_channel_trylock(peer)) {
715  continue;
716  }
717  if (forwarded && ast_channel_trylock(forwarded)) {
718  ast_channel_unlock(peer);
719  continue;
720  }
721  break;
722  }
723 
724  if (ast_strlen_zero(dialstatus)) {
725  set_dial_masquerade(caller, peer, dialstring);
726  } else {
727  remove_dial_masquerade(peer);
728  }
729  }
730 
731  ast_channel_publish_dial_internal(caller, peer, forwarded, dialstring, dialstatus,
732  forward);
733 
734  if (caller) {
735  if (forwarded) {
736  ast_channel_unlock(forwarded);
737  }
738  ast_channel_unlock(peer);
739  remove_dial_masquerade_caller(caller);
740  ast_channel_unlock(caller);
741  }
742 }
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 922 of file stasis_channels.c.

References ao2_ref, ast_channel_snapshot_type(), ast_channel_topic(), OBJ_NODATA, OBJ_SEARCH_KEY, OBJ_UNLINK, stasis_message_create(), and stasis_publish().

Referenced by ast_channel_destructor().

923 {
924  struct ast_channel_snapshot_update *update;
925  struct stasis_message *message;
926 
927  if (!ast_channel_snapshot_type()) {
928  return;
929  }
930 
931  update = channel_snapshot_update_create(chan);
932  if (!update) {
933  return;
934  }
935 
937  /* In the success path message holds a reference to update so it will be valid
938  * for the lifetime of this function until the end.
939  */
940  ao2_ref(update, -1);
941  if (!message) {
942  return;
943  }
944 
945  ao2_find(channel_cache, ast_channel_uniqueid(chan), OBJ_SEARCH_KEY | OBJ_UNLINK | OBJ_NODATA);
946  ao2_find(channel_cache_by_name, ast_channel_name(chan), OBJ_SEARCH_KEY | OBJ_UNLINK | OBJ_NODATA);
947 
948  ast_channel_snapshot_set(chan, NULL);
949 
950  stasis_publish(ast_channel_topic(chan), message);
951  ao2_ref(message, -1);
952 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
Structure representing a change of snapshot of channel state.
#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 * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
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 1060 of file stasis_channels.c.

References ao2_link_flags, ao2_ref, ast_channel_snapshot_type(), ast_channel_topic(), AST_FLAG_SNAPSHOT_STAGE, ast_channel_snapshot_update::new_snapshot, OBJ_NODATA, OBJ_NOLOCK, OBJ_SEARCH_KEY, OBJ_UNLINK, ast_channel_snapshot_update::old_snapshot, stasis_message_create(), and stasis_publish().

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(), channel_do_masquerade(), do_forward(), and pbx_exec().

1061 {
1062  struct ast_channel_snapshot_update *update;
1063  struct stasis_message *message;
1064 
1065  if (!ast_channel_snapshot_type()) {
1066  return;
1067  }
1068 
1069  if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_SNAPSHOT_STAGE)) {
1070  return;
1071  }
1072 
1073  update = channel_snapshot_update_create(chan);
1074  if (!update) {
1075  return;
1076  }
1077 
1078  /* If an old snapshot exists and is the same as this newly created one don't bother
1079  * raising a message as it hasn't changed.
1080  */
1081  if (update->old_snapshot && !memcmp(update->old_snapshot, update->new_snapshot, sizeof(struct ast_channel_snapshot))) {
1082  ao2_ref(update, -1);
1083  return;
1084  }
1085 
1086  message = stasis_message_create(ast_channel_snapshot_type(), update);
1087  /* In the success path message holds a reference to update so it will be valid
1088  * for the lifetime of this function until the end.
1089  */
1090  ao2_ref(update, -1);
1091  if (!message) {
1092  return;
1093  }
1094 
1095  /* We lock these ourselves so that the update is atomic and there isn't time where a
1096  * snapshot is not in the cache.
1097  */
1098  ao2_wrlock(channel_cache);
1099  ao2_find(channel_cache, ast_channel_uniqueid(chan), OBJ_SEARCH_KEY | OBJ_UNLINK | OBJ_NODATA | OBJ_NOLOCK);
1100 
1101  ao2_link_flags(channel_cache, update->new_snapshot, OBJ_NOLOCK);
1102  ao2_unlock(channel_cache);
1103 
1104  /* The same applies here. */
1105  ao2_wrlock(channel_cache_by_name);
1106  ao2_find(channel_cache_by_name, ast_channel_name(chan), OBJ_SEARCH_KEY | OBJ_UNLINK | OBJ_NODATA | OBJ_NOLOCK);
1107 
1108  ao2_link_flags(channel_cache_by_name, update->new_snapshot, OBJ_NOLOCK);
1109  ao2_unlock(channel_cache_by_name);
1110 
1111  ast_channel_snapshot_set(chan, update->new_snapshot);
1112 
1113  /* As this is now the new snapshot any existing invalidated segments have been
1114  * created fresh and are up to date.
1115  */
1116  ast_clear_flag(ast_channel_snapshot_segment_flags(chan), AST_FLAGS_ALL);
1117 
1118  ast_assert(ast_channel_topic(chan) != NULL);
1119  stasis_publish(ast_channel_topic(chan), message);
1120  ao2_ref(message, -1);
1121 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
Structure representing a snapshot of channel state.
Assume that the ao2_container is already locked.
Definition: astobj2.h:1063
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
Definition: astobj2.h:1554
Structure representing a change of snapshot of channel state.
#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 * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
struct ast_channel_snapshot * new_snapshot
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
struct ast_channel_snapshot * old_snapshot
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 1153 of file stasis_channels.c.

References ast_alloca, ast_channel_has_manager_vars(), ast_channel_publish_blob(), ast_channel_publish_snapshot(), ast_channel_varset_type(), ast_json_pack(), ast_json_unref(), ast_utf8_replace_invalid_chars(), and AST_UTF8_REPLACE_VALID.

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

1154 {
1155  struct ast_json *blob;
1156  enum ast_utf8_replace_result result;
1157  char *new_value = NULL;
1158  size_t new_value_size = 0;
1159 
1160  ast_assert(name != NULL);
1161  ast_assert(value != NULL);
1162 
1163  /*
1164  * Call with new-value == NULL to just check for invalid UTF-8
1165  * sequences and get size of buffer needed.
1166  */
1167  result = ast_utf8_replace_invalid_chars(new_value, &new_value_size,
1168  value, strlen(value));
1169 
1170  if (result == AST_UTF8_REPLACE_VALID) {
1171  /*
1172  * If there were no invalid sequences, we can use
1173  * the value directly.
1174  */
1175  new_value = (char *)value;
1176  } else {
1177  /*
1178  * If there were invalid sequences, we need to replace
1179  * them with the UTF-8 U+FFFD replacement character.
1180  */
1181  new_value = ast_alloca(new_value_size);
1182 
1183  result = ast_utf8_replace_invalid_chars(new_value, &new_value_size,
1184  value, strlen(value));
1185 
1186  ast_log(LOG_WARNING, "%s: The contents of variable '%s' had invalid UTF-8 sequences which were replaced",
1187  ast_channel_name(chan), name);
1188  }
1189 
1190  blob = ast_json_pack("{s: s, s: s}",
1191  "variable", name,
1192  "value", new_value);
1193  if (!blob) {
1194  ast_log(LOG_ERROR, "Error creating message\n");
1195  return;
1196  }
1197 
1198  /*! If there are manager variables, force a cache update */
1199  if (chan && ast_channel_has_manager_vars()) {
1201  }
1202 
1203  /* This function is NULL safe for global variables */
1205  ast_json_unref(blob);
1206 }
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
Source contained fully valid UTF-8.
Definition: utf8.h:76
struct stasis_message_type * ast_channel_varset_type(void)
Message type for when a variable is set on a channel.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
ast_utf8_replace_result
Definition: utf8.h:70
Abstract JSON element (object, array, string, int, ...).
int ast_channel_has_manager_vars(void)
Return whether or not any manager variables have been set.
Definition: channel.c:7855
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
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
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
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 456 of file stasis_channels.c.

References ast_channel_snapshot::amaflags, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_bump, ao2_ref, ast_channel_snapshot::ari_vars, ast_channel_get_ari_vars(), ast_channel_get_manager_vars(), 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::base, ast_channel_snapshot::bridge, ast_channel_snapshot::caller, ast_channel_snapshot::connected, ast_channel_snapshot::dialplan, ast_channel_snapshot::flags, ast_channel_snapshot::hangup, ast_channel_snapshot::manager_vars, ast_channel_snapshot::peer, ast_channel_snapshot::softhangup_flags, and ast_channel_snapshot::state.

Referenced by ast_do_pickup(), and ast_multi_object_blob_single_channel_publish().

457 {
458  struct ast_channel_snapshot *old_snapshot;
459  struct ast_channel_snapshot *snapshot;
460 
461  /* no snapshots for dummy channels */
462  if (!ast_channel_tech(chan)) {
463  return NULL;
464  }
465 
466  snapshot = ao2_alloc_options(sizeof(*snapshot), channel_snapshot_dtor,
468  if (!snapshot) {
469  return NULL;
470  }
471 
472  old_snapshot = ast_channel_snapshot(chan);
473 
474  /* Channels automatically have all segments invalidated on them initially so a check for an old
475  * snapshot existing before usage is not done here, as it can not happen. If the stored snapshot
476  * on the channel is updated as a result of this then all segments marked as invalidated will be
477  * cleared.
478  */
479  if (ast_test_flag(ast_channel_snapshot_segment_flags(chan), AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE)) {
480  /* The base information has changed so update our snapshot */
481  snapshot->base = channel_snapshot_base_create(chan);
482  if (!snapshot->base) {
483  ao2_ref(snapshot, -1);
484  return NULL;
485  }
486  } else {
487  snapshot->base = ao2_bump(old_snapshot->base);
488  }
489 
490  if (ast_test_flag(ast_channel_snapshot_segment_flags(chan), AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER)) {
491  /* The peer information has changed so update our snapshot */
492  snapshot->peer = channel_snapshot_peer_create(chan);
493  if (!snapshot->peer) {
494  ao2_ref(snapshot, -1);
495  return NULL;
496  }
497  } else {
498  snapshot->peer = ao2_bump(old_snapshot->peer);
499  }
500 
501  /* Unfortunately both caller and connected information do not have an enforced contract with
502  * the channel API. This has allowed consumers to directly get the caller or connected structure
503  * and manipulate it. Until such time as there is an enforced contract (which is being tracked under
504  * ASTERISK-28164) they are each regenerated every time a channel snapshot is created.
505  */
506  snapshot->caller = channel_snapshot_caller_create(chan);
507  if (!snapshot->caller) {
508  ao2_ref(snapshot, -1);
509  return NULL;
510  }
511 
512  snapshot->connected = channel_snapshot_connected_create(chan);
513  if (!snapshot->connected) {
514  ao2_ref(snapshot, -1);
515  return NULL;
516  }
517 
518  if (ast_test_flag(ast_channel_snapshot_segment_flags(chan), AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE)) {
519  /* The bridge has changed so update our snapshot */
520  snapshot->bridge = channel_snapshot_bridge_create(chan);
521  if (!snapshot->bridge) {
522  ao2_ref(snapshot, -1);
523  return NULL;
524  }
525  } else {
526  snapshot->bridge = ao2_bump(old_snapshot->bridge);
527  }
528 
529  if (ast_test_flag(ast_channel_snapshot_segment_flags(chan), AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN)) {
530  /* The dialplan information has changed so update our snapshot */
531  snapshot->dialplan = channel_snapshot_dialplan_create(chan);
532  if (!snapshot->dialplan) {
533  ao2_ref(snapshot, -1);
534  return NULL;
535  }
536  } else {
537  snapshot->dialplan = ao2_bump(old_snapshot->dialplan);
538  }
539 
540  if (ast_test_flag(ast_channel_snapshot_segment_flags(chan), AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP)) {
541  /* The hangup information has changed so update our snapshot */
542  snapshot->hangup = channel_snapshot_hangup_create(chan);
543  if (!snapshot->hangup) {
544  ao2_ref(snapshot, -1);
545  return NULL;
546  }
547  } else {
548  snapshot->hangup = ao2_bump(old_snapshot->hangup);
549  }
550 
551  snapshot->state = ast_channel_state(chan);
552  snapshot->amaflags = ast_channel_amaflags(chan);
553  ast_copy_flags(&snapshot->flags, ast_channel_flags(chan), 0xFFFFFFFF);
554  ast_set_flag(&snapshot->softhangup_flags, ast_channel_softhangup_internal_flag(chan));
555 
556  /* These have to be recreated as they may have changed, unfortunately */
557  snapshot->manager_vars = ast_channel_get_manager_vars(chan);
558  snapshot->ari_vars = ast_channel_get_ari_vars(chan);
559 
560  return snapshot;
561 }
struct ast_channel_snapshot_base * base
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:7983
Structure representing a snapshot of channel state.
ast_channel_state
ast_channel states
Definition: channelstate.h:35
struct ast_channel_snapshot_dialplan * dialplan
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
struct varshead * ari_vars
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
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:7988
struct ast_channel_snapshot_hangup * hangup
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
struct ast_channel_snapshot_caller * caller
struct ast_flags softhangup_flags
struct varshead * manager_vars
enum ast_channel_state state
struct ast_flags flags
struct ast_channel_snapshot_bridge * bridge
struct ast_channel_snapshot_peer * peer
struct ast_channel_snapshot_connected * connected
struct ast_channel_snapshot* ast_channel_snapshot_get_latest ( const char *  uniqueid)
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 915 of file stasis_channels.c.

References OBJ_SEARCH_KEY.

Referenced by action_coreshowchannelmap(), and coreshowchannelmap_add_connected_channels().

916 {
917  ast_assert(!ast_strlen_zero(name));
918 
919  return ao2_find(channel_cache_by_name, name, OBJ_SEARCH_KEY);
920 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
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.

Since
17
Precondition
chan is locked
Parameters
chanChannel to invalidate the segment on.
segmentThe segment to invalidate.

Definition at line 1054 of file stasis_channels.c.

Referenced by ast_channel_internal_bridge_set(), ast_channel_internal_copy_linkedid(), ast_channel_set_caller(), ast_channel_set_caller_event(), ast_channel_set_connected_line(), and ast_channel_set_redirecting().

1056 {
1057  ast_set_flag(ast_channel_snapshot_segment_flags(chan), segment);
1058 }
struct stasis_message_type* ast_channel_snapshot_type ( void  )
void ast_channel_stage_snapshot ( struct ast_channel chan)

Set flag to indicate channel snapshot is being staged.

Since
12
Precondition
chan is locked
Parameters
chanChannel being staged.

Definition at line 1043 of file stasis_channels.c.

References AST_FLAG_SNAPSHOT_STAGE.

Referenced by __ast_channel_alloc_ap(), __ast_request_and_dial(), ast_ari_channels_dial(), ast_bridge_vars_set(), ast_call_forward(), ast_iax2_new(), ast_rtp_instance_set_stats_vars(), ast_unreal_call_setup(), begin_dial_prerun(), chan_pjsip_new(), console_new(), dial_exec_full(), jingle_new(), and unistim_new().

1044 {
1045  ast_set_flag(ast_channel_flags(chan), AST_FLAG_SNAPSHOT_STAGE);
1046 }
void ast_channel_stage_snapshot_done ( struct ast_channel chan)

Clear flag to indicate channel snapshot is being staged, and publish snapshot.

Since
12
Precondition
chan is locked
Parameters
chanChannel being staged.

Definition at line 1048 of file stasis_channels.c.

References ast_channel_publish_snapshot(), and AST_FLAG_SNAPSHOT_STAGE.

Referenced by __ast_channel_alloc_ap(), __ast_request_and_dial(), ast_ari_channels_dial(), ast_bridge_vars_set(), ast_call_forward(), ast_iax2_new(), ast_rtp_instance_set_stats_vars(), ast_unreal_call_setup(), begin_dial_prerun(), chan_pjsip_new(), console_new(), dial_exec_full(), jingle_new(), and unistim_new().

1049 {
1050  ast_clear_flag(ast_channel_flags(chan), AST_FLAG_SNAPSHOT_STAGE);
1052 }
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
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().

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().

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 129 of file stasis_channels.c.

Referenced by ast_channel_topic(), create_subscriptions(), forwards_create_channel(), load_module(), manager_channels_init(), and manager_confbridge_init().

130 {
131  return channel_topic_all;
132 }
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(), and manager_channels_init().

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(), and ast_stasis_channels_init().

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(), and manager_channels_init().

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 293 of file stasis_endpoints.c.

References ao2_ref, ast_endpoint_snapshot_create(), ast_json_null(), ast_json_ref(), and stasis_message_create().

Referenced by ast_endpoint_blob_publish().

295 {
296  struct ast_endpoint_blob *obj;
297  struct stasis_message *msg;
298 
299  if (!type) {
300  return NULL;
301  }
302  if (!blob) {
303  blob = ast_json_null();
304  }
305 
306  if (!(obj = ao2_alloc(sizeof(*obj), endpoint_blob_dtor))) {
307  return NULL;
308  }
309 
310  if (endpoint) {
311  if (!(obj->snapshot = ast_endpoint_snapshot_create(endpoint))) {
312  ao2_ref(obj, -1);
313 
314  return NULL;
315  }
316  }
317 
318  obj->blob = ast_json_ref(blob);
319  msg = stasis_message_create(type, obj);
320  ao2_ref(obj, -1);
321 
322  return msg;
323 }
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
struct ast_endpoint_snapshot * ast_endpoint_snapshot_create(struct ast_endpoint *endpoint)
Create a snapshot of an endpoint.
Blob of data associated with an endpoint.
struct ast_json * ast_json_null(void)
Get the JSON null value.
Definition: json.c:248
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
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 325 of file stasis_endpoints.c.

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

Referenced by update_registry().

327 {
328  struct stasis_message *message;
329 
330  if (!blob) {
331  return;
332  }
333 
334  message = ast_endpoint_blob_create(endpoint, type, blob);
335  if (message) {
336  stasis_publish(ast_endpoint_topic(endpoint), message);
337  ao2_ref(message, -1);
338  }
339 }
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.
struct stasis_topic * ast_endpoint_topic(struct ast_endpoint *endpoint)
Returns the topic for a specific endpoint.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
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 111 of file stasis_endpoints.c.

References stasis_cp_all_cache().

Referenced by ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), and ast_endpoint_latest_snapshot().

112 {
113  return stasis_cp_all_cache(endpoint_cache_all);
114 }
struct stasis_cache * stasis_cp_all_cache(struct stasis_cp_all *all)
Get the cache.
struct stasis_message_type* ast_endpoint_contact_state_type ( void  )

Message type for endpoint contact state changes.

Since
13.5

Referenced by ast_endpoint_stasis_init(), forwards_create_endpoint(), and manager_endpoints_init().

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 341 of file stasis_endpoints.c.

References ao2_ref, ast_asprintf, ast_endpoint_cache(), ast_endpoint_snapshot_type(), ast_tech_to_upper(), stasis_cache_get(), and stasis_message_data().

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

343 {
344  char *id = NULL;
345  struct stasis_message *msg;
346  struct ast_endpoint_snapshot *snapshot;
347 
348  if (ast_strlen_zero(name)) {
349  ast_asprintf(&id, "%s", tech);
350  } else {
351  ast_asprintf(&id, "%s/%s", tech, name);
352  }
353  if (!id) {
354  return NULL;
355  }
356  ast_tech_to_upper(id);
357 
359  ast_free(id);
360  if (!msg) {
361  return NULL;
362  }
363 
364  snapshot = stasis_message_data(msg);
365  ast_assert(snapshot != NULL);
366 
367  ao2_ref(snapshot, +1);
368  ao2_ref(msg, -1);
369 
370  return snapshot;
371 }
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
A snapshot of an endpoint's state.
char * ast_tech_to_upper(char *dev_str)
Convert the tech portion of a device string to upper case.
Definition: strings.h:1236
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
const ast_string_field tech
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
struct stasis_cache * ast_endpoint_cache(void)
Backend cache for ast_endpoint_topic_all_cached().
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.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ast_string_field_build, ast_string_field_init, ast_string_field_set, ast_endpoint_snapshot::channel_ids, ast_endpoint::channel_ids, lock, ast_endpoint_snapshot::max_channels, ast_endpoint::max_channels, 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().

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);
455  ast_assert(!ast_strlen_zero(endpoint->resource));
456 
457  channel_count = ao2_container_count(endpoint->channel_ids);
458 
459  snapshot = ao2_alloc_options(
460  sizeof(*snapshot) + channel_count * sizeof(char *),
461  endpoint_snapshot_dtor,
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 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ao2_container * channel_ids
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
const ast_string_field resource
ast_mutex_t lock
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359
A snapshot of an endpoint's state.
enum ast_endpoint_state state
const ast_string_field tech
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
Definition: lock.h:604
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
Definition: stringfields.h:555
int max_channels
Max channels for this endpoint. -1 means unlimited or unknown.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
enum ast_endpoint_state state
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
struct stasis_message_type* ast_endpoint_snapshot_type ( void  )
struct stasis_message_type* ast_endpoint_state_type ( void  )

Message type for endpoint state changes.

Since
12

Referenced by ast_endpoint_stasis_init(), forwards_create_endpoint(), manager_endpoints_init(), and update_registry().

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.

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(), and forwards_create_endpoint().

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

Topic for all endpoint related messages.

Since
12

Definition at line 116 of file stasis_endpoints.c.

References stasis_cp_all_topic().

Referenced by ast_endpoint_topic().

117 {
118  return stasis_cp_all_topic(endpoint_cache_all);
119 }
struct stasis_topic * stasis_cp_all_topic(struct stasis_cp_all *all)
Get the aggregate topic.
struct stasis_topic* ast_endpoint_topic_all_cached ( void  )

Cached topic for all endpoint related messages.

Since
12

Definition at line 121 of file stasis_endpoints.c.

References stasis_cp_all_topic_cached().

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

122 {
123  return stasis_cp_all_topic_cached(endpoint_cache_all);
124 }
struct stasis_topic * stasis_cp_all_topic_cached(struct stasis_cp_all *all)
Get the caching topic.
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.

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

Referenced by forwards_create_endpoint().

102 {
103  if (!endpoint) {
105  }
106  return stasis_cp_single_topic_cached(endpoint->topics);
107 }
struct stasis_topic * stasis_cp_single_topic_cached(struct stasis_cp_single *one)
Get the caching topic for this instance.
struct stasis_topic * ast_endpoint_topic_all_cached(void)
Cached topic for all endpoint related messages.
struct stasis_cp_single * topics
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 961 of file stasis_channels.c.

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

Referenced by local_optimization_started_cb().

962 {
963  struct channel_role_snapshot *role_snapshot;
964  int role_len = strlen(role) + 1;
965 
966  if (!obj || ast_strlen_zero(role) || !snapshot) {
967  return;
968  }
969 
970  role_snapshot = ao2_alloc_options(sizeof(*role_snapshot) + role_len,
971  channel_role_snapshot_dtor, AO2_ALLOC_OPT_LOCK_NOLOCK);
972  if (!role_snapshot) {
973  return;
974  }
975  ast_copy_string(role_snapshot->role, role, role_len);
976  role_snapshot->snapshot = snapshot;
977  ao2_ref(role_snapshot->snapshot, +1);
978  ao2_link(obj->channel_snapshots, role_snapshot);
979  ao2_ref(role_snapshot, -1);
980 }
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct ast_channel_snapshot * snapshot
struct ao2_container * channel_snapshots
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
A channel snapshot wrapper object used in ast_multi_channel_blob objects.
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
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 886 of file stasis_channels.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_ref, ast_json_ref(), ast_multi_channel_blob::blob, and ast_multi_channel_blob::channel_snapshots.

887 {
888  struct ast_multi_channel_blob *obj;
889 
890  ast_assert(blob != NULL);
891 
892  obj = ao2_alloc(sizeof(*obj), multi_channel_blob_dtor);
893  if (!obj) {
894  return NULL;
895  }
896 
898  NUM_MULTI_CHANNEL_BLOB_BUCKETS, channel_role_hash_cb, NULL, channel_role_cmp_cb);
899  if (!obj->channel_snapshots) {
900  ao2_ref(obj, -1);
901  return NULL;
902  }
903 
904  obj->blob = ast_json_ref(blob);
905  return obj;
906 }
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
struct ast_json * blob
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#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
struct ao2_container * channel_snapshots
A multi channel blob data structure for multi_channel_blob stasis messages.
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 982 of file stasis_channels.c.

References ao2_ref, ast_multi_channel_blob::channel_snapshots, OBJ_SEARCH_KEY, and channel_role_snapshot::snapshot.

Referenced by channel_dial_cb(), and handle_dial_message().

983 {
984  struct channel_role_snapshot *role_snapshot;
985  struct ast_channel_snapshot *snapshot;
986 
987  if (!obj || ast_strlen_zero(role)) {
988  return NULL;
989  }
990  role_snapshot = ao2_find(obj->channel_snapshots, role, OBJ_SEARCH_KEY);
991  /* Note that this function does not increase the ref count on snapshot */
992  if (!role_snapshot) {
993  return NULL;
994  }
995  snapshot = role_snapshot->snapshot;
996  ao2_ref(role_snapshot, -1);
997  return snapshot;
998 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
Structure representing a snapshot of channel state.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
struct ast_channel_snapshot * snapshot
struct ao2_container * channel_snapshots
A channel snapshot wrapper object used in ast_multi_channel_blob objects.
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 1000 of file stasis_channels.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_callback, ao2_container_alloc_hash, ao2_iterator_destroy(), ao2_link, ao2_ref, ast_strdupa, ast_multi_channel_blob::channel_snapshots, OBJ_MULTIPLE, OBJ_SEARCH_KEY, and channel_role_snapshot::snapshot.

1001 {
1002  struct ao2_container *ret_container;
1003  struct ao2_iterator *it_role_snapshots;
1004  struct channel_role_snapshot *role_snapshot;
1005  char *arg;
1006 
1007  if (!obj || ast_strlen_zero(role)) {
1008  return NULL;
1009  }
1010 
1012  NUM_MULTI_CHANNEL_BLOB_BUCKETS,
1013  channel_snapshot_hash_cb, NULL, channel_snapshot_cmp_cb);
1014  if (!ret_container) {
1015  return NULL;
1016  }
1017 
1018  arg = ast_strdupa(role);
1019  it_role_snapshots = ao2_callback(obj->channel_snapshots,
1020  OBJ_MULTIPLE | OBJ_SEARCH_KEY, channel_role_cmp_cb, arg);
1021  if (!it_role_snapshots) {
1022  ao2_ref(ret_container, -1);
1023  return NULL;
1024  }
1025 
1026  while ((role_snapshot = ao2_iterator_next(it_role_snapshots))) {
1027  ao2_link(ret_container, role_snapshot->snapshot);
1028  ao2_ref(role_snapshot, -1);
1029  }
1030  ao2_iterator_destroy(it_role_snapshots);
1031 
1032  return ret_container;
1033 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
Definition: astobj2.h:1693
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#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
struct ast_channel_snapshot * snapshot
struct ao2_container * channel_snapshots
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821
Generic container type.
A channel snapshot wrapper object used in ast_multi_channel_blob objects.
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
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 1035 of file stasis_channels.c.

References ast_multi_channel_blob::blob.

Referenced by channel_dial_cb(), and handle_dial_message().

1036 {
1037  if (!obj) {
1038  return NULL;
1039  }
1040  return obj->blob;
1041 }
struct ast_json * blob
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 2001 of file stasis.c.

References AST_VECTOR_APPEND.

Referenced by ast_multi_object_blob_single_channel_publish(), and stasis_app_user_event().

2003 {
2004  if (!multi || !object || AST_VECTOR_APPEND(&multi->snapshots[type], object)) {
2005  ao2_cleanup(object);
2006  }
2007 }
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256
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 1975 of file stasis.c.

References ao2_ref, ast_json_ref(), AST_VECTOR_INIT, and STASIS_UMOS_MAX.

Referenced by ast_multi_object_blob_single_channel_publish(), and stasis_app_user_event().

1976 {
1977  int type;
1978  struct ast_multi_object_blob *multi;
1979 
1980  ast_assert(blob != NULL);
1981 
1982  multi = ao2_alloc(sizeof(*multi), multi_object_blob_dtor);
1983  if (!multi) {
1984  return NULL;
1985  }
1986 
1987  for (type = 0; type < STASIS_UMOS_MAX; ++type) {
1988  if (AST_VECTOR_INIT(&multi->snapshots[type], 0)) {
1989  ao2_ref(multi, -1);
1990 
1991  return NULL;
1992  }
1993  }
1994 
1995  multi->blob = ast_json_ref(blob);
1996 
1997  return multi;
1998 }
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
#define STASIS_UMOS_MAX
Number of snapshot types.
Definition: stasis.h:1360
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
A multi object blob data structure to carry user event stasis messages.
Definition: stasis.c:1950
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
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 2010 of file stasis.c.

References ao2_ref, ast_channel_snapshot_create(), ast_channel_topic(), ast_multi_object_blob_add(), ast_multi_object_blob_create(), stasis_message_create(), stasis_publish(), and STASIS_UMOS_CHANNEL.

2012 {
2013  struct stasis_message *message;
2014  struct ast_channel_snapshot *channel_snapshot;
2015  struct ast_multi_object_blob *multi;
2016 
2017  if (!type) {
2018  return;
2019  }
2020 
2021  multi = ast_multi_object_blob_create(blob);
2022  if (!multi) {
2023  return;
2024  }
2025 
2026  channel_snapshot = ast_channel_snapshot_create(chan);
2027  if (!channel_snapshot) {
2028  ao2_ref(multi, -1);
2029  return;
2030  }
2031 
2032  /* this call steals the channel_snapshot reference */
2033  ast_multi_object_blob_add(multi, STASIS_UMOS_CHANNEL, channel_snapshot);
2034 
2035  message = stasis_message_create(type, multi);
2036  ao2_ref(multi, -1);
2037  if (message) {
2038  /* app_userevent still publishes to channel */
2039  stasis_publish(ast_channel_topic(chan), message);
2040  ao2_ref(message, -1);
2041  }
2042 }
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:1975
Structure representing a snapshot of channel state.
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...
A multi object blob data structure to carry user event stasis messages.
Definition: stasis.c:1950
#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 * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
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:2001
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
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(), and stasis_init().

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_routes(), publish_parked_call(), and publish_parked_call_failure().

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.

References parking_topic.

Referenced by create_subscriptions(), publish_parked_call(), and publish_parked_call_failure().

68 {
69  return parking_topic;
70 }
static struct stasis_topic * parking_topic
Topic for parking lots.
Definition: parking.c:41
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(), and ast_rtp_engine_init().

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_rtp_engine_init().

struct stasis_message_type* stasis_cache_clear_type ( void  )

Message type for clearing a message from a stasis cache.

Since
12

Referenced by stasis_cache_clear_create(), and stasis_caching_accept_message_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 cache_update(), and stasis_message_router_add_cache_update().

struct stasis_message_type* stasis_subscription_change_type ( void  )

Gets the message type for subscription change notices.

Returns
The stasis_message_type for subscription change notices
Since
12

Referenced by app_create(), message_sink_cb(), stasis_caching_accept_message_type(), stasis_cleanup(), stasis_init(), stasis_subscription_final_message(), and subscription_invoke().