- ret = handle_discarded_elements(iterator, new_packet, stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot handle discarded elements for new packet.");
- goto error;
- }
-
- /* Beginning of the new packet */
- if (packet_begin_notif) {
- add_action_push_notif(iterator, packet_begin_notif);
- } else if (new_packet) {
- ret = add_action_push_notif_packet_begin(iterator,
- new_packet);
- if (ret) {
- BT_LOGE_STR("Cannot add \"push packet beginning notification\" action.");
- goto error;
- }
- }
-
- add_action_set_stream_state_cur_packet(iterator, stream_state,
- new_packet);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_stream_begin(
- struct bt_notification_iterator_private_connection *iterator,
- struct bt_notification *notif,
- struct bt_stream *notif_stream)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_STREAM_BEGIN);
- BT_ASSERT(notif_stream);
- ret = ensure_stream_state_exists(iterator, notif, notif_stream,
- &stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot ensure that stream state exists.");
- goto error;
- }
-
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_stream_end(
- struct bt_notification_iterator_private_connection *iterator,
- struct bt_notification *notif,
- struct bt_stream *notif_stream)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_STREAM_END);
- BT_ASSERT(notif_stream);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot ensure that stream state exists.");
- goto error;
- }
-
- ret = handle_packet_switch(iterator, NULL, NULL, stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot handle packet switch.");
- goto error;
- }
-
- add_action_push_notif(iterator, notif);
- add_action_set_stream_state_is_ended(iterator, stream_state);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_discarded_elements(
- struct bt_notification_iterator_private_connection *iterator,
- struct bt_notification *notif,
- struct bt_stream *notif_stream)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_DISCARDED_EVENTS ||
- notif->type == BT_NOTIFICATION_TYPE_DISCARDED_PACKETS);
- BT_ASSERT(notif_stream);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot ensure that stream state exists.");
- goto error;
- }
-
- add_action_push_notif(iterator, notif);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_packet_begin(
- struct bt_notification_iterator_private_connection *iterator,
- struct bt_notification *notif,
- struct bt_stream *notif_stream,
- struct bt_packet *notif_packet)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_PACKET_BEGIN);
- BT_ASSERT(notif_packet);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot ensure that stream state exists.");
- goto error;
- }
-
- ret = handle_packet_switch(iterator, notif, notif_packet, stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot handle packet switch.");
- goto error;
- }
-
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_packet_end(
- struct bt_notification_iterator_private_connection *iterator,
- struct bt_notification *notif,
- struct bt_stream *notif_stream,
- struct bt_packet *notif_packet)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_PACKET_END);
- BT_ASSERT(notif_packet);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot ensure that stream state exists.");
- goto error;
- }
-
- ret = handle_packet_switch(iterator, NULL, notif_packet, stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot handle packet switch.");
- goto error;
- }
-
- /* End of the current packet */
- add_action_push_notif(iterator, notif);
- add_action_set_stream_state_cur_packet(iterator, stream_state, NULL);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int handle_notif_event(
- struct bt_notification_iterator_private_connection *iterator,
- struct bt_notification *notif,
- struct bt_stream *notif_stream,
- struct bt_packet *notif_packet)
-{
- int ret = 0;
- struct stream_state *stream_state;
-
- BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_EVENT);
- BT_ASSERT(notif_packet);
- ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
- &stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot ensure that stream state exists.");
- goto error;
- }
-
- ret = handle_packet_switch(iterator, NULL, notif_packet, stream_state);
- if (ret) {
- BT_LOGE_STR("Cannot handle packet switch.");
- goto error;
- }
-
- add_action_push_notif(iterator, notif);
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
-static
-int enqueue_notification_and_automatic(
- struct bt_notification_iterator_private_connection *iterator,
- struct bt_notification *notif)
-{
- int ret = 0;
- struct bt_event *notif_event = NULL;
- struct bt_stream *notif_stream = NULL;
- struct bt_packet *notif_packet = NULL;