vaapiencode: initial port to GStreamer 1.2.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
This commit is contained in:
Wind Yuan 2013-11-07 17:42:21 +08:00 committed by Gwenole Beauchesne
parent 2e356b0f7e
commit 3e96f10cf2
3 changed files with 37 additions and 2 deletions

View file

@ -20,11 +20,11 @@
*/
#include "gst/vaapi/sysdeps.h"
#include <gst/video/videocontext.h>
#include <gst/vaapi/gstvaapidisplay.h>
#include <gst/vaapi/gstvaapiencoder_priv.h>
#include <gst/vaapi/gstvaapiencoder_objects.h>
#include "gstvaapiencode.h"
#include "gstvaapivideocontext.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideometa.h"
#include "gstvaapivideomemory.h"
@ -67,6 +67,19 @@ gst_vaapiencode_implements_iface_init (GstImplementsInterfaceClass * iface)
#endif
/* context(display) interface */
#if GST_CHECK_VERSION(1,1,0)
static void
gst_vaapiencode_set_context (GstElement * element, GstContext * context)
{
GstVaapiEncode *const encode = GST_VAAPIENCODE (element);
GstVaapiDisplay *display = NULL;
if (gst_vaapi_video_context_get_display (context, &display)) {
GST_INFO_OBJECT (element, "set display %p", display);
gst_vaapi_display_replace (&encode->display, display);
}
}
#else
static void
gst_vaapiencode_set_video_context (GstVideoContext * context,
const gchar * type, const GValue * value)
@ -81,6 +94,7 @@ gst_video_context_interface_init (GstVideoContextInterface * iface)
{
iface->set_context = gst_vaapiencode_set_video_context;
}
#endif
G_DEFINE_TYPE_WITH_CODE (GstVaapiEncode,
gst_vaapiencode, GST_TYPE_VIDEO_ENCODER,
@ -88,8 +102,11 @@ G_DEFINE_TYPE_WITH_CODE (GstVaapiEncode,
G_IMPLEMENT_INTERFACE (GST_TYPE_IMPLEMENTS_INTERFACE,
gst_vaapiencode_implements_iface_init);
#endif
#if !GST_CHECK_VERSION(1,1,0)
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_CONTEXT,
gst_video_context_interface_init))
gst_video_context_interface_init)
#endif
)
static gboolean
gst_vaapiencode_query (GstPad * pad, GstObject * parent,
@ -739,6 +756,7 @@ static void
gst_vaapiencode_class_init (GstVaapiEncodeClass * klass)
{
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
GstVideoEncoderClass *const venc_class = GST_VIDEO_ENCODER_CLASS (klass);
GST_DEBUG_CATEGORY_INIT (gst_vaapiencode_debug,
@ -758,6 +776,10 @@ gst_vaapiencode_class_init (GstVaapiEncodeClass * klass)
klass->allocate_buffer = gst_vaapiencode_default_allocate_buffer;
#if GST_CHECK_VERSION(1,1,0)
element_class->set_context = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_context);
#endif
/* Registering debug symbols for function pointers */
GST_DEBUG_REGISTER_FUNCPTR (gst_vaapiencode_get_caps);
GST_DEBUG_REGISTER_FUNCPTR (gst_vaapiencode_query);

View file

@ -24,6 +24,7 @@
#include "gstvaapiencode_h264.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideomemory.h"
#include "gst/vaapi/gstvaapiencoder_h264.h"
#include "gst/vaapi/gstvaapiencoder_h264_priv.h"
#include "gst/vaapi/gstvaapidisplay.h"
@ -38,9 +39,14 @@ GST_DEBUG_CATEGORY_STATIC (gst_vaapi_h264_encode_debug);
#define GST_CAPS_CODEC(CODEC) CODEC "; "
static const char gst_vaapiencode_h264_sink_caps_str[] =
#if GST_CHECK_VERSION(1,1,0)
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE,
"{ ENCODED, NV12, I420, YV12 }") ", "
#else
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) ", "
GST_CAPS_INTERLACED_FALSE "; "
GST_VAAPI_SURFACE_CAPS ", "
#endif
GST_CAPS_INTERLACED_FALSE;
static const char gst_vaapiencode_h264_src_caps_str[] =

View file

@ -24,6 +24,7 @@
#include "gstvaapiencode_mpeg2.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideomemory.h"
#include "gst/vaapi/gstvaapiencoder_mpeg2.h"
#include "gst/vaapi/gstvaapiencoder_mpeg2_priv.h"
#include "gst/vaapi/gstvaapidisplay.h"
@ -38,8 +39,14 @@ GST_DEBUG_CATEGORY_STATIC (gst_vaapi_mpeg2_encode_debug);
#define GST_CAPS_CODEC(CODEC) CODEC "; "
static const char gst_vaapiencode_mpeg2_sink_caps_str[] =
#if GST_CHECK_VERSION(1,1,0)
GST_VIDEO_CAPS_MAKE_WITH_FEATURES(GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE,
"{ ENCODED, NV12, I420, YV12 }") ", "
GST_CAPS_INTERLACED_FALSE;
#else
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) "; "
GST_VAAPI_SURFACE_CAPS;
#endif
static const char gst_vaapiencode_mpeg2_src_caps_str[] =
GST_CAPS_CODEC ("video/mpeg,"