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
dc9ea089
Commit
dc9ea089
authored
Jun 23, 2011
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a Queue in gstnicesrc to avoid multiple read_callbacks overwriting the out buffer
parent
67de01c9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
gst/gstnicesrc.c
gst/gstnicesrc.c
+14
-8
gst/gstnicesrc.h
gst/gstnicesrc.h
+1
-1
No files found.
gst/gstnicesrc.c
View file @
dc9ea089
...
@@ -184,6 +184,7 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class)
...
@@ -184,6 +184,7 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class)
src
->
mainloop
=
g_main_loop_new
(
src
->
mainctx
,
FALSE
);
src
->
mainloop
=
g_main_loop_new
(
src
->
mainctx
,
FALSE
);
src
->
unlocked
=
FALSE
;
src
->
unlocked
=
FALSE
;
src
->
idle_source
=
NULL
;
src
->
idle_source
=
NULL
;
src
->
outbufs
=
g_queue_new
();
}
}
static
void
static
void
...
@@ -196,14 +197,16 @@ gst_nice_src_read_callback (NiceAgent *agent,
...
@@ -196,14 +197,16 @@ 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
);
GstBuffer
*
buffer
=
NULL
;
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
,
nicesrc
->
flow_ret
=
gst_pad_alloc_buffer
(
basesrc
->
srcpad
,
nicesrc
->
offset
,
len
,
GST_PAD_CAPS
(
basesrc
->
srcpad
),
&
nicesrc
->
outbuf
);
len
,
GST_PAD_CAPS
(
basesrc
->
srcpad
),
&
buffer
);
if
(
nicesrc
->
flow_ret
==
GST_FLOW_OK
)
{
if
(
nicesrc
->
flow_ret
==
GST_FLOW_OK
)
{
memcpy
(
nicesrc
->
outbuf
->
data
,
buf
,
len
);
memcpy
(
buffer
->
data
,
buf
,
len
);
nicesrc
->
outbuf
->
size
=
len
;
buffer
->
size
=
len
;
g_queue_push_tail
(
nicesrc
->
outbufs
,
buffer
);
}
}
g_main_loop_quit
(
nicesrc
->
mainloop
);
g_main_loop_quit
(
nicesrc
->
mainloop
);
...
@@ -277,7 +280,6 @@ gst_nice_src_create (
...
@@ -277,7 +280,6 @@ gst_nice_src_create (
GST_LOG_OBJECT
(
nicesrc
,
"create called"
);
GST_LOG_OBJECT
(
nicesrc
,
"create called"
);
nicesrc
->
outbuf
=
NULL
;
nicesrc
->
offset
=
offset
;
nicesrc
->
offset
=
offset
;
GST_OBJECT_LOCK
(
basesrc
);
GST_OBJECT_LOCK
(
basesrc
);
...
@@ -287,12 +289,12 @@ gst_nice_src_create (
...
@@ -287,12 +289,12 @@ gst_nice_src_create (
}
}
GST_OBJECT_UNLOCK
(
basesrc
);
GST_OBJECT_UNLOCK
(
basesrc
);
if
(
g_queue_is_empty
(
nicesrc
->
outbufs
))
g_main_loop_run
(
nicesrc
->
mainloop
);
g_main_loop_run
(
nicesrc
->
mainloop
);
if
(
nicesrc
->
outbuf
)
{
*
buffer
=
g_queue_pop_head
(
nicesrc
->
outbufs
);
if
(
*
buffer
!=
NULL
)
{
GST_LOG_OBJECT
(
nicesrc
,
"Got buffer, pushing"
);
GST_LOG_OBJECT
(
nicesrc
,
"Got buffer, pushing"
);
*
buffer
=
nicesrc
->
outbuf
;
return
nicesrc
->
flow_ret
;
return
nicesrc
->
flow_ret
;
}
else
{
}
else
{
GST_LOG_OBJECT
(
nicesrc
,
"Got interrupting, returning wrong-state"
);
GST_LOG_OBJECT
(
nicesrc
,
"Got interrupting, returning wrong-state"
);
...
@@ -318,6 +320,10 @@ gst_nice_src_dispose (GObject *object)
...
@@ -318,6 +320,10 @@ gst_nice_src_dispose (GObject *object)
g_main_context_unref
(
src
->
mainctx
);
g_main_context_unref
(
src
->
mainctx
);
src
->
mainctx
=
NULL
;
src
->
mainctx
=
NULL
;
if
(
src
->
outbufs
)
g_queue_free
(
src
->
outbufs
);
src
->
outbufs
=
NULL
;
GST_CALL_PARENT
(
G_OBJECT_CLASS
,
dispose
,
(
object
));
GST_CALL_PARENT
(
G_OBJECT_CLASS
,
dispose
,
(
object
));
}
}
...
...
gst/gstnicesrc.h
View file @
dc9ea089
...
@@ -69,7 +69,7 @@ struct _GstNiceSrc
...
@@ -69,7 +69,7 @@ struct _GstNiceSrc
GMainLoop
*
mainloop
;
GMainLoop
*
mainloop
;
guint64
offset
;
guint64
offset
;
GstFlowReturn
flow_ret
;
GstFlowReturn
flow_ret
;
G
stBuffer
*
outbuf
;
G
Queue
*
outbufs
;
gboolean
unlocked
;
gboolean
unlocked
;
GSource
*
idle_source
;
GSource
*
idle_source
;
};
};
...
...
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