Lines Matching refs:src
137 GSource *src; in gst_soup_session_finalize() local
143 src = g_idle_source_new (); in gst_soup_session_finalize()
145 g_source_set_callback (src, _soup_session_finalize_cb, sess, NULL); in gst_soup_session_finalize()
146 g_source_attach (src, g_main_loop_get_context (sess->loop)); in gst_soup_session_finalize()
147 g_source_unref (src); in gst_soup_session_finalize()
270 static gboolean gst_soup_http_src_set_location (GstSoupHTTPSrc * src,
272 static gboolean gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src,
275 static gboolean gst_soup_http_src_build_message (GstSoupHTTPSrc * src,
277 static gboolean gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src,
279 static gboolean gst_soup_http_src_session_open (GstSoupHTTPSrc * src);
280 static void gst_soup_http_src_session_close (GstSoupHTTPSrc * src);
282 GstSoupHTTPSrc * src);
283 static GstFlowReturn gst_soup_http_src_got_headers (GstSoupHTTPSrc * src,
560 gst_soup_http_src_reset (GstSoupHTTPSrc * src) in gst_soup_http_src_reset() argument
562 src->retry_count = 0; in gst_soup_http_src_reset()
563 src->have_size = FALSE; in gst_soup_http_src_reset()
564 src->got_headers = FALSE; in gst_soup_http_src_reset()
565 src->headers_ret = GST_FLOW_OK; in gst_soup_http_src_reset()
566 src->seekable = FALSE; in gst_soup_http_src_reset()
567 src->read_position = 0; in gst_soup_http_src_reset()
568 src->request_position = 0; in gst_soup_http_src_reset()
569 src->stop_position = -1; in gst_soup_http_src_reset()
573 src->content_size = -1; in gst_soup_http_src_reset()
575 src->content_size = 0; in gst_soup_http_src_reset()
577 src->have_body = FALSE; in gst_soup_http_src_reset()
579 src->reduce_blocksize_count = 0; in gst_soup_http_src_reset()
580 src->increase_blocksize_count = 0; in gst_soup_http_src_reset()
581 src->last_socket_read_time = 0; in gst_soup_http_src_reset()
585 src->wait_already = 0; in gst_soup_http_src_reset()
586 src->error_code = 0; in gst_soup_http_src_reset()
589 g_cancellable_reset (src->cancellable); in gst_soup_http_src_reset()
591 gst_caps_replace (&src->src_caps, NULL); in gst_soup_http_src_reset()
592 g_free (src->iradio_name); in gst_soup_http_src_reset()
593 src->iradio_name = NULL; in gst_soup_http_src_reset()
594 g_free (src->iradio_genre); in gst_soup_http_src_reset()
595 src->iradio_genre = NULL; in gst_soup_http_src_reset()
596 g_free (src->iradio_url); in gst_soup_http_src_reset()
597 src->iradio_url = NULL; in gst_soup_http_src_reset()
601 gst_soup_http_src_init (GstSoupHTTPSrc * src) in gst_soup_http_src_init() argument
605 g_mutex_init (&src->session_mutex); in gst_soup_http_src_init()
606 g_cond_init (&src->session_cond); in gst_soup_http_src_init()
610 g_mutex_init (&src->wait_lock); in gst_soup_http_src_init()
611 g_cond_init (&src->wait_cond); in gst_soup_http_src_init()
613 src->cancellable = g_cancellable_new (); in gst_soup_http_src_init()
614 src->location = NULL; in gst_soup_http_src_init()
615 src->redirection_uri = NULL; in gst_soup_http_src_init()
616 src->automatic_redirect = TRUE; in gst_soup_http_src_init()
617 src->user_agent = g_strdup (DEFAULT_USER_AGENT); in gst_soup_http_src_init()
618 src->user_id = NULL; in gst_soup_http_src_init()
619 src->user_pw = NULL; in gst_soup_http_src_init()
620 src->proxy_id = NULL; in gst_soup_http_src_init()
621 src->proxy_pw = NULL; in gst_soup_http_src_init()
622 src->cookies = NULL; in gst_soup_http_src_init()
623 src->iradio_mode = DEFAULT_IRADIO_MODE; in gst_soup_http_src_init()
624 src->session = NULL; in gst_soup_http_src_init()
625 src->external_session = NULL; in gst_soup_http_src_init()
626 src->msg = NULL; in gst_soup_http_src_init()
627 src->timeout = DEFAULT_TIMEOUT; in gst_soup_http_src_init()
628 src->log_level = DEFAULT_SOUP_LOG_LEVEL; in gst_soup_http_src_init()
629 src->compress = DEFAULT_COMPRESS; in gst_soup_http_src_init()
630 src->keep_alive = DEFAULT_KEEP_ALIVE; in gst_soup_http_src_init()
631 src->ssl_strict = DEFAULT_SSL_STRICT; in gst_soup_http_src_init()
632 src->ssl_use_system_ca_file = DEFAULT_SSL_USE_SYSTEM_CA_FILE; in gst_soup_http_src_init()
633 src->tls_database = DEFAULT_TLS_DATABASE; in gst_soup_http_src_init()
634 src->tls_interaction = DEFAULT_TLS_INTERACTION; in gst_soup_http_src_init()
635 src->max_retries = DEFAULT_RETRIES; in gst_soup_http_src_init()
636 src->method = DEFAULT_SOUP_METHOD; in gst_soup_http_src_init()
637 src->minimum_blocksize = gst_base_src_get_blocksize (GST_BASE_SRC_CAST (src)); in gst_soup_http_src_init()
640 src->last_status_code = 0; in gst_soup_http_src_init()
641 src->exit_block = FALSE; in gst_soup_http_src_init()
642 src->buffering_time = 0; in gst_soup_http_src_init()
643 src->wait_time = DEFAULT_TIMEOUT * GST_MSECOND; in gst_soup_http_src_init()
644 src->trickmode_key_units = -1; in gst_soup_http_src_init()
645 src->has_sent_first_request = FALSE; in gst_soup_http_src_init()
646 src->has_received_first_response = FALSE; in gst_soup_http_src_init()
647 src->playerState = GST_PLAYER_STATUS_IDLE; in gst_soup_http_src_init()
651 if (!gst_soup_http_src_set_proxy (src, proxy)) { in gst_soup_http_src_init()
652 GST_WARNING_OBJECT (src, in gst_soup_http_src_init()
657 gst_base_src_set_automatic_eos (GST_BASE_SRC (src), FALSE); in gst_soup_http_src_init()
659 gst_soup_http_src_reset (src); in gst_soup_http_src_init()
665 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (gobject); in gst_soup_http_src_dispose() local
667 GST_DEBUG_OBJECT (src, "dispose"); in gst_soup_http_src_dispose()
669 gst_soup_http_src_session_close (src); in gst_soup_http_src_dispose()
671 g_clear_object (&src->external_session); in gst_soup_http_src_dispose()
679 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (gobject); in gst_soup_http_src_finalize() local
681 GST_DEBUG_OBJECT (src, "finalize"); in gst_soup_http_src_finalize()
685 g_mutex_clear (&src->wait_lock); in gst_soup_http_src_finalize()
686 g_cond_clear (&src->wait_cond); in gst_soup_http_src_finalize()
688 g_mutex_clear (&src->session_mutex); in gst_soup_http_src_finalize()
689 g_cond_clear (&src->session_cond); in gst_soup_http_src_finalize()
690 g_object_unref (src->cancellable); in gst_soup_http_src_finalize()
691 g_free (src->location); in gst_soup_http_src_finalize()
692 g_free (src->redirection_uri); in gst_soup_http_src_finalize()
693 g_free (src->user_agent); in gst_soup_http_src_finalize()
694 if (src->proxy != NULL) { in gst_soup_http_src_finalize()
695 gst_soup_uri_free (src->proxy); in gst_soup_http_src_finalize()
697 g_free (src->user_id); in gst_soup_http_src_finalize()
698 g_free (src->user_pw); in gst_soup_http_src_finalize()
699 g_free (src->proxy_id); in gst_soup_http_src_finalize()
700 g_free (src->proxy_pw); in gst_soup_http_src_finalize()
701 g_strfreev (src->cookies); in gst_soup_http_src_finalize()
703 if (src->extra_headers) { in gst_soup_http_src_finalize()
704 gst_structure_free (src->extra_headers); in gst_soup_http_src_finalize()
705 src->extra_headers = NULL; in gst_soup_http_src_finalize()
708 g_free (src->ssl_ca_file); in gst_soup_http_src_finalize()
710 if (src->tls_database) in gst_soup_http_src_finalize()
711 g_object_unref (src->tls_database); in gst_soup_http_src_finalize()
712 g_free (src->method); in gst_soup_http_src_finalize()
714 if (src->tls_interaction) in gst_soup_http_src_finalize()
715 g_object_unref (src->tls_interaction); in gst_soup_http_src_finalize()
724 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (object); in gst_soup_http_src_set_property() local
737 if (!gst_soup_http_src_set_location (src, location, NULL)) { in gst_soup_http_src_set_property()
744 g_free (src->user_agent); in gst_soup_http_src_set_property()
745 src->user_agent = g_value_dup_string (value); in gst_soup_http_src_set_property()
748 src->iradio_mode = g_value_get_boolean (value); in gst_soup_http_src_set_property()
751 src->automatic_redirect = g_value_get_boolean (value); in gst_soup_http_src_set_property()
758 if (!gst_soup_http_src_set_proxy (src, proxy)) { in gst_soup_http_src_set_property()
765 g_strfreev (src->cookies); in gst_soup_http_src_set_property()
766 src->cookies = g_strdupv (g_value_get_boxed (value)); in gst_soup_http_src_set_property()
769 gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value)); in gst_soup_http_src_set_property()
772 g_free (src->user_id); in gst_soup_http_src_set_property()
773 src->user_id = g_value_dup_string (value); in gst_soup_http_src_set_property()
776 g_free (src->user_pw); in gst_soup_http_src_set_property()
777 src->user_pw = g_value_dup_string (value); in gst_soup_http_src_set_property()
780 g_free (src->proxy_id); in gst_soup_http_src_set_property()
781 src->proxy_id = g_value_dup_string (value); in gst_soup_http_src_set_property()
784 g_free (src->proxy_pw); in gst_soup_http_src_set_property()
785 src->proxy_pw = g_value_dup_string (value); in gst_soup_http_src_set_property()
788 src->timeout = g_value_get_uint (value); in gst_soup_http_src_set_property()
793 if (src->extra_headers) in gst_soup_http_src_set_property()
794 gst_structure_free (src->extra_headers); in gst_soup_http_src_set_property()
796 src->extra_headers = s ? gst_structure_copy (s) : NULL; in gst_soup_http_src_set_property()
800 src->log_level = g_value_get_enum (value); in gst_soup_http_src_set_property()
803 src->compress = g_value_get_boolean (value); in gst_soup_http_src_set_property()
806 src->keep_alive = g_value_get_boolean (value); in gst_soup_http_src_set_property()
809 src->ssl_strict = g_value_get_boolean (value); in gst_soup_http_src_set_property()
812 g_clear_object (&src->tls_database); in gst_soup_http_src_set_property()
813 src->tls_database = g_value_dup_object (value); in gst_soup_http_src_set_property()
816 g_clear_object (&src->tls_interaction); in gst_soup_http_src_set_property()
817 src->tls_interaction = g_value_dup_object (value); in gst_soup_http_src_set_property()
820 src->max_retries = g_value_get_int (value); in gst_soup_http_src_set_property()
823 g_free (src->method); in gst_soup_http_src_set_property()
824 src->method = g_value_dup_string (value); in gst_soup_http_src_set_property()
828 g_free (src->ssl_ca_file); in gst_soup_http_src_set_property()
829 src->ssl_ca_file = g_value_dup_string (value); in gst_soup_http_src_set_property()
834 src->ssl_use_system_ca_file = g_value_get_boolean (value); in gst_soup_http_src_set_property()
840 GST_DEBUG_OBJECT (src, "set g_value_get_int = %d ", g_value_get_int (value)); in gst_soup_http_src_set_property()
841 src->wait_time = src->timeout * GST_MSECOND; in gst_soup_http_src_set_property()
842 src->playerState = g_value_get_int (value); in gst_soup_http_src_set_property()
847 GST_INFO_OBJECT (src, "exit_block come, broadcast wait_cond and don't wait anymore"); in gst_soup_http_src_set_property()
848 g_mutex_lock (&src->wait_lock); in gst_soup_http_src_set_property()
849 src->exit_block = TRUE; in gst_soup_http_src_set_property()
850 g_cond_broadcast (&src->wait_cond); in gst_soup_http_src_set_property()
851 g_mutex_unlock (&src->wait_lock); in gst_soup_http_src_set_property()
853 GST_DEBUG_OBJECT (src, "souphttpsrc exit_block :%d", exit_block); in gst_soup_http_src_set_property()
869 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (object); in gst_soup_http_src_get_property() local
873 g_value_set_string (value, src->location); in gst_soup_http_src_get_property()
876 g_value_set_string (value, src->user_agent); in gst_soup_http_src_get_property()
879 g_value_set_boolean (value, src->automatic_redirect); in gst_soup_http_src_get_property()
882 if (src->proxy == NULL) in gst_soup_http_src_get_property()
885 char *proxy = gst_soup_uri_to_string (src->proxy); in gst_soup_http_src_get_property()
891 g_value_set_boxed (value, g_strdupv (src->cookies)); in gst_soup_http_src_get_property()
894 g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src))); in gst_soup_http_src_get_property()
897 g_value_set_boolean (value, src->iradio_mode); in gst_soup_http_src_get_property()
900 g_value_set_string (value, src->user_id); in gst_soup_http_src_get_property()
903 g_value_set_string (value, src->user_pw); in gst_soup_http_src_get_property()
906 g_value_set_string (value, src->proxy_id); in gst_soup_http_src_get_property()
909 g_value_set_string (value, src->proxy_pw); in gst_soup_http_src_get_property()
912 g_value_set_uint (value, src->timeout); in gst_soup_http_src_get_property()
915 gst_value_set_structure (value, src->extra_headers); in gst_soup_http_src_get_property()
918 g_value_set_enum (value, src->log_level); in gst_soup_http_src_get_property()
921 g_value_set_boolean (value, src->compress); in gst_soup_http_src_get_property()
924 g_value_set_boolean (value, src->keep_alive); in gst_soup_http_src_get_property()
927 g_value_set_boolean (value, src->ssl_strict); in gst_soup_http_src_get_property()
930 g_value_set_object (value, src->tls_database); in gst_soup_http_src_get_property()
933 g_value_set_object (value, src->tls_interaction); in gst_soup_http_src_get_property()
936 g_value_set_int (value, src->max_retries); in gst_soup_http_src_get_property()
939 g_value_set_string (value, src->method); in gst_soup_http_src_get_property()
943 g_value_set_string (value, src->ssl_ca_file); in gst_soup_http_src_get_property()
947 g_value_set_boolean (value, src->ssl_use_system_ca_file); in gst_soup_http_src_get_property()
966 gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src, guint64 offset, in gst_soup_http_src_add_range_header() argument
972 _soup_message_get_request_headers (src->msg); in gst_soup_http_src_add_range_header()
990 src->read_position = offset; in gst_soup_http_src_add_range_header()
997 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (user_data); in _append_extra_header() local
1001 _soup_message_get_request_headers (src->msg); in _append_extra_header()
1015 GST_ERROR_OBJECT (src, "extra-headers field '%s' contains no value " in _append_extra_header()
1020 GST_DEBUG_OBJECT (src, "Appending extra header: \"%s: %s\"", field_name, in _append_extra_header()
1062 gst_soup_http_src_add_extra_headers (GstSoupHTTPSrc * src) in gst_soup_http_src_add_extra_headers() argument
1064 if (!src->extra_headers) in gst_soup_http_src_add_extra_headers()
1067 return gst_structure_foreach (src->extra_headers, _append_extra_headers, src); in gst_soup_http_src_add_extra_headers()
1073 GstSoupHTTPSrc *src = user_data; in thread_func() local
1074 GstSoupSession *session = src->session; in thread_func()
1077 GST_DEBUG_OBJECT (src, "thread start"); in thread_func()
1089 "timeout", DEFAULT_TIMEOUT, "tls-interaction", src->tls_interaction, in thread_func()
1091 "timeout", src->timeout, "tls-interaction", src->tls_interaction, in thread_func()
1094 "max-conns", src->session_is_shared ? G_MAXINT : 10, in thread_func()
1095 "max-conns-per-host", src->session_is_shared ? G_MAXINT : 2, NULL); in thread_func()
1099 if (src->proxy != NULL) { in thread_func()
1101 char *proxy_string = gst_soup_uri_to_string (src->proxy); in thread_func()
1104 g_object_set (src->session->session, "proxy-resolver", proxy_resolver, in thread_func()
1110 g_object_set (session->session, "ssl-strict", src->ssl_strict, NULL); in thread_func()
1111 if (src->proxy != NULL) { in thread_func()
1113 g_object_set (session->session, "proxy-uri", src->proxy->soup_uri, NULL); in thread_func()
1118 gst_soup_util_log_setup (session->session, src->log_level, in thread_func()
1135 G_CALLBACK (gst_soup_http_src_authenticate_cb_2), src); in thread_func()
1138 if (!src->session_is_shared) { in thread_func()
1139 if (src->tls_database) in thread_func()
1140 g_object_set (src->session->session, "tls-database", src->tls_database, in thread_func()
1143 if (src->ssl_ca_file) in thread_func()
1144 g_object_set (src->session->session, "ssl-ca-file", src->ssl_ca_file, in thread_func()
1147 g_object_set (src->session->session, "ssl-use-system-ca-file", in thread_func()
1148 src->ssl_use_system_ca_file, NULL); in thread_func()
1156 src = NULL; in thread_func()
1177 GstSoupHTTPSrc *src = user_data; in _session_ready_cb() local
1179 GST_DEBUG_OBJECT (src, "thread ready"); in _session_ready_cb()
1181 g_mutex_lock (&src->session_mutex); in _session_ready_cb()
1182 g_cond_signal (&src->session_cond); in _session_ready_cb()
1183 g_mutex_unlock (&src->session_mutex); in _session_ready_cb()
1190 gst_soup_http_src_session_open (GstSoupHTTPSrc * src) in gst_soup_http_src_session_open() argument
1195 if (src->session) { in gst_soup_http_src_session_open()
1196 GST_DEBUG_OBJECT (src, "Session is already open"); in gst_soup_http_src_session_open()
1200 if (!src->location) { in gst_soup_http_src_session_open()
1201 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (_("No URL set.")), in gst_soup_http_src_session_open()
1206 can_share = (src->timeout == DEFAULT_TIMEOUT) in gst_soup_http_src_session_open()
1207 && (src->cookies == NULL) in gst_soup_http_src_session_open()
1208 && (src->ssl_strict == DEFAULT_SSL_STRICT) in gst_soup_http_src_session_open()
1209 && (src->tls_interaction == NULL) && (src->proxy == NULL) in gst_soup_http_src_session_open()
1210 && (src->tls_database == DEFAULT_TLS_DATABASE); in gst_soup_http_src_session_open()
1213 can_share = can_share && (src->ssl_ca_file == DEFAULT_SSL_CA_FILE) && in gst_soup_http_src_session_open()
1214 (src->ssl_use_system_ca_file == DEFAULT_SSL_USE_SYSTEM_CA_FILE); in gst_soup_http_src_session_open()
1217 if (gst_pad_peer_query (GST_BASE_SRC_PAD (src), query)) { in gst_soup_http_src_session_open()
1221 gst_element_set_context (GST_ELEMENT_CAST (src), context); in gst_soup_http_src_session_open()
1226 gst_message_new_need_context (GST_OBJECT_CAST (src), in gst_soup_http_src_session_open()
1228 gst_element_post_message (GST_ELEMENT_CAST (src), message); in gst_soup_http_src_session_open()
1232 GST_OBJECT_LOCK (src); in gst_soup_http_src_session_open()
1234 src->session_is_shared = can_share; in gst_soup_http_src_session_open()
1236 if (src->external_session && can_share) { in gst_soup_http_src_session_open()
1237 GST_DEBUG_OBJECT (src, "Using external session %p", src->external_session); in gst_soup_http_src_session_open()
1238 src->session = g_object_ref (src->external_session); in gst_soup_http_src_session_open()
1241 g_signal_connect (src->session->session, "authenticate", in gst_soup_http_src_session_open()
1242 G_CALLBACK (gst_soup_http_src_authenticate_cb_2), src); in gst_soup_http_src_session_open()
1248 GST_DEBUG_OBJECT (src, "Creating session (can share %d)", can_share); in gst_soup_http_src_session_open()
1250 src->session = in gst_soup_http_src_session_open()
1253 GST_DEBUG_OBJECT (src, "Created session %p", src->session); in gst_soup_http_src_session_open()
1257 src->session->loop = g_main_loop_new (ctx, FALSE); in gst_soup_http_src_session_open()
1261 src->session->thread = g_thread_try_new ("souphttpsrc-thread", in gst_soup_http_src_session_open()
1262 thread_func, src, NULL); in gst_soup_http_src_session_open()
1264 if (!src->session->thread) { in gst_soup_http_src_session_open()
1269 g_source_set_callback (source, _session_ready_cb, src, NULL); in gst_soup_http_src_session_open()
1273 GST_DEBUG_OBJECT (src, "Waiting for thread to start..."); in gst_soup_http_src_session_open()
1274 while (!g_main_loop_is_running (src->session->loop)) in gst_soup_http_src_session_open()
1275 g_cond_wait (&src->session_cond, &src->session_mutex); in gst_soup_http_src_session_open()
1276 GST_DEBUG_OBJECT (src, "Soup thread started"); in gst_soup_http_src_session_open()
1279 GST_OBJECT_UNLOCK (src); in gst_soup_http_src_session_open()
1281 if (src->session_is_shared) { in gst_soup_http_src_session_open()
1286 GST_DEBUG_OBJECT (src->session, "Sharing session %p", src->session); in gst_soup_http_src_session_open()
1290 gst_structure_set (s, "session", GST_TYPE_SOUP_SESSION, src->session, NULL); in gst_soup_http_src_session_open()
1292 gst_element_set_context (GST_ELEMENT_CAST (src), context); in gst_soup_http_src_session_open()
1293 message = gst_message_new_have_context (GST_OBJECT_CAST (src), context); in gst_soup_http_src_session_open()
1294 gst_element_post_message (GST_ELEMENT_CAST (src), message); in gst_soup_http_src_session_open()
1300 g_clear_object (&src->session); in gst_soup_http_src_session_open()
1301 GST_ELEMENT_ERROR (src, LIBRARY, INIT, (NULL), ("Failed to create session")); in gst_soup_http_src_session_open()
1302 GST_OBJECT_UNLOCK (src); in gst_soup_http_src_session_open()
1310 GstSoupHTTPSrc *src = user_data; in _session_close_cb() local
1312 if (src->msg) { in _session_close_cb()
1313 gst_soup_session_cancel_message (src->session->session, src->msg, in _session_close_cb()
1314 src->cancellable); in _session_close_cb()
1315 g_clear_object (&src->msg); in _session_close_cb()
1322 g_signal_handlers_disconnect_by_func (src->session->session, in _session_close_cb()
1323 G_CALLBACK (gst_soup_http_src_authenticate_cb_2), src); in _session_close_cb()
1325 g_mutex_lock (&src->session_mutex); in _session_close_cb()
1326 g_clear_object (&src->session); in _session_close_cb()
1327 g_cond_signal (&src->session_cond); in _session_close_cb()
1328 g_mutex_unlock (&src->session_mutex); in _session_close_cb()
1334 gst_soup_http_src_session_close (GstSoupHTTPSrc * src) in gst_soup_http_src_session_close() argument
1339 GST_DEBUG_OBJECT (src, "Closing session"); in gst_soup_http_src_session_close()
1341 if (!src->session) { in gst_soup_http_src_session_close()
1346 sess = g_object_ref (src->session); in gst_soup_http_src_session_close()
1350 g_mutex_lock (&src->session_mutex); in gst_soup_http_src_session_close()
1352 g_source_set_callback (source, _session_close_cb, src, NULL); in gst_soup_http_src_session_close()
1353 g_source_attach (source, g_main_loop_get_context (src->session->loop)); in gst_soup_http_src_session_close()
1356 while (src->session) in gst_soup_http_src_session_close()
1357 g_cond_wait (&src->session_cond, &src->session_mutex); in gst_soup_http_src_session_close()
1359 g_mutex_unlock (&src->session_mutex); in gst_soup_http_src_session_close()
1376 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (data); in gst_soup_http_src_authenticate_cb() local
1380 if (!GST_IS_SOUP_HTTP_SRC (src) || msg != src->msg) in gst_soup_http_src_authenticate_cb()
1389 if (src->user_id && src->user_pw) { in gst_soup_http_src_authenticate_cb()
1390 _soup_auth_authenticate (auth, src->user_id, src->user_pw); in gst_soup_http_src_authenticate_cb()
1393 if (src->proxy_id && src->proxy_pw) { in gst_soup_http_src_authenticate_cb()
1394 _soup_auth_authenticate (auth, src->proxy_id, src->proxy_pw); in gst_soup_http_src_authenticate_cb()
1407 GstSoupHTTPSrc *src = user_data; in gst_soup_http_src_accept_certificate_cb() local
1410 if (!GST_IS_SOUP_HTTP_SRC (src) || msg != src->msg) in gst_soup_http_src_accept_certificate_cb()
1414 if (!src->ssl_strict) in gst_soup_http_src_accept_certificate_cb()
1458 gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg) in gst_soup_http_src_got_headers() argument
1475 if (src->has_received_first_response == FALSE) { in gst_soup_http_src_got_headers()
1476 src->has_received_first_response = TRUE; in gst_soup_http_src_got_headers()
1479 GST_INFO_OBJECT (src, "got headers, status code %d", status_code); in gst_soup_http_src_got_headers()
1480 if ((src->last_status_code != status_code) && (status_code >= SOUP_STATUS_MULTIPLE_CHOICES) && in gst_soup_http_src_got_headers()
1482 src->last_status_code = status_code; in gst_soup_http_src_got_headers()
1485 GST_INFO_OBJECT (src, "got headers"); in gst_soup_http_src_got_headers()
1489 src->proxy_id && src->proxy_pw) { in gst_soup_http_src_got_headers()
1495 gst_structure_set (http_headers, "uri", G_TYPE_STRING, src->location, in gst_soup_http_src_got_headers()
1497 if (src->redirection_uri) in gst_soup_http_src_got_headers()
1499 src->redirection_uri, NULL); in gst_soup_http_src_got_headers()
1511 gst_element_post_message (GST_ELEMENT_CAST (src), in gst_soup_http_src_got_headers()
1512 gst_message_new_element (GST_OBJECT_CAST (src), in gst_soup_http_src_got_headers()
1518 return gst_soup_http_src_parse_status (msg, src); in gst_soup_http_src_got_headers()
1521 src->got_headers = TRUE; in gst_soup_http_src_got_headers()
1525 gst_event_replace (&src->http_headers_event, http_headers_event); in gst_soup_http_src_got_headers()
1532 newsize = src->request_position + in gst_soup_http_src_got_headers()
1534 if (!src->have_size || (src->content_size != newsize)) { in gst_soup_http_src_got_headers()
1535 src->content_size = newsize; in gst_soup_http_src_got_headers()
1536 src->have_size = TRUE; in gst_soup_http_src_got_headers()
1537 src->seekable = TRUE; in gst_soup_http_src_got_headers()
1538 GST_DEBUG_OBJECT (src, "size = %" G_GUINT64_FORMAT, src->content_size); in gst_soup_http_src_got_headers()
1540 basesrc = GST_BASE_SRC_CAST (src); in gst_soup_http_src_got_headers()
1541 basesrc->segment.duration = src->content_size; in gst_soup_http_src_got_headers()
1542 gst_element_post_message (GST_ELEMENT (src), in gst_soup_http_src_got_headers()
1543 gst_message_new_duration_changed (GST_OBJECT (src))); in gst_soup_http_src_got_headers()
1553 src->seekable = FALSE; in gst_soup_http_src_got_headers()
1567 GST_DEBUG_OBJECT (src, "icy-metaint: %s (parsed: %d)", value, in gst_soup_http_src_got_headers()
1570 if (src->src_caps) in gst_soup_http_src_got_headers()
1571 gst_caps_unref (src->src_caps); in gst_soup_http_src_got_headers()
1573 src->src_caps = gst_caps_new_simple ("application/x-icy", in gst_soup_http_src_got_headers()
1576 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps); in gst_soup_http_src_got_headers()
1584 GST_WARNING_OBJECT (src, "Content-Type is invalid UTF-8"); in gst_soup_http_src_got_headers()
1590 GST_DEBUG_OBJECT (src, "Content-Type: %s", value); in gst_soup_http_src_got_headers()
1592 if (src->src_caps) { in gst_soup_http_src_got_headers()
1593 gst_caps_unref (src->src_caps); in gst_soup_http_src_got_headers()
1594 src->src_caps = NULL; in gst_soup_http_src_got_headers()
1616 src->src_caps = gst_caps_new_simple ("audio/x-unaligned-raw", in gst_soup_http_src_got_headers()
1621 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps); in gst_soup_http_src_got_headers()
1624 GST_DEBUG_OBJECT (src, "Content-Type: %s", value); in gst_soup_http_src_got_headers()
1627 if (src->src_caps) { in gst_soup_http_src_got_headers()
1628 src->src_caps = gst_caps_make_writable (src->src_caps); in gst_soup_http_src_got_headers()
1629 gst_caps_set_simple (src->src_caps, "content-type", G_TYPE_STRING, in gst_soup_http_src_got_headers()
1631 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps); in gst_soup_http_src_got_headers()
1643 g_free (src->iradio_name); in gst_soup_http_src_got_headers()
1644 src->iradio_name = gst_soup_http_src_unicodify (value); in gst_soup_http_src_got_headers()
1645 if (src->iradio_name) { in gst_soup_http_src_got_headers()
1647 src->iradio_name, NULL); in gst_soup_http_src_got_headers()
1655 g_free (src->iradio_genre); in gst_soup_http_src_got_headers()
1656 src->iradio_genre = gst_soup_http_src_unicodify (value); in gst_soup_http_src_got_headers()
1657 if (src->iradio_genre) { in gst_soup_http_src_got_headers()
1659 src->iradio_genre, NULL); in gst_soup_http_src_got_headers()
1666 g_free (src->iradio_url); in gst_soup_http_src_got_headers()
1667 src->iradio_url = gst_soup_http_src_unicodify (value); in gst_soup_http_src_got_headers()
1668 if (src->iradio_url) { in gst_soup_http_src_got_headers()
1670 src->iradio_url, NULL); in gst_soup_http_src_got_headers()
1675 GST_DEBUG_OBJECT (src, in gst_soup_http_src_got_headers()
1677 gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tag_list)); in gst_soup_http_src_got_headers()
1683 return gst_soup_http_src_parse_status (msg, src); in gst_soup_http_src_got_headers()
1687 gst_soup_http_src_alloc_buffer (GstSoupHTTPSrc * src) in gst_soup_http_src_alloc_buffer() argument
1689 GstBaseSrc *basesrc = GST_BASE_SRC_CAST (src); in gst_soup_http_src_alloc_buffer()
1702 #define SOUP_HTTP_SRC_ERROR(src,soup_msg,cat,code,error_message) \ argument
1704 GST_ELEMENT_ERROR_WITH_DETAILS ((src), cat, code, ("%s", error_message), \
1706 … _soup_message_get_status (soup_msg), (src)->location, GST_STR_NULL ((src)->redirection_uri)), \
1708 "http-redirect-uri", G_TYPE_STRING, GST_STR_NULL ((src)->redirection_uri), NULL)); \
1713 #define SOUP_HTTP_SRC_ERROR_HTTP_STANDARD_ERRORS(src, soup_msg, http_error_code, cat, code, error_m… argument
1715 GST_ELEMENT_ERROR_WITH_DETAILS ((src), cat, code, ("%s", error_message), \
1717 http_error_code, (src)->location, GST_STR_NULL ((src)->redirection_uri)), \
1719 "http-redirect-uri", G_TYPE_STRING, GST_STR_NULL ((src)->redirection_uri), NULL)); \
1723 wait_for_connect_exit (GstSoupHTTPSrc *src, SoupMessage *msg) in wait_for_connect_exit() argument
1725 g_mutex_lock (&src->wait_lock); in wait_for_connect_exit()
1726 if (!src->exit_block) { in wait_for_connect_exit()
1727 …SOUP_HTTP_SRC_ERROR_HTTP_STANDARD_ERRORS (src, msg, SOUP_STATUS_REQUEST_TIMEOUT, RESOURCE, TIME_OU… in wait_for_connect_exit()
1729 src->headers_ret = GST_FLOW_CUSTOM_SUCCESS; in wait_for_connect_exit()
1732 GST_INFO_OBJECT (src, "now it's reset, don't post timeout msg!, return EOS"); in wait_for_connect_exit()
1733 src->headers_ret = GST_FLOW_EOS; in wait_for_connect_exit()
1736 src->wait_time = -1; in wait_for_connect_exit()
1737 src->wait_already = 0; in wait_for_connect_exit()
1738 src->exit_block = FALSE; in wait_for_connect_exit()
1739 g_mutex_unlock (&src->wait_lock); in wait_for_connect_exit()
1743 proc_buffering_time (GstSoupHTTPSrc *src, gint64 timeout) in proc_buffering_time() argument
1745 g_mutex_lock (&src->wait_lock); in proc_buffering_time()
1746 if ((timeout <= 0) || src->exit_block) { in proc_buffering_time()
1747 GST_INFO_OBJECT (src, "wait time out, or should quit immediately" in proc_buffering_time()
1748 " timeout:%"G_GUINT64_FORMAT", src->exit_block:%d", timeout, src->exit_block); in proc_buffering_time()
1749 g_mutex_unlock (&src->wait_lock); in proc_buffering_time()
1753 if (src->retry_count == SOUP_HTTP_SRC_RETRY_COUNT_ONCE) { in proc_buffering_time()
1754 src->buffering_time = g_get_monotonic_time (); in proc_buffering_time()
1755 …GST_INFO_OBJECT (src, "can not connect before start,begin to time:%"G_GUINT64_FORMAT" ", src->buff… in proc_buffering_time()
1756 …} else if ((src->buffering_time == SOUP_HTTP_SRC_BUFFERING_TIME) && (src->trickmode_key_units != 1… in proc_buffering_time()
1757 GST_INFO_OBJECT (src, "souphttpsrc not in buffering, sleep 20ms wait for buffering, " in proc_buffering_time()
1758 …"src->retry_count:%d, src->buffering_time:%"G_GUINT64_FORMAT"\n", src->retry_count, src->buffering… in proc_buffering_time()
1759 if (src->exit_block || g_cond_wait_until (&src->wait_cond, &src->wait_lock, in proc_buffering_time()
1761 g_mutex_unlock (&src->wait_lock); in proc_buffering_time()
1764 g_mutex_unlock (&src->wait_lock); in proc_buffering_time()
1765 src->retry_count = 0; in proc_buffering_time()
1766 src->headers_ret = GST_FLOW_CUSTOM_ERROR; in proc_buffering_time()
1768 …} else if ((src->buffering_time == SOUP_HTTP_SRC_BUFFERING_TIME) && (src->trickmode_key_units == 1… in proc_buffering_time()
1769 src->buffering_time = g_get_monotonic_time (); in proc_buffering_time()
1770 …GST_INFO_OBJECT (src, "it's trickmode key units,begin to time:%"G_GUINT64_FORMAT" ", src->bufferin… in proc_buffering_time()
1771 src->retry_count = 1; in proc_buffering_time()
1773 g_mutex_unlock (&src->wait_lock); in proc_buffering_time()
1779 wait_for_connect (GstSoupHTTPSrc *src, SoupMessage *msg, gint64 timeout) in wait_for_connect() argument
1781 if ((src == NULL) || (msg == NULL)) { in wait_for_connect()
1785 gint ret = proc_buffering_time (src, timeout); in wait_for_connect()
1789 wait_for_connect_exit (src, msg); in wait_for_connect()
1793 gint64 time_diff_us = (g_get_monotonic_time () - src->buffering_time); in wait_for_connect()
1794 if (src->retry_count == SOUP_HTTP_SRC_RETRY_COUNT_ONCE) { in wait_for_connect()
1795 src->max_retries = (timeout - time_diff_us) / DEFAULT_WAIT_STEP + 1; in wait_for_connect()
1798 …GST_DEBUG_OBJECT (src, "max_retries:%d, timeout:%"G_GUINT64_FORMAT" time_diff_us = %"G_GUINT64_FOR… in wait_for_connect()
1799 src->max_retries, timeout, time_diff_us, g_get_monotonic_time (), src->buffering_time); in wait_for_connect()
1802 …GST_ERROR_OBJECT (src, "now wait time is %"G_GUINT64_FORMAT" us, timeout:%"G_GUINT64_FORMAT", and … in wait_for_connect()
1803 wait_for_connect_exit (src, msg); in wait_for_connect()
1807 …GST_INFO_OBJECT (src, "retry_count:%d, and sleep :%d us, timeout:%"G_GUINT64_FORMAT"", src->retry_… in wait_for_connect()
1808 g_mutex_lock (&src->wait_lock); in wait_for_connect()
1809 if (src->exit_block || g_cond_wait_until (&src->wait_cond, &src->wait_lock, in wait_for_connect()
1811 g_mutex_unlock (&src->wait_lock); in wait_for_connect()
1812 wait_for_connect_exit (src, msg); in wait_for_connect()
1815 g_mutex_unlock (&src->wait_lock); in wait_for_connect()
1816 src->headers_ret = GST_FLOW_CUSTOM_ERROR; in wait_for_connect()
1821 gst_soup_http_src_handle_connect_fail_ohos (SoupMessage * msg, GstSoupHTTPSrc * src) in gst_soup_http_src_handle_connect_fail_ohos() argument
1827 if (!src->exit_block) { in gst_soup_http_src_handle_connect_fail_ohos()
1828 …if (src->playerState == GST_PLAYER_STATUS_PAUSED || src->playerState == GST_PLAYER_STATUS_PLAYING)… in gst_soup_http_src_handle_connect_fail_ohos()
1829 src->retry_count = 0; in gst_soup_http_src_handle_connect_fail_ohos()
1834 …if (_soup_message_get_status (msg) == SOUP_STATUS_IO_ERROR && src->playerState != GST_PLAYER_STATU… in gst_soup_http_src_handle_connect_fail_ohos()
1835 wait_for_connect (src, msg, 0); in gst_soup_http_src_handle_connect_fail_ohos()
1837 wait_for_connect (src, msg, (gint64) src->wait_time - (gint64) src->wait_already); in gst_soup_http_src_handle_connect_fail_ohos()
1840 if (src->max_retries == -1 || src->retry_count < src->max_retries) in gst_soup_http_src_handle_connect_fail_ohos()
1847 gst_soup_http_src_parse_status_ohos (SoupMessage * msg, GstSoupHTTPSrc * src) in gst_soup_http_src_parse_status_ohos() argument
1855 if ((ret = gst_soup_http_src_handle_connect_fail_ohos(msg, src)) != GST_FLOW_OK) { in gst_soup_http_src_parse_status_ohos()
1858 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND, _("Could not resolve server name.")); in gst_soup_http_src_parse_status_ohos()
1864 if ((ret = gst_soup_http_src_handle_connect_fail_ohos(msg, src)) != GST_FLOW_OK) { in gst_soup_http_src_parse_status_ohos()
1867 …SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ, _("Could not establish connection to server.")… in gst_soup_http_src_parse_status_ohos()
1872 if ((ret = gst_soup_http_src_handle_connect_fail_ohos(msg, src)) != GST_FLOW_OK) { in gst_soup_http_src_parse_status_ohos()
1875 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ, in gst_soup_http_src_parse_status_ohos()
1881 SOUP_HTTP_SRC_ERROR_HTTP_STANDARD_ERRORS (src, msg, SOUP_STATUS_BAD_REQUEST, RESOURCE, READ, in gst_soup_http_src_parse_status_ohos()
1895 gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src) in gst_soup_http_src_parse_status() argument
1900 GST_DEBUG_OBJECT (src, "Ignoring error %d during HEAD request", in gst_soup_http_src_parse_status()
1910 GstFlowReturn ret = gst_soup_http_src_parse_status_ohos (msg, src); in gst_soup_http_src_parse_status()
1918 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND, in gst_soup_http_src_parse_status()
1923 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ, in gst_soup_http_src_parse_status()
1927 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ, in gst_soup_http_src_parse_status()
1931 if (src->max_retries == -1 || src->retry_count < src->max_retries) in gst_soup_http_src_parse_status()
1933 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ, in gst_soup_http_src_parse_status()
1938 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ, in gst_soup_http_src_parse_status()
1958 GST_ERROR_OBJECT (src, "Invalid UTF-8 in reason"); in gst_soup_http_src_parse_status()
1968 src->have_body && (!src->have_size || in gst_soup_http_src_parse_status()
1969 (src->request_position >= src->content_size))) { in gst_soup_http_src_parse_status()
1970 GST_DEBUG_OBJECT (src, "Requested range out of limits and received full " in gst_soup_http_src_parse_status()
1979 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND, (reason_phrase)); in gst_soup_http_src_parse_status()
1988 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_AUTHORIZED, (reason_phrase)); in gst_soup_http_src_parse_status()
1994 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ, (reason_phrase)); in gst_soup_http_src_parse_status()
2007 gst_soup_http_src_restarted_cb (SoupMessage * msg, GstSoupHTTPSrc * src) in gst_soup_http_src_restarted_cb() argument
2014 src->redirection_uri = gst_soup_message_uri_to_string (msg); in gst_soup_http_src_restarted_cb()
2015 src->redirection_permanent = (status == SOUP_STATUS_MOVED_PERMANENTLY); in gst_soup_http_src_restarted_cb()
2017 GST_DEBUG_OBJECT (src, "%u redirect to \"%s\" (permanent %d)", in gst_soup_http_src_restarted_cb()
2018 status, src->redirection_uri, src->redirection_permanent); in gst_soup_http_src_restarted_cb()
2022 gst_soup_http_src_build_message (GstSoupHTTPSrc * src, const gchar * method) in gst_soup_http_src_build_message() argument
2026 g_return_val_if_fail (src->msg == NULL, FALSE); in gst_soup_http_src_build_message()
2028 src->msg = _soup_message_new (method, src->location); in gst_soup_http_src_build_message()
2029 if (!src->msg) { in gst_soup_http_src_build_message()
2030 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, in gst_soup_http_src_build_message()
2031 ("Error parsing URL."), ("URL: %s", src->location)); in gst_soup_http_src_build_message()
2035 request_headers = _soup_message_get_request_headers (src->msg); in gst_soup_http_src_build_message()
2040 if (!src->user_agent || !*src->user_agent) { in gst_soup_http_src_build_message()
2046 } else if (g_str_has_suffix (src->user_agent, " ")) { in gst_soup_http_src_build_message()
2047 gchar *user_agent = g_strdup_printf ("%slibsoup/%u.%u.%u", src->user_agent, in gst_soup_http_src_build_message()
2054 src->user_agent); in gst_soup_http_src_build_message()
2057 if (!src->keep_alive) { in gst_soup_http_src_build_message()
2060 if (src->iradio_mode) { in gst_soup_http_src_build_message()
2063 if (src->cookies) { in gst_soup_http_src_build_message()
2066 for (cookie = src->cookies; *cookie != NULL; cookie++) { in gst_soup_http_src_build_message()
2070 _soup_message_disable_feature (src->msg, _soup_cookie_jar_get_type ()); in gst_soup_http_src_build_message()
2073 if (!src->compress) { in gst_soup_http_src_build_message()
2074 _soup_message_headers_append (_soup_message_get_request_headers (src->msg), in gst_soup_http_src_build_message()
2079 g_signal_connect (src->msg, "accept-certificate", in gst_soup_http_src_build_message()
2080 G_CALLBACK (gst_soup_http_src_accept_certificate_cb), src); in gst_soup_http_src_build_message()
2081 g_signal_connect (src->msg, "authenticate", in gst_soup_http_src_build_message()
2082 G_CALLBACK (gst_soup_http_src_authenticate_cb), src); in gst_soup_http_src_build_message()
2087 src->automatic_redirect ? 0 : SOUP_MESSAGE_NO_REDIRECT; in gst_soup_http_src_build_message()
2097 _soup_message_set_flags (src->msg, flags); in gst_soup_http_src_build_message()
2100 if (src->automatic_redirect) { in gst_soup_http_src_build_message()
2101 g_signal_connect (src->msg, "restarted", in gst_soup_http_src_build_message()
2102 G_CALLBACK (gst_soup_http_src_restarted_cb), src); in gst_soup_http_src_build_message()
2105 gst_soup_http_src_add_range_header (src, src->request_position, in gst_soup_http_src_build_message()
2106 src->stop_position); in gst_soup_http_src_build_message()
2108 gst_soup_http_src_add_extra_headers (src); in gst_soup_http_src_build_message()
2116 send_message_wait (GstSoupHTTPSrc *src, const GError *err) in send_message_wait() argument
2123 (_soup_message_get_status (src->msg) == SOUP_STATUS_NONE)) { in send_message_wait()
2124 GST_ERROR_OBJECT (src, "G_IO_ERROR_TIMED_OUT wait begin"); in send_message_wait()
2125 wait_for_connect (src, src->msg, (gint64) src->wait_time - (gint64) src->wait_already); in send_message_wait()
2129 src->headers_ret = GST_FLOW_CUSTOM_ERROR; in send_message_wait()
2139 GstSoupHTTPSrc *src; member
2147 GstSoupHTTPSrc *src = msrc->src; in _session_send_cb() local
2150 g_mutex_lock (&src->session_mutex); in _session_send_cb()
2152 src->input_stream = _soup_session_send_finish (src->session->session, in _session_send_cb()
2157 if (src->has_sent_first_request == FALSE) { in _session_send_cb()
2158 src->has_sent_first_request = TRUE; in _session_send_cb()
2163 src->headers_ret = GST_FLOW_FLUSHING; in _session_send_cb()
2165 src->headers_ret = gst_soup_http_src_got_headers (src, src->msg); in _session_send_cb()
2168 if (!src->input_stream) { in _session_send_cb()
2169 GST_DEBUG_OBJECT (src, "Sending message failed: %s", error->message); in _session_send_cb()
2172 if (send_message_wait (src, error) != 0) { in _session_send_cb()
2186 g_cond_broadcast (&src->session_cond); in _session_send_cb()
2187 g_mutex_unlock (&src->session_mutex); in _session_send_cb()
2194 GstSoupHTTPSrc *src = msrc->src; in _session_send_idle_cb() local
2196 _soup_session_send_async (src->session->session, src->msg, src->cancellable, in _session_send_idle_cb()
2204 gst_soup_http_src_send_message (GstSoupHTTPSrc * src) in gst_soup_http_src_send_message() argument
2210 g_return_val_if_fail (src->msg != NULL, GST_FLOW_ERROR); in gst_soup_http_src_send_message()
2211 g_assert (src->input_stream == NULL); in gst_soup_http_src_send_message()
2213 msrc.src = src; in gst_soup_http_src_send_message()
2218 src->headers_ret = GST_FLOW_OK; in gst_soup_http_src_send_message()
2221 g_source_attach (source, g_main_loop_get_context (src->session->loop)); in gst_soup_http_src_send_message()
2224 while (!src->input_stream && !msrc.error) in gst_soup_http_src_send_message()
2225 g_cond_wait (&src->session_cond, &src->session_mutex); in gst_soup_http_src_send_message()
2227 ret = src->headers_ret; in gst_soup_http_src_send_message()
2233 if (!src->input_stream) { in gst_soup_http_src_send_message()
2234 GST_DEBUG_OBJECT (src, "Didn't get an input stream: %s", in gst_soup_http_src_send_message()
2241 GST_DEBUG_OBJECT (src, "Successfully got a reply"); in gst_soup_http_src_send_message()
2250 gst_soup_http_src_do_request (GstSoupHTTPSrc * src, const gchar * method) in gst_soup_http_src_do_request() argument
2255 if (src->max_retries != -1 && src->retry_count > src->max_retries) { in gst_soup_http_src_do_request()
2256 GST_DEBUG_OBJECT (src, "Max retries reached"); in gst_soup_http_src_do_request()
2260 src->retry_count++; in gst_soup_http_src_do_request()
2265 if (src->request_position == src->stop_position || src->request_position >= src->content_size) in gst_soup_http_src_do_request()
2267 if (src->request_position == src->stop_position) in gst_soup_http_src_do_request()
2271 GST_LOG_OBJECT (src, "Running request for method: %s", method); in gst_soup_http_src_do_request()
2273 if (src->msg) in gst_soup_http_src_do_request()
2274 request_headers = _soup_message_get_request_headers (src->msg); in gst_soup_http_src_do_request()
2277 if (src->msg && src->request_position > 0) { in gst_soup_http_src_do_request()
2278 gst_soup_http_src_add_range_header (src, src->request_position, in gst_soup_http_src_do_request()
2279 src->stop_position); in gst_soup_http_src_do_request()
2280 } else if (src->msg && src->request_position == 0) in gst_soup_http_src_do_request()
2287 src->read_position = src->request_position; in gst_soup_http_src_do_request()
2289 if (!src->msg) { in gst_soup_http_src_do_request()
2290 if (!gst_soup_http_src_build_message (src, method)) { in gst_soup_http_src_do_request()
2295 if (g_cancellable_is_cancelled (src->cancellable)) { in gst_soup_http_src_do_request()
2296 GST_INFO_OBJECT (src, "interrupted"); in gst_soup_http_src_do_request()
2300 ret = gst_soup_http_src_send_message (src); in gst_soup_http_src_do_request()
2303 if (ret == GST_FLOW_OK && src->request_position > 0 && in gst_soup_http_src_do_request()
2304 _soup_message_get_status (src->msg) != SOUP_STATUS_PARTIAL_CONTENT) { in gst_soup_http_src_do_request()
2305 src->seekable = FALSE; in gst_soup_http_src_do_request()
2306 GST_ELEMENT_ERROR_WITH_DETAILS (src, RESOURCE, SEEK, in gst_soup_http_src_do_request()
2309 src->location, GST_STR_NULL (src->redirection_uri)), in gst_soup_http_src_do_request()
2310 ("http-status-code", G_TYPE_UINT, _soup_message_get_status (src->msg), in gst_soup_http_src_do_request()
2312 GST_STR_NULL (src->redirection_uri), NULL)); in gst_soup_http_src_do_request()
2325 gst_soup_http_src_check_update_blocksize (GstSoupHTTPSrc * src, in gst_soup_http_src_check_update_blocksize() argument
2328 guint blocksize = gst_base_src_get_blocksize (GST_BASE_SRC_CAST (src)); in gst_soup_http_src_check_update_blocksize()
2331 g_get_monotonic_time () * GST_USECOND - src->last_socket_read_time; in gst_soup_http_src_check_update_blocksize()
2333 GST_LOG_OBJECT (src, "Checking to update blocksize. Read: %" G_GINT64_FORMAT in gst_soup_http_src_check_update_blocksize()
2339 src->reduce_blocksize_count = 0; in gst_soup_http_src_check_update_blocksize()
2340 src->increase_blocksize_count++; in gst_soup_http_src_check_update_blocksize()
2342 if (src->increase_blocksize_count >= GROW_BLOCKSIZE_COUNT) { in gst_soup_http_src_check_update_blocksize()
2344 GST_DEBUG_OBJECT (src, "Increased blocksize to %u", blocksize); in gst_soup_http_src_check_update_blocksize()
2345 gst_base_src_set_blocksize (GST_BASE_SRC_CAST (src), blocksize); in gst_soup_http_src_check_update_blocksize()
2346 src->increase_blocksize_count = 0; in gst_soup_http_src_check_update_blocksize()
2350 src->reduce_blocksize_count++; in gst_soup_http_src_check_update_blocksize()
2351 src->increase_blocksize_count = 0; in gst_soup_http_src_check_update_blocksize()
2353 if (src->reduce_blocksize_count >= REDUCE_BLOCKSIZE_COUNT) { in gst_soup_http_src_check_update_blocksize()
2355 blocksize = MAX (blocksize, src->minimum_blocksize); in gst_soup_http_src_check_update_blocksize()
2356 GST_DEBUG_OBJECT (src, "Decreased blocksize to %u", blocksize); in gst_soup_http_src_check_update_blocksize()
2357 gst_base_src_set_blocksize (GST_BASE_SRC_CAST (src), blocksize); in gst_soup_http_src_check_update_blocksize()
2358 src->reduce_blocksize_count = 0; in gst_soup_http_src_check_update_blocksize()
2361 src->reduce_blocksize_count = src->increase_blocksize_count = 0; in gst_soup_http_src_check_update_blocksize()
2366 gst_soup_http_src_update_position (GstSoupHTTPSrc * src, gint64 bytes_read) in gst_soup_http_src_update_position() argument
2368 GstBaseSrc *basesrc = GST_BASE_SRC_CAST (src); in gst_soup_http_src_update_position()
2371 new_position = src->read_position + bytes_read; in gst_soup_http_src_update_position()
2372 if (G_LIKELY (src->request_position == src->read_position)) in gst_soup_http_src_update_position()
2373 src->request_position = new_position; in gst_soup_http_src_update_position()
2374 src->read_position = new_position; in gst_soup_http_src_update_position()
2376 if (src->have_size) { in gst_soup_http_src_update_position()
2377 if (new_position > src->content_size) { in gst_soup_http_src_update_position()
2378 GST_DEBUG_OBJECT (src, "Got position previous estimated content size " in gst_soup_http_src_update_position()
2380 src->content_size); in gst_soup_http_src_update_position()
2381 src->content_size = new_position; in gst_soup_http_src_update_position()
2382 basesrc->segment.duration = src->content_size; in gst_soup_http_src_update_position()
2383 gst_element_post_message (GST_ELEMENT (src), in gst_soup_http_src_update_position()
2384 gst_message_new_duration_changed (GST_OBJECT (src))); in gst_soup_http_src_update_position()
2385 } else if (new_position == src->content_size) { in gst_soup_http_src_update_position()
2386 GST_DEBUG_OBJECT (src, "We're EOS now"); in gst_soup_http_src_update_position()
2393 GstSoupHTTPSrc *src; member
2405 g_mutex_lock (&res->src->session_mutex); in _session_read_cb()
2410 g_cond_signal (&res->src->session_cond); in _session_read_cb()
2411 g_mutex_unlock (&res->src->session_mutex); in _session_read_cb()
2419 g_input_stream_read_async (res->src->input_stream, res->buffer, in _session_read_idle_cb()
2420 res->bufsize, G_PRIORITY_DEFAULT, res->src->cancellable, in _session_read_idle_cb()
2427 gst_soup_http_src_read_buffer (GstSoupHTTPSrc * src, GstBuffer ** outbuf) in gst_soup_http_src_read_buffer() argument
2435 bsrc = GST_BASE_SRC_CAST (src); in gst_soup_http_src_read_buffer()
2437 *outbuf = gst_soup_http_src_alloc_buffer (src); in gst_soup_http_src_read_buffer()
2439 GST_WARNING_OBJECT (src, "Failed to allocate buffer"); in gst_soup_http_src_read_buffer()
2444 GST_WARNING_OBJECT (src, "Failed to map buffer"); in gst_soup_http_src_read_buffer()
2448 res.src = src; in gst_soup_http_src_read_buffer()
2456 g_mutex_lock (&src->session_mutex); in gst_soup_http_src_read_buffer()
2460 g_source_attach (source, g_main_loop_get_context (src->session->loop)); in gst_soup_http_src_read_buffer()
2465 g_cond_wait (&src->session_cond, &src->session_mutex); in gst_soup_http_src_read_buffer()
2466 g_mutex_unlock (&src->session_mutex); in gst_soup_http_src_read_buffer()
2468 GST_DEBUG_OBJECT (src, "Read %" G_GSSIZE_FORMAT " bytes from http input", in gst_soup_http_src_read_buffer()
2477 GST_ERROR_OBJECT (src, "Got error from libsoup: %s", res.error->message); in gst_soup_http_src_read_buffer()
2490 gst_soup_http_src_update_position (src, res.nbytes); in gst_soup_http_src_read_buffer()
2493 src->retry_count = 0; in gst_soup_http_src_read_buffer()
2495 gst_soup_http_src_check_update_blocksize (src, res.nbytes); in gst_soup_http_src_read_buffer()
2497 src->last_socket_read_time = g_get_monotonic_time () * GST_USECOND; in gst_soup_http_src_read_buffer()
2505 SoupMessage *msg = src->msg; in gst_soup_http_src_read_buffer()
2512 src->msg = NULL; in gst_soup_http_src_read_buffer()
2513 src->have_body = TRUE; in gst_soup_http_src_read_buffer()
2515 g_mutex_lock (&src->session_mutex); in gst_soup_http_src_read_buffer()
2521 g_source_attach (source, g_main_loop_get_context (src->session->loop)); in gst_soup_http_src_read_buffer()
2525 g_cond_wait (&src->session_cond, &src->session_mutex); in gst_soup_http_src_read_buffer()
2526 g_mutex_unlock (&src->session_mutex); in gst_soup_http_src_read_buffer()
2532 GST_ERROR_OBJECT (src, in gst_soup_http_src_read_buffer()
2537 if (src->have_size && src->read_position < src->content_size) { in gst_soup_http_src_read_buffer()
2541 g_clear_object (&src->msg); in gst_soup_http_src_read_buffer()
2542 src->msg = NULL; in gst_soup_http_src_read_buffer()
2544 src->have_body = TRUE; in gst_soup_http_src_read_buffer()
2556 GstSoupHTTPSrc *src = user_data; in _session_stream_clear_cb() local
2558 g_mutex_lock (&src->session_mutex); in _session_stream_clear_cb()
2560 g_clear_object (&src->input_stream); in _session_stream_clear_cb()
2564 g_cond_broadcast (&src->session_cond); in _session_stream_clear_cb()
2565 src->retry_count = 0; in _session_stream_clear_cb()
2567 g_cond_signal (&src->session_cond); in _session_stream_clear_cb()
2570 g_mutex_unlock (&src->session_mutex); in _session_stream_clear_cb()
2576 gst_soup_http_src_stream_clear (GstSoupHTTPSrc * src) in gst_soup_http_src_stream_clear() argument
2580 if (!src->input_stream) in gst_soup_http_src_stream_clear()
2583 g_mutex_lock (&src->session_mutex); in gst_soup_http_src_stream_clear()
2587 g_source_set_callback (source, _session_stream_clear_cb, src, NULL); in gst_soup_http_src_stream_clear()
2588 g_source_attach (source, g_main_loop_get_context (src->session->loop)); in gst_soup_http_src_stream_clear()
2591 while (src->input_stream) in gst_soup_http_src_stream_clear()
2592 g_cond_wait (&src->session_cond, &src->session_mutex); in gst_soup_http_src_stream_clear()
2594 g_mutex_unlock (&src->session_mutex); in gst_soup_http_src_stream_clear()
2600 GstSoupHTTPSrc *src; in gst_soup_http_src_create() local
2604 src = GST_SOUP_HTTP_SRC (psrc); in gst_soup_http_src_create()
2609 if (src->request_position != src->read_position && src->input_stream) { in gst_soup_http_src_create()
2610 gst_soup_http_src_stream_clear (src); in gst_soup_http_src_create()
2613 if (g_cancellable_is_cancelled (src->cancellable)) { in gst_soup_http_src_create()
2619 if (!src->input_stream) { in gst_soup_http_src_create()
2621 g_mutex_lock (&src->session_mutex); in gst_soup_http_src_create()
2623 gst_soup_http_src_do_request (src, in gst_soup_http_src_create()
2624 src->method ? src->method : SOUP_METHOD_GET); in gst_soup_http_src_create()
2625 http_headers_event = src->http_headers_event; in gst_soup_http_src_create()
2626 src->http_headers_event = NULL; in gst_soup_http_src_create()
2627 g_mutex_unlock (&src->session_mutex); in gst_soup_http_src_create()
2632 gst_pad_push_event (GST_BASE_SRC_PAD (src), http_headers_event); in gst_soup_http_src_create()
2638 ret = gst_soup_http_src_read_buffer (src, outbuf); in gst_soup_http_src_create()
2641 GST_DEBUG_OBJECT (src, "Returning %d %s", ret, gst_flow_get_name (ret)); in gst_soup_http_src_create()
2646 if (src->input_stream) { in gst_soup_http_src_create()
2647 gst_soup_http_src_stream_clear (src); in gst_soup_http_src_create()
2656 src->retry_count = 0; in gst_soup_http_src_create()
2665 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_start() local
2668 GST_DEBUG_OBJECT (src, "start(\"%s\")", src->location); in gst_soup_http_src_start()
2670 g_mutex_lock (&src->session_mutex); in gst_soup_http_src_start()
2671 ret = gst_soup_http_src_session_open (src); in gst_soup_http_src_start()
2672 g_mutex_unlock (&src->session_mutex); in gst_soup_http_src_start()
2679 GstSoupHTTPSrc *src; in gst_soup_http_src_stop() local
2681 src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_stop()
2682 GST_DEBUG_OBJECT (src, "stop()"); in gst_soup_http_src_stop()
2684 gst_soup_http_src_stream_clear (src); in gst_soup_http_src_stop()
2686 if (src->keep_alive && !src->msg && !src->session_is_shared) in gst_soup_http_src_stop()
2687 g_cancellable_cancel (src->cancellable); in gst_soup_http_src_stop()
2689 gst_soup_http_src_session_close (src); in gst_soup_http_src_stop()
2691 gst_soup_http_src_reset (src); in gst_soup_http_src_stop()
2699 GstSoupHTTPSrc *src; in gst_soup_http_src_change_state() local
2701 src = GST_SOUP_HTTP_SRC (element); in gst_soup_http_src_change_state()
2705 gst_soup_http_src_session_close (src); in gst_soup_http_src_change_state()
2710 GST_DEBUG_OBJECT (src, "souphttpsrc paused_to_ready"); in gst_soup_http_src_change_state()
2711 src->has_sent_first_request = FALSE; in gst_soup_http_src_change_state()
2712 src->has_received_first_response = FALSE; in gst_soup_http_src_change_state()
2716 GST_DEBUG_OBJECT (src, "souphttpsrc ready_to_paused"); in gst_soup_http_src_change_state()
2717 src->has_sent_first_request = FALSE; in gst_soup_http_src_change_state()
2718 src->has_received_first_response = FALSE; in gst_soup_http_src_change_state()
2719 g_mutex_lock (&src->wait_lock); in gst_soup_http_src_change_state()
2720 src->exit_block = FALSE; in gst_soup_http_src_change_state()
2721 g_mutex_unlock (&src->wait_lock); in gst_soup_http_src_change_state()
2737 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (element); in gst_soup_http_src_set_context() local
2743 GST_OBJECT_LOCK (src); in gst_soup_http_src_set_context()
2745 g_clear_object (&src->external_session); in gst_soup_http_src_set_context()
2747 &src->external_session, NULL); in gst_soup_http_src_set_context()
2749 GST_DEBUG_OBJECT (src, "Setting external session %p", in gst_soup_http_src_set_context()
2750 src->external_session); in gst_soup_http_src_set_context()
2751 GST_OBJECT_UNLOCK (src); in gst_soup_http_src_set_context()
2761 GstSoupHTTPSrc *src; in gst_soup_http_src_unlock() local
2763 src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_unlock()
2764 GST_DEBUG_OBJECT (src, "unlock()"); in gst_soup_http_src_unlock()
2766 g_cancellable_cancel (src->cancellable); in gst_soup_http_src_unlock()
2774 GstSoupHTTPSrc *src; in gst_soup_http_src_unlock_stop() local
2776 src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_unlock_stop()
2777 GST_DEBUG_OBJECT (src, "unlock_stop()"); in gst_soup_http_src_unlock_stop()
2779 g_cancellable_reset (src->cancellable); in gst_soup_http_src_unlock_stop()
2786 GstSoupHTTPSrc *src; in gst_soup_http_src_get_size() local
2788 src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_get_size()
2790 if (src->have_size) { in gst_soup_http_src_get_size()
2791 GST_DEBUG_OBJECT (src, "get_size() = %" G_GUINT64_FORMAT, in gst_soup_http_src_get_size()
2792 src->content_size); in gst_soup_http_src_get_size()
2793 *size = src->content_size; in gst_soup_http_src_get_size()
2796 GST_DEBUG_OBJECT (src, "get_size() = FALSE"); in gst_soup_http_src_get_size()
2801 gst_soup_http_src_check_seekable (GstSoupHTTPSrc * src) in gst_soup_http_src_check_seekable() argument
2809 if (!src->got_headers && GST_STATE (src) >= GST_STATE_PAUSED) { in gst_soup_http_src_check_seekable()
2810 g_mutex_lock (&src->session_mutex); in gst_soup_http_src_check_seekable()
2811 while (!src->got_headers && !g_cancellable_is_cancelled (src->cancellable) in gst_soup_http_src_check_seekable()
2813 if ((src->msg && _soup_message_get_method (src->msg) != SOUP_METHOD_HEAD)) { in gst_soup_http_src_check_seekable()
2815 g_cond_wait (&src->session_cond, &src->session_mutex); in gst_soup_http_src_check_seekable()
2816 ret = src->headers_ret; in gst_soup_http_src_check_seekable()
2818 if (gst_soup_http_src_session_open (src)) { in gst_soup_http_src_check_seekable()
2819 ret = gst_soup_http_src_do_request (src, SOUP_METHOD_HEAD); in gst_soup_http_src_check_seekable()
2823 g_mutex_unlock (&src->session_mutex); in gst_soup_http_src_check_seekable()
2830 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_is_seekable() local
2832 gst_soup_http_src_check_seekable (src); in gst_soup_http_src_is_seekable()
2834 return src->seekable; in gst_soup_http_src_is_seekable()
2840 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_do_seek() local
2842 GST_DEBUG_OBJECT (src, "do_seek(%" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT in gst_soup_http_src_do_seek()
2844 if (src->read_position == segment->start && in gst_soup_http_src_do_seek()
2845 src->request_position == src->read_position && in gst_soup_http_src_do_seek()
2846 src->stop_position == segment->stop) { in gst_soup_http_src_do_seek()
2847 GST_DEBUG_OBJECT (src, in gst_soup_http_src_do_seek()
2852 gst_soup_http_src_check_seekable (src); in gst_soup_http_src_do_seek()
2856 if (src->got_headers && !src->seekable) { in gst_soup_http_src_do_seek()
2857 GST_WARNING_OBJECT (src, "Not seekable"); in gst_soup_http_src_do_seek()
2862 GST_WARNING_OBJECT (src, "Invalid seek segment"); in gst_soup_http_src_do_seek()
2866 if (src->have_size && segment->start >= src->content_size) { in gst_soup_http_src_do_seek()
2867 GST_WARNING_OBJECT (src, in gst_soup_http_src_do_seek()
2872 src->request_position = segment->start; in gst_soup_http_src_do_seek()
2873 src->stop_position = segment->stop; in gst_soup_http_src_do_seek()
2881 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc); in gst_soup_http_src_query() local
2888 gst_query_set_uri (query, src->location); in gst_soup_http_src_query()
2889 if (src->redirection_uri != NULL) { in gst_soup_http_src_query()
2890 gst_query_set_uri_redirection (query, src->redirection_uri); in gst_soup_http_src_query()
2892 src->redirection_permanent); in gst_soup_http_src_query()
2918 gst_soup_http_src_set_location (GstSoupHTTPSrc * src, const gchar * uri, in gst_soup_http_src_set_location() argument
2924 if (src->location) { in gst_soup_http_src_set_location()
2925 g_free (src->location); in gst_soup_http_src_set_location()
2926 src->location = NULL; in gst_soup_http_src_set_location()
2934 src->location = in gst_soup_http_src_set_location()
2940 if (src->redirection_uri) { in gst_soup_http_src_set_location()
2941 g_free (src->redirection_uri); in gst_soup_http_src_set_location()
2942 src->redirection_uri = NULL; in gst_soup_http_src_set_location()
2945 src->location = g_strdup (uri); in gst_soup_http_src_set_location()
2951 gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri) in gst_soup_http_src_set_proxy() argument
2953 if (src->proxy) { in gst_soup_http_src_set_proxy()
2954 gst_soup_uri_free (src->proxy); in gst_soup_http_src_set_proxy()
2955 src->proxy = NULL; in gst_soup_http_src_set_proxy()
2962 src->proxy = gst_soup_uri_new (uri); in gst_soup_http_src_set_proxy()
2966 src->proxy = gst_soup_uri_new (new_uri); in gst_soup_http_src_set_proxy()
2970 return (src->proxy != NULL); in gst_soup_http_src_set_proxy()
2995 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler); in gst_soup_http_src_uri_get_uri() local
2998 return g_strdup (src->location); in gst_soup_http_src_uri_get_uri()
3005 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler); in gst_soup_http_src_uri_set_uri() local
3007 return gst_soup_http_src_set_location (src, uri, error); in gst_soup_http_src_uri_set_uri()