Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gv: option to select discovery network interface #979

Closed

Conversation

yuhamag
Copy link
Contributor

@yuhamag yuhamag commented Feb 5, 2025

fix #505

This pull request adds an option to specify the network interface for discovering gv cameras.

The current implementation sends camera discovery packets to all network interfaces installed on the machine.
In this PR, by adding an option “gv-discovery-interface”, it is possible to send camera discovery packets only to a specific interface.

We have several methods of implementing setter/getter and network interface matching, as follows.

Method1: arvnetwork.c
We need to implement the network interface matching for each OS.

Method2: arvgvinterface.c
We can implement the minimum in the inherited class, but we cannot use setter/getter in other inherited classes.

Method3: arvinterface.c + arvgvinterface.c
We can implement a setter/getter in the parent class and call the getter from the inherited classes.

We have implemented this PR using method3. What do you think?

@EmmanuelP

@EmmanuelP
Copy link
Contributor

Hi,

Thanks for your work.

I don't think it is interesting to implement a generic ArvInterface API. What would this option mean to the other interfaces ?

It would be better to rename set/get_discovery_option to set/get_discovery_interface_name to better reflect what they do.

Emmanuel.

@yuhamag
Copy link
Contributor Author

yuhamag commented Feb 6, 2025

Hi,

Thank you for your comment. I renamed the function name.

Currently, I don't have a specific meaning for other interfaces.
It would be better to move the setter/getter from ArvInterface to ArvGvInterface, right?

@EmmanuelP

@EmmanuelP
Copy link
Contributor

It would be better to move the setter/getter from ArvInterface to ArvGvInterface, right?

Right.

@yuhamag yuhamag changed the title [WIP] Add gv: option to select discovery network interface Add gv: option to select discovery network interface Feb 7, 2025
@yuhamag yuhamag marked this pull request as ready for review February 7, 2025 01:24
@@ -353,8 +360,20 @@ struct _ArvGvInterfaceClass {

G_DEFINE_TYPE_WITH_CODE (ArvGvInterface, arv_gv_interface, ARV_TYPE_INTERFACE, G_ADD_PRIVATE (ArvGvInterface))

void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make these two functions use arv_gv_interface_get_instance to find the interface instance. Use the mutex to protect private data access.

void
arv_gv_interface_set_discovery_interface_name (ArvInterface *interface, const char *discovery_interface)
{
ARV_GV_INTERFACE (interface)->priv->discovery_interface = strdup (discovery_interface);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If discovery_interface was already set, a memory leak occurs. Free the content before setting the new one. Use g_strdup instead of strdup.

src/arvsystem.c Outdated
@@ -260,6 +260,29 @@ arv_set_interface_flags(const char *interface_id, int flags)
g_warning ("[Arv::enable_interface] Unknown interface '%s'", interface_id);
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed.

src/arvtool.c Outdated
@@ -802,6 +808,9 @@ main (int argc, char **argv)
if (arv_option_gv_allow_broadcast_discovery_ack)
arv_set_interface_flags ("GigEVision", ARV_GV_INTERFACE_FLAGS_ALLOW_BROADCAST_DISCOVERY_ACK);

if (arv_option_gv_discovery_interface)
arv_set_interface_discovery_option ("GigEVision", arv_option_gv_discovery_interface);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use arv_gv_interface_set _discovery_interface_name() here.

@yuhamag
Copy link
Contributor Author

yuhamag commented Feb 10, 2025

Thanks. I created the new commit regarding the comments.

@EmmanuelP

@yuhamag yuhamag force-pushed the selecting_network_interface branch from a647265 to 784ce8c Compare February 12, 2025 05:02
@EmmanuelP
Copy link
Contributor

I have committed a slightly edited version of your work.

Thanks !

@EmmanuelP EmmanuelP closed this Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selecting network interface to be used by Aravis
2 participants