static GstFlowReturn gst_hlsdemux_test_network_error_src_create (GstTestHTTPSrc * src, guint64 offset, guint length, GstBuffer ** retbuf, gpointer context, gpointer user_data) { const GstHlsDemuxTestCase *test_case = (const GstHlsDemuxTestCase *) user_data; GstHlsDemuxTestInputData *input = (GstHlsDemuxTestInputData *) context; const gchar *failure_suffix; guint64 failure_position = 0; fail_unless (test_case != NULL); fail_unless (input != NULL); fail_unless (input->uri != NULL); failure_suffix = gst_structure_get_string (test_case->state, "failure-suffix"); if (!failure_suffix) { failure_suffix = ".ts"; } if (!gst_structure_get_uint64 (test_case->state, "failure-position", &failure_position)) { failure_position = 10 * TS_PACKET_LEN; } GST_DEBUG ("network_error %s %s %" G_GUINT64_FORMAT " @ %" G_GUINT64_FORMAT, input->uri, failure_suffix, offset, failure_position); if (g_str_has_suffix (input->uri, failure_suffix) && offset >= failure_position) { GST_DEBUG ("return error"); GST_ELEMENT_ERROR (src, RESOURCE, READ, (("A network error occurred, or the server closed the connection unexpectedly.")), ("A network error occurred, or the server closed the connection unexpectedly.")); *retbuf = NULL; return GST_FLOW_ERROR; } return gst_hlsdemux_test_src_create (src, offset, length, retbuf, context, user_data); }
static gboolean get_video_recv_info (KmsRembLocal * rl, guint64 * bitrate, guint * fraction_lost, guint64 * packets_rcv_interval) { GValueArray *arr = NULL; GValue *val; guint i; gboolean ret = FALSE; if (!KMS_REMB_BASE (rl)->rtpsess) { GST_WARNING ("Session object does not exist"); return ret; } g_object_get (KMS_REMB_BASE (rl)->rtpsess, "sources", &arr, NULL); if (arr == NULL) { GST_WARNING ("Sources array not found"); return ret; } for (i = 0; i < arr->n_values; i++) { GObject *source; guint ssrc; GstStructure *s; val = g_value_array_get_nth (arr, i); source = g_value_get_object (val); g_object_get (source, "ssrc", &ssrc, "stats", &s, NULL); GST_TRACE_OBJECT (source, "source ssrc: %u", ssrc); GST_TRACE_OBJECT (KMS_REMB_BASE (rl)->rtpsess, "stats: %" GST_PTR_FORMAT, s); if (ssrc == rl->remote_ssrc) { GstClockTime current_time; guint64 octets_received, packets_received; if (!gst_structure_get_uint64 (s, "bitrate", bitrate)) { break; } if (!gst_structure_get_uint64 (s, "octets-received", &octets_received)) { break; } if (!gst_structure_get_uint (s, "sent-rb-fractionlost", fraction_lost)) { break; } if (!gst_structure_get_uint64 (s, "packets-received", &packets_received)) { break; } current_time = kms_utils_get_time_nsecs (); if (rl->last_time != 0) { GstClockTime elapsed = current_time - rl->last_time; guint64 bytes_handled = octets_received - rl->last_octets_received; *bitrate = gst_util_uint64_scale (bytes_handled, 8 * GST_SECOND, elapsed); GST_TRACE_OBJECT (KMS_REMB_BASE (rl)->rtpsess, "Elapsed %" G_GUINT64_FORMAT " bytes %" G_GUINT64_FORMAT ", rate %" G_GUINT64_FORMAT, elapsed, bytes_handled, *bitrate); } rl->last_time = current_time; rl->last_octets_received = octets_received; *packets_rcv_interval = packets_received - rl->last_packets_received; rl->last_packets_received = packets_received; ret = TRUE; } gst_structure_free (s); if (ret) { break; } } g_value_array_free (arr); return ret; }