mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 14:56:36 +00:00
omxaudioenc: Use audio base classes from gst-plugins-base instead of having our own copies
This commit is contained in:
parent
9917fbe4c5
commit
217ac7b3be
11 changed files with 96 additions and 4456 deletions
|
@ -54,7 +54,7 @@ AC_LIBTOOL_WIN32_DLL
|
|||
AM_PROG_LIBTOOL
|
||||
|
||||
dnl *** required versions of GStreamer stuff ***
|
||||
GST_REQ=0.10.29
|
||||
GST_REQ=0.10.35.1
|
||||
|
||||
dnl *** autotools stuff ****
|
||||
|
||||
|
|
|
@ -16,10 +16,7 @@ libgstopenmax_la_SOURCES = \
|
|||
gstbasevideocodec.c \
|
||||
gstbasevideodecoder.c \
|
||||
gstbasevideoencoder.c \
|
||||
gstbasevideoutils.c \
|
||||
gstbaseaudiodecoder.c \
|
||||
gstbaseaudioencoder.c \
|
||||
gstbaseaudioutils.c
|
||||
gstbasevideoutils.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
gstomx.h \
|
||||
|
@ -37,10 +34,7 @@ noinst_HEADERS = \
|
|||
gstbasevideocodec.h \
|
||||
gstbasevideodecoder.h \
|
||||
gstbasevideoencoder.h \
|
||||
gstbasevideoutils.h \
|
||||
gstbaseaudiodecoder.h \
|
||||
gstbaseaudioencoder.h \
|
||||
gstbaseaudioutils.h
|
||||
gstbasevideoutils.h
|
||||
|
||||
fixbaseclasses = \
|
||||
-DGstBaseVideoCodec=OMXBaseVideoCodec \
|
||||
|
@ -48,11 +42,7 @@ fixbaseclasses = \
|
|||
-DGstBaseVideoEncoder=OMXBaseVideoEncoder \
|
||||
-DGstBaseVideoEncoderClass=OMXBaseVideoEncoderClass \
|
||||
-DGstBaseVideoDecoder=OMXBaseVideoDecoder \
|
||||
-DGstBaseVideoDecoderClass=OMXBaseVideoDecoderClass \
|
||||
-DGstBaseAudioDecoder=OMXBaseAudioDecoder \
|
||||
-DGstBaseAudioDecoderClass=OMXBaseAudioDecoderClass \
|
||||
-DGstBaseAudioEncoder=OMXBaseAudioEncoder \
|
||||
-DGstBaseAudioEncoderClass=OMXBaseAudioEncoderClass
|
||||
-DGstBaseVideoDecoderClass=OMXBaseVideoDecoderClass
|
||||
|
||||
libgstopenmax_la_CFLAGS = \
|
||||
-DGST_USE_UNSTABLE_API=1 \
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,270 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2009 Igalia S.L.
|
||||
* Author: Iago Toral Quiroga <itoral@igalia.com>
|
||||
* Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
|
||||
* Copyright (C) 2011 Nokia Corporation. All rights reserved.
|
||||
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GST_BASE_AUDIO_DECODER_H_
|
||||
#define _GST_BASE_AUDIO_DECODER_H_
|
||||
|
||||
#ifndef GST_USE_UNSTABLE_API
|
||||
#warning "GstBaseAudioDecoder is unstable API and may change in future."
|
||||
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include "gstbaseaudioutils.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_BASE_AUDIO_DECODER \
|
||||
(gst_base_audio_decoder_get_type())
|
||||
#define GST_BASE_AUDIO_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_AUDIO_DECODER,GstBaseAudioDecoder))
|
||||
#define GST_BASE_AUDIO_DECODER_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_AUDIO_DECODER,GstBaseAudioDecoderClass))
|
||||
#define GST_BASE_AUDIO_DECODER_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_AUDIO_DECODER,GstBaseAudioDecoderClass))
|
||||
#define GST_IS_BASE_AUDIO_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_AUDIO_DECODER))
|
||||
#define GST_IS_BASE_AUDIO_DECODER_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_AUDIO_DECODER))
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_DECODER_SINK_NAME:
|
||||
*
|
||||
* The name of the templates for the sink pad.
|
||||
*/
|
||||
#define GST_BASE_AUDIO_DECODER_SINK_NAME "sink"
|
||||
/**
|
||||
* GST_BASE_AUDIO_DECODER_SRC_NAME:
|
||||
*
|
||||
* The name of the templates for the source pad.
|
||||
*/
|
||||
#define GST_BASE_AUDIO_DECODER_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_DECODER_SRC_PAD:
|
||||
* @obj: base audio codec instance
|
||||
*
|
||||
* Gives the pointer to the source #GstPad object of the element.
|
||||
*/
|
||||
#define GST_BASE_AUDIO_DECODER_SRC_PAD(obj) (((GstBaseAudioDecoder *) (obj))->srcpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_DECODER_SINK_PAD:
|
||||
* @obj: base audio codec instance
|
||||
*
|
||||
* Gives the pointer to the sink #GstPad object of the element.
|
||||
*/
|
||||
#define GST_BASE_AUDIO_DECODER_SINK_PAD(obj) (((GstBaseAudioDecoder *) (obj))->sinkpad)
|
||||
|
||||
#define GST_BASE_AUDIO_DECODER_STREAM_LOCK(dec) g_static_rec_mutex_lock (&GST_BASE_AUDIO_DECODER (dec)->stream_lock)
|
||||
#define GST_BASE_AUDIO_DECODER_STREAM_UNLOCK(dec) g_static_rec_mutex_unlock (&GST_BASE_AUDIO_DECODER (dec)->stream_lock)
|
||||
|
||||
typedef struct _GstBaseAudioDecoder GstBaseAudioDecoder;
|
||||
typedef struct _GstBaseAudioDecoderClass GstBaseAudioDecoderClass;
|
||||
|
||||
typedef struct _GstBaseAudioDecoderPrivate GstBaseAudioDecoderPrivate;
|
||||
typedef struct _GstBaseAudioDecoderContext GstBaseAudioDecoderContext;
|
||||
|
||||
/* do not use this one, use macro below */
|
||||
GstFlowReturn _gst_base_audio_decoder_error (GstBaseAudioDecoder *dec, gint weight,
|
||||
GQuark domain, gint code,
|
||||
gchar *txt, gchar *debug,
|
||||
const gchar *file, const gchar *function,
|
||||
gint line);
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_DECODER_ERROR:
|
||||
* @el: the base audio decoder element that generates the error
|
||||
* @weight: element defined weight of the error, added to error count
|
||||
* @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
|
||||
* @code: error code defined for that domain (see #gstreamer-GstGError)
|
||||
* @text: the message to display (format string and args enclosed in
|
||||
* parentheses)
|
||||
* @debug: debugging information for the message (format string and args
|
||||
* enclosed in parentheses)
|
||||
* @ret: variable to receive return value
|
||||
*
|
||||
* Utility function that audio decoder elements can use in case they encountered
|
||||
* a data processing error that may be fatal for the current "data unit" but
|
||||
* need not prevent subsequent decoding. Such errors are counted and if there
|
||||
* are too many, as configured in the context's max_errors, the pipeline will
|
||||
* post an error message and the application will be requested to stop further
|
||||
* media processing. Otherwise, it is considered a "glitch" and only a warning
|
||||
* is logged. In either case, @ret is set to the proper value to
|
||||
* return to upstream/caller (indicating either GST_FLOW_ERROR or GST_FLOW_OK).
|
||||
*/
|
||||
#define GST_BASE_AUDIO_DECODER_ERROR(el, w, domain, code, text, debug, ret) \
|
||||
G_STMT_START { \
|
||||
gchar *__txt = _gst_element_error_printf text; \
|
||||
gchar *__dbg = _gst_element_error_printf debug; \
|
||||
GstBaseAudioDecoder *dec = GST_BASE_AUDIO_DECODER (el); \
|
||||
ret = _gst_base_audio_decoder_error (dec, w, GST_ ## domain ## _ERROR, \
|
||||
GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, \
|
||||
GST_FUNCTION, __LINE__); \
|
||||
} G_STMT_END
|
||||
|
||||
/**
|
||||
* GstBaseAudioDecoderContext:
|
||||
* @state: a #GstAudioState describing input audio format
|
||||
* @eos: no (immediate) subsequent data in stream
|
||||
* @sync: stream parsing in sync
|
||||
* @delay: number of frames pending decoding (typically at least 1 for current)
|
||||
* @do_plc: whether subclass is prepared to handle (packet) loss concealment
|
||||
* @min_latency: min latency of element
|
||||
* @max_latency: max latency of element
|
||||
* @lookahead: decoder lookahead (in units of input rate samples)
|
||||
*
|
||||
* Transparent #GstBaseAudioEncoderContext data structure.
|
||||
*/
|
||||
struct _GstBaseAudioDecoderContext {
|
||||
/* input */
|
||||
/* (output) audio format */
|
||||
GstAudioState state;
|
||||
|
||||
/* parsing state */
|
||||
gboolean eos;
|
||||
gboolean sync;
|
||||
|
||||
/* misc */
|
||||
gint delay;
|
||||
|
||||
/* output */
|
||||
gboolean do_plc;
|
||||
gboolean do_byte_time;
|
||||
gint max_errors;
|
||||
/* MT-protected (with LOCK) */
|
||||
GstClockTime min_latency;
|
||||
GstClockTime max_latency;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstBaseAudioDecoder:
|
||||
*
|
||||
* The opaque #GstBaseAudioDecoder data structure.
|
||||
*/
|
||||
struct _GstBaseAudioDecoder
|
||||
{
|
||||
GstElement element;
|
||||
|
||||
/*< protected >*/
|
||||
/* source and sink pads */
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad;
|
||||
|
||||
/* protects all data processing, i.e. is locked
|
||||
* in the chain function, finish_frame and when
|
||||
* processing serialized events */
|
||||
GStaticRecMutex stream_lock;
|
||||
|
||||
/* MT-protected (with STREAM_LOCK) */
|
||||
GstSegment segment;
|
||||
GstBaseAudioDecoderContext *ctx;
|
||||
|
||||
/* properties */
|
||||
GstClockTime latency;
|
||||
GstClockTime tolerance;
|
||||
gboolean plc;
|
||||
|
||||
/*< private >*/
|
||||
GstBaseAudioDecoderPrivate *priv;
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
/**
|
||||
* GstBaseAudioDecoderClass:
|
||||
* @start: Optional.
|
||||
* Called when the element starts processing.
|
||||
* Allows opening external resources.
|
||||
* @stop: Optional.
|
||||
* Called when the element stops processing.
|
||||
* Allows closing external resources.
|
||||
* @set_format: Notifies subclass of incoming data format (caps).
|
||||
* @parse: Optional.
|
||||
* Allows chopping incoming data into manageable units (frames)
|
||||
* for subsequent decoding. This division is at subclass
|
||||
* discretion and may or may not correspond to 1 (or more)
|
||||
* frames as defined by audio format.
|
||||
* @handle_frame: Provides input data (or NULL to clear any remaining data)
|
||||
* to subclass. Input data ref management is performed by
|
||||
* base class, subclass should not care or intervene.
|
||||
* @flush: Optional.
|
||||
* Instructs subclass to clear any codec caches and discard
|
||||
* any pending samples and not yet returned encoded data.
|
||||
* @hard indicates whether a FLUSH is being processed,
|
||||
* or otherwise a DISCONT (or conceptually similar).
|
||||
* @event: Optional.
|
||||
* Event handler on the sink pad. This function should return
|
||||
* TRUE if the event was handled and should be discarded
|
||||
* (i.e. not unref'ed).
|
||||
* @pre_push: Optional.
|
||||
* Called just prior to pushing (encoded data) buffer downstream.
|
||||
* Subclass has full discretionary access to buffer,
|
||||
* and a not OK flow return will abort downstream pushing.
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
* needed. At minimum @handle_frame (and likely @set_format) needs to be
|
||||
* overridden.
|
||||
*/
|
||||
struct _GstBaseAudioDecoderClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
/* virtual methods for subclasses */
|
||||
|
||||
gboolean (*start) (GstBaseAudioDecoder *dec);
|
||||
|
||||
gboolean (*stop) (GstBaseAudioDecoder *dec);
|
||||
|
||||
gboolean (*set_format) (GstBaseAudioDecoder *dec,
|
||||
GstCaps *caps);
|
||||
|
||||
GstFlowReturn (*parse) (GstBaseAudioDecoder *dec,
|
||||
GstAdapter *adapter,
|
||||
gint *offset, gint *length);
|
||||
|
||||
GstFlowReturn (*handle_frame) (GstBaseAudioDecoder *dec,
|
||||
GstBuffer *buffer);
|
||||
|
||||
void (*flush) (GstBaseAudioDecoder *dec, gboolean hard);
|
||||
|
||||
GstFlowReturn (*pre_push) (GstBaseAudioDecoder *dec,
|
||||
GstBuffer **buffer);
|
||||
|
||||
gboolean (*event) (GstBaseAudioDecoder *dec,
|
||||
GstEvent *event);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
GstFlowReturn gst_base_audio_decoder_finish_frame (GstBaseAudioDecoder * dec,
|
||||
GstBuffer * buf, gint frames);
|
||||
|
||||
GType gst_base_audio_decoder_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,234 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
|
||||
* Copyright (C) 2011 Nokia Corporation. All rights reserved.
|
||||
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_BASE_AUDIO_ENCODER_H__
|
||||
#define __GST_BASE_AUDIO_ENCODER_H__
|
||||
|
||||
#ifndef GST_USE_UNSTABLE_API
|
||||
#warning "GstBaseAudioEncoder is unstable API and may change in future."
|
||||
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstbaseaudioutils.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_BASE_AUDIO_ENCODER (gst_base_audio_encoder_get_type())
|
||||
#define GST_BASE_AUDIO_ENCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_AUDIO_ENCODER,GstBaseAudioEncoder))
|
||||
#define GST_BASE_AUDIO_ENCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_AUDIO_ENCODER,GstBaseAudioEncoderClass))
|
||||
#define GST_BASE_AUDIO_ENCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_AUDIO_ENCODER,GstBaseAudioEncoderClass))
|
||||
#define GST_IS_BASE_AUDIO_ENCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_AUDIO_ENCODER))
|
||||
#define GST_IS_BASE_AUDIO_ENCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_AUDIO_ENCODER))
|
||||
#define GST_BASE_AUDIO_ENCODER_CAST(obj) ((GstBaseAudioEncoder *)(obj))
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_ENCODER_SINK_NAME:
|
||||
*
|
||||
* the name of the templates for the sink pad
|
||||
*/
|
||||
#define GST_BASE_AUDIO_ENCODER_SINK_NAME "sink"
|
||||
/**
|
||||
* GST_BASE_AUDIO_ENCODER_SRC_NAME:
|
||||
*
|
||||
* the name of the templates for the source pad
|
||||
*/
|
||||
#define GST_BASE_AUDIO_ENCODER_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_ENCODER_SRC_PAD:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Gives the pointer to the source #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_AUDIO_ENCODER_SRC_PAD(obj) (GST_BASE_AUDIO_ENCODER_CAST (obj)->srcpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_ENCODER_SINK_PAD:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Gives the pointer to the sink #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_AUDIO_ENCODER_SINK_PAD(obj) (GST_BASE_AUDIO_ENCODER_CAST (obj)->sinkpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_AUDIO_ENCODER_SEGMENT:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Gives the segment of the element.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_AUDIO_ENCODER_SEGMENT(obj) (GST_BASE_AUDIO_ENCODER_CAST (obj)->segment)
|
||||
|
||||
#define GST_BASE_AUDIO_ENCODER_STREAM_LOCK(enc) g_static_rec_mutex_lock (&GST_BASE_AUDIO_ENCODER (enc)->stream_lock)
|
||||
#define GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK(enc) g_static_rec_mutex_unlock (&GST_BASE_AUDIO_ENCODER (enc)->stream_lock)
|
||||
|
||||
typedef struct _GstBaseAudioEncoder GstBaseAudioEncoder;
|
||||
typedef struct _GstBaseAudioEncoderClass GstBaseAudioEncoderClass;
|
||||
|
||||
typedef struct _GstBaseAudioEncoderPrivate GstBaseAudioEncoderPrivate;
|
||||
typedef struct _GstBaseAudioEncoderContext GstBaseAudioEncoderContext;
|
||||
|
||||
/**
|
||||
* GstBaseAudioEncoderContext:
|
||||
* @state: a #GstAudioState describing input audio format
|
||||
* @frame_samples_min: number of samples (per channel) subclass needs to be handed
|
||||
* at least, or will be handed all available if 0.
|
||||
* @frame_samples_max: number of samples (per channel) subclass needs to be handed
|
||||
* at most, or will be handed all available if 0.
|
||||
* @frame_max: max number of frames of size @frame_samples accepted at once
|
||||
* (assumed minimally 1). Requires @frame_samples_min and @frame_samples_max
|
||||
* to be the equal.
|
||||
* @min_latency: min latency of element
|
||||
* @max_latency: max latency of element
|
||||
* @lookahead: encoder lookahead (in units of input rate samples)
|
||||
*
|
||||
* Transparent #GstBaseAudioEncoderContext data structure.
|
||||
*/
|
||||
struct _GstBaseAudioEncoderContext {
|
||||
/* input */
|
||||
GstAudioState state;
|
||||
|
||||
/* output */
|
||||
gint frame_samples_min, frame_samples_max;
|
||||
gint frame_max;
|
||||
gint lookahead;
|
||||
/* MT-protected (with LOCK) */
|
||||
GstClockTime min_latency;
|
||||
GstClockTime max_latency;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstBaseAudioEncoder:
|
||||
* @element: the parent element.
|
||||
*
|
||||
* The opaque #GstBaseAudioEncoder data structure.
|
||||
*/
|
||||
struct _GstBaseAudioEncoder {
|
||||
GstElement element;
|
||||
|
||||
/*< protected >*/
|
||||
/* source and sink pads */
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad;
|
||||
|
||||
/* protects all data processing, i.e. is locked
|
||||
* in the chain function, finish_frame and when
|
||||
* processing serialized events */
|
||||
GStaticRecMutex stream_lock;
|
||||
|
||||
/* MT-protected (with STREAM_LOCK) */
|
||||
GstSegment segment;
|
||||
GstBaseAudioEncoderContext *ctx;
|
||||
|
||||
/* properties */
|
||||
gint64 tolerance;
|
||||
gboolean perfect_ts;
|
||||
gboolean hard_resync;
|
||||
gboolean granule;
|
||||
|
||||
/*< private >*/
|
||||
GstBaseAudioEncoderPrivate *priv;
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
/**
|
||||
* GstBaseAudioEncoderClass:
|
||||
* @start: Optional.
|
||||
* Called when the element starts processing.
|
||||
* Allows opening external resources.
|
||||
* @stop: Optional.
|
||||
* Called when the element stops processing.
|
||||
* Allows closing external resources.
|
||||
* @set_format: Notifies subclass of incoming data format.
|
||||
* GstBaseAudioEncoderContext fields have already been
|
||||
* set according to provided caps.
|
||||
* @handle_frame: Provides input samples (or NULL to clear any remaining data)
|
||||
* according to directions as provided by subclass in the
|
||||
* #GstBaseAudioEncoderContext. Input data ref management
|
||||
* is performed by base class, subclass should not care or
|
||||
* intervene.
|
||||
* @flush: Optional.
|
||||
* Instructs subclass to clear any codec caches and discard
|
||||
* any pending samples and not yet returned encoded data.
|
||||
* @event: Optional.
|
||||
* Event handler on the sink pad. This function should return
|
||||
* TRUE if the event was handled and should be discarded
|
||||
* (i.e. not unref'ed).
|
||||
* @pre_push: Optional.
|
||||
* Called just prior to pushing (encoded data) buffer downstream.
|
||||
* Subclass has full discretionary access to buffer,
|
||||
* and a not OK flow return will abort downstream pushing.
|
||||
* @getcaps: Optional.
|
||||
* Allows for a custom sink getcaps implementation (e.g.
|
||||
* for multichannel input specification). If not implemented,
|
||||
* default returns gst_base_audio_encoder_proxy_getcaps
|
||||
* applied to sink template caps.
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
* needed. At minimum @set_format and @handle_frame needs to be overridden.
|
||||
*/
|
||||
struct _GstBaseAudioEncoderClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
/* virtual methods for subclasses */
|
||||
|
||||
gboolean (*start) (GstBaseAudioEncoder *enc);
|
||||
|
||||
gboolean (*stop) (GstBaseAudioEncoder *enc);
|
||||
|
||||
gboolean (*set_format) (GstBaseAudioEncoder *enc,
|
||||
GstAudioState *state);
|
||||
|
||||
GstFlowReturn (*handle_frame) (GstBaseAudioEncoder *enc,
|
||||
GstBuffer *buffer);
|
||||
|
||||
void (*flush) (GstBaseAudioEncoder *enc);
|
||||
|
||||
GstFlowReturn (*pre_push) (GstBaseAudioEncoder *enc,
|
||||
GstBuffer **buffer);
|
||||
|
||||
gboolean (*event) (GstBaseAudioEncoder *enc,
|
||||
GstEvent *event);
|
||||
|
||||
GstCaps * (*getcaps) (GstBaseAudioEncoder *enc);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
GType gst_base_audio_encoder_get_type (void);
|
||||
|
||||
GstFlowReturn gst_base_audio_encoder_finish_frame (GstBaseAudioEncoder * enc,
|
||||
GstBuffer *buffer, gint samples);
|
||||
|
||||
GstCaps * gst_base_audio_encoder_proxy_getcaps (GstBaseAudioEncoder * enc,
|
||||
GstCaps * caps);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_BASE_AUDIO_ENCODER_H__ */
|
|
@ -1,315 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
|
||||
* Copyright (C) 2011 Nokia Corporation. All rights reserved.
|
||||
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gstbaseaudioutils.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
|
||||
|
||||
#define CHECK_VALUE(var, val) \
|
||||
G_STMT_START { \
|
||||
if (!res) \
|
||||
goto fail; \
|
||||
if (var != val) \
|
||||
changed = TRUE; \
|
||||
var = val; \
|
||||
} G_STMT_END
|
||||
|
||||
/**
|
||||
* gst_base_audio_parse_caps:
|
||||
* @caps: a #GstCaps
|
||||
* @state: a #GstAudioState
|
||||
* @changed: whether @caps introduced a change in current @state
|
||||
*
|
||||
* Parses audio format as represented by @caps into a more concise form
|
||||
* as represented by @state, while checking if for changes to currently
|
||||
* defined audio format.
|
||||
*
|
||||
* Returns: TRUE if parsing succeeded, otherwise FALSE
|
||||
*/
|
||||
gboolean
|
||||
gst_base_audio_parse_caps (GstCaps * caps, GstAudioState * state,
|
||||
gboolean * _changed)
|
||||
{
|
||||
gboolean res = TRUE, changed = FALSE;
|
||||
GstStructure *s;
|
||||
gboolean vb;
|
||||
gint vi;
|
||||
|
||||
g_return_val_if_fail (caps != NULL, FALSE);
|
||||
g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
|
||||
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
if (gst_structure_has_name (s, "audio/x-raw-int"))
|
||||
state->is_int = TRUE;
|
||||
else if (gst_structure_has_name (s, "audio/x-raw-float"))
|
||||
state->is_int = FALSE;
|
||||
else
|
||||
goto fail;
|
||||
|
||||
res = gst_structure_get_int (s, "rate", &vi);
|
||||
CHECK_VALUE (state->rate, vi);
|
||||
res &= gst_structure_get_int (s, "channels", &vi);
|
||||
CHECK_VALUE (state->channels, vi);
|
||||
res &= gst_structure_get_int (s, "width", &vi);
|
||||
CHECK_VALUE (state->width, vi);
|
||||
res &= (!state->is_int || gst_structure_get_int (s, "depth", &vi));
|
||||
CHECK_VALUE (state->depth, vi);
|
||||
res &= gst_structure_get_int (s, "endianness", &vi);
|
||||
CHECK_VALUE (state->endian, vi);
|
||||
res &= (!state->is_int || gst_structure_get_boolean (s, "signed", &vb));
|
||||
CHECK_VALUE (state->sign, vb);
|
||||
|
||||
state->bpf = (state->width / 8) * state->channels;
|
||||
GST_LOG ("bpf: %d", state->bpf);
|
||||
if (!state->bpf)
|
||||
goto fail;
|
||||
|
||||
g_free (state->channel_pos);
|
||||
state->channel_pos = gst_audio_get_channel_positions (s);
|
||||
|
||||
if (_changed)
|
||||
*_changed = changed;
|
||||
|
||||
return res;
|
||||
|
||||
/* ERRORS */
|
||||
fail:
|
||||
{
|
||||
/* there should not be caps out there that fail parsing ... */
|
||||
GST_WARNING ("failed to parse caps %" GST_PTR_FORMAT, caps);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_base_audio_add_streamheader:
|
||||
* @caps: a #GstCaps
|
||||
* @buf: header buffers
|
||||
*
|
||||
* Adds given buffers to an array of buffers set as streamheader field
|
||||
* on the given @caps. List of buffer arguments must be NULL-terminated.
|
||||
*
|
||||
* Returns: input caps with a streamheader field added, or NULL if some error
|
||||
*/
|
||||
GstCaps *
|
||||
gst_base_audio_add_streamheader (GstCaps * caps, GstBuffer * buf, ...)
|
||||
{
|
||||
GstStructure *structure = NULL;
|
||||
va_list va;
|
||||
GValue array = { 0 };
|
||||
GValue value = { 0 };
|
||||
|
||||
g_return_val_if_fail (caps != NULL, NULL);
|
||||
g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
|
||||
|
||||
caps = gst_caps_make_writable (caps);
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
g_value_init (&array, GST_TYPE_ARRAY);
|
||||
|
||||
va_start (va, buf);
|
||||
/* put buffers in a fixed list */
|
||||
while (buf) {
|
||||
g_assert (gst_buffer_is_metadata_writable (buf));
|
||||
|
||||
/* mark buffer */
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
|
||||
|
||||
g_value_init (&value, GST_TYPE_BUFFER);
|
||||
buf = gst_buffer_copy (buf);
|
||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
|
||||
gst_value_set_buffer (&value, buf);
|
||||
gst_buffer_unref (buf);
|
||||
gst_value_array_append_value (&array, &value);
|
||||
g_value_unset (&value);
|
||||
|
||||
buf = va_arg (va, GstBuffer *);
|
||||
}
|
||||
|
||||
gst_structure_set_value (structure, "streamheader", &array);
|
||||
g_value_unset (&array);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_base_audio_encoded_audio_convert:
|
||||
* @fmt: audio format of the encoded audio
|
||||
* @bytes: number of encoded bytes
|
||||
* @samples: number of encoded samples
|
||||
* @src_format: source format
|
||||
* @src_value: source value
|
||||
* @dest_format: destination format
|
||||
* @dest_value: destination format
|
||||
*
|
||||
* Helper function to convert @src_value in @src_format to @dest_value in
|
||||
* @dest_format for encoded audio data. Conversion is possible between
|
||||
* BYTE and TIME format by using estimated bitrate based on
|
||||
* @samples and @bytes (and @fmt).
|
||||
*/
|
||||
gboolean
|
||||
gst_base_audio_encoded_audio_convert (GstAudioState * fmt,
|
||||
gint64 bytes, gint64 samples, GstFormat src_format,
|
||||
gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
g_return_val_if_fail (dest_format != NULL, FALSE);
|
||||
g_return_val_if_fail (dest_value != NULL, FALSE);
|
||||
|
||||
if (G_UNLIKELY (src_format == *dest_format || src_value == 0 ||
|
||||
src_value == -1)) {
|
||||
if (dest_value)
|
||||
*dest_value = src_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (samples == 0 || bytes == 0 || fmt->rate == 0) {
|
||||
GST_DEBUG ("not enough metadata yet to convert");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
bytes *= fmt->rate;
|
||||
|
||||
switch (src_format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_TIME:
|
||||
*dest_value = gst_util_uint64_scale (src_value,
|
||||
GST_SECOND * samples, bytes);
|
||||
res = TRUE;
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
*dest_value = gst_util_uint64_scale (src_value, bytes,
|
||||
samples * GST_SECOND);
|
||||
res = TRUE;
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
|
||||
exit:
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_base_audio_raw_audio_convert:
|
||||
* @fmt: audio format of the encoded audio
|
||||
* @src_format: source format
|
||||
* @src_value: source value
|
||||
* @dest_format: destination format
|
||||
* @dest_value: destination format
|
||||
*
|
||||
* Helper function to convert @src_value in @src_format to @dest_value in
|
||||
* @dest_format for encoded audio data. Conversion is possible between
|
||||
* BYTE, DEFAULT and TIME format based on audio characteristics provided
|
||||
* by @fmt.
|
||||
*/
|
||||
gboolean
|
||||
gst_base_audio_raw_audio_convert (GstAudioState * fmt, GstFormat src_format,
|
||||
gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
guint scale = 1;
|
||||
gint bytes_per_sample, rate, byterate;
|
||||
|
||||
g_return_val_if_fail (dest_format != NULL, FALSE);
|
||||
g_return_val_if_fail (dest_value != NULL, FALSE);
|
||||
|
||||
if (G_UNLIKELY (src_format == *dest_format || src_value == 0 ||
|
||||
src_value == -1)) {
|
||||
if (dest_value)
|
||||
*dest_value = src_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bytes_per_sample = fmt->bpf;
|
||||
rate = fmt->rate;
|
||||
byterate = bytes_per_sample * rate;
|
||||
|
||||
if (G_UNLIKELY (bytes_per_sample == 0 || rate == 0)) {
|
||||
GST_DEBUG ("not enough metadata yet to convert");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
switch (src_format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
*dest_value = src_value / bytes_per_sample;
|
||||
res = TRUE;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
*dest_value =
|
||||
gst_util_uint64_scale_int (src_value, GST_SECOND, byterate);
|
||||
res = TRUE;
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
break;
|
||||
case GST_FORMAT_DEFAULT:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
*dest_value = src_value * bytes_per_sample;
|
||||
res = TRUE;
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
*dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND, rate);
|
||||
res = TRUE;
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_BYTES:
|
||||
scale = bytes_per_sample;
|
||||
/* fallthrough */
|
||||
case GST_FORMAT_DEFAULT:
|
||||
*dest_value = gst_util_uint64_scale_int (src_value,
|
||||
scale * rate, GST_SECOND);
|
||||
res = TRUE;
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
|
||||
exit:
|
||||
return res;
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
|
||||
* Copyright (C) 2011 Nokia Corporation. All rights reserved.
|
||||
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GST_BASE_AUDIO_UTILS_H_
|
||||
#define _GST_BASE_AUDIO_UTILS_H_
|
||||
|
||||
#ifndef GST_USE_UNSTABLE_API
|
||||
#warning "Base audio utils provide unstable API and may change in future."
|
||||
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GstAudioState:
|
||||
* @is_int: whether sample data is int or float
|
||||
* @rate: rate of sample data
|
||||
* @channels: number of channels in sample data
|
||||
* @width: width (in bits) of sample data
|
||||
* @depth: used bits in sample data (if integer)
|
||||
* @sign: sign of sample data (if integer)
|
||||
* @endian: endianness of sample data
|
||||
* @bpf: bytes per audio frame
|
||||
*/
|
||||
typedef struct _GstAudioState {
|
||||
gboolean is_int;
|
||||
gint rate;
|
||||
gint channels;
|
||||
gint width;
|
||||
gint depth;
|
||||
gboolean sign;
|
||||
gint endian;
|
||||
GstAudioChannelPosition *channel_pos;
|
||||
|
||||
gint bpf;
|
||||
} GstAudioState;
|
||||
|
||||
gboolean gst_base_audio_parse_caps (GstCaps * caps,
|
||||
GstAudioState * state, gboolean * changed);
|
||||
|
||||
GstCaps *gst_base_audio_add_streamheader (GstCaps * caps, GstBuffer * buf, ...);
|
||||
|
||||
gboolean gst_base_audio_encoded_audio_convert (GstAudioState * fmt,
|
||||
gint64 bytes, gint64 samples, GstFormat src_format,
|
||||
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
||||
|
||||
gboolean gst_base_audio_raw_audio_convert (GstAudioState * fmt, GstFormat src_format,
|
||||
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
@ -36,11 +36,11 @@ static void gst_omx_aac_enc_set_property (GObject * object, guint prop_id,
|
|||
static void gst_omx_aac_enc_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static gboolean gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc,
|
||||
GstOMXPort * port, GstAudioState * state);
|
||||
GstOMXPort * port, GstAudioInfo * info);
|
||||
static GstCaps *gst_omx_aac_enc_get_caps (GstOMXAudioEnc * enc,
|
||||
GstOMXPort * port, GstAudioState * state);
|
||||
GstOMXPort * port, GstAudioInfo * info);
|
||||
static guint gst_omx_aac_enc_get_num_samples (GstOMXAudioEnc * enc,
|
||||
GstOMXPort * port, GstAudioState * state, GstOMXBuffer * buf);
|
||||
GstOMXPort * port, GstAudioInfo * info, GstOMXBuffer * buf);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ gst_omx_aac_enc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
|
||||
static gboolean
|
||||
gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
|
||||
GstAudioState * state)
|
||||
GstAudioInfo * info)
|
||||
{
|
||||
GstOMXAACEnc *self = GST_OMX_AAC_ENC (enc);
|
||||
OMX_AUDIO_PARAM_AACPROFILETYPE aac_profile;
|
||||
|
@ -250,7 +250,7 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
peercaps = gst_pad_peer_get_caps (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
peercaps = gst_pad_peer_get_caps (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
if (peercaps) {
|
||||
GstCaps *intersection;
|
||||
GstStructure *s;
|
||||
|
@ -259,7 +259,7 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
|
|||
|
||||
intersection =
|
||||
gst_caps_intersect (peercaps,
|
||||
gst_pad_get_pad_template_caps (GST_BASE_AUDIO_ENCODER_SRC_PAD (self)));
|
||||
gst_pad_get_pad_template_caps (GST_AUDIO_ENCODER_SRC_PAD (self)));
|
||||
gst_caps_unref (peercaps);
|
||||
if (gst_caps_is_empty (intersection)) {
|
||||
gst_caps_unref (intersection);
|
||||
|
@ -340,7 +340,7 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
|
|||
|
||||
static GstCaps *
|
||||
gst_omx_aac_enc_get_caps (GstOMXAudioEnc * enc, GstOMXPort * port,
|
||||
GstAudioState * state)
|
||||
GstAudioInfo * info)
|
||||
{
|
||||
GstCaps *caps;
|
||||
OMX_ERRORTYPE err;
|
||||
|
@ -437,7 +437,7 @@ gst_omx_aac_enc_get_caps (GstOMXAudioEnc * enc, GstOMXPort * port,
|
|||
|
||||
static guint
|
||||
gst_omx_aac_enc_get_num_samples (GstOMXAudioEnc * enc, GstOMXPort * port,
|
||||
GstAudioState * state, GstOMXBuffer * buf)
|
||||
GstAudioInfo * info, GstOMXBuffer * buf)
|
||||
{
|
||||
/* FIXME: Depends on the profile at least */
|
||||
return 1024;
|
||||
|
|
|
@ -37,15 +37,15 @@ static GstStateChangeReturn
|
|||
gst_omx_audio_enc_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
static gboolean gst_omx_audio_enc_start (GstBaseAudioEncoder * encoder);
|
||||
static gboolean gst_omx_audio_enc_stop (GstBaseAudioEncoder * encoder);
|
||||
static gboolean gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder,
|
||||
GstAudioState * state);
|
||||
static gboolean gst_omx_audio_enc_event (GstBaseAudioEncoder * encoder,
|
||||
static gboolean gst_omx_audio_enc_start (GstAudioEncoder * encoder);
|
||||
static gboolean gst_omx_audio_enc_stop (GstAudioEncoder * encoder);
|
||||
static gboolean gst_omx_audio_enc_set_format (GstAudioEncoder * encoder,
|
||||
GstAudioInfo * info);
|
||||
static gboolean gst_omx_audio_enc_event (GstAudioEncoder * encoder,
|
||||
GstEvent * event);
|
||||
static GstFlowReturn gst_omx_audio_enc_handle_frame (GstBaseAudioEncoder *
|
||||
static GstFlowReturn gst_omx_audio_enc_handle_frame (GstAudioEncoder *
|
||||
encoder, GstBuffer * buffer);
|
||||
static void gst_omx_audio_enc_flush (GstBaseAudioEncoder * encoder);
|
||||
static void gst_omx_audio_enc_flush (GstAudioEncoder * encoder);
|
||||
|
||||
static GstFlowReturn gst_omx_audio_enc_drain (GstOMXAudioEnc * self);
|
||||
|
||||
|
@ -60,8 +60,8 @@ enum
|
|||
GST_DEBUG_CATEGORY_INIT (gst_omx_audio_enc_debug_category, "omxaudioenc", 0, \
|
||||
"debug category for gst-omx audio encoder base class");
|
||||
|
||||
GST_BOILERPLATE_FULL (GstOMXAudioEnc, gst_omx_audio_enc, GstBaseAudioEncoder,
|
||||
GST_TYPE_BASE_AUDIO_ENCODER, DEBUG_INIT);
|
||||
GST_BOILERPLATE_FULL (GstOMXAudioEnc, gst_omx_audio_enc, GstAudioEncoder,
|
||||
GST_TYPE_AUDIO_ENCODER, DEBUG_INIT);
|
||||
|
||||
static void
|
||||
gst_omx_audio_enc_base_init (gpointer g_class)
|
||||
|
@ -203,22 +203,21 @@ gst_omx_audio_enc_class_init (GstOMXAudioEncClass * klass)
|
|||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
GstBaseAudioEncoderClass *base_audio_encoder_class =
|
||||
GST_BASE_AUDIO_ENCODER_CLASS (klass);
|
||||
GstAudioEncoderClass *audio_encoder_class = GST_AUDIO_ENCODER_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = gst_omx_audio_enc_finalize;
|
||||
|
||||
element_class->change_state =
|
||||
GST_DEBUG_FUNCPTR (gst_omx_audio_enc_change_state);
|
||||
|
||||
base_audio_encoder_class->start = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_start);
|
||||
base_audio_encoder_class->stop = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_stop);
|
||||
base_audio_encoder_class->flush = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_flush);
|
||||
base_audio_encoder_class->set_format =
|
||||
audio_encoder_class->start = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_start);
|
||||
audio_encoder_class->stop = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_stop);
|
||||
audio_encoder_class->flush = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_flush);
|
||||
audio_encoder_class->set_format =
|
||||
GST_DEBUG_FUNCPTR (gst_omx_audio_enc_set_format);
|
||||
base_audio_encoder_class->handle_frame =
|
||||
audio_encoder_class->handle_frame =
|
||||
GST_DEBUG_FUNCPTR (gst_omx_audio_enc_handle_frame);
|
||||
base_audio_encoder_class->event = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_event);
|
||||
audio_encoder_class->event = GST_DEBUG_FUNCPTR (gst_omx_audio_enc_event);
|
||||
|
||||
klass->default_sink_template_caps = "audio/x-raw-int, "
|
||||
"rate = (int) [ 1, MAX ], "
|
||||
|
@ -432,31 +431,32 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!GST_PAD_CAPS (GST_BASE_AUDIO_ENCODER_SRC_PAD (self))
|
||||
if (!GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (self))
|
||||
|| acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURED) {
|
||||
GstAudioState *state = &GST_BASE_AUDIO_ENCODER (self)->ctx->state;
|
||||
GstAudioInfo *info =
|
||||
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (self));
|
||||
GstCaps *caps;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Port settings have changed, updating caps");
|
||||
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
caps = klass->get_caps (self, self->out_port, state);
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
caps = klass->get_caps (self, self->out_port, info);
|
||||
if (!caps) {
|
||||
if (buf)
|
||||
gst_omx_port_release_buffer (self->out_port, buf);
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
goto caps_failed;
|
||||
}
|
||||
|
||||
if (!gst_pad_set_caps (GST_BASE_AUDIO_ENCODER_SRC_PAD (self), caps)) {
|
||||
if (!gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (self), caps)) {
|
||||
gst_caps_unref (caps);
|
||||
if (buf)
|
||||
gst_omx_port_release_buffer (self->out_port, buf);
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
goto caps_failed;
|
||||
}
|
||||
gst_caps_unref (caps);
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
/* Now get a buffer */
|
||||
if (acq_return != GST_OMX_ACQUIRE_BUFFER_OK)
|
||||
|
@ -468,7 +468,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %lu", buf->omx_buf->nFlags,
|
||||
buf->omx_buf->nTimeStamp);
|
||||
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
is_eos = ! !(buf->omx_buf->nFlags & OMX_BUFFERFLAG_EOS);
|
||||
|
||||
if ((buf->omx_buf->nFlags & OMX_BUFFERFLAG_CODECCONFIG)
|
||||
|
@ -476,18 +476,18 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
GstCaps *caps;
|
||||
GstBuffer *codec_data;
|
||||
|
||||
caps = gst_caps_copy (GST_PAD_CAPS (GST_BASE_AUDIO_ENCODER_SRC_PAD (self)));
|
||||
caps = gst_caps_copy (GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (self)));
|
||||
codec_data = gst_buffer_new_and_alloc (buf->omx_buf->nFilledLen);
|
||||
memcpy (GST_BUFFER_DATA (codec_data),
|
||||
buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
|
||||
buf->omx_buf->nFilledLen);
|
||||
|
||||
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, codec_data, NULL);
|
||||
if (!gst_pad_set_caps (GST_BASE_AUDIO_ENCODER_SRC_PAD (self), caps)) {
|
||||
if (!gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (self), caps)) {
|
||||
gst_caps_unref (caps);
|
||||
if (buf)
|
||||
gst_omx_port_release_buffer (self->out_port, buf);
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
goto caps_failed;
|
||||
}
|
||||
gst_caps_unref (caps);
|
||||
|
@ -498,7 +498,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
|
||||
n_samples =
|
||||
klass->get_num_samples (self, self->out_port,
|
||||
&GST_BASE_AUDIO_ENCODER (self)->ctx->state, buf);
|
||||
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (self)), buf);
|
||||
|
||||
if (buf->omx_buf->nFilledLen > 0) {
|
||||
outbuf = gst_buffer_new_and_alloc (buf->omx_buf->nFilledLen);
|
||||
|
@ -511,7 +511,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
}
|
||||
|
||||
gst_buffer_set_caps (outbuf,
|
||||
GST_PAD_CAPS (GST_BASE_AUDIO_ENCODER_SRC_PAD (self)));
|
||||
GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (self)));
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) =
|
||||
gst_util_uint64_scale (buf->omx_buf->nTimeStamp, GST_SECOND,
|
||||
|
@ -522,7 +522,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
OMX_TICKS_PER_SECOND);
|
||||
|
||||
flow_ret =
|
||||
gst_base_audio_encoder_finish_frame (GST_BASE_AUDIO_ENCODER (self),
|
||||
gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (self),
|
||||
outbuf, n_samples);
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self)
|
|||
if (flow_ret != GST_FLOW_OK)
|
||||
goto flow_error;
|
||||
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
return;
|
||||
|
||||
|
@ -558,9 +558,8 @@ component_error:
|
|||
("OpenMAX component in error state %s (0x%08x)",
|
||||
gst_omx_component_get_last_error_string (self->component),
|
||||
gst_omx_component_get_last_error (self->component)));
|
||||
gst_pad_push_event (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (self), gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
self->downstream_flow_ret = GST_FLOW_ERROR;
|
||||
self->started = FALSE;
|
||||
return;
|
||||
|
@ -568,7 +567,7 @@ component_error:
|
|||
flushing:
|
||||
{
|
||||
GST_DEBUG_OBJECT (self, "Flushing -- stopping task");
|
||||
gst_pad_pause_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
self->downstream_flow_ret = GST_FLOW_WRONG_STATE;
|
||||
self->started = FALSE;
|
||||
return;
|
||||
|
@ -578,29 +577,28 @@ flow_error:
|
|||
if (flow_ret == GST_FLOW_UNEXPECTED) {
|
||||
GST_DEBUG_OBJECT (self, "EOS");
|
||||
|
||||
gst_pad_push_event (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
} else if (flow_ret == GST_FLOW_NOT_LINKED
|
||||
|| flow_ret < GST_FLOW_UNEXPECTED) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, FAILED, ("Internal data stream error."),
|
||||
("stream stopped, reason %s", gst_flow_get_name (flow_ret)));
|
||||
|
||||
gst_pad_push_event (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
}
|
||||
self->started = FALSE;
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
return;
|
||||
}
|
||||
reconfigure_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS, (NULL),
|
||||
("Unable to reconfigure output port"));
|
||||
gst_pad_push_event (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (self), gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
self->downstream_flow_ret = GST_FLOW_NOT_NEGOTIATED;
|
||||
self->started = FALSE;
|
||||
return;
|
||||
|
@ -608,9 +606,8 @@ reconfigure_error:
|
|||
caps_failed:
|
||||
{
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, SETTINGS, (NULL), ("Failed to set caps"));
|
||||
gst_pad_push_event (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (self), gst_event_new_eos ());
|
||||
gst_pad_pause_task (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
self->downstream_flow_ret = GST_FLOW_NOT_NEGOTIATED;
|
||||
self->started = FALSE;
|
||||
return;
|
||||
|
@ -618,7 +615,7 @@ caps_failed:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_omx_audio_enc_start (GstBaseAudioEncoder * encoder)
|
||||
gst_omx_audio_enc_start (GstAudioEncoder * encoder)
|
||||
{
|
||||
GstOMXAudioEnc *self;
|
||||
gboolean ret;
|
||||
|
@ -628,14 +625,14 @@ gst_omx_audio_enc_start (GstBaseAudioEncoder * encoder)
|
|||
self->eos = FALSE;
|
||||
self->downstream_flow_ret = GST_FLOW_OK;
|
||||
ret =
|
||||
gst_pad_start_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_pad_start_task (GST_AUDIO_ENCODER_SRC_PAD (self),
|
||||
(GstTaskFunction) gst_omx_audio_enc_loop, self);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_omx_audio_enc_stop (GstBaseAudioEncoder * encoder)
|
||||
gst_omx_audio_enc_stop (GstAudioEncoder * encoder)
|
||||
{
|
||||
GstOMXAudioEnc *self;
|
||||
|
||||
|
@ -646,7 +643,7 @@ gst_omx_audio_enc_stop (GstBaseAudioEncoder * encoder)
|
|||
gst_omx_port_set_flushing (self->in_port, TRUE);
|
||||
gst_omx_port_set_flushing (self->out_port, TRUE);
|
||||
|
||||
gst_pad_stop_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (encoder));
|
||||
gst_pad_stop_task (GST_AUDIO_ENCODER_SRC_PAD (encoder));
|
||||
|
||||
if (gst_omx_component_get_state (self->component, 0) > OMX_StateIdle)
|
||||
gst_omx_component_set_state (self->component, OMX_StateIdle);
|
||||
|
@ -666,8 +663,7 @@ gst_omx_audio_enc_stop (GstBaseAudioEncoder * encoder)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder,
|
||||
GstAudioState * state)
|
||||
gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info)
|
||||
{
|
||||
GstOMXAudioEnc *self;
|
||||
GstOMXAudioEncClass *klass;
|
||||
|
@ -683,10 +679,10 @@ gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder,
|
|||
GST_DEBUG_OBJECT (self, "Setting new caps");
|
||||
|
||||
/* Set audio encoder base class properties */
|
||||
encoder->ctx->frame_samples_min =
|
||||
gst_audio_encoder_set_frame_samples_min (encoder,
|
||||
gst_util_uint64_scale_ceil (OMX_MIN_PCMPAYLOAD_MSEC,
|
||||
GST_MSECOND * state->rate, GST_SECOND);
|
||||
encoder->ctx->frame_samples_max = 0;
|
||||
GST_MSECOND * info->rate, GST_SECOND));
|
||||
gst_audio_encoder_set_frame_samples_max (encoder, 0);
|
||||
|
||||
gst_omx_port_get_port_definition (self->in_port, &port_def);
|
||||
|
||||
|
@ -714,20 +710,22 @@ gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder,
|
|||
|
||||
GST_OMX_INIT_STRUCT (&pcm_param);
|
||||
pcm_param.nPortIndex = self->in_port->index;
|
||||
pcm_param.nChannels = state->channels;
|
||||
pcm_param.nChannels = info->channels;
|
||||
pcm_param.eNumData =
|
||||
(state->sign ? OMX_NumericalDataSigned : OMX_NumericalDataUnsigned);
|
||||
((info->finfo->flags & GST_AUDIO_FORMAT_FLAG_SIGNED) ?
|
||||
OMX_NumericalDataSigned : OMX_NumericalDataUnsigned);
|
||||
pcm_param.eEndian =
|
||||
((state->endian == G_LITTLE_ENDIAN) ? OMX_EndianLittle : OMX_EndianBig);
|
||||
((info->finfo->endianness == G_LITTLE_ENDIAN) ?
|
||||
OMX_EndianLittle : OMX_EndianBig);
|
||||
pcm_param.bInterleaved = OMX_TRUE;
|
||||
pcm_param.nBitPerSample = state->width;
|
||||
pcm_param.nSamplingRate = state->rate;
|
||||
pcm_param.nBitPerSample = info->finfo->width;
|
||||
pcm_param.nSamplingRate = info->rate;
|
||||
pcm_param.ePCMMode = OMX_AUDIO_PCMModeLinear;
|
||||
|
||||
for (i = 0; i < pcm_param.nChannels; i++) {
|
||||
OMX_AUDIO_CHANNELTYPE pos;
|
||||
|
||||
switch (state->channel_pos[i]) {
|
||||
switch (info->position[i]) {
|
||||
case GST_AUDIO_CHANNEL_POSITION_FRONT_MONO:
|
||||
case GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER:
|
||||
pos = OMX_AUDIO_ChannelCF;
|
||||
|
@ -773,7 +771,7 @@ gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder,
|
|||
}
|
||||
|
||||
if (klass->set_format) {
|
||||
if (!klass->set_format (self, self->in_port, state)) {
|
||||
if (!klass->set_format (self, self->in_port, info)) {
|
||||
GST_ERROR_OBJECT (self, "Subclass failed to set the new format");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -821,14 +819,14 @@ gst_omx_audio_enc_set_format (GstBaseAudioEncoder * encoder,
|
|||
|
||||
/* Start the srcpad loop again */
|
||||
self->downstream_flow_ret = GST_FLOW_OK;
|
||||
gst_pad_start_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_pad_start_task (GST_AUDIO_ENCODER_SRC_PAD (self),
|
||||
(GstTaskFunction) gst_omx_audio_enc_loop, encoder);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_omx_audio_enc_flush (GstBaseAudioEncoder * encoder)
|
||||
gst_omx_audio_enc_flush (GstAudioEncoder * encoder)
|
||||
{
|
||||
GstOMXAudioEnc *self;
|
||||
|
||||
|
@ -842,10 +840,10 @@ gst_omx_audio_enc_flush (GstBaseAudioEncoder * encoder)
|
|||
gst_omx_port_set_flushing (self->out_port, TRUE);
|
||||
|
||||
/* Wait until the srcpad loop is finished */
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_PAD_STREAM_LOCK (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
GST_PAD_STREAM_UNLOCK (GST_BASE_AUDIO_ENCODER_SRC_PAD (self));
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_PAD_STREAM_LOCK (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
GST_PAD_STREAM_UNLOCK (GST_AUDIO_ENCODER_SRC_PAD (self));
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
|
||||
gst_omx_port_set_flushing (self->in_port, FALSE);
|
||||
gst_omx_port_set_flushing (self->out_port, FALSE);
|
||||
|
@ -853,13 +851,12 @@ gst_omx_audio_enc_flush (GstBaseAudioEncoder * encoder)
|
|||
/* Start the srcpad loop again */
|
||||
self->downstream_flow_ret = GST_FLOW_OK;
|
||||
self->eos = FALSE;
|
||||
gst_pad_start_task (GST_BASE_AUDIO_ENCODER_SRC_PAD (self),
|
||||
gst_pad_start_task (GST_AUDIO_ENCODER_SRC_PAD (self),
|
||||
(GstTaskFunction) gst_omx_audio_enc_loop, encoder);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_omx_audio_enc_handle_frame (GstBaseAudioEncoder * encoder,
|
||||
GstBuffer * inbuf)
|
||||
gst_omx_audio_enc_handle_frame (GstAudioEncoder * encoder, GstBuffer * inbuf)
|
||||
{
|
||||
GstOMXAcquireBufferReturn acq_ret = GST_OMX_ACQUIRE_BUFFER_ERROR;
|
||||
GstOMXAudioEnc *self;
|
||||
|
@ -893,9 +890,9 @@ gst_omx_audio_enc_handle_frame (GstBaseAudioEncoder * encoder,
|
|||
/* Make sure to release the base class stream lock, otherwise
|
||||
* _loop() can't call _finish_frame() and we might block forever
|
||||
* because no input buffers are released */
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
acq_ret = gst_omx_port_acquire_buffer (self->in_port, &buf);
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
|
||||
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_ERROR) {
|
||||
goto component_error;
|
||||
|
@ -990,7 +987,7 @@ reconfigure_error:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_omx_audio_enc_event (GstBaseAudioEncoder * encoder, GstEvent * event)
|
||||
gst_omx_audio_enc_event (GstAudioEncoder * encoder, GstEvent * event)
|
||||
{
|
||||
GstOMXAudioEnc *self;
|
||||
|
||||
|
@ -1012,7 +1009,7 @@ gst_omx_audio_enc_event (GstBaseAudioEncoder * encoder, GstEvent * event)
|
|||
/* Make sure to release the base class stream lock, otherwise
|
||||
* _loop() can't call _finish_frame() and we might block forever
|
||||
* because no input buffers are released */
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
/* Send an EOS buffer to the component and let the base
|
||||
* class drop the EOS event. We will send it later when
|
||||
|
@ -1026,7 +1023,7 @@ gst_omx_audio_enc_event (GstBaseAudioEncoder * encoder, GstEvent * event)
|
|||
GST_ERROR_OBJECT (self, "Failed to acquire buffer for EOS: %d", acq_ret);
|
||||
}
|
||||
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1057,14 +1054,14 @@ gst_omx_audio_enc_drain (GstOMXAudioEnc * self)
|
|||
/* Make sure to release the base class stream lock, otherwise
|
||||
* _loop() can't call _finish_frame() and we might block forever
|
||||
* because no input buffers are released */
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
|
||||
|
||||
/* Send an EOS buffer to the component and let the base
|
||||
* class drop the EOS event. We will send it later when
|
||||
* the EOS buffer arrives on the output port. */
|
||||
acq_ret = gst_omx_port_acquire_buffer (self->in_port, &buf);
|
||||
if (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) {
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
GST_ERROR_OBJECT (self, "Failed to acquire buffer for draining: %d",
|
||||
acq_ret);
|
||||
return GST_FLOW_ERROR;
|
||||
|
@ -1078,7 +1075,7 @@ gst_omx_audio_enc_drain (GstOMXAudioEnc * self)
|
|||
g_cond_wait (self->drain_cond, self->drain_lock);
|
||||
GST_DEBUG_OBJECT (self, "Drained component");
|
||||
g_mutex_unlock (self->drain_lock);
|
||||
GST_BASE_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
GST_AUDIO_ENCODER_STREAM_LOCK (self);
|
||||
|
||||
self->started = FALSE;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define __GST_OMX_AUDIO_ENC_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstbaseaudioencoder.h"
|
||||
#include <gst/audio/gstaudioencoder.h>
|
||||
|
||||
#include "gstomx.h"
|
||||
|
||||
|
@ -46,7 +46,7 @@ typedef struct _GstOMXAudioEncClass GstOMXAudioEncClass;
|
|||
|
||||
struct _GstOMXAudioEnc
|
||||
{
|
||||
GstBaseAudioEncoder parent;
|
||||
GstAudioEncoder parent;
|
||||
|
||||
/* < protected > */
|
||||
GstOMXCore *core;
|
||||
|
@ -72,7 +72,7 @@ struct _GstOMXAudioEnc
|
|||
|
||||
struct _GstOMXAudioEncClass
|
||||
{
|
||||
GstBaseAudioEncoderClass parent_class;
|
||||
GstAudioEncoderClass parent_class;
|
||||
|
||||
const gchar *core_name;
|
||||
const gchar *component_name;
|
||||
|
@ -85,9 +85,9 @@ struct _GstOMXAudioEncClass
|
|||
|
||||
guint64 hacks;
|
||||
|
||||
gboolean (*set_format) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioState * state);
|
||||
GstCaps *(*get_caps) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioState * state);
|
||||
guint (*get_num_samples) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioState * state, GstOMXBuffer * buffer);
|
||||
gboolean (*set_format) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioInfo * info);
|
||||
GstCaps *(*get_caps) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioInfo * info);
|
||||
guint (*get_num_samples) (GstOMXAudioEnc * self, GstOMXPort * port, GstAudioInfo * info, GstOMXBuffer * buffer);
|
||||
};
|
||||
|
||||
GType gst_omx_audio_enc_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue