+ if (msg_it->medium.medops.switch_packet) {
+ enum ctf_msg_iter_medium_status medium_status;
+
+ medium_status = msg_it->medium.medops.switch_packet(msg_it->medium.data);
+ if (medium_status == CTF_MSG_ITER_MEDIUM_STATUS_EOF) {
+ /* No more packets. */
+ msg_it->state = STATE_CHECK_EMIT_MSG_STREAM_END;
+ status = CTF_MSG_ITER_STATUS_OK;
+ goto end;
+ } else if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
+ status = (int) medium_status;
+ goto end;
+ }
+
+ /*
+ * After the packet switch, the medium might want to give us a
+ * different buffer for the new packet.
+ */
+ status = request_medium_bytes(msg_it);
+ if (status != CTF_MSG_ITER_STATUS_OK) {
+ goto end;
+ }
+ }
+