mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
Implement basic wrapper around MediaCodec API
Ideally nothing else will be needed from the elements later.
This commit is contained in:
parent
f99214a657
commit
d0ebf261ff
3 changed files with 1706 additions and 43 deletions
192
sys/androidmedia/gstamc-constants.h
Normal file
192
sys/androidmedia/gstamc-constants.h
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2012, Collabora Ltd.
|
||||||
|
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>, Collabora Ltd.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation
|
||||||
|
* version 2.1 of the License.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GST_AMC_CONSTANTS_H__
|
||||||
|
#define __GST_AMC_CONSTANTS_H__
|
||||||
|
|
||||||
|
/* FIXME: We might need to get these values from Java if there's
|
||||||
|
* ever a device or Android version that changes these values
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Copies from MediaCodec.java */
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BUFFER_FLAG_SYNC_FRAME = 1,
|
||||||
|
BUFFER_FLAG_CODEC_CONFIG = 2,
|
||||||
|
BUFFER_FLAG_END_OF_STREAM = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CONFIGURE_FLAG_ENCODE = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
INFO_TRY_AGAIN_LATER = -1,
|
||||||
|
INFO_OUTPUT_FORMAT_CHANGED = -2,
|
||||||
|
INFO_OUTPUT_BUFFERS_CHANGED = -3
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Copies from MediaCodecInfo.java */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
COLOR_FormatMonochrome = 1,
|
||||||
|
COLOR_Format8bitRGB332 = 2,
|
||||||
|
COLOR_Format12bitRGB444 = 3,
|
||||||
|
COLOR_Format16bitARGB4444 = 4,
|
||||||
|
COLOR_Format16bitARGB1555 = 5,
|
||||||
|
COLOR_Format16bitRGB565 = 6,
|
||||||
|
COLOR_Format16bitBGR565 = 7,
|
||||||
|
COLOR_Format18bitRGB666 = 8,
|
||||||
|
COLOR_Format18bitARGB1665 = 9,
|
||||||
|
COLOR_Format19bitARGB1666 = 10,
|
||||||
|
COLOR_Format24bitRGB888 = 11,
|
||||||
|
COLOR_Format24bitBGR888 = 12,
|
||||||
|
COLOR_Format24bitARGB1887 = 13,
|
||||||
|
COLOR_Format25bitARGB1888 = 14,
|
||||||
|
COLOR_Format32bitBGRA8888 = 15,
|
||||||
|
COLOR_Format32bitARGB8888 = 16,
|
||||||
|
COLOR_FormatYUV411Planar = 17,
|
||||||
|
COLOR_FormatYUV411PackedPlanar = 18,
|
||||||
|
COLOR_FormatYUV420Planar = 19,
|
||||||
|
COLOR_FormatYUV420PackedPlanar = 20,
|
||||||
|
COLOR_FormatYUV420SemiPlanar = 21,
|
||||||
|
COLOR_FormatYUV422Planar = 22,
|
||||||
|
COLOR_FormatYUV422PackedPlanar = 23,
|
||||||
|
COLOR_FormatYUV422SemiPlanar = 24,
|
||||||
|
COLOR_FormatYCbYCr = 25,
|
||||||
|
COLOR_FormatYCrYCb = 26,
|
||||||
|
COLOR_FormatCbYCrY = 27,
|
||||||
|
COLOR_FormatCrYCbY = 28,
|
||||||
|
COLOR_FormatYUV444Interleaved = 29,
|
||||||
|
COLOR_FormatRawBayer8bit = 30,
|
||||||
|
COLOR_FormatRawBayer10bit = 31,
|
||||||
|
COLOR_FormatRawBayer8bitcompressed = 32,
|
||||||
|
COLOR_FormatL2 = 33,
|
||||||
|
COLOR_FormatL4 = 34,
|
||||||
|
COLOR_FormatL8 = 35,
|
||||||
|
COLOR_FormatL16 = 36
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
AVCProfileBaseline = 0x01,
|
||||||
|
AVCProfileMain = 0x02,
|
||||||
|
AVCProfileExtended = 0x04,
|
||||||
|
AVCProfileHigh = 0x08,
|
||||||
|
AVCProfileHigh10 = 0x10,
|
||||||
|
AVCProfileHigh422 = 0x20,
|
||||||
|
AVCProfileHigh444 = 0x40
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
AVCLevel1 = 0x01,
|
||||||
|
AVCLevel1b = 0x02,
|
||||||
|
AVCLevel11 = 0x04,
|
||||||
|
AVCLevel12 = 0x08,
|
||||||
|
AVCLevel13 = 0x10,
|
||||||
|
AVCLevel2 = 0x20,
|
||||||
|
AVCLevel21 = 0x40,
|
||||||
|
AVCLevel22 = 0x80,
|
||||||
|
AVCLevel3 = 0x100,
|
||||||
|
AVCLevel31 = 0x200,
|
||||||
|
AVCLevel32 = 0x400,
|
||||||
|
AVCLevel4 = 0x800,
|
||||||
|
AVCLevel41 = 0x1000,
|
||||||
|
AVCLevel42 = 0x2000,
|
||||||
|
AVCLevel5 = 0x4000,
|
||||||
|
AVCLevel51 = 0x8000
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
H263ProfileBaseline = 0x01,
|
||||||
|
H263ProfileH320Coding = 0x02,
|
||||||
|
H263ProfileBackwardCompatible = 0x04,
|
||||||
|
H263ProfileISWV2 = 0x08,
|
||||||
|
H263ProfileISWV3 = 0x10,
|
||||||
|
H263ProfileHighCompression = 0x20,
|
||||||
|
H263ProfileInternet = 0x40,
|
||||||
|
H263ProfileInterlace = 0x80,
|
||||||
|
H263ProfileHighLatency = 0x100
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
H263Level10 = 0x01,
|
||||||
|
H263Level20 = 0x02,
|
||||||
|
H263Level30 = 0x04,
|
||||||
|
H263Level40 = 0x08,
|
||||||
|
H263Level45 = 0x10,
|
||||||
|
H263Level50 = 0x20,
|
||||||
|
H263Level60 = 0x40,
|
||||||
|
H263Level70 = 0x80
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MPEG4ProfileSimple = 0x01,
|
||||||
|
MPEG4ProfileSimpleScalable = 0x02,
|
||||||
|
MPEG4ProfileCore = 0x04,
|
||||||
|
MPEG4ProfileMain = 0x08,
|
||||||
|
MPEG4ProfileNbit = 0x10,
|
||||||
|
MPEG4ProfileScalableTexture = 0x20,
|
||||||
|
MPEG4ProfileSimpleFace = 0x40,
|
||||||
|
MPEG4ProfileSimpleFBA = 0x80,
|
||||||
|
MPEG4ProfileBasicAnimated = 0x100,
|
||||||
|
MPEG4ProfileHybrid = 0x200,
|
||||||
|
MPEG4ProfileAdvancedRealTime = 0x400,
|
||||||
|
MPEG4ProfileCoreScalable = 0x800,
|
||||||
|
MPEG4ProfileAdvancedCoding = 0x1000,
|
||||||
|
MPEG4ProfileAdvancedCore = 0x2000,
|
||||||
|
MPEG4ProfileAdvancedScalable = 0x4000,
|
||||||
|
MPEG4ProfileAdvancedSimple = 0x8000
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MPEG4Level0 = 0x01,
|
||||||
|
MPEG4Level0b = 0x02,
|
||||||
|
MPEG4Level1 = 0x04,
|
||||||
|
MPEG4Level2 = 0x08,
|
||||||
|
MPEG4Level3 = 0x10,
|
||||||
|
MPEG4Level4 = 0x20,
|
||||||
|
MPEG4Level4a = 0x40,
|
||||||
|
MPEG4Level5 = 0x80
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
AACObjectMain = 1,
|
||||||
|
AACObjectLC = 2,
|
||||||
|
AACObjectSSR = 3,
|
||||||
|
AACObjectLTP = 4,
|
||||||
|
AACObjectHE = 5,
|
||||||
|
AACObjectScalable = 6,
|
||||||
|
AACObjectERLC = 17,
|
||||||
|
AACObjectLD = 23,
|
||||||
|
AACObjectHE_PS = 29,
|
||||||
|
AACObjectELD = 39
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -22,6 +22,7 @@
|
||||||
#define __GST_AMC_H__
|
#define __GST_AMC_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <gst/video/video.h>
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -29,7 +30,7 @@ G_BEGIN_DECLS
|
||||||
typedef struct _GstAmcCodecInfo GstAmcCodecInfo;
|
typedef struct _GstAmcCodecInfo GstAmcCodecInfo;
|
||||||
typedef struct _GstAmcCodecType GstAmcCodecType;
|
typedef struct _GstAmcCodecType GstAmcCodecType;
|
||||||
typedef struct _GstAmcCodec GstAmcCodec;
|
typedef struct _GstAmcCodec GstAmcCodec;
|
||||||
typedef struct _GstAmcCodecBufferInfo GstAmcBufferInfo;
|
typedef struct _GstAmcBufferInfo GstAmcBufferInfo;
|
||||||
typedef struct _GstAmcFormat GstAmcFormat;
|
typedef struct _GstAmcFormat GstAmcFormat;
|
||||||
typedef struct _GstAmcBuffer GstAmcBuffer;
|
typedef struct _GstAmcBuffer GstAmcBuffer;
|
||||||
|
|
||||||
|
@ -54,49 +55,48 @@ struct _GstAmcCodecInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAmcBuffer {
|
struct _GstAmcBuffer {
|
||||||
|
jobject object; /* global reference */
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize len;
|
gsize size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAmcFormat {
|
struct _GstAmcFormat {
|
||||||
/* < private > */
|
/* < private > */
|
||||||
jobject format; /* global reference */
|
jobject object; /* global reference */
|
||||||
jclass format_class; /* global reference */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAmcCodec {
|
struct _GstAmcCodec {
|
||||||
/* < private > */
|
/* < private > */
|
||||||
jobject codec; /* global reference */
|
jobject object; /* global reference */
|
||||||
jclass codec_class; /* global reference */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAmcBufferInfo {
|
struct _GstAmcBufferInfo {
|
||||||
gint flags;
|
gint flags;
|
||||||
gint offset;
|
gint offset;
|
||||||
gint64 presentationTimeUs;
|
gint64 presentation_time_us;
|
||||||
gint size;
|
gint size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GstAmcCodec * gst_amc_codec_new (const gchar *name);
|
GstAmcCodec * gst_amc_codec_new (const gchar *name);
|
||||||
void gst_amc_codec_free (GstAmcCodec * codec);
|
void gst_amc_codec_free (GstAmcCodec * codec);
|
||||||
|
|
||||||
void gst_amc_codec_configure (GstAmcCodec * codec, gint flags);
|
gboolean gst_amc_codec_configure (GstAmcCodec * codec, GstAmcFormat * format, gint flags);
|
||||||
GstAmcFormat * gst_amc_codec_get_output_format (GstAmcCodec * codec);
|
GstAmcFormat * gst_amc_codec_get_output_format (GstAmcCodec * codec);
|
||||||
|
|
||||||
void gst_amc_codec_start (GstAmcCodec * codec);
|
gboolean gst_amc_codec_start (GstAmcCodec * codec);
|
||||||
void gst_amc_codec_stop (GstAmcCodec * codec);
|
gboolean gst_amc_codec_stop (GstAmcCodec * codec);
|
||||||
void gst_amc_codec_flush (GstAmcCodec * codec);
|
gboolean gst_amc_codec_flush (GstAmcCodec * codec);
|
||||||
|
gboolean gst_amc_codec_release (GstAmcCodec * codec);
|
||||||
|
|
||||||
GstAmcBuffer * gst_amc_codec_get_output_buffers (GstAmcCodec * codec, gsize * n_buffers);
|
GstAmcBuffer * gst_amc_codec_get_output_buffers (GstAmcCodec * codec, gsize * n_buffers);
|
||||||
GstAmcBuffer * gst_amc_codec_get_input_buffers (GstAmcCodec * codec, gsize * n_buffers);
|
GstAmcBuffer * gst_amc_codec_get_input_buffers (GstAmcCodec * codec, gsize * n_buffers);
|
||||||
|
void gst_amc_codec_free_buffers (GstAmcBuffer * buffers, gsize n_buffers);
|
||||||
|
|
||||||
gint gst_amc_codec_dequeue_input_buffer (GstAmcCodec * codec, gint64 timeoutUs);
|
gint gst_amc_codec_dequeue_input_buffer (GstAmcCodec * codec, gint64 timeoutUs);
|
||||||
gint gst_amc_codec_dequeue_output_buffer (GstAmcCodec * codec, GstAmcBufferInfo *info, gint64 timeoutUs);
|
gint gst_amc_codec_dequeue_output_buffer (GstAmcCodec * codec, GstAmcBufferInfo *info, gint64 timeoutUs);
|
||||||
|
|
||||||
void gst_amc_codec_queue_input_buffer (GstAmcCodec * codec, gint index, const GstAmcBufferInfo *info);
|
gboolean gst_amc_codec_queue_input_buffer (GstAmcCodec * codec, gint index, const GstAmcBufferInfo *info);
|
||||||
void gst_amc_codec_release_output_buffer (GstAmcCodec * codec, gint index);
|
gboolean gst_amc_codec_release_output_buffer (GstAmcCodec * codec, gint index);
|
||||||
|
|
||||||
|
|
||||||
GstAmcFormat * gst_amc_format_new_audio (const gchar *mime, gint sample_rate, gint channels);
|
GstAmcFormat * gst_amc_format_new_audio (const gchar *mime, gint sample_rate, gint channels);
|
||||||
|
@ -106,12 +106,30 @@ void gst_amc_format_free (GstAmcFormat * format);
|
||||||
gboolean gst_amc_format_contains_key (GstAmcFormat *format, const gchar *key);
|
gboolean gst_amc_format_contains_key (GstAmcFormat *format, const gchar *key);
|
||||||
|
|
||||||
gboolean gst_amc_format_get_float (GstAmcFormat *format, const gchar *key, gfloat *value);
|
gboolean gst_amc_format_get_float (GstAmcFormat *format, const gchar *key, gfloat *value);
|
||||||
void gst_amc_format_set_float (GstAmcFormat *format, const gchar *key, gfloat *value);
|
void gst_amc_format_set_float (GstAmcFormat *format, const gchar *key, gfloat value);
|
||||||
gboolean gst_amc_format_get_int (GstAmcFormat *format, const gchar *key, gint *value);
|
gboolean gst_amc_format_get_int (GstAmcFormat *format, const gchar *key, gint *value);
|
||||||
void gst_amc_format_set_int (GstAmcFormat *format, const gchar *key, gint *value);
|
void gst_amc_format_set_int (GstAmcFormat *format, const gchar *key, gint value);
|
||||||
gboolean gst_amc_format_get_string (GstAmcFormat *format, const gchar *key, gchar **value);
|
gboolean gst_amc_format_get_string (GstAmcFormat *format, const gchar *key, gchar **value);
|
||||||
void gst_amc_format_set_string (GstAmcFormat *format, const gchar *key, const gchar *value);
|
void gst_amc_format_set_string (GstAmcFormat *format, const gchar *key, const gchar *value);
|
||||||
|
|
||||||
|
GstVideoFormat gst_amc_color_format_to_video_format (gint color_format);
|
||||||
|
gint gst_amc_video_format_to_color_format (GstVideoFormat video_format);
|
||||||
|
|
||||||
|
const gchar * gst_amc_avc_profile_to_string (gint profile);
|
||||||
|
gint gst_amc_avc_profile_from_string (const gchar *profile);
|
||||||
|
const gchar * gst_amc_avc_level_to_string (gint level);
|
||||||
|
gint gst_amc_avc_level_from_string (const gchar *level);
|
||||||
|
gint gst_amc_h263_profile_to_gst_id (gint profile);
|
||||||
|
gint gst_amc_h263_profile_from_gst_id (gint profile);
|
||||||
|
gint gst_amc_h263_level_to_gst_id (gint level);
|
||||||
|
gint gst_amc_h263_level_from_gst_id (gint level);
|
||||||
|
const gchar * gst_amc_mpeg4_profile_to_string (gint profile);
|
||||||
|
gint gst_amc_avc_mpeg4_profile_from_string (const gchar *profile);
|
||||||
|
const gchar * gst_amc_mpeg4_level_to_string (gint level);
|
||||||
|
gint gst_amc_mpeg4_level_from_string (const gchar *level);
|
||||||
|
const gchar * gst_amc_aac_profile_to_string (gint profile);
|
||||||
|
gint gst_amc_aac_profile_from_string (const gchar *profile);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_AMC_H__ */
|
#endif /* __GST_AMC_H__ */
|
||||||
|
|
Loading…
Reference in a new issue