Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gstreamer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
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
Michael Grüner
gstreamer
Commits
464f6459
Commit
464f6459
authored
Sep 22, 2020
by
Michael Grüner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bufferpool: Subclass mini object pool
parent
ad289254
Pipeline
#204578
waiting for manual action with stages
in 32 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
837 deletions
+118
-837
gst/gstbufferpool.c
gst/gstbufferpool.c
+74
-747
gst/gstbufferpool.h
gst/gstbufferpool.h
+22
-90
gst/gstminiobjectpool.c
gst/gstminiobjectpool.c
+19
-0
gst/gstminiobjectpool.h
gst/gstminiobjectpool.h
+3
-0
No files found.
gst/gstbufferpool.c
View file @
464f6459
This diff is collapsed.
Click to expand it.
gst/gstbufferpool.h
View file @
464f6459
...
...
@@ -24,6 +24,7 @@
#define __GST_BUFFER_POOL_H__
#include <gst/gstminiobject.h>
#include <gst/gstminiobjectpool.h>
#include <gst/gstpad.h>
#include <gst/gstbuffer.h>
...
...
@@ -42,11 +43,7 @@ typedef struct _GstBufferPoolClass GstBufferPoolClass;
/**
* GstBufferPoolAcquireFlags:
* @GST_BUFFER_POOL_ACQUIRE_FLAG_NONE: no flags
* @GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT: buffer is keyframe
* @GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT: when the bufferpool is empty, acquire_buffer
* will by default block until a buffer is released into the pool again. Setting
* this flag makes acquire_buffer return #GST_FLOW_EOS instead of blocking.
* @GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT: buffer is discont
* @GST_BUFFER_POOL_ACQUIRE_FLAG_LAST: last flag, subclasses can use private flags
* starting from this value.
...
...
@@ -54,47 +51,33 @@ typedef struct _GstBufferPoolClass GstBufferPoolClass;
* Additional flags to control the allocation of a buffer
*/
typedef
enum
{
GST_BUFFER_POOL_ACQUIRE_FLAG_NONE
=
0
,
GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT
=
(
1
<<
0
),
GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT
=
(
1
<<
1
),
GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT
=
(
1
<<
2
),
GST_BUFFER_POOL_ACQUIRE_FLAG_LAST
=
(
1
<<
16
),
GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT
=
(
GST_MINI_OBJECT_POOL_ACQUIRE_FLAG_LAST
<<
0
),
GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT
=
(
GST_MINI_OBJECT_POOL_ACQUIRE_FLAG_LAST
<<
2
),
GST_BUFFER_POOL_ACQUIRE_FLAG_LAST
=
(
GST_MINI_OBJECT_POOL_ACQUIRE_FLAG_LAST
<<
15
),
}
GstBufferPoolAcquireFlags
;
typedef
struct
_GstBufferPoolAcquireParams
GstBufferPoolAcquireParams
;
/**
* GstBufferPoolAcquireParams:
* @format: the format of @start and @stop
* @start: the start position
* @stop: the stop position
* @flags: additional flags
* GST_BUFFER_POOL_ACQUIRE_FLAG_NONE:
*
* Parameters passed to the gst_buffer_pool_acquire_buffer() function to control the
* allocation of the buffer.
*
* The default implementation ignores the @start and @stop members but other
* implementations can use this extra information to decide what buffer to
* return.
* Alias of #GST_MINI_OBJECT_POOL_ACQUIRE_FLAG_NONE. Use the later on
* newly written code.
*/
struct
_GstBufferPoolAcquireParams
{
GstFormat
format
;
gint64
start
;
gint64
stop
;
GstBufferPoolAcquireFlags
flags
;
#define GST_BUFFER_POOL_ACQUIRE_FLAG_NONE GST_MINI_OBJECT_POOL_ACQUIRE_FLAG_NONE
/*< private >*/
gpointer
_gst_reserved
[
GST_PADDING
];
};
/**
* GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT:
*
* Alias of #GST_MINI_OBJECT_POOL_ACQUIRE_FLAG_DONTWAIT. Use the later
* on newly written code.
*/
#define GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT GST_MINI_OBJECT_POOL_ACQUIRE_FLAG_DONTWAIT
/**
* GST_BUFFER_POOL_IS_FLUSHING:
* @pool: a GstBufferPool
* GstBufferPoolAcquireParams:
*
* Check if the bufferpool is flushing. Subclasses might want to check the
* state of the pool in the acquire function.
* Alias of #GstMiniObjectPoolAcquireParams. Use the later on newly written code.
*/
#define GST_BUFFER_POOL_IS_FLUSHING(pool) (g_atomic_int_get (&pool->flushing))
typedef
GstMiniObjectPoolAcquireParams
GstBufferPoolAcquireParams
;
/**
* GstBufferPool:
...
...
@@ -103,10 +86,7 @@ struct _GstBufferPoolAcquireParams {
* variables.
*/
struct
_GstBufferPool
{
GstObject
object
;
/*< protected >*/
gint
flushing
;
GstMiniObjectPool
pool
;
/*< private >*/
GstBufferPoolPrivate
*
priv
;
...
...
@@ -117,62 +97,14 @@ struct _GstBufferPool {
/**
* GstBufferPoolClass:
* @object_class: Object parent class
* @get_options: get a list of options supported by this pool
* @set_config: apply the bufferpool configuration. The default configuration
* will parse the default config parameters
* @start: start the bufferpool. The default implementation will preallocate
* min-buffers buffers and put them in the queue
* @stop: stop the bufferpool. the default implementation will free the
* preallocated buffers. This function is called when all the buffers are
* returned to the pool.
* @acquire_buffer: get a new buffer from the pool. The default implementation
* will take a buffer from the queue and optionally wait for a buffer to
* be released when there are no buffers available.
* @alloc_buffer: allocate a buffer. the default implementation allocates
* buffers from the configured memory allocator and with the configured
* parameters. All metadata that is present on the allocated buffer will
* be marked as #GST_META_FLAG_POOLED and #GST_META_FLAG_LOCKED and will
* not be removed from the buffer in @reset_buffer. The buffer should
* have the GST_BUFFER_FLAG_TAG_MEMORY cleared.
* @reset_buffer: reset the buffer to its state when it was freshly allocated.
* The default implementation will clear the flags, timestamps and
* will remove the metadata without the #GST_META_FLAG_POOLED flag (even
* the metadata with #GST_META_FLAG_LOCKED). If the
* #GST_BUFFER_FLAG_TAG_MEMORY was set, this function can also try to
* restore the memory and clear the #GST_BUFFER_FLAG_TAG_MEMORY again.
* @release_buffer: release a buffer back in the pool. The default
* implementation will put the buffer back in the queue and notify any
* blocking acquire_buffer calls when the #GST_BUFFER_FLAG_TAG_MEMORY
* is not set on the buffer. If #GST_BUFFER_FLAG_TAG_MEMORY is set, the
* buffer will be freed with @free_buffer.
* @free_buffer: free a buffer. The default implementation unrefs the buffer.
* @flush_start: enter the flushing state. (Since: 1.4)
* @flush_stop: leave the flushign state. (Since: 1.4)
*
* The GstBufferPool class.
*/
struct
_GstBufferPoolClass
{
GstObjectClass
object_class
;
/*< public >*/
const
gchar
**
(
*
get_options
)
(
GstBufferPool
*
pool
);
gboolean
(
*
set_config
)
(
GstBufferPool
*
pool
,
GstStructure
*
config
);
gboolean
(
*
start
)
(
GstBufferPool
*
pool
);
gboolean
(
*
stop
)
(
GstBufferPool
*
pool
);
GstFlowReturn
(
*
acquire_buffer
)
(
GstBufferPool
*
pool
,
GstBuffer
**
buffer
,
GstBufferPoolAcquireParams
*
params
);
GstFlowReturn
(
*
alloc_buffer
)
(
GstBufferPool
*
pool
,
GstBuffer
**
buffer
,
GstBufferPoolAcquireParams
*
params
);
void
(
*
reset_buffer
)
(
GstBufferPool
*
pool
,
GstBuffer
*
buffer
);
void
(
*
release_buffer
)
(
GstBufferPool
*
pool
,
GstBuffer
*
buffer
);
void
(
*
free_buffer
)
(
GstBufferPool
*
pool
,
GstBuffer
*
buffer
);
void
(
*
flush_start
)
(
GstBufferPool
*
pool
);
void
(
*
flush_stop
)
(
GstBufferPool
*
pool
);
GstMiniObjectPoolClass
pool_class
;
/*< private >*/
gpointer
_gst_reserved
[
GST_PADDING
-
2
];
gpointer
_gst_reserved
[
GST_PADDING
+
9
];
};
GST_API
...
...
@@ -246,7 +178,7 @@ gboolean gst_buffer_pool_config_validate_params (GstStructure *config, G
GST_API
GstFlowReturn
gst_buffer_pool_acquire_buffer
(
GstBufferPool
*
pool
,
GstBuffer
**
buffer
,
Gst
Buffer
PoolAcquireParams
*
params
);
Gst
MiniObject
PoolAcquireParams
*
params
);
GST_API
void
gst_buffer_pool_release_buffer
(
GstBufferPool
*
pool
,
GstBuffer
*
buffer
);
...
...
gst/gstminiobjectpool.c
View file @
464f6459
...
...
@@ -1182,3 +1182,22 @@ gst_mini_object_pool_set_flushing (GstMiniObjectPool * pool, gboolean flushing)
done:
GST_MINI_OBJECT_POOL_UNLOCK
(
pool
);
}
/**
* gst_mini_object_pool_discard_object:
* @pool: a #GstMiniObjectPool
* @object: the #GstMiniObject to discard from the pool
*
* Discard a mini-object from the pool by removing it. Typically
* called by subclasses to handle errors.
*/
void
gst_mini_object_pool_discard_object
(
GstMiniObjectPool
*
pool
,
GstMiniObject
*
object
)
{
g_return_if_fail
(
GST_IS_MINI_OBJECT_POOL
(
pool
));
g_return_if_fail
(
object
);
do_free_object
(
pool
,
object
);
gst_poll_write_control
(
pool
->
priv
->
poll
);
}
gst/gstminiobjectpool.h
View file @
464f6459
...
...
@@ -222,6 +222,9 @@ GstFlowReturn gst_mini_object_pool_acquire_object (GstMiniObjectPool *pool,
GST_API
void
gst_mini_object_pool_release_object
(
GstMiniObjectPool
*
pool
,
GstMiniObject
*
object
);
GST_API
void
gst_mini_object_pool_discard_object
(
GstMiniObjectPool
*
pool
,
GstMiniObject
*
object
);
G_END_DECLS
#endif
/* __GST_MINI_OBJECT_POOL_H__ */
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