Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
73c5a0b3
Commit
73c5a0b3
authored
Nov 03, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit 'tester/src-netbuffer' into nice-kakaroto
parents
ddb6df15
cbe7189a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
14 deletions
+109
-14
configure.ac
configure.ac
+1
-0
gst/gstnicesrc.c
gst/gstnicesrc.c
+95
-9
gst/gstnicesrc.h
gst/gstnicesrc.h
+13
-5
No files found.
configure.ac
View file @
73c5a0b3
...
@@ -68,6 +68,7 @@ AS_IF([test "$with_gstreamer" != no], [
...
@@ -68,6 +68,7 @@ AS_IF([test "$with_gstreamer" != no], [
PKG_CHECK_MODULES(GST, [
PKG_CHECK_MODULES(GST, [
gstreamer-0.10 >= 0.10.0
gstreamer-0.10 >= 0.10.0
gstreamer-base-0.10 >= 0.10.0
gstreamer-base-0.10 >= 0.10.0
gstreamer-netbuffer-0.10 >= 0.10.0
],
],
[
[
with_gstreamer=yes
with_gstreamer=yes
...
...
gst/gstnicesrc.c
View file @
73c5a0b3
...
@@ -195,15 +195,21 @@ gst_nice_src_read_callback (NiceAgent *agent,
...
@@ -195,15 +195,21 @@ gst_nice_src_read_callback (NiceAgent *agent,
{
{
GstBaseSrc
*
basesrc
=
GST_BASE_SRC
(
data
);
GstBaseSrc
*
basesrc
=
GST_BASE_SRC
(
data
);
GstNiceSrc
*
nicesrc
=
GST_NICE_SRC
(
basesrc
);
GstNiceSrc
*
nicesrc
=
GST_NICE_SRC
(
basesrc
);
GstNetBuffer
*
mybuf
;
GST_LOG_OBJECT
(
agent
,
"Got buffer, getting out of the main loop"
);
GST_LOG_OBJECT
(
agent
,
"Got buffer, getting out of the main loop"
);
nicesrc
->
flow_ret
=
gst_pad_alloc_buffer
(
basesrc
->
srcpad
,
nicesrc
->
offset
,
mybuf
=
gst_netbuffer_new
();
len
,
GST_PAD_CAPS
(
basesrc
->
srcpad
),
&
nicesrc
->
outbuf
);
GST_BUFFER_MALLOCDATA
(
mybuf
)
=
g_memdup
(
buf
,
len
);
if
(
nicesrc
->
flow_ret
==
GST_FLOW_OK
)
{
GST_BUFFER_SIZE
(
mybuf
)
=
len
;
memcpy
(
nicesrc
->
outbuf
->
data
,
buf
,
len
);
GST_BUFFER_DATA
(
mybuf
)
=
GST_BUFFER_MALLOCDATA
(
mybuf
);
nicesrc
->
outbuf
->
size
=
len
;
if
(
GST_PAD_CAPS
(
basesrc
->
srcpad
))
}
GST_BUFFER_CAPS
(
mybuf
)
=
gst_caps_ref
(
GST_PAD_CAPS
(
basesrc
->
srcpad
));
mybuf
->
from
=
nicesrc
->
from
;
mybuf
->
to
=
nicesrc
->
to
;
nicesrc
->
outbuf
=
GST_BUFFER_CAST
(
mybuf
);
g_main_loop_quit
(
nicesrc
->
mainloop
);
g_main_loop_quit
(
nicesrc
->
mainloop
);
}
}
...
@@ -215,8 +221,10 @@ gst_nice_src_unlock_idler (gpointer data)
...
@@ -215,8 +221,10 @@ gst_nice_src_unlock_idler (gpointer data)
g_main_loop_quit
(
nicesrc
->
mainloop
);
g_main_loop_quit
(
nicesrc
->
mainloop
);
GST_OBJECT_LOCK
(
nicesrc
);
g_source_unref
(
nicesrc
->
idle_source
);
g_source_unref
(
nicesrc
->
idle_source
);
nicesrc
->
idle_source
=
NULL
;
nicesrc
->
idle_source
=
NULL
;
GST_OBJECT_UNLOCK
(
nicesrc
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -267,7 +275,6 @@ gst_nice_src_create (
...
@@ -267,7 +275,6 @@ gst_nice_src_create (
GST_LOG_OBJECT
(
nicesrc
,
"create called"
);
GST_LOG_OBJECT
(
nicesrc
,
"create called"
);
nicesrc
->
outbuf
=
NULL
;
nicesrc
->
outbuf
=
NULL
;
nicesrc
->
offset
=
offset
;
GST_OBJECT_LOCK
(
basesrc
);
GST_OBJECT_LOCK
(
basesrc
);
if
(
nicesrc
->
unlocked
)
{
if
(
nicesrc
->
unlocked
)
{
...
@@ -282,12 +289,13 @@ gst_nice_src_create (
...
@@ -282,12 +289,13 @@ gst_nice_src_create (
GST_LOG_OBJECT
(
nicesrc
,
"Got buffer, pushing"
);
GST_LOG_OBJECT
(
nicesrc
,
"Got buffer, pushing"
);
*
buffer
=
nicesrc
->
outbuf
;
*
buffer
=
nicesrc
->
outbuf
;
return
nicesrc
->
flow_ret
;
GST_BUFFER_OFFSET
(
*
buffer
)
=
offset
;
return
GST_FLOW_OK
;
}
else
{
}
else
{
GST_LOG_OBJECT
(
nicesrc
,
"Got interrupting, returning wrong-state"
);
GST_LOG_OBJECT
(
nicesrc
,
"Got interrupting, returning wrong-state"
);
return
GST_FLOW_WRONG_STATE
;
return
GST_FLOW_WRONG_STATE
;
}
}
}
}
static
void
static
void
...
@@ -295,6 +303,10 @@ gst_nice_src_dispose (GObject *object)
...
@@ -295,6 +303,10 @@ gst_nice_src_dispose (GObject *object)
{
{
GstNiceSrc
*
src
=
GST_NICE_SRC
(
object
);
GstNiceSrc
*
src
=
GST_NICE_SRC
(
object
);
if
(
src
->
new_selected_pair_id
)
g_signal_handler_disconnect
(
src
->
agent
,
src
->
new_selected_pair_id
);
src
->
new_selected_pair_id
=
0
;
if
(
src
->
agent
)
if
(
src
->
agent
)
g_object_unref
(
src
->
agent
);
g_object_unref
(
src
->
agent
);
src
->
agent
=
NULL
;
src
->
agent
=
NULL
;
...
@@ -368,6 +380,69 @@ gst_nice_src_get_property (
...
@@ -368,6 +380,69 @@ gst_nice_src_get_property (
}
}
}
}
static
void
nice_address_to_gst_net_address
(
NiceAddress
*
niceaddr
,
GstNetAddress
*
gstaddr
)
{
switch
(
niceaddr
->
s
.
addr
.
sa_family
)
{
case
AF_INET
:
gst_netaddress_set_ip4_address
(
gstaddr
,
niceaddr
->
s
.
ip4
.
sin_addr
.
s_addr
,
niceaddr
->
s
.
ip4
.
sin_port
);
break
;
case
AF_INET6
:
gst_netaddress_set_ip6_address
(
gstaddr
,
niceaddr
->
s
.
ip6
.
sin6_addr
.
s6_addr
,
niceaddr
->
s
.
ip6
.
sin6_port
);
break
;
default:
break
;
}
}
static
void
new_selected_pair_cb
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
gchar
*
local_cand
,
gchar
*
remote_cand
,
GstNiceSrc
*
src
)
{
GST_OBJECT_LOCK
(
src
);
if
(
stream_id
==
src
->
stream_id
&&
component_id
==
src
->
component_id
)
{
GSList
*
local_candidates
=
nice_agent_get_local_candidates
(
src
->
agent
,
stream_id
,
component_id
);
GSList
*
remote_candidates
=
nice_agent_get_remote_candidates
(
src
->
agent
,
stream_id
,
component_id
);
GSList
*
item
=
NULL
;
for
(
item
=
local_candidates
;
item
;
item
=
g_slist_next
(
item
))
{
NiceCandidate
*
cand
=
item
->
data
;
if
(
!
strcmp
(
local_cand
,
cand
->
foundation
))
{
nice_address_to_gst_net_address
(
&
cand
->
addr
,
&
src
->
to
);
break
;
}
}
for
(
item
=
remote_candidates
;
item
;
item
=
g_slist_next
(
item
))
{
NiceCandidate
*
cand
=
item
->
data
;
if
(
!
strcmp
(
remote_cand
,
cand
->
foundation
))
{
nice_address_to_gst_net_address
(
&
cand
->
addr
,
&
src
->
from
);
break
;
}
}
g_slist_foreach
(
local_candidates
,
(
GFunc
)
nice_candidate_free
,
NULL
);
g_slist_free
(
local_candidates
);
g_slist_foreach
(
remote_candidates
,
(
GFunc
)
nice_candidate_free
,
NULL
);
g_slist_free
(
remote_candidates
);
}
GST_OBJECT_UNLOCK
(
src
);
}
static
GstStateChangeReturn
static
GstStateChangeReturn
gst_nice_src_change_state
(
GstElement
*
element
,
GstStateChange
transition
)
gst_nice_src_change_state
(
GstElement
*
element
,
GstStateChange
transition
)
{
{
...
@@ -386,14 +461,25 @@ gst_nice_src_change_state (GstElement * element, GstStateChange transition)
...
@@ -386,14 +461,25 @@ gst_nice_src_change_state (GstElement * element, GstStateChange transition)
}
}
else
else
{
{
GST_OBJECT_LOCK
(
src
);
nice_agent_attach_recv
(
src
->
agent
,
src
->
stream_id
,
src
->
component_id
,
nice_agent_attach_recv
(
src
->
agent
,
src
->
stream_id
,
src
->
component_id
,
g_main_loop_get_context
(
src
->
mainloop
),
g_main_loop_get_context
(
src
->
mainloop
),
gst_nice_src_read_callback
,
(
gpointer
)
src
);
gst_nice_src_read_callback
,
(
gpointer
)
src
);
if
(
!
src
->
new_selected_pair_id
)
src
->
new_selected_pair_id
=
g_signal_connect
(
src
->
agent
,
"new-selected-pair"
,
G_CALLBACK
(
new_selected_pair_cb
),
src
);
GST_OBJECT_UNLOCK
(
src
);
}
}
break
;
break
;
case
GST_STATE_CHANGE_READY_TO_NULL
:
case
GST_STATE_CHANGE_READY_TO_NULL
:
GST_OBJECT_LOCK
(
src
);
nice_agent_attach_recv
(
src
->
agent
,
src
->
stream_id
,
src
->
component_id
,
nice_agent_attach_recv
(
src
->
agent
,
src
->
stream_id
,
src
->
component_id
,
g_main_loop_get_context
(
src
->
mainloop
),
NULL
,
NULL
);
g_main_loop_get_context
(
src
->
mainloop
),
NULL
,
NULL
);
if
(
src
->
new_selected_pair_id
)
g_signal_handler_disconnect
(
src
->
agent
,
src
->
new_selected_pair_id
);
src
->
new_selected_pair_id
=
0
;
GST_OBJECT_UNLOCK
(
src
);
break
;
break
;
default:
default:
break
;
break
;
...
...
gst/gstnicesrc.h
View file @
73c5a0b3
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include <gst/gst.h>
#include <gst/gst.h>
#include <gst/base/gstbasesrc.h>
#include <gst/base/gstbasesrc.h>
#include <gst/netbuffer/gstnetbuffer.h>
#include <nice/nice.h>
#include <nice/nice.h>
...
@@ -62,15 +63,22 @@ struct _GstNiceSrc
...
@@ -62,15 +63,22 @@ struct _GstNiceSrc
{
{
GstBaseSrc
parent
;
GstBaseSrc
parent
;
GstPad
*
srcpad
;
GstPad
*
srcpad
;
GMainLoop
*
mainloop
;
/* Protected by the object lock */
gboolean
unlocked
;
GSource
*
idle_source
;
NiceAgent
*
agent
;
NiceAgent
*
agent
;
guint
stream_id
;
guint
stream_id
;
guint
component_id
;
guint
component_id
;
GMainLoop
*
mainloop
;
guint64
offset
;
/* Protected by the stream lock */
GstFlowReturn
flow_ret
;
GstBuffer
*
outbuf
;
GstBuffer
*
outbuf
;
gboolean
unlocked
;
GSource
*
idle_source
;
/* Protected by the object lock */
gulong
new_selected_pair_id
;
GstNetAddress
from
;
GstNetAddress
to
;
};
};
typedef
struct
_GstNiceSrcClass
GstNiceSrcClass
;
typedef
struct
_GstNiceSrcClass
GstNiceSrcClass
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment