Projects
Mega:23.09
libnice
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
_service:tar_scm:libnice.spec
Changed
@@ -1,6 +1,6 @@ Name: libnice -Version: 0.1.19 -Release: 2 +Version: 0.1.21 +Release: 1 Summary: An implementation of ICE standard License: LGPLv2 and MPLv1.1 URL: https://nice.freedesktop.org/wiki/ @@ -12,7 +12,7 @@ BuildRequires: gobject-introspection-devel gstreamer1-devel >= 0.11.91 BuildRequires: gstreamer1-plugins-base-devel >= 0.11.91 BuildRequires: gtk-doc gupnp-igd-devel >= 0.1.2 graphviz meson -BuildRequires: cmake +BuildRequires: cmake gnupg2 %description Libnice is an implementation of the IETF's Interactive Connectivity @@ -70,6 +70,9 @@ %{_datadir}/{gtk-doc/html/libnice/,gir-1.0/Nice-0.1.gir} %changelog +* Wed Oct 11 2023 Ge Wang <wang__ge@126.com> - 0.1.21-1 +- Update to 0.1.21 + * Mon Aug 07 2023 xuping <707078654@qq.com> - 0.1.19-2 - fix build unresolvable due to gupnp upgrade
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="url">git@gitee.com:src-openeuler/libnice.git</param> <param name="scm">git</param> - <param name="revision">openEuler-23.09</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:libnice-0.1.19.tar.gz/.gitlab-ci.yml -> _service:tar_scm:libnice-0.1.21.tar.gz/.gitlab-ci.yml
Changed
@@ -1,5 +1,6 @@ stages: - verify + - containers - build - test - deploy @@ -11,9 +12,6 @@ - if: $CI_COMMIT_BRANCH == "latest-release" - if: $CI_PIPELINE_SOURCE == "web" -default: - image: registry.freedesktop.org/libnice/libnice/centos7/meson-build - # # Check "allow-edit" checkbox on merge requests with ci-fairy # @@ -21,6 +19,14 @@ include: - project: 'freedesktop/ci-templates' file: '/templates/ci-fairy.yml' + - project: 'freedesktop/ci-templates' + file: '/templates/centos.yml' + +.libnice.centos:7: + variables: + FDO_DISTRIBUTION_VERSION: '7' + FDO_DISTRIBUTION_TAG: '2022-10-17-cov' + FDO_UPSTREAM_REPO: 'libnice/libnice' check-allow-collaboration: extends: @@ -36,8 +42,20 @@ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: always +build-centos-container:7: + extends: + - .fdo.container-build@centos # the CI template + - .libnice.centos:7 # our template job above + stage: containers + variables: + FDO_DISTRIBUTION_PACKAGES: 'git gtk-doc gnutls-devel gupnp-igd-devel gstreamer1-devel gobject-introspection-devel valgrind net-tools centos-release-scl graphviz' + FDO_DISTRIBUTION_EXEC: 'tests/docker/centos7-meson/pip-installs.sh' + build: stage: build + extends: + - .fdo.distribution-image@centos + - .libnice.centos:7 interruptible: true variables: PREFIX: "${CI_PROJECT_DIR}/libnice-prefix" @@ -48,8 +66,8 @@ script: ## && true to make gitlab-ci happy - source scl_source enable rh-python36 && true - - meson --werror --warnlevel 2 -Dgtk_doc=enabled --prefix=$PREFIX build/ - - ninja-build -C build/ + - meson --werror --warnlevel 2 -Dgtk_doc=enabled --prefix=$PREFIX -Db_coverage=true build/ + - ninja -C build/ artifacts: paths: - build/ @@ -150,6 +168,12 @@ meson build $env:MESON_ARGS && ninja -C build && meson test -C build --print-errorlogs --suite libnice" + artifacts: + reports: + junit: build/meson-logs/testlog-*.junit.xml + when: on_failure + paths: + - build/meson-logs/ build msvc amd64: extends: .build msvc @@ -202,6 +226,9 @@ test: stage: test + extends: + - .fdo.distribution-image@centos + - .libnice.centos:7 interruptible: true needs: - build @@ -210,24 +237,35 @@ script: - ifconfig - source scl_source enable rh-python36 && true + - ninja -C build/ - meson test -C build/ --setup debug + - ninja -C build coverage + - lcov_cobertura build/meson-logs/coverage.info -o build/meson-logs/coverage.xml + coverage: '/lines......: \d+\.\d+% /' artifacts: + reports: + junit: build/meson-logs/testlog-*.junit.xml + coverage_report: + coverage_format: cobertura + path: build/meson-logs/coverage.xml when: on_failure paths: - build/meson-logs/ - test valgrind: extends: test script: - ifconfig - source scl_source enable rh-python36 && true - meson configure build -Dgtk_doc=disabled + - ninja -C build/ - meson test -C build/ --setup valgrind --print-errorlogs - doc-and-install: stage: test + extends: + - .fdo.distribution-image@centos + - .libnice.centos:7 interruptible: true needs: - build @@ -237,8 +275,8 @@ PREFIX: "${CI_PROJECT_DIR}/libnice-prefix" script: - source scl_source enable rh-python36 && true - - ninja-build -C build/ libnice-doc - - ninja-build -C build/ install + - ninja -C build/ libnice-doc + - ninja -C build/ install - ls -lR ${PREFIX} artifacts: paths: @@ -246,6 +284,9 @@ submit-to-coverity: stage: test + extends: + - .fdo.distribution-image@centos + - .libnice.centos:7 variables: COVERITY_PROJECT: libnice PREFIX: "${CI_PROJECT_DIR}/libnice-prefix" @@ -259,10 +300,10 @@ - curl -v https://scan.coverity.com/download/linux64 -o coverity_tool.tgz --data "token=${COVERITY_TOKEN}&project=${COVERITY_PROJECT}" && tar xf coverity_tool.tgz && rm coverity_tool.tgz - mv cov-analysis-linux64-* cov-analysis-linux64 - source scl_source enable rh-python36 && true - - meson --werror --warnlevel 2 -Dgtk_doc=disabled -Dinstrospection=disabled --prefix=$PREFIX cov-build/ + - meson --werror --warnlevel 2 -Dgtk_doc=disabled -Dintrospection=disabled --prefix=$PREFIX cov-build/ - export PATH="$PATH:${CI_PROJECT_DIR}/cov-analysis-linux64/bin" - echo $PATH - - cov-build --dir cov-int ninja-build -C cov-build + - cov-build --dir cov-int ninja -C cov-build - tar czvf libnice.tgz cov-int - curl --form token=$COVERITY_TOKEN --form email=olivier.crete@ocrete.ca --form file=@libnice.tgz --form version="${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}" --form description="CI weekly run" https://scan.coverity.com/builds?project=libnice
View file
_service:tar_scm:libnice-0.1.21.tar.gz/.lcovrc
Added
@@ -0,0 +1,14 @@ +# lcov and genhtml configuration +# See http://ltp.sourceforge.net/coverage/lcov/lcovrc.5.php + +# Always enable branch coverage +lcov_branch_coverage = 1 + +# Exclude precondition assertions, as we can never reasonably get full branch +# coverage of them, as they should never normally fail. +# See https://github.com/linux-test-project/lcov/issues/44 +# Also ignore g_clear macros as we don't care about the NULL path often +lcov_excl_br_line = LCOV_EXCL_BR_LINE|g_return_if_fail|g_return_val_if_fail|g_assert|g_assert_|g_warn_if_fail|g_clear_ + +# Similarly for unreachable assertions. +lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_assert_not_reached|g_warn_if_reached|nice_debug|g_error
View file
_service:tar_scm:libnice-0.1.19.tar.gz/NEWS -> _service:tar_scm:libnice-0.1.21.tar.gz/NEWS
Changed
@@ -1,3 +1,21 @@ +libnice 0.1.21 (2023-01-07) +=========================== +Only use `ifr_ifindex` if OS supports it, fixes build on iOS and FreeBSD + +libnice 0.1.20 (2023-01-06) +=========================== +Remove support for GStreamer 0.10 builds +Add macro to check LIBNICE version +Added utility function to get the STUN server from a candidate +Support additional header in built-in HTTP proxy client +Add boxed type for NiceAddress for bindings +Add API to get the interface index for a local address +Explicitly bind to a specific interface when creating UDP sockets +Limit the number of stored incoming checks based on a property +Do asynchronous DNS resolution for STUN and TURN servers +Add introspection friendly API to get an allocated string from a NiceCandidate +Enable gst-full to link in a single element + libnice 0.1.19 (2022-05-03) =========================== Allow incoming connchecks before remote candidates are set, allows for connection based on received bind requests
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/address.c -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/address.c
Changed
@@ -88,6 +88,9 @@ #endif +NICEAPI_EXPORT +G_DEFINE_BOXED_TYPE (NiceAddress, nice_address, nice_address_dup, + nice_address_free); NICEAPI_EXPORT void nice_address_init (NiceAddress *addr) @@ -258,6 +261,16 @@ } } +NICEAPI_EXPORT gchar * +nice_address_dup_string (const NiceAddress *addr) +{ + char dstMAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) = ""; + + nice_address_to_string (addr, dst); + + return g_strdup (dst); +} + NICEAPI_EXPORT gboolean nice_address_equal (const NiceAddress *a, const NiceAddress *b)
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/address.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/address.h
Changed
@@ -51,6 +51,7 @@ #include <glib.h> +#include <glib-object.h> #ifdef G_OS_WIN32 #include <winsock2.h> @@ -64,6 +65,9 @@ G_BEGIN_DECLS +#define NICE_TYPE_ADDRESS (nice_address_get_type()) + +GType nice_address_get_type (void); /** * NiceAddress: @@ -256,7 +260,7 @@ nice_address_equal_no_port (const NiceAddress *a, const NiceAddress *b); /** - * nice_address_to_string: + * nice_address_to_string: (skip) * @addr: The #NiceAddress to query * @dst: The string to fill * @@ -267,6 +271,19 @@ nice_address_to_string (const NiceAddress *addr, gchar *dst); /** + * nice_address_dup_string: + * @addr: The #NiceAddress to query + * + * Transforms the address @addr into a newly allocated human readable string + * + * Returns: (transfer full): the address string + * + * Since: 0.1.20 + */ +gchar * +nice_address_dup_string (const NiceAddress *addr); + +/** * nice_address_is_private: * @addr: The #NiceAddress to query *
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/agent-priv.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/agent-priv.h
Changed
@@ -140,6 +140,7 @@ NiceProxyType proxy_type; /* property: Proxy type */ gchar *proxy_username; /* property: Proxy username */ gchar *proxy_password; /* property: Proxy password */ + GHashTable *proxy_extra_headers;/* property: Proxy extra headers */ gboolean saved_controlling_mode;/* property: controlling-mode */ guint timer_ta; /* property: timer Ta */ guint max_conn_checks; /* property: max connectivity checks */ @@ -181,6 +182,9 @@ gboolean bytestream_tcp; /* property: bytestream-tcp */ gboolean keepalive_conncheck; /* property: keepalive_conncheck */ + GCancellable *stun_resolving_cancellable; /* Cancel STUN name resolution */ + GSList *stun_resolving_list; /* List of ongoing resolutions */ + GQueue pending_signals; gboolean use_ice_udp; gboolean use_ice_tcp;
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/agent.c -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/agent.c
Changed
@@ -112,6 +112,7 @@ PROP_PROXY_PORT, PROP_PROXY_USERNAME, PROP_PROXY_PASSWORD, + PROP_PROXY_EXTRA_HEADERS, PROP_UPNP, PROP_UPNP_TIMEOUT, PROP_RELIABLE, @@ -400,7 +401,7 @@ g_param_spec_string ( "stun-server", "STUN server IP address", - "The IP address (not the hostname) of the STUN server to use", + "The IP address (or hostname) of the STUN server to use", NULL, G_PARAM_READWRITE)); @@ -615,6 +616,23 @@ G_PARAM_READWRITE)); /** + * NiceAgent:proxy-extra-headers: (type GLib.HashTable(utf8,utf8)) + * + * Optional extra headers to append to the HTTP proxy CONNECT request. + * Provided as key/value-pairs in hash table corresponding to + * header-name/header-value. + * + * Since: 0.1.20 + */ + g_object_class_install_property (gobject_class, PROP_PROXY_EXTRA_HEADERS, + g_param_spec_boxed ( + "proxy-extra-headers", + "Extra headers for HTTP proxy connect", + "Extra headers to append to the HTTP proxy CONNECT request", + G_TYPE_HASH_TABLE, + G_PARAM_READWRITE)); + + /** * NiceAgent:upnp: * * Whether the agent should use UPnP to open a port in the router and @@ -1293,6 +1311,8 @@ agent->use_ice_udp = TRUE; agent->use_ice_tcp = TRUE; + agent->stun_resolving_cancellable = g_cancellable_new(); + agent->rng = nice_rng_new (); priv_generate_tie_breaker (agent); @@ -1427,6 +1447,10 @@ g_value_set_string (value, agent->proxy_password); break; + case PROP_PROXY_EXTRA_HEADERS: + g_value_set_boxed (value, agent->proxy_extra_headers); + break; + case PROP_UPNP: #ifdef HAVE_GUPNP g_value_set_boolean (value, agent->upnp_enabled); @@ -1564,6 +1588,12 @@ } static void +copy_hash_entry (const gchar *key, const gchar *value, GHashTable *hdest) +{ + g_hash_table_insert (hdest, g_strdup (key), g_strdup (value)); +} + +static void nice_agent_set_property ( GObject *object, guint property_id, @@ -1652,6 +1682,17 @@ agent->proxy_password = g_value_dup_string (value); break; + case PROP_PROXY_EXTRA_HEADERS:{ + GHashTable *h = g_value_get_boxed (value); + if (agent->proxy_extra_headers) { + g_hash_table_unref (agent->proxy_extra_headers); + } + agent->proxy_extra_headers = g_hash_table_new_full (g_str_hash, + g_str_equal, g_free, g_free); + g_hash_table_foreach (h, (GHFunc)copy_hash_entry, + agent->proxy_extra_headers); + break; + } case PROP_UPNP_TIMEOUT: #ifdef HAVE_GUPNP agent->upnp_timeout = g_value_get_uint (value); @@ -2251,8 +2292,13 @@ void agent_gathering_done (NiceAgent *agent) { gboolean upnp_running = FALSE; + gboolean dns_resolution_ongoing = FALSE; GSList *i, *j, *k, *l, *m; + if (agent->stun_resolving_list) { + nice_debug ("Agent %p: Gathering not done, resolving names", agent); + } + for (i = agent->streams; i; i = i->next) { NiceStream *stream = i->data; @@ -2274,6 +2320,11 @@ for (j = stream->components; j; j = j->next) { NiceComponent *component = j->data; + if (nice_component_resolving_turn (component)) { + dns_resolution_ongoing = TRUE; + continue; + } + for (k = component->local_candidates; k;) { NiceCandidate *local_candidate = k->data; GSList *next = k->next; @@ -2342,7 +2393,8 @@ } } - if (agent->discovery_timer_source == NULL && !upnp_running) + if (agent->discovery_timer_source == NULL && !upnp_running && + !dns_resolution_ongoing) agent_signal_gathering_done (agent); } @@ -2617,6 +2669,8 @@ return nice_candidate_pair_priority (remote->priority, local->priority); } + + static void priv_add_new_candidate_discovery_stun (NiceAgent *agent, NiceSocket *nicesock, NiceAddress server, @@ -2647,6 +2701,118 @@ ++agent->discovery_unsched_items; } +struct StunResolverData { + GWeakRef agent_ref; + guint stream_id; +}; + +static void +stun_server_resolved_cb (GObject *src, GAsyncResult *result, + gpointer user_data) +{ + GResolver *resolver = G_RESOLVER (src); + GList *addresses, *item; + GError *error = NULL; + struct StunResolverData *data = user_data; + guint stream_id; + NiceAgent *agent; + NiceStream *stream; + + agent = g_weak_ref_get (&data->agent_ref); + g_weak_ref_clear (&data->agent_ref); + if (agent == NULL) + return; + stream_id = data->stream_id; + g_slice_free (struct StunResolverData, data); + + agent->stun_resolving_list = g_slist_remove_all (agent->stun_resolving_list, + data); + + addresses = g_resolver_lookup_by_name_finish (resolver, result, &error); + + if (addresses == NULL) { + g_warning ("Agent: %p: s:%d: Can't resolve STUN server: %s", agent, + stream_id, error->message); + g_clear_error (&error); + goto done; + } + + agent_lock (agent); + + stream = agent_find_stream (agent, stream_id); + + for (item = addresses; item; item = item->next) { + GInetAddress *addr = item->data; + guint cid; + NiceAddress stun_server; + const guint8 *addr_bytes = g_inet_address_to_bytes (addr); + + if (nice_debug_is_enabled ()) { + char *resolved_addr = g_inet_address_to_string (addr); + + nice_debug ("Agent %p: s:%d: Resolved STUN server %s to %s", + agent, stream_id, agent->stun_server_ip, resolved_addr); + g_free (resolved_addr); + } + + switch (g_inet_address_get_family (addr)) { + case G_SOCKET_FAMILY_IPV4: + nice_address_set_ipv4 (&stun_server, ntohl (*((guint32 *) addr_bytes))); + break; + case G_SOCKET_FAMILY_IPV6: + nice_address_set_ipv6 (&stun_server, addr_bytes); + break; + default: + /* Ignore others */ + continue; + } + nice_address_set_port (&stun_server, agent->stun_server_port); + + for (cid = 1; cid <= stream->n_components; cid++) { + NiceComponent *component = nice_stream_find_component_by_id (stream, + cid); + GSList *citem; + + if (component == NULL) + continue; + + for (citem = component->local_candidates; citem; citem = citem->next) { + NiceCandidateImpl *host_candidate = citem->data; + + if (host_candidate->c.type != NICE_CANDIDATE_TYPE_HOST) + continue; + + if (nice_address_is_linklocal (&host_candidate->c.addr)) + continue; + + /* TODO: Add server-reflexive support for TCP candidates */ + if (host_candidate->c.transport != NICE_CANDIDATE_TRANSPORT_UDP) + continue; + if (nice_address_ip_version (&host_candidate->c.addr) != + nice_address_ip_version (&stun_server)) + continue; + + priv_add_new_candidate_discovery_stun (agent, + host_candidate->sockptr, + stun_server, + stream, + cid); + } + } + } + + if (agent->discovery_unsched_items) + discovery_schedule (agent); + else + agent_gathering_done (agent); + agent_unlock_and_emit (agent); + + done: + g_list_free_full (addresses, g_object_unref); + g_object_unref (agent); +} + + NiceSocket * agent_create_tcp_turn_socket (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceSocket *nicesock, @@ -2673,7 +2839,8 @@ agent->proxy_username, agent->proxy_password); } else if (agent->proxy_type == NICE_PROXY_TYPE_HTTP){ nicesock = nice_http_socket_new (nicesock, server, - agent->proxy_username, agent->proxy_password); + agent->proxy_username, agent->proxy_password, + agent->proxy_extra_headers); } else { nice_socket_free (nicesock); nicesock = NULL; @@ -2759,13 +2926,8 @@ agent->compatibility == NICE_COMPATIBILITY_OC2007R2)) reliable_tcp = TRUE; - /* Ignore tcp candidates if we disabled ice-tcp */ - if ((agent->use_ice_udp == FALSE && reliable_tcp == FALSE) || - (agent->use_ice_tcp == FALSE && reliable_tcp == TRUE)) { - goto skip; - } - - if (turn_tcp == FALSE) { + /* Ignore reliable tcp candidates if we disabled ice-tcp */ + if (agent->use_ice_tcp == FALSE && reliable_tcp == TRUE) { goto skip; } @@ -2856,6 +3018,167 @@ return ret; } +struct TurnResolverData { + GWeakRef component_ref; + TurnServer *turn; +}; + +static void +turn_server_resolved_cb (GObject *src, GAsyncResult *result, + gpointer user_data) +{ + GResolver *resolver = G_RESOLVER (src); + GList *addresses = NULL, *item; + GError *error = NULL; + struct TurnResolverData *rd = user_data; + NiceAgent *agent; + NiceStream *stream; + NiceComponent *component; + TurnServer *turn = rd->turn; + gboolean first_filled = FALSE; + + component = g_weak_ref_get (&rd->component_ref); + g_weak_ref_clear (&rd->component_ref); + g_slice_free (struct TurnResolverData, rd); + if (component == NULL) { + turn_server_unref (turn); + return; + } + + agent = g_weak_ref_get (&component->agent_ref); + if (agent == NULL) { + g_object_unref (component); + turn_server_unref (turn); + return; + } + + agent_lock (agent); + + if (g_list_find (component->turn_servers, turn) == NULL) { + /* No longer relevant turn server */ + goto done; + } + + stream = agent_find_stream (agent, component->stream_id); + + addresses = g_resolver_lookup_by_name_finish (resolver, result, &error); + + if (addresses == NULL) { + g_warning ("Agent: %p: s:%d/c:%d: Can't resolve TURN server %s: %s", agent, + component->stream_id, component->id, turn->server_address, + error->message); + g_clear_error (&error); + turn->resolution_failed = TRUE; + goto done; + } + + for (item = addresses; item; item = item->next) { + GInetAddress *addr = item->data; + const guint8 *addr_bytes = g_inet_address_to_bytes (addr); + GSList *citem; + + if (nice_debug_is_enabled ()) { + char *resolved_addr = g_inet_address_to_string (addr); + + nice_debug ("Agent %p: s:%d/c:%d: Resolved TURN server %s to %s", + agent, component->stream_id, component->id, turn->server_address, + resolved_addr); + g_free (resolved_addr); + } + + /* If there is already one resolved, duplicate it */ + if (first_filled) { + TurnServer *copy = turn_server_copy (turn); + + turn_server_unref (turn); + turn = copy; + component->turn_servers = g_list_append (component->turn_servers, + turn_server_ref (turn)); + } + + switch (g_inet_address_get_family (addr)) { + case G_SOCKET_FAMILY_IPV4: + nice_address_set_ipv4 (&turn->server, ntohl (*((guint32 *) addr_bytes))); + break; + case G_SOCKET_FAMILY_IPV6: + nice_address_set_ipv6 (&turn->server, addr_bytes); + break; + default: + /* Ignore others */ + continue; + } + nice_address_set_port (&turn->server, turn->server_port); + + first_filled = TRUE; + + if (stream->gathering_started) { + for (citem = component->local_candidates; citem; citem = citem->next) { + NiceCandidateImpl *host_candidate = citem->data; + + if (host_candidate->c.type != NICE_CANDIDATE_TYPE_HOST) + continue; + + if (nice_address_is_linklocal (&host_candidate->c.addr)) + continue; + + /* TODO: Add server-reflexive support for TCP candidates */ + if (host_candidate->c.transport == + NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE) + continue; + if (nice_address_ip_version (&host_candidate->c.addr) != + nice_address_ip_version (&turn->server)) + continue; + + priv_add_new_candidate_discovery_turn (agent, + host_candidate->sockptr, turn, stream, component->id, + host_candidate->c.transport != NICE_CANDIDATE_TRANSPORT_UDP); + } + } + } + + if (agent->discovery_unsched_items) + discovery_schedule (agent); + else + agent_gathering_done (agent); + + done: + agent_unlock_and_emit (agent); + g_list_free_full (addresses, g_object_unref); + turn_server_unref (turn); + g_object_unref (component); + g_object_unref (agent); +} + +static gboolean +resolve_turn_in_context (NiceAgent *agent, gpointer data) +{ + struct TurnResolverData *rd = data; + NiceComponent *component; + GResolver *resolver; + + component = g_weak_ref_get (&rd->component_ref); + if (component == NULL) { + g_weak_ref_clear (&rd->component_ref); + turn_server_unref (rd->turn); + g_slice_free (struct TurnResolverData, rd); + + return G_SOURCE_REMOVE; + } + + resolver = g_resolver_get_default (); + + g_main_context_push_thread_default (agent->main_context); + g_resolver_lookup_by_name_async (resolver, rd->turn->server_address, + component->turn_resolving_cancellable, turn_server_resolved_cb, + rd); + g_main_context_pop_thread_default (agent->main_context); + + g_object_unref (resolver); + + g_object_unref (component); + + return G_SOURCE_REMOVE; +} NICEAPI_EXPORT gboolean nice_agent_set_relay_info(NiceAgent *agent, @@ -2890,7 +3213,7 @@ length = g_list_length (component->turn_servers); if (length == NICE_CANDIDATE_MAX_TURN_SERVERS) { - g_warning ("Agent %p : cannot have more than %d turn servers.", + g_warning ("Agent %p : cannot have more than %d turn servers per component.", agent, length); ret = FALSE; goto done; @@ -2898,11 +3221,6 @@ turn = turn_server_new (server_ip, server_port, username, password, type); - if (!turn) { - ret = FALSE; - goto done; - } - nice_debug ("Agent %p: added relay server %s:%d of type %d to s/c %d/%d " "with user/pass : %s -- %s", agent, server_ip, server_port, type, stream_id, component_id, username, @@ -2915,25 +3233,43 @@ turn->preference = length; component->turn_servers = g_list_append (component->turn_servers, turn); - if (stream->gathering_started) { + if (!nice_address_is_valid (&turn->server)) { + GSource *source = NULL; + struct TurnResolverData *rd = g_slice_new (struct TurnResolverData); + + g_weak_ref_init (&rd->component_ref, component); + rd->turn = turn_server_ref (turn); + + nice_debug("Agent:%p s:%d/%d: Resolving TURN server %s", + agent, stream_id, component_id, server_ip); + + agent_timeout_add_with_context (agent, &source, "TURN resolution", 0, + resolve_turn_in_context, rd); + g_source_unref (source); + } + + if (stream->gathering_started) { GSList *i; stream->gathering = TRUE; - for (i = component->local_candidates; i; i = i->next) { - NiceCandidateImpl *c = i->data; + if (nice_address_is_valid (&turn->server)) { + for (i = component->local_candidates; i; i = i->next) { + NiceCandidateImpl *c = i->data; + + if (c->c.type == NICE_CANDIDATE_TYPE_HOST && + c->c.transport != NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE && + nice_address_ip_version (&c->c.addr) == + nice_address_ip_version (&turn->server)) { + priv_add_new_candidate_discovery_turn (agent, + c->sockptr, turn, stream, component_id, + c->c.transport != NICE_CANDIDATE_TRANSPORT_UDP); + } + } - if (c->c.type == NICE_CANDIDATE_TYPE_HOST && - c->c.transport != NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE && - nice_address_ip_version (&c->c.addr) == - nice_address_ip_version (&turn->server)) - priv_add_new_candidate_discovery_turn (agent, - c->sockptr, turn, stream, component_id, - c->c.transport != NICE_CANDIDATE_TRANSPORT_UDP); + if (agent->discovery_unsched_items) + discovery_schedule (agent); } - - if (agent->discovery_unsched_items) - discovery_schedule (agent); } @@ -3081,6 +3417,7 @@ &externaddr, host_candidate->c.transport, host_candidate->sockptr, + NULL, TRUE); check_upnp_gathering_done (agent, stream); @@ -3289,6 +3626,25 @@ } } +static gboolean +resolve_stun_in_context (NiceAgent *agent, gpointer data) +{ + GResolver *resolver = g_resolver_get_default (); + struct StunResolverData *rd = data; + + nice_debug("Agent:%p s:%d: Resolving STUN server %s", + agent, rd->stream_id, agent->stun_server_ip); + + g_main_context_push_thread_default (agent->main_context); + g_resolver_lookup_by_name_async (resolver, agent->stun_server_ip, + agent->stun_resolving_cancellable, stun_server_resolved_cb, rd); + g_main_context_pop_thread_default (agent->main_context); + + g_object_unref (resolver); + + return G_SOURCE_REMOVE; +} + NICEAPI_EXPORT gboolean nice_agent_gather_candidates ( NiceAgent *agent, @@ -3300,6 +3656,7 @@ GSList *local_addresses = NULL; gboolean ret = TRUE; guint length; + gboolean resolving_turn = FALSE; g_return_val_if_fail (NICE_IS_AGENT (agent), FALSE); g_return_val_if_fail (stream_id >= 1, FALSE); @@ -3354,6 +3711,23 @@ agent, NICE_CANDIDATE_MAX_LOCAL_ADDRESSES); } + if (agent->full_mode && agent->stun_server_ip && !agent->force_relay) + { + struct StunResolverData *rd = g_slice_new (struct StunResolverData); + GSource *source = NULL; + + g_weak_ref_init (&rd->agent_ref, agent); + rd->stream_id = stream_id; + + nice_debug("Agent:%p s:%d: Resolving STUN server %s", + agent, stream_id, agent->stun_server_ip); + agent_timeout_add_with_context (agent, &source, "STUN resolution", 0, + resolve_stun_in_context, rd); + g_source_unref (source); + agent->stun_resolving_list = g_slist_prepend (agent->stun_resolving_list, + rd); + } + for (cid = 1; cid <= stream->n_components; cid++) { NiceComponent *component = nice_stream_find_component_by_id (stream, cid); gboolean found_local_address = FALSE; @@ -3453,24 +3827,6 @@ priv_add_upnp_discovery (agent, stream, (NiceCandidate *) host_candidate); - /* TODO: Add server-reflexive support for TCP candidates */ - if (agent->full_mode && agent->stun_server_ip && !agent->force_relay && - !nice_address_is_linklocal (addr) && - transport == NICE_CANDIDATE_TRANSPORT_UDP) { - NiceAddress stun_server; - if (nice_address_set_from_string (&stun_server, agent->stun_server_ip)) { - nice_address_set_port (&stun_server, agent->stun_server_port); - - if (nice_address_ip_version (&host_candidate->c.addr) == - nice_address_ip_version (&stun_server)) - priv_add_new_candidate_discovery_stun (agent, - host_candidate->sockptr, - stun_server, - stream, - cid); - } - } - if (agent->full_mode && component && !nice_address_is_linklocal (addr) && transport != NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE) { GList *item; @@ -3479,6 +3835,12 @@ for (item = component->turn_servers; item; item = item->next) { TurnServer *turn = item->data; + if (!nice_address_is_valid (&turn->server)) { + if (!turn->resolution_failed) + resolving_turn = TRUE; + continue; + } + if (host_ip_version != nice_address_ip_version (&turn->server)) { continue; } @@ -3526,6 +3888,8 @@ /* note: no async discoveries pending, signal that we are ready */ if (agent->discovery_unsched_items == 0 && + agent->stun_resolving_list == NULL && + resolving_turn == FALSE && #ifdef HAVE_GUPNP stream->upnp_mapping == NULL) { #else @@ -4219,6 +4583,7 @@ /* We need an address for packet parsing, below. */ if (message->from == NULL) { + nice_address_init (&from); message->from = &from; } @@ -5696,6 +6061,11 @@ /* step: free resources for the connectivity check timers */ conn_check_free (agent); + g_cancellable_cancel (agent->stun_resolving_cancellable); + g_clear_object (&agent->stun_resolving_cancellable); + g_slist_free (agent->stun_resolving_list); + agent->stun_resolving_list = NULL; + priv_remove_keepalive_timer (agent); for (i = agent->local_addresses; i; i = i->next) @@ -5759,7 +6129,10 @@ agent->proxy_username = NULL; g_free (agent->proxy_password); agent->proxy_password = NULL; - + if (agent->proxy_extra_headers != NULL) { + g_hash_table_unref (agent->proxy_extra_headers); + agent->proxy_extra_headers = NULL; + } nice_rng_free (agent->rng); agent->rng = NULL; @@ -5783,7 +6156,6 @@ if (G_OBJECT_CLASS (nice_agent_parent_class)->dispose) G_OBJECT_CLASS (nice_agent_parent_class)->dispose (object); - } gboolean @@ -7380,6 +7752,7 @@ g_object_ref (agent); agent_lock (agent); + g_cancellable_cancel (agent->stun_resolving_cancellable); refresh_prune_agent_async (agent, on_agent_refreshes_pruned, task); agent_unlock (agent);
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/agent.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/agent.h
Changed
@@ -260,9 +260,11 @@ /** * NICE_AGENT_MAX_REMOTE_CANDIDATES: * - * A hard limit for the number of remote candidates. This - * limit is enforced to protect against malevolent remote - * clients. + * Was a limit on the number of remote candidates one can set, but is + * no longer used by libnice itself. + * + * Deprecated: 0.1.20: Replace with dynamic value based on the + * #NiceAgent::max-connectivity-checks property */ #define NICE_AGENT_MAX_REMOTE_CANDIDATES 25 @@ -580,7 +582,7 @@ * @agent: The #NiceAgent Object * @stream_id: The ID of the stream * @component_id: The ID of the component - * @server_ip: The IP address of the TURN server + * @server_ip: The address of the TURN server * @server_port: The port of the TURN server * @username: The TURN username to use for the allocate * @password: The TURN password to use for the allocate
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/candidate-priv.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/candidate-priv.h
Changed
@@ -71,6 +71,7 @@ * TurnServer: * @ref_count: Reference count for the structure. * @server: The #NiceAddress of the TURN server + * @server_address: The unresolved server address * @username: The TURN username * @password: The TURN password * @decoded_username: The base64 decoded TURN username @@ -87,6 +88,8 @@ gint ref_count; NiceAddress server; + gchar *server_address; + guint server_port; gchar *username; gchar *password; guint8 *decoded_username; @@ -95,6 +98,8 @@ gsize decoded_password_len; NiceRelayType type; guint preference; + + gboolean resolution_failed; }; @@ -105,6 +110,8 @@ * of type %NICE_CANDIDATE_TYPE_RELAYED * @sockptr: The underlying socket * @keepalive_next_tick: The timestamp for the next keepalive + * @stun_server: The STUN server address, if the candidate is + * of type %NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE * * A structure to represent an ICE candidate */ @@ -114,9 +121,10 @@ TurnServer *turn; NiceSocket *sockptr; guint64 keepalive_next_tick; /* next tick timestamp */ + NiceAddress *stun_server; }; G_END_DECLS -#endif /* __LIBNICE_CANDIDATE_H__ */ \ No newline at end of file +#endif /* __LIBNICE_CANDIDATE_H__ */
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/candidate.c -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/candidate.c
Changed
@@ -88,6 +88,9 @@ if (c->turn) turn_server_unref (c->turn); + if (c->stun_server) + nice_address_free (c->stun_server); + g_slice_free (NiceCandidateImpl, c); } @@ -414,6 +417,8 @@ copy->turn = NULL; copy->c.username = g_strdup (copy->c.username); copy->c.password = g_strdup (copy->c.password); + if (copy->stun_server) + copy->stun_server = nice_address_dup (copy->stun_server); return (NiceCandidate *) copy; } @@ -470,7 +475,23 @@ const NiceCandidateImpl *c = (NiceCandidateImpl *) candidate; g_return_if_fail (candidate != NULL); - g_return_if_fail (candidate->type != NICE_CANDIDATE_TYPE_RELAYED); + g_return_if_fail (candidate->type == NICE_CANDIDATE_TYPE_RELAYED); *addr = c->turn->server; } + +NICEAPI_EXPORT gboolean +nice_candidate_stun_server_address (const NiceCandidate *candidate, NiceAddress *addr) +{ + const NiceCandidateImpl *c = (NiceCandidateImpl *) candidate; + + g_return_val_if_fail (candidate != NULL, FALSE); + g_return_val_if_fail (candidate->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE, FALSE); + + if (c->stun_server) { + *addr = *c->stun_server; + return TRUE; + } else { + return FALSE; + } +}
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/candidate.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/candidate.h
Changed
@@ -90,11 +90,11 @@ /** * NiceCandidateType: * @NICE_CANDIDATE_TYPE_HOST: A host candidate - * @NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: A server reflexive candidate + * @NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: A server reflexive candidate (or a NAT-assisted candidate) * @NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: A peer reflexive candidate * @NICE_CANDIDATE_TYPE_RELAYED: A relay candidate * - * An enum represneting the type of a candidate + * An enum representing the type of a candidate */ typedef enum { @@ -269,6 +269,21 @@ nice_candidate_relay_address (const NiceCandidate *candidate, NiceAddress *addr); /** + * nice_candidate_stun_server_address: + * @candidate: A server-reflexive candidate + * @addr: The #NiceAddress to fill + * + * In case the given candidate server-reflexive, use this utility function to get its address. The + * address will be filled only if the candidate was generated using an STUN server. + * + * Returns: TRUE if it's a STUN created ICE candidate, or FALSE if the reflexed's server was not STUN. + * + * Since: 0.1.20 + */ +gboolean +nice_candidate_stun_server_address (const NiceCandidate *candidate, NiceAddress *addr); + +/** * NICE_TYPE_CANDIDATE: * * A boxed type for a #NiceCandidate.
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/component.c -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/component.c
Changed
@@ -1164,6 +1164,8 @@ component->rfc4571_buffer_size = sizeof (guint16) + G_MAXUINT16; component->rfc4571_buffer = g_malloc (component->rfc4571_buffer_size); + + component->turn_resolving_cancellable = g_cancellable_new (); } static void @@ -1272,6 +1274,9 @@ g_list_free_full (cmp->valid_candidates, (GDestroyNotify) nice_candidate_free); + g_cancellable_cancel (cmp->turn_resolving_cancellable); + g_clear_object (&cmp->turn_resolving_cancellable); + g_clear_object (&cmp->tcp); g_clear_object (&cmp->stop_cancellable); g_clear_object (&cmp->iostream); @@ -1557,17 +1562,16 @@ turn_server_new (const gchar *server_ip, guint server_port, const gchar *username, const gchar *password, NiceRelayType type) { - TurnServer *turn = g_slice_new (TurnServer); + TurnServer *turn = g_slice_new0 (TurnServer); nice_address_init (&turn->server); turn->ref_count = 1; - if (nice_address_set_from_string (&turn->server, server_ip)) { + turn->server_port = server_port; + if (nice_address_set_from_string (&turn->server, server_ip)) nice_address_set_port (&turn->server, server_port); - } else { - g_slice_free (TurnServer, turn); - return NULL; - } + else + turn->server_address = g_strdup (server_ip); turn->username = g_strdup (username); turn->password = g_strdup (password); turn->decoded_username = @@ -1593,6 +1597,7 @@ turn->ref_count--; if (turn->ref_count == 0) { + g_free (turn->server_address); g_free (turn->username); g_free (turn->password); g_free (turn->decoded_username); @@ -1601,6 +1606,28 @@ } } +TurnServer * +turn_server_copy (TurnServer *turn) +{ + TurnServer *copy = g_slice_new0 (TurnServer); + + copy->ref_count = 1; + copy->server = turn->server; + copy->server_address = g_strdup (turn->server_address); + copy->username = g_strdup (turn->username); + copy->password = g_strdup (turn->password); + copy->decoded_username = g_memdup (turn->decoded_username, + turn->decoded_username_len); + copy->decoded_password = g_memdup (turn->decoded_password, + turn->decoded_password_len); + copy->decoded_username_len = turn->decoded_username_len; + copy->decoded_password_len = turn->decoded_password_len; + copy->type = turn->type; + copy->preference = turn->preference; + + return copy; +} + void nice_component_add_valid_candidate (NiceAgent *agent, NiceComponent *component, const NiceCandidate *candidate) @@ -1706,3 +1733,21 @@ { return component->rfc4571_buffer_offset - component->rfc4571_frame_offset; } + +gboolean +nice_component_resolving_turn (NiceComponent *component) +{ + GList *item; + + for (item = component->turn_servers; item; item = item->next) { + TurnServer *turn = item->data; + + if (turn->resolution_failed) + continue; + + if (!nice_address_is_valid (&turn->server)) + return TRUE; + } + + return FALSE; +}
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/component.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/component.h
Changed
@@ -251,6 +251,9 @@ guint rfc4571_consumed_size; NiceAddress rfc4571_remote_addr; gboolean rfc4571_wakeup_needed; + + /* TURN resolution */ + GCancellable *turn_resolving_cancellable; }; typedef struct { @@ -329,6 +332,9 @@ const gchar *username, const gchar *password, NiceRelayType type); TurnServer * +turn_server_copy (TurnServer *turn); + +TurnServer * turn_server_ref (TurnServer *turn); void @@ -348,6 +354,10 @@ guint nice_component_compute_rfc4571_headroom (NiceComponent *component); +gboolean +nice_component_resolving_turn (NiceComponent *component); + + G_END_DECLS #endif /* _NICE_COMPONENT_H */
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/conncheck.c -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/conncheck.c
Changed
@@ -65,7 +65,7 @@ static void priv_update_check_list_failed_components (NiceAgent *agent, NiceStream *stream); static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, NiceComponent *component); static gboolean priv_schedule_triggered_check (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceSocket *local_socket, NiceCandidate *remote_cand); -static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceCandidate *localcand, NiceCandidate *remotecand); +static gboolean priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceCandidate *localcand, NiceCandidate *remotecand); static size_t priv_create_username (NiceAgent *agent, NiceStream *stream, guint component_id, NiceCandidate *remote, NiceCandidate *local, uint8_t *dest, guint dest_len, gboolean inbound); @@ -212,11 +212,12 @@ nice_address_to_string (&icheck->local_socket->addr, tmpbuf1); nice_address_to_string (&icheck->from, tmpbuf2); nice_debug ("Agent %p : *** sc=%d/%d : icheck %p : " - "sock %s %s:%u > %s:%u", + "sock %s %s:%u > %s:%u, use_cand %u", agent, stream->id, component->id, icheck, priv_socket_type_to_string (icheck->local_socket->type), tmpbuf1, nice_address_get_port (&icheck->local_socket->addr), - tmpbuf2, nice_address_get_port (&icheck->from)); + tmpbuf2, nice_address_get_port (&icheck->from), + icheck->use_candidate); } } @@ -1281,7 +1282,7 @@ agent_signal_component_state_change (agent, pair->keepalive.stream_id, pair->keepalive.component_id, NICE_COMPONENT_STATE_FAILED); } else { - guint64 delay = (consent_timeout - now - pair->remote_consent.last_received) / 1000; + guint64 delay = (consent_timeout - (now - pair->remote_consent.last_received)) / 1000; nice_debug ("Agent %p : pair %p rechecking consent in %" G_GUINT64_FORMAT ".%03" G_GUINT64_FORMAT "s", agent, pair, delay / 1000, delay % 1000); agent_timeout_add_with_context (agent, @@ -2223,20 +2224,44 @@ * The remote party has signalled that the candidate pair * described by 'component' and 'remotecand' is nominated * for use. + * return TRUE if at least one matching pair is found and got nominated (or marked to be nominated on response_arrival). */ -static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceCandidate *localcand, NiceCandidate *remotecand) +static gboolean priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceCandidate *localcand, NiceCandidate *remotecand) { GSList *i; + gboolean res = FALSE; g_assert (component); if (NICE_AGENT_IS_COMPATIBLE_WITH_RFC5245_OR_OC2007R2 (agent) && agent->controlling_mode) - return; + return res; + + if (nice_debug_is_verbose()) { + gchar remote_strINET6_ADDRSTRLEN; + gchar local_strINET6_ADDRSTRLEN; + nice_address_to_string(&remotecand->addr, remote_str); + nice_address_to_string(&localcand->addr, local_str); + nice_debug ("Agent %p : *** priv_mark_pair_nominated: local candidate %p %s:%u, remote candidate %p %s:%u", + agent, localcand, local_str, nice_address_get_port (&localcand->addr), + remotecand, remote_str, nice_address_get_port (&remotecand->addr)); + } /* step: search for at least one nominated pair */ for (i = stream->conncheck_list; i; i = i->next) { CandidateCheckPair *pair = i->data; + + if (nice_debug_is_verbose()) { + gchar remote_strINET6_ADDRSTRLEN; + gchar local_strINET6_ADDRSTRLEN; + nice_address_to_string(&pair->remote->addr, remote_str); + nice_address_to_string(&pair->local->addr, local_str); + nice_debug ("Agent %p : *** priv_mark_pair_nominated: conncheck pair %p, state %u, valid %u, nom %u, disc p %p: local candidate %p %s:%u, remote candidate %p %s:%u", + agent, pair, pair->state, pair->valid, pair->nominated, pair->discovered_pair, + pair->local, local_str, nice_address_get_port (&pair->local->addr), + pair->remote, remote_str, nice_address_get_port (&pair->remote->addr)); + } + if (pair->local == localcand && pair->remote == remotecand) { /* ICE, 7.2.1.5. Updating the Nominated Flag */ /* note: TCP candidates typically produce peer reflexive @@ -2245,6 +2270,8 @@ */ if (pair->state == NICE_CHECK_SUCCEEDED && pair->discovered_pair != NULL) { + nice_debug ("Agent %p : priv_mark_pair_nominated: conncheck pair %p - replace with discovered pair %p", + agent, pair, pair->discovered_pair); pair = pair->discovered_pair; g_assert (pair->state == NICE_CHECK_DISCOVERED); } @@ -2266,6 +2293,7 @@ * priv_schedule_triggered_check(), case NICE_CHECK_IN_PROGRESS. */ pair->mark_nominated_on_response_arrival = TRUE; + res = TRUE; nice_debug ("Agent %p : pair %p (%s) is %s, " "will be nominated on response receipt.", agent, pair, pair->foundation, @@ -2293,10 +2321,13 @@ stream->id, component->id, NICE_COMPONENT_STATE_CONNECTED); } - if (pair->nominated) + if (pair->nominated) { conn_check_update_check_list_state_for_ready (agent, stream, component); + res = TRUE; + } } } + return res; } /* @@ -2603,7 +2634,7 @@ /* * Prunes the list of connectivity checks for items related - * to stream 'stream_id'. + * to stream 'stream_id'. * * @return TRUE on success, FALSE on a fatal error */ @@ -3278,23 +3309,18 @@ * before we get information about the remote candidates (via * SDP or other signaling means). * - * @return non-zero on error, zero on success + * @return pointer to created pending check, zero on error */ -static int priv_store_pending_check (NiceAgent *agent, NiceComponent *component, +static IncomingCheck *priv_store_pending_check (NiceAgent *agent, NiceComponent *component, const NiceAddress *from, NiceSocket *sockptr, uint8_t *username, uint16_t username_len, uint32_t priority, gboolean use_candidate) { - IncomingCheck *icheck; - nice_debug ("Agent %p : Storing pending check.", agent); + IncomingCheck *icheck = NULL; + guint max_incoming_checks = agent->max_conn_checks * 2; - if (g_queue_get_length (&component->incoming_checks) >= - NICE_AGENT_MAX_REMOTE_CANDIDATES) { - nice_debug ("Agent %p : WARN: unable to store information for early incoming check.", agent); - return -1; - } + nice_debug ("Agent %p : Storing pending check.", agent); icheck = g_slice_new0 (IncomingCheck); - g_queue_push_tail (&component->incoming_checks, icheck); icheck->from = *from; icheck->local_socket = sockptr; icheck->priority = priority; @@ -3303,8 +3329,19 @@ icheck->username = NULL; if (username_len > 0) icheck->username = g_memdup (username, username_len); + g_queue_push_tail (&component->incoming_checks, icheck); - return 0; + if (g_queue_get_length (&component->incoming_checks) >= max_incoming_checks) { + IncomingCheck *old_icheck = g_queue_pop_head (&component->incoming_checks); + + g_free (old_icheck->username); + g_slice_free (IncomingCheck, old_icheck); + + nice_debug ("Agent %p : WARN: Over %d early checks, dropping the oldest", + agent, max_incoming_checks); + } + + return icheck; } /* @@ -3758,7 +3795,7 @@ * * @return TRUE if a matching transaction is found */ -static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessage *resp) +static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessage *resp, const NiceAddress *server_address) { union { struct sockaddr_storage storage; @@ -3814,14 +3851,17 @@ &niceaddr, NICE_CANDIDATE_TRANSPORT_UDP, d->nicesock, + server_address, FALSE); + if (agent->use_ice_tcp) discovery_discover_tcp_server_reflexive_candidates ( agent, d->stream_id, d->component_id, &niceaddr, - d->nicesock); + d->nicesock, + server_address); } d->stun_message.buffer = NULL; d->stun_message.buffer_len = 0; @@ -4045,6 +4085,7 @@ &mappedniceaddr, NICE_CANDIDATE_TRANSPORT_UDP, d->nicesock, + &niceaddr, FALSE); } if (agent->use_ice_tcp) { @@ -4059,7 +4100,8 @@ d->stream_id, d->component_id, &mappedniceaddr, - d->nicesock); + d->nicesock, + &niceaddr); } } } @@ -4324,12 +4366,13 @@ static gboolean priv_map_reply_to_keepalive_conncheck (NiceAgent *agent, NiceComponent *component, StunMessage *resp) { + guint64 now = g_get_monotonic_time(); + nice_debug ("Agent %p : Keepalive for selected pair %p received.", agent, &component->selected_pair); - if (agent->consent_freshness) { - guint64 now = g_get_monotonic_time(); - component->selected_pair.remote_consent.last_received = now; - } + + /* timeout is checked even if consent_freshness is disabled */ + component->selected_pair.remote_consent.last_received = now; return TRUE; } @@ -4423,7 +4466,7 @@ */ static gboolean conn_check_handle_renomination (NiceAgent *agent, NiceStream *stream, NiceComponent *component, StunMessage *req, - NiceCandidate *remote_candidate, NiceCandidate *local_candidate) + NiceCandidate *remote_candidate, NiceCandidate *local_candidate, IncomingCheck *pending_check) { GSList *lst; if (!agent->controlling_mode && NICE_AGENT_IS_COMPATIBLE_WITH_RFC5245_OR_OC2007R2 (agent) && @@ -4468,7 +4511,22 @@ } } } - priv_mark_pair_nominated (agent, stream, component, local_candidate, remote_candidate); + if (!priv_mark_pair_nominated (agent, stream, component, local_candidate, remote_candidate)) { + /* No matching pair in conn check list. It means that we are probably handling incoming conn check, + * so triggered check (pending_check) will be performed in future once we have credentials and remote candidates. + * Constructed pair needs to be nominated then, so set use_candidate for pending check. + */ + if (nice_debug_is_enabled ()) { + gchar remote_strINET6_ADDRSTRLEN; + nice_address_to_string(&remote_candidate->addr, remote_str); + nice_debug ("Agent %p : no matching pair nominated while handling NOMINATION attr for " + "remote candidate %s:%u, pending check: %p - %s", + agent, remote_str, nice_address_get_port (&remote_candidate->addr), + pending_check, pending_check ? "set use_candidate" : "skip"); + } + if (pending_check) + pending_check->use_candidate = TRUE; + } return TRUE; } return FALSE; @@ -4514,6 +4572,7 @@ NiceCandidate *remote_candidate2 = NULL; NiceCandidate *local_candidate = NULL; gboolean discovery_msg = FALSE; + IncomingCheck *pending_check = NULL; nice_address_copy_to_sockaddr (from, &sockaddr.addr); @@ -4863,7 +4922,7 @@ * we get information about the remote candidates */ /* step: send a reply immediately but postpone other processing */ - priv_store_pending_check (agent, component, from, nicesock, + pending_check = priv_store_pending_check (agent, component, from, nicesock, username, username_len, priority, use_candidate); priv_print_conn_check_lists (agent, G_STRFUNC, ", icheck stored"); } @@ -4885,7 +4944,7 @@ /* step: let's try to match the response to an existing discovery */ if (trans_found != TRUE) - trans_found = priv_map_reply_to_discovery_request (agent, &req); + trans_found = priv_map_reply_to_discovery_request (agent, &req, from); /* step: let's try to match the response to an existing turn allocate */ if (trans_found != TRUE) @@ -4909,7 +4968,7 @@ } /* RENOMINATION attribute support */ - conn_check_handle_renomination(agent, stream, component, &req, remote_candidate, local_candidate); + conn_check_handle_renomination(agent, stream, component, &req, remote_candidate, local_candidate, pending_check); return TRUE; }
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/discovery.c -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/discovery.c
Changed
@@ -848,7 +848,7 @@ * * @return pointer to the created candidate, or NULL on error */ -NiceCandidate* +void discovery_add_server_reflexive_candidate ( NiceAgent *agent, guint stream_id, @@ -856,6 +856,7 @@ NiceAddress *address, NiceCandidateTransport transport, NiceSocket *base_socket, + const NiceAddress *server_address, gboolean nat_assisted) { NiceCandidate *candidate; @@ -865,7 +866,7 @@ gboolean result = FALSE; if (!agent_find_component (agent, stream_id, component_id, &stream, &component)) - return NULL; + return; candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE); c = (NiceCandidateImpl *) candidate; @@ -891,6 +892,9 @@ agent->reliable, nat_assisted); } + if (server_address != NULL) + c->stun_server = nice_address_dup (server_address); + priv_generate_candidate_credentials (agent, candidate); priv_assign_foundation (agent, candidate); @@ -902,8 +906,6 @@ /* error: duplicate candidate */ nice_candidate_free (candidate), candidate = NULL; } - - return candidate; } /* @@ -919,7 +921,8 @@ guint stream_id, guint component_id, NiceAddress *address, - NiceSocket *base_socket) + NiceSocket *base_socket, + const NiceAddress *server_addr) { NiceComponent *component; NiceStream *stream; @@ -948,6 +951,7 @@ address, c->transport, ((NiceCandidateImpl *) c)->sockptr, + server_addr, FALSE); } }
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/discovery.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/discovery.h
Changed
@@ -131,7 +131,7 @@ TurnServer *turn, uint32_t *lifetime); -NiceCandidate* +void discovery_add_server_reflexive_candidate ( NiceAgent *agent, guint stream_id, @@ -139,6 +139,7 @@ NiceAddress *address, NiceCandidateTransport transport, NiceSocket *base_socket, + const NiceAddress *server_address, gboolean nat_assisted); void @@ -147,7 +148,8 @@ guint stream_id, guint component_id, NiceAddress *address, - NiceSocket *base_socket); + NiceSocket *base_socket, + const NiceAddress *server_address); NiceCandidate* discovery_add_peer_reflexive_candidate (
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/interfaces.c -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/interfaces.c
Changed
@@ -370,6 +370,71 @@ return ips; } +static guint +get_local_if_index_by_addr_ioctl (NiceAddress *addr) +{ +#ifdef HAVE_IFR_IFINDEX + gint sockfd; + gint size = 0; + struct ifreq *ifr; + struct ifconf ifc; + guint if_index = 0; + + if ((sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) { + nice_debug ("error : Cannot open socket to retrieve interface list"); + return 0; + } + + ifc.ifc_len = 0; + ifc.ifc_req = NULL; + + /* Loop and get each interface the system has, one by one... */ + do { + size += sizeof (struct ifreq); + /* realloc buffer size until no overflow occurs */ + if (NULL == (ifc.ifc_req = realloc (ifc.ifc_req, size))) { + nice_debug ("Error : Out of memory while allocation interface" + "configuration structure"); + close (sockfd); + return 0; + } + ifc.ifc_len = size; + + if (ioctl (sockfd, SIOCGIFCONF, &ifc)) { + perror ("ioctl SIOCFIFCONF"); + close (sockfd); + free (ifc.ifc_req); + return 0; + } + } while (size <= ifc.ifc_len); + + + /* Loop throught the interface list and get the IP address of each IF */ + for (ifr = ifc.ifc_req; + (gchar *) ifr < (gchar *) ifc.ifc_req + ifc.ifc_len; + ++ifr) { + NiceAddress *myaddr = (NiceAddress *) &ifr->ifr_addr; + + if (!nice_address_equal_no_port (myaddr, addr)) + continue; + if (ifr->ifr_ifindex == 0) + continue; + + if_index = ifr->ifr_ifindex; + break; + } + + free (ifc.ifc_req); + close (sockfd); + + return if_index; +#else + g_critical ("getifaddrs() should not fail on a platform that doesn't" + " include ifr_index in the struct ifreq. Please report the bug."); + return 0; +#endif +} + #ifdef HAVE_GETIFADDRS GList * @@ -498,6 +563,47 @@ return ips; } +guint +nice_interfaces_get_if_index_by_addr (NiceAddress *addr) +{ + struct ifaddrs *ifa, *results; + guint if_index = 0; + + if (getifaddrs (&results) < 0) { + nice_debug ("Failed to retrieve list of network interfaces with \"getifaddrs\": %s." + "Trying to use fallback ...", strerror (errno)); + return get_local_if_index_by_addr_ioctl (addr); + } + + /* Loop through the interface list and get the IP address of each IF */ + for (ifa = results; ifa; ifa = ifa->ifa_next) { + NiceAddress *ifa_addr = (NiceAddress *) ifa->ifa_addr; + + /* no ip address from interface that is down */ + if ((ifa->ifa_flags & IFF_UP) == 0) + continue; + + /* no ip address from interface that isn't running */ + if ((ifa->ifa_flags & IFF_RUNNING) == 0) + continue; + + if (ifa->ifa_addr == NULL || ifa->ifa_name == NULL) + continue; + + if (!nice_address_equal_no_port (ifa_addr, addr)) + continue; + + if_index = if_nametoindex (ifa->ifa_name); + + if (if_index != 0) + break; + } + + freeifaddrs (results); + + return if_index; +} + #else /* ! HAVE_GETIFADDRS */ GList * @@ -506,6 +612,13 @@ return get_local_ips_ioctl (include_loopback); } + +guint +nice_interfaces_get_if_index_by_addr (NiceAddress *addr) +{ + return get_local_if_index_by_addr_ioctl (addr); +} + #endif /* HAVE_GETIFADDRS */ gchar * @@ -788,6 +901,49 @@ } +guint +nice_interfaces_get_if_index_by_addr (NiceAddress *addr) +{ + IP_ADAPTER_ADDRESSES *addresses, *a; + IP_ADAPTER_UNICAST_ADDRESS *unicast; + guint if_index = 0; + + addresses = _nice_get_adapters_addresses (); + if (!addresses) + return NULL; + + for (a = addresses; a != NULL; a = a->Next) { + /* Various conditions for ignoring the interface. */ + if (a->OperStatus == IfOperStatusDown || + a->OperStatus == IfOperStatusNotPresent || + a->OperStatus == IfOperStatusLowerLayerDown) { + continue; + } + + /* Grab the interface’s ipv4 unicast addresses. */ + for (unicast = a->FirstUnicastAddress; + unicast != NULL; unicast = unicast->Next) { + NiceAddress *uni_addr = (NiceAddress *) unicast->Address.lpSockaddr; + + if (nice_address_equal_no_port (uni_addr, addr)) { + if (unicast->Address.lpSockaddr->sa_family == AF_INET) + if_index = a->IfIndex; + else if (unicast->Address.lpSockaddr->sa_family == AF_INET6) + if_index = a->Ipv6IfIndex; + goto out; + } + } + } + +out: + g_free (addresses); + + return if_index; +} + + + + #else /* G_OS_WIN32 */ #error Can not use this method for retreiving ip list from OS other than unix or windows #endif /* G_OS_WIN32 */
View file
_service:tar_scm:libnice-0.1.19.tar.gz/agent/interfaces.h -> _service:tar_scm:libnice-0.1.21.tar.gz/agent/interfaces.h
Changed
@@ -37,6 +37,7 @@ */ #include <glib.h> +#include <address.h> G_BEGIN_DECLS @@ -77,6 +78,21 @@ */ GList * nice_interfaces_get_local_interfaces (void); + +/** + * nice_interfaces_get_if_index_by_addr: + * @addr: A #NiceAddress for a local interface + * + * Returns the interface index match the local address passed. This can + * by used for APIs that need a specific address. + * + * Returns: The interface index or 0 on error + * + * Since: 0.1.20 + */ + +guint nice_interfaces_get_if_index_by_addr (NiceAddress *addr); + G_END_DECLS #endif /* __LIBNICE_INTERFACES_H__ */
View file
_service:tar_scm:libnice-0.1.19.tar.gz/docs/reference/libnice/libnice-docs.xml -> _service:tar_scm:libnice-0.1.21.tar.gz/docs/reference/libnice/libnice-docs.xml
Changed
@@ -121,6 +121,10 @@ <title>Index of new symbols in 0.1.19</title> <xi:include href="xml/api-index-0.1.19.xml"><xi:fallback/></xi:include> </index> + <index role="0.1.20"> + <title>Index of new symbols in 0.1.20</title> + <xi:include href="xml/api-index-0.1.20.xml"><xi:fallback/></xi:include> + </index> <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> </part> </book>
View file
_service:tar_scm:libnice-0.1.19.tar.gz/docs/reference/libnice/libnice-sections.txt -> _service:tar_scm:libnice-0.1.21.tar.gz/docs/reference/libnice/libnice-sections.txt
Changed
@@ -59,6 +59,7 @@ nice_agent_close_async nice_agent_consent_lost nice_component_state_to_string +NICE_CHECK_VERSION <SUBSECTION Standard> NICE_AGENT NICE_IS_AGENT @@ -100,6 +101,7 @@ nice_candidate_transport_to_string nice_candidate_type_to_string nice_candidate_relay_address +nice_candidate_stun_server_address <SUBSECTION Standard> NICE_TYPE_CANDIDATE nice_candidate_get_type @@ -143,10 +145,14 @@ nice_address_equal nice_address_equal_no_port nice_address_to_string +nice_address_dup_string nice_address_is_private nice_address_is_linklocal nice_address_is_valid nice_address_ip_version +<SUBSECTION Standard> +NICE_TYPE_ADDRESS +nice_address_get_type </SECTION> @@ -163,6 +169,7 @@ nice_interfaces_get_ip_for_interface nice_interfaces_get_local_interfaces nice_interfaces_get_local_ips +nice_interfaces_get_if_index_by_addr </SECTION> <SECTION>
View file
_service:tar_scm:libnice-0.1.19.tar.gz/docs/reference/libnice/meson.build -> _service:tar_scm:libnice-0.1.21.tar.gz/docs/reference/libnice/meson.build
Changed
@@ -41,7 +41,7 @@ main_xml: 'libnice-docs.xml', namespace: 'nice', mode: 'none', - src_dir: agent_include, stun_include, + src_dir: agent_include, stun_include, nice_include, content_files: fake_makefile, dependencies: libnice_dep, scan_args:
View file
_service:tar_scm:libnice-0.1.19.tar.gz/gst/gstnice.c -> _service:tar_scm:libnice-0.1.21.tar.gz/gst/gstnice.c
Changed
@@ -44,28 +44,19 @@ static gboolean plugin_init (GstPlugin *plugin) { - if (!gst_element_register (plugin, "nicesrc", - GST_RANK_NONE, GST_TYPE_NICE_SRC)) + if (!gst_element_register_nicesrc (plugin)) return FALSE; - if (!gst_element_register (plugin, "nicesink", - GST_RANK_NONE, GST_TYPE_NICE_SINK)) + if (!gst_element_register_nicesink (plugin)) return FALSE; return TRUE; } -#if GST_CHECK_VERSION (1,0,0) -#define PLUGIN_NAME nice -#else -#define PLUGIN_NAME "nice" -#endif - GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, - PLUGIN_NAME, + nice, "Interactive UDP connectivity establishment", plugin_init, VERSION, "LGPL", PACKAGE_NAME, "https://nice.freedesktop.org/"); -
View file
_service:tar_scm:libnice-0.1.19.tar.gz/gst/gstnicesink.c -> _service:tar_scm:libnice-0.1.21.tar.gz/gst/gstnicesink.c
Changed
@@ -49,12 +49,10 @@ gst_nice_sink_render ( GstBaseSink *basesink, GstBuffer *buffer); -#if GST_CHECK_VERSION (1,0,0) static GstFlowReturn gst_nice_sink_render_list ( GstBaseSink *basesink, GstBufferList *buffer_list); -#endif static gboolean gst_nice_sink_unlock (GstBaseSink *basesink); @@ -85,10 +83,8 @@ static void gst_nice_sink_dispose (GObject *object); -#if GST_CHECK_VERSION (1,0,0) static void gst_nice_sink_finalize (GObject *object); -#endif static GstStateChangeReturn gst_nice_sink_change_state ( @@ -123,9 +119,7 @@ gstbasesink_class = (GstBaseSinkClass *) klass; gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_nice_sink_render); -#if GST_CHECK_VERSION (1,0,0) gstbasesink_class->render_list = GST_DEBUG_FUNCPTR (gst_nice_sink_render_list); -#endif gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_nice_sink_unlock); gstbasesink_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_nice_sink_unlock_stop); @@ -133,20 +127,14 @@ gobject_class->set_property = gst_nice_sink_set_property; gobject_class->get_property = gst_nice_sink_get_property; gobject_class->dispose = gst_nice_sink_dispose; -#if GST_CHECK_VERSION (1,0,0) gobject_class->finalize = gst_nice_sink_finalize; -#endif gstelement_class = (GstElementClass *) klass; gstelement_class->change_state = gst_nice_sink_change_state; gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&gst_nice_sink_sink_template)); -#if GST_CHECK_VERSION (1,0,0) gst_element_class_set_metadata (gstelement_class, -#else - gst_element_class_set_details_simple (gstelement_class, -#endif "ICE sink", "Sink", "Interactive UDP connectivity establishment", @@ -185,13 +173,10 @@ static void gst_nice_sink_init (GstNiceSink *sink) { -#if GST_CHECK_VERSION (1,0,0) guint max_mem; -#endif g_cond_init (&sink->writable_cond); -#if GST_CHECK_VERSION (1,0,0) /* pre-allocate OutputVector, MapInfo and OutputMessage arrays * for use in the render and render_list functions */ max_mem = gst_buffer_get_max_memory (); @@ -204,7 +189,6 @@ sink->n_messages = 1; sink->messages = g_new (NiceOutputMessage, sink->n_messages); -#endif #if GST_CHECK_VERSION (1,12,0) gst_base_sink_set_drop_out_of_segment (GST_BASE_SINK (sink), FALSE); @@ -222,7 +206,6 @@ GST_OBJECT_UNLOCK (sink); } -#if GST_CHECK_VERSION (1,0,0) static gsize fill_vectors (GOutputVector * vecs, GstMapInfo * maps, guint n, GstBuffer * buf) { @@ -319,14 +302,12 @@ return flow_ret; } -#endif static GstFlowReturn gst_nice_sink_render (GstBaseSink *basesink, GstBuffer *buffer) { GstNiceSink *nicesink = GST_NICE_SINK (basesink); GstFlowReturn flow_ret = GST_FLOW_OK; -#if GST_CHECK_VERSION (1,0,0) guint8 n_mem; n_mem = gst_buffer_n_memory (buffer); @@ -336,36 +317,9 @@ n_mem); } -#else - guint written = 0; - gint ret; - gchar *data = NULL; - guint size = 0; - - data = (gchar *) GST_BUFFER_DATA (buffer); - size = GST_BUFFER_SIZE (buffer); - - GST_OBJECT_LOCK (nicesink); - do { - ret = nice_agent_send (nicesink->agent, nicesink->stream_id, - nicesink->component_id, size - written, data + written); - if (ret > 0) - written += ret; - - if (nicesink->reliable && written < size) - g_cond_wait (&nicesink->writable_cond, GST_OBJECT_GET_LOCK (nicesink)); - if (nicesink->flushing) { - flow_ret = GST_FLOW_WRONG_STATE; - break; - } - } while (nicesink->reliable && written < size); - GST_OBJECT_UNLOCK (nicesink); - -#endif return flow_ret; } -#if GST_CHECK_VERSION (1,0,0) static GstFlowReturn gst_nice_sink_render_list (GstBaseSink *basesink, GstBufferList *buffer_list) { @@ -401,7 +355,6 @@ return flow_ret; } -#endif static gboolean gst_nice_sink_unlock (GstBaseSink *basesink) { @@ -441,7 +394,6 @@ G_OBJECT_CLASS (gst_nice_sink_parent_class)->dispose (object); } -#if GST_CHECK_VERSION (1,0,0) static void gst_nice_sink_finalize (GObject *object) { @@ -459,7 +411,6 @@ G_OBJECT_CLASS (gst_nice_sink_parent_class)->finalize (object); } -#endif static void gst_nice_sink_set_property ( @@ -586,3 +537,10 @@ return ret; } + +gboolean +gst_element_register_nicesink (GstPlugin * plugin) +{ + return gst_element_register (plugin, "nicesink", GST_RANK_NONE, + GST_TYPE_NICE_SINK); +}
View file
_service:tar_scm:libnice-0.1.19.tar.gz/gst/gstnicesink.h -> _service:tar_scm:libnice-0.1.21.tar.gz/gst/gstnicesink.h
Changed
@@ -70,7 +70,6 @@ gulong writable_id; gboolean flushing; -#if GST_CHECK_VERSION (1,0,0) /* pre-allocated scrap space for render function */ GOutputVector *vecs; guint n_vecs; @@ -78,7 +77,6 @@ guint n_maps; NiceOutputMessage *messages; guint n_messages; -#endif }; typedef struct _GstNiceSinkClass GstNiceSinkClass; @@ -90,6 +88,8 @@ GType gst_nice_sink_get_type (void); +gboolean gst_element_register_nicesink (GstPlugin * plugin); + G_END_DECLS #endif
View file
_service:tar_scm:libnice-0.1.19.tar.gz/gst/gstnicesrc.c -> _service:tar_scm:libnice-0.1.21.tar.gz/gst/gstnicesrc.c
Changed
@@ -129,11 +129,7 @@ gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&gst_nice_src_src_template)); -#if GST_CHECK_VERSION (1,0,0) gst_element_class_set_metadata (gstelement_class, -#else - gst_element_class_set_details_simple (gstelement_class, -#endif "ICE source", "Source", "Interactive UDP connectivity establishment", @@ -198,13 +194,8 @@ GST_LOG_OBJECT (agent, "Got buffer, getting out of the main loop"); -#if GST_CHECK_VERSION (1,0,0) buffer = gst_buffer_new_allocate (NULL, len, NULL); gst_buffer_fill (buffer, 0, buf, len); -#else - buffer = gst_buffer_new_and_alloc (len); - memcpy (GST_BUFFER_DATA (buffer), buf, len); -#endif GST_OBJECT_LOCK (nicesrc); g_queue_push_tail (nicesrc->outbufs, buffer); g_main_loop_quit (nicesrc->mainloop); @@ -280,11 +271,7 @@ GST_OBJECT_LOCK (basesrc); if (nicesrc->unlocked) { GST_OBJECT_UNLOCK (basesrc); -#if GST_CHECK_VERSION (1,0,0) return GST_FLOW_FLUSHING; -#else - return GST_FLOW_WRONG_STATE; -#endif } if (g_queue_is_empty (nicesrc->outbufs)) { GST_OBJECT_UNLOCK (basesrc); @@ -300,11 +287,7 @@ return GST_FLOW_OK; } else { GST_LOG_OBJECT (nicesrc, "Got interrupting, returning wrong-state"); -#if GST_CHECK_VERSION (1,0,0) return GST_FLOW_FLUSHING; -#else - return GST_FLOW_WRONG_STATE; -#endif } } @@ -467,4 +450,9 @@ return ret; } - +gboolean +gst_element_register_nicesrc (GstPlugin * plugin) +{ + return gst_element_register (plugin, "nicesrc", GST_RANK_NONE, + GST_TYPE_NICE_SRC); +}
View file
_service:tar_scm:libnice-0.1.19.tar.gz/gst/gstnicesrc.h -> _service:tar_scm:libnice-0.1.21.tar.gz/gst/gstnicesrc.h
Changed
@@ -81,6 +81,8 @@ GType gst_nice_src_get_type (void); +gboolean gst_element_register_nicesrc (GstPlugin * plugin); + G_END_DECLS #endif // _GSTNICESRC_H
View file
_service:tar_scm:libnice-0.1.19.tar.gz/meson.build -> _service:tar_scm:libnice-0.1.21.tar.gz/meson.build
Changed
@@ -1,5 +1,5 @@ project('libnice', 'c', - version: '0.1.19', + version: '0.1.21', meson_version : '>= 0.52', default_options : 'warning_level=1', 'buildtype=debugoptimized') @@ -11,7 +11,7 @@ if version_arr.length() == 4 version_nano = version_arr3 else - version_nano = 0 + version_nano = '0' endif # maintain compatibility with the previous libtool versioning @@ -20,7 +20,7 @@ # B is the ABI age, change it on new APIs that don't break existing ones, changing it resets C to 0 # C is the revision, change on new updates that don't change APIs soversion = 10 -libversion = '10.12.0' +libversion = '10.13.1' glib_req = '>= 2.54' gnutls_req = '>= 2.12.0' @@ -78,8 +78,21 @@ '-DHAVE_CONFIG_H', '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_' + glib_req_minmax_str, '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_' + glib_req_minmax_str, + '-DNICE_VERSION_MAJOR=' + version_major, + '-DNICE_VERSION_MINOR=' + version_minor, + '-DNICE_VERSION_MICRO=' + version_micro, + '-DNICE_VERSION_NANO=' + version_nano, language: 'c') +version_conf = configuration_data() +version_conf.set('NICE_VERSION_MAJOR', version_major) +version_conf.set('NICE_VERSION_MINOR', version_minor) +version_conf.set('NICE_VERSION_MICRO', version_micro) +version_conf.set('NICE_VERSION_NANO', version_nano) +nice_version_h = configure_file(output: 'nice-version.h', + install_dir: get_option('includedir') / 'nice', + configuration: version_conf) + cdata = configuration_data() cdata.set_quoted('PACKAGE_STRING', meson.project_name()) @@ -106,6 +119,10 @@ endif endforeach +if cc.has_member('struct ifreq', 'ifr_ifindex', prefix: '#include <net/if.h>') + cdata.set('HAVE_IFR_IFINDEX', 1) +endif + if cc.has_argument('-fno-strict-aliasing') add_project_arguments('-fno-strict-aliasing', language: 'c') endif
View file
_service:tar_scm:libnice-0.1.19.tar.gz/nice/libnice.sym -> _service:tar_scm:libnice-0.1.21.tar.gz/nice/libnice.sym
Changed
@@ -2,8 +2,10 @@ nice_address_dup nice_address_equal nice_address_equal_no_port +nice_address_dup_string nice_address_free nice_address_get_port +nice_address_get_type nice_address_init nice_address_ip_version nice_address_is_private @@ -73,12 +75,14 @@ nice_candidate_type_get_type nice_candidate_type_to_string nice_candidate_relay_address +nice_candidate_stun_server_address nice_compatibility_get_type nice_component_state_get_type nice_component_state_to_string nice_component_type_get_type nice_debug_disable nice_debug_enable +nice_interfaces_get_if_index_by_addr nice_interfaces_get_ip_for_interface nice_interfaces_get_local_interfaces nice_interfaces_get_local_ips
View file
_service:tar_scm:libnice-0.1.19.tar.gz/nice/meson.build -> _service:tar_scm:libnice-0.1.21.tar.gz/nice/meson.build
Changed
@@ -1,4 +1,4 @@ -nice_gen_sources = +nice_gen_sources = nice_version_h nice_link_args = # libnice.def
View file
_service:tar_scm:libnice-0.1.19.tar.gz/nice/nice.h -> _service:tar_scm:libnice-0.1.21.tar.gz/nice/nice.h
Changed
@@ -39,6 +39,26 @@ #ifndef _NICE_H #define _NICE_H +#include "nice-version.h" + +/** + * NICE_CHECK_VERSION: + * @major: The major numbe of the version + * @minor: The major numbe of the version + * @micro: The major numbe of the version + * + * Macro that returns TRUE if the version if libnice that you are compiling + * against is greater or equal to the argument + * + * Since: 0.1.20 + */ + +#define NICE_CHECK_VERSION(major, minor, micro) \ + (NICE_VERSION_MAJOR > (major) || \ + (NICE_VERSION_MAJOR == (major) && NICE_VERSION_MINOR > (minor)) || \ + (NICE_VERSION_MAJOR == (major) && NICE_VERSION_MINOR == (minor) && \ + NICE_VERSION_MICRO >= (micro))) + #include "agent.h" #include "interfaces.h"
View file
_service:tar_scm:libnice-0.1.19.tar.gz/socket/http.c -> _service:tar_scm:libnice-0.1.21.tar.gz/socket/http.c
Changed
@@ -97,9 +97,17 @@ NiceSocketWritableCb callback, gpointer user_data); static gboolean socket_is_based_on (NiceSocket *sock, NiceSocket *other); +static void +_append_extra_header (gpointer key, gpointer value, gpointer user_data) +{ + GString *str = user_data; + g_string_append_printf (str, "%s: %s\r\n", (gchar *)key, (gchar *)value); +} + NiceSocket * nice_http_socket_new (NiceSocket *base_socket, - NiceAddress *addr, gchar *username, gchar *password) + NiceAddress *addr, gchar *username, gchar *password, + GHashTable *extra_headers) { HttpPriv *priv; NiceSocket *sock = NULL; @@ -133,7 +141,7 @@ /* Send HTTP CONNECT */ { gchar *msg = NULL; - gchar *credential = NULL; + GString *str = NULL; gchar hostINET6_ADDRSTRLEN; gint port = nice_address_get_port (&priv->addr); GOutputVector local_bufs; @@ -141,25 +149,31 @@ nice_address_to_string (&priv->addr, host); + str = g_string_new (NULL); + g_string_printf (str, "CONNECT %s:%d HTTP/1.0\r\n" + "Host: %s\r\n" + "User-Agent: %s\r\n" + "Content-Length: 0\r\n" + "Proxy-Connection: Keep-Alive\r\n" + "Connection: Keep-Alive\r\n" + "Cache-Control: no-cache\r\n" + "Pragma: no-cache\r\n", + host, port, host, HTTP_USER_AGENT); + + if (extra_headers) { + g_hash_table_foreach (extra_headers, _append_extra_header, str); + } + if (username) { gchar * userpass = g_strdup_printf ("%s:%s", username, password ? password : ""); gchar * auth = g_base64_encode ((guchar *)userpass, strlen (userpass)); - credential = g_strdup_printf ("Proxy-Authorization: Basic %s\r\n", auth); + g_string_append_printf (str, "Proxy-Authorization: Basic %s\r\n", auth); g_free (auth); g_free (userpass); } - msg = g_strdup_printf ("CONNECT %s:%d HTTP/1.0\r\n" - "Host: %s\r\n" - "User-Agent: %s\r\n" - "Content-Length: 0\r\n" - "Proxy-Connection: Keep-Alive\r\n" - "Connection: Keep-Alive\r\n" - "Cache-Control: no-cache\r\n" - "Pragma: no-cache\r\n" - "%s\r\n", host, port, host, HTTP_USER_AGENT, - credential? credential : "" ); - g_free (credential); + g_string_append_printf (str, "\r\n"); + msg = g_string_free (str, FALSE); local_bufs.buffer = msg; local_bufs.size = strlen (msg);
View file
_service:tar_scm:libnice-0.1.19.tar.gz/socket/http.h -> _service:tar_scm:libnice-0.1.21.tar.gz/socket/http.h
Changed
@@ -45,7 +45,8 @@ NiceSocket * nice_http_socket_new (NiceSocket *base_socket, - NiceAddress *addr, gchar *username, gchar *password); + NiceAddress *addr, gchar *username, gchar *password, + GHashTable *extra_headers); G_END_DECLS
View file
_service:tar_scm:libnice-0.1.19.tar.gz/socket/udp-bsd.c -> _service:tar_scm:libnice-0.1.21.tar.gz/socket/udp-bsd.c
Changed
@@ -51,6 +51,7 @@ #include "udp-bsd.h" #include "agent-priv.h" +#include "interfaces.h" #ifndef G_OS_WIN32 #include <unistd.h> @@ -119,6 +120,33 @@ return NULL; } +#if defined(IP_UNICAST_IF) && defined(IPV6_UNICAST_IF) + if (addr) { + guint if_index = nice_interfaces_get_if_index_by_addr (addr); + + if (if_index) { + guint level, optname; + GError *gerr = NULL; + + if (nice_address_ip_version (addr) == 6) { + level = IPPROTO_IPV6; + optname = IPV6_UNICAST_IF; + } else { + level = IPPROTO_IP; + optname = IP_UNICAST_IF; + } + + if_index = htonl (if_index); + if (!g_socket_set_option (gsock, level, optname, if_index, &gerr)) { + nice_debug ("Could not bind socket to specific interface: %s", + gerr->message); + g_clear_error (&gerr); + } + } + } +#endif + + /* GSocket: All socket file descriptors are set to be close-on-exec. */ g_socket_set_blocking (gsock, false); gaddr = g_socket_address_new_from_native (&name.addr, sizeof (name));
View file
_service:tar_scm:libnice-0.1.19.tar.gz/tests/docker/centos7-meson/Dockerfile -> _service:tar_scm:libnice-0.1.21.tar.gz/tests/docker/centos7-meson/Dockerfile
Changed
@@ -15,13 +15,7 @@ FROM centos:centos7 RUN yum -y update; yum clean all -RUN yum -y install git gtk-doc gnutls-devel gupnp-igd-devel gstreamer1-devel gobject-introspection-devel valgrind; yum clean all -RUN yum -y install net-tools; yum clean all +RUN yum -y install git gtk-doc gnutls-devel gupnp-igd-devel gstreamer1-devel gobject-introspection-devel valgrind net-tools centos-release-scl graphviz - -RUN yum -y install centos-release-scl ; yum clean all -RUN yum -y install rh-python36; yum clean all -RUN scl enable rh-python36 "pip3 install meson" - -RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm; yum clean all -RUN yum -y install ninja-build; yum clean all +ADD pip-installs.sh / +RUN bash -ex /pip-installs.sh && rm /pip-installs.sh
View file
_service:tar_scm:libnice-0.1.21.tar.gz/tests/docker/centos7-meson/pip-installs.sh
Added
@@ -0,0 +1,12 @@ +#/bin/sh + +set -ex + +yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +yum -y install rh-python36 lcov + +scl enable rh-python36 "pip3 install meson==0.60.3" +scl enable rh-python36 "pip3 install lcov-cobertura" +scl enable rh-python36 "pip3 install ninja" + +yum clean all
View file
_service:tar_scm:libnice-0.1.19.tar.gz/tests/test-consent.c -> _service:tar_scm:libnice-0.1.21.tar.gz/tests/test-consent.c
Changed
@@ -234,10 +234,8 @@ global_ragent_cands = 0; global_ragent_read_exit = 32; - g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, - "consent-freshness", TRUE, NULL); - g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, - "consent-freshness", TRUE, NULL); + g_object_set (G_OBJECT (lagent), "controlling-mode", TRUE, NULL); + g_object_set (G_OBJECT (ragent), "controlling-mode", FALSE, NULL); /* step: add one stream, with RTP+RTCP components, to each agent */ ls_id = nice_agent_add_stream (lagent, 2);
View file
_service:tar_scm:libnice-0.1.19.tar.gz/tests/test-turn.c -> _service:tar_scm:libnice-0.1.21.tar.gz/tests/test-turn.c
Changed
@@ -340,10 +340,6 @@ NICE_RELAY_TYPE_TURN_TCP); } - - - - int main (int argc, char **argv) { @@ -362,11 +358,11 @@ if (g_spawn_command_line_sync ("turnserver --help", &out_str, &err_str, NULL, NULL) && err_str) { if (!strstr(err_str, "--user")) { - g_print ("rfc5766-turn-server not installed, skipping turn test\n"); + g_print ("coturn not installed, skipping turn test\n"); return 0; } } else { - g_print ("rfc5766-turn-server not installed, skipping turn test\n"); + g_print ("coturn not installed, skipping turn test\n"); return 0; } g_free (err_str); @@ -377,6 +373,9 @@ "--user", "toto:0xaae440b3348d50265b63703117c7bfd5", "--realm", "realm", "--listening-port", portstr, + "--listening-ip", "127.0.0.1", + "--allow-loopback-peers", + "--no-cli", NULL); g_test_add_func ("/nice/turn/udp", udp_no_force_no_remove_udp);
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2