Skip to content

Commit 7e6dbaa

Browse files
author
Isaac Raño Jares
committed
Allow to create GSocketInetAddress from a constructor.
Now it can be created just as any other GObject in the library
1 parent 3d03d12 commit 7e6dbaa

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/org/freedesktop/gstreamer/GInetSocketAddress.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ public class GInetSocketAddress extends GSocketAddress{
1111
public static final String GTYPE_NAME = "GInetSocketAddress";
1212

1313

14-
protected static GInetSocketAddress create(String address, int port) {
14+
protected static Initializer createRawAddress(String address, int port) {
1515
Pointer nativePointer = GioAPI.g_inet_socket_address_new_from_string(address, port);
1616
if (nativePointer == null) {
1717
throw new GstException("Can not create "+GInetSocketAddress.class.getSimpleName()+" for "+address+":"+port+", please check that the IP address is valid, with format x.x.x.x");
1818
}
19-
return new GInetSocketAddress(initializer(nativePointer));
19+
return initializer(nativePointer);
20+
}
21+
22+
public GInetSocketAddress(String address, int port) {
23+
this(createRawAddress(address, port));
2024
}
2125

2226
public GInetSocketAddress(Initializer init) {

src/org/freedesktop/gstreamer/GSocket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public GSocket(Initializer init) {
3333
}
3434

3535
public GSocket bind(String address, int port) {
36-
GInetSocketAddress boundAddress = GInetSocketAddress.create(address, port);
36+
GInetSocketAddress boundAddress = new GInetSocketAddress(address, port);
3737
GErrorStruct reference = new GErrorStruct();
3838
GErrorStruct[] errorArray = (GErrorStruct[]) reference.toArray(1);
3939
if ( ! GioAPI.g_socket_bind(getNativeAddress(), boundAddress.getNativeAddress(), true, reference.getPointer()) ) {
@@ -44,7 +44,7 @@ public GSocket bind(String address, int port) {
4444
}
4545

4646
public void connect(String address, int port) {
47-
GInetSocketAddress connectedAddress = GInetSocketAddress.create(address, port);
47+
GInetSocketAddress connectedAddress = new GInetSocketAddress(address, port);
4848
GErrorStruct reference = new GErrorStruct();
4949
GErrorStruct[] errorArray = (GErrorStruct[]) reference.toArray(1);
5050
if ( ! GioAPI.g_socket_connect(getNativeAddress(), connectedAddress.getNativeAddress(), new GCancellable().getNativeAddress(), reference.getPointer()) ) {

0 commit comments

Comments
 (0)