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
b8b053ae
Commit
b8b053ae
authored
Apr 22, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gstreamer element using mainloop
darcs-hash:20080422163806-4f0f6-347a05842219dbf47903a1813c3a46df01a6b4af.gz
parent
360e6b9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
16 deletions
+52
-16
gst/gstnicesrc.c
gst/gstnicesrc.c
+48
-16
gst/gstnicesrc.h
gst/gstnicesrc.h
+4
-0
No files found.
gst/gstnicesrc.c
View file @
b8b053ae
...
...
@@ -161,8 +161,34 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class)
gst_base_src_set_live
(
GST_BASE_SRC
(
src
),
TRUE
);
gst_base_src_set_format
(
GST_BASE_SRC
(
src
),
GST_FORMAT_TIME
);
gst_base_src_set_do_timestamp
(
GST_BASE_SRC
(
src
),
TRUE
);
src
->
agent
=
NULL
;
src
->
stream_id
=
0
;
src
->
component_id
=
0
;
src
->
mainloop
=
g_main_loop_new
(
g_main_context_new
(),
FALSE
);
}
static
void
gst_nice_src_read_callback
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
guint
len
,
gchar
*
buf
,
gpointer
data
)
{
GstBaseSrc
*
basesrc
=
GST_BASE_SRC
(
data
);
GstNiceSrc
*
nicesrc
=
GST_NICE_SRC
(
basesrc
);
nicesrc
->
flow_ret
=
gst_pad_alloc_buffer
(
basesrc
->
srcpad
,
nicesrc
->
offset
,
len
,
GST_PAD_CAPS
(
basesrc
->
srcpad
),
&
nicesrc
->
outbuf
);
if
(
nicesrc
->
flow_ret
==
GST_FLOW_OK
)
{
memcpy
(
nicesrc
->
outbuf
->
data
,
buf
,
len
);
nicesrc
->
outbuf
->
size
=
len
;
}
g_main_loop_quit
(
nicesrc
->
mainloop
);
}
static
GstFlowReturn
gst_nice_src_create
(
GstBaseSrc
*
basesrc
,
...
...
@@ -170,24 +196,20 @@ gst_nice_src_create (
guint
length
,
GstBuffer
**
buffer
)
{
GstFlowReturn
res
;
GstBuffer
*
buf
;
GstNiceSrc
*
nicesrc
;
guint
len
;
nicesrc
=
GST_NICE_SRC
(
basesrc
);
res
=
gst_pad_alloc_buffer
(
basesrc
->
srcpad
,
offset
,
BUFFER_SIZE
,
GST_PAD_CAPS
(
basesrc
->
srcpad
),
&
buf
);
if
(
res
!=
GST_FLOW_OK
)
return
res
;
len
=
nice_agent_recv
(
nicesrc
->
agent
,
nicesrc
->
stream_id
,
nicesrc
->
component_id
,
BUFFER_SIZE
,
(
gchar
*
)
buf
->
data
);
g_assert
(
len
);
buf
->
size
=
len
;
*
buffer
=
buf
;
return
GST_FLOW_OK
;
nicesrc
->
outbuf
=
NULL
;
nicesrc
->
offset
=
offset
;
g_main_loop_run
(
nicesrc
->
mainloop
);
if
(
nicesrc
->
outbuf
)
{
*
buffer
=
nicesrc
->
outbuf
;
}
return
nicesrc
->
flow_ret
;
}
static
void
...
...
@@ -274,12 +296,22 @@ gst_nice_src_change_state (GstElement * element, GstStateChange transition)
switch
(
transition
)
{
case
GST_STATE_CHANGE_NULL_TO_READY
:
if
(
src
->
agent
==
NULL
)
if
(
src
->
agent
==
NULL
||
src
->
stream_id
==
0
||
src
->
component_id
==
0
)
{
GST_ERROR_OBJECT
(
element
,
"Trying to start Nice source without an agent set"
);
return
GST_STATE_CHANGE_FAILURE
;
}
else
{
nice_agent_attach_recv
(
src
->
agent
,
src
->
stream_id
,
src
->
component_id
,
g_main_loop_get_context
(
src
->
mainloop
),
gst_nice_src_read_callback
,
(
gpointer
)
src
);
}
break
;
case
GST_STATE_CHANGE_READY_TO_NULL
:
nice_agent_attach_recv
(
src
->
agent
,
src
->
stream_id
,
src
->
component_id
,
g_main_loop_get_context
(
src
->
mainloop
),
NULL
,
NULL
);
break
;
default:
break
;
...
...
gst/gstnicesrc.h
View file @
b8b053ae
...
...
@@ -65,6 +65,10 @@ struct _GstNiceSrc
NiceAgent
*
agent
;
guint
stream_id
;
guint
component_id
;
GMainLoop
*
mainloop
;
guint64
offset
;
GstFlowReturn
flow_ret
;
GstBuffer
*
outbuf
;
};
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