static int create_parked_subscription_full(struct ast_channel *chan, const char *parkee_uuid, int hangup_after, struct transfer_channel_data *parked_channel_data) { struct ast_datastore *datastore; struct parked_subscription_datastore *parked_datastore; struct parked_subscription_data *subscription_data; char *parker_uuid = ast_strdupa(ast_channel_uniqueid(chan)); size_t parker_uuid_size = strlen(parker_uuid) + 1; /* If there is already a subscription, get rid of it. */ wipe_subscription_datastore(chan); if (!(datastore = ast_datastore_alloc(&parked_subscription_info, NULL))) { return -1; } if (!(parked_datastore = ast_calloc(1, sizeof(*parked_datastore)))) { ast_datastore_free(datastore); return -1; } if (!(subscription_data = ast_calloc(1, sizeof(*subscription_data) + parker_uuid_size + strlen(parkee_uuid) + 1))) { ast_datastore_free(datastore); ast_free(parked_datastore); return -1; } if (parked_channel_data) { subscription_data->transfer_data = parked_channel_data; ao2_ref(parked_channel_data, +1); } subscription_data->hangup_after = hangup_after; subscription_data->parkee_uuid = subscription_data->parker_uuid + parker_uuid_size; strcpy(subscription_data->parkee_uuid, parkee_uuid); strcpy(subscription_data->parker_uuid, parker_uuid); if (!(parked_datastore->parked_subscription = stasis_subscribe_pool(ast_parking_topic(), parker_update_cb, subscription_data))) { return -1; } datastore->data = parked_datastore; ast_channel_lock(chan); ast_channel_datastore_add(chan, datastore); ast_channel_unlock(chan); return 0; }
void publish_parked_call(struct parked_user *pu, enum ast_parked_call_event_type event_type) { RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup); RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup); payload = parked_call_payload_from_parked_user(pu, event_type); if (!payload) { return; } msg = stasis_message_create(ast_parked_call_type(), payload); if (!msg) { return; } stasis_publish(ast_parking_topic(), msg); }
void publish_parked_call_failure(struct ast_channel *parkee) { RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup); RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup); payload = parked_call_payload_from_failure(parkee); if (!payload) { return; } msg = stasis_message_create(ast_parked_call_type(), payload); if (!msg) { return; } stasis_publish(ast_parking_topic(), msg); }
static void parking_manager_enable_stasis(void) { if (!parking_sub) { parking_sub = stasis_subscribe(ast_parking_topic(), parking_event_cb, NULL); } }