static GstFlowReturn gst_omx_h264_enc_handle_output_frame (GstOMXVideoEnc * self, GstOMXPort * port, GstOMXBuffer * buf, GstVideoFrame * frame) { if (buf->omx_buf->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { /* The codec data is SPS/PPS with a startcode => bytestream stream format * For bytestream stream format the SPS/PPS is only in-stream and not * in the caps! */ if (buf->omx_buf->nFilledLen >= 4 && GST_READ_UINT32_BE (buf->omx_buf->pBuffer + buf->omx_buf->nOffset) == 0x00000001) { GstBuffer *hdrs; GST_DEBUG_OBJECT (self, "got codecconfig in byte-stream format"); buf->omx_buf->nFlags &= ~OMX_BUFFERFLAG_CODECCONFIG; hdrs = gst_buffer_new_and_alloc (buf->omx_buf->nFilledLen); memcpy (GST_BUFFER_DATA (hdrs), buf->omx_buf->pBuffer + buf->omx_buf->nOffset, buf->omx_buf->nFilledLen); gst_base_video_encoder_set_headers (GST_BASE_VIDEO_ENCODER (self), hdrs); gst_buffer_unref (hdrs); } } return GST_OMX_VIDEO_ENC_CLASS (parent_class)->handle_output_frame (self, port, buf, frame); }
static void gst_omx_h264_enc_class_init (GstOMXH264EncClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstVideoEncoderClass *basevideoenc_class = GST_VIDEO_ENCODER_CLASS (klass); GstOMXVideoEncClass *videoenc_class = GST_OMX_VIDEO_ENC_CLASS (klass); videoenc_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_set_format); videoenc_class->get_caps = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_get_caps); gobject_class->set_property = gst_omx_h264_enc_set_property; gobject_class->get_property = gst_omx_h264_enc_get_property; #ifdef USE_OMX_TARGET_RPI g_object_class_install_property (gobject_class, PROP_INLINESPSPPSHEADERS, g_param_spec_boolean ("inline-header", "Inline SPS/PPS headers before IDR", "Inline SPS/PPS header before IDR", GST_OMX_H264_VIDEO_ENC_INLINE_SPS_PPS_HEADERS_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_READY)); #endif g_object_class_install_property (gobject_class, PROP_PERIODICITYOFIDRFRAMES, g_param_spec_uint ("periodicty-idr", "Target Bitrate", "Periodicity of IDR frames (0xffffffff=component default)", 0, G_MAXUINT, GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_READY)); g_object_class_install_property (gobject_class, PROP_INTERVALOFCODINGINTRAFRAMES, g_param_spec_uint ("interval-intraframes", "Interval of coding Intra frames", "Interval of coding Intra frames (0xffffffff=component default)", 0, G_MAXUINT, GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_READY)); basevideoenc_class->flush = gst_omx_h264_enc_flush; basevideoenc_class->stop = gst_omx_h264_enc_stop; videoenc_class->cdata.default_src_template_caps = "video/x-h264, " "width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]"; videoenc_class->handle_output_frame = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_handle_output_frame); gst_element_class_set_static_metadata (element_class, "OpenMAX H.264 Video Encoder", "Codec/Encoder/Video", "Encode H.264 video streams", "Sebastian Dröge <*****@*****.**>"); gst_omx_set_default_role (&videoenc_class->cdata, "video_encoder.avc"); }
static void gst_omx_h264_enc_class_init (GstOMXH264EncClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstOMXVideoEncClass *videoenc_class = GST_OMX_VIDEO_ENC_CLASS (klass); gobject_class->finalize = gst_omx_h264_enc_finalize; videoenc_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_set_format); videoenc_class->get_caps = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_get_caps); videoenc_class->default_src_template_caps = "video/x-h264, " "width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]"; videoenc_class->handle_output_frame = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_handle_output_frame); }
static void gst_omx_h264_enc_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstOMXVideoEncClass *videoenc_class = GST_OMX_VIDEO_ENC_CLASS (g_class); gst_element_class_set_details_simple (element_class, "OpenMAX H.264 Video Encoder", "Codec/Encoder/Video", "Encode H.264 video streams", "Sebastian Dröge <*****@*****.**>"); /* If no role was set from the config file we set the * default H264 video encoder role */ if (!videoenc_class->component_role) videoenc_class->component_role = "video_encoder.avc"; }
static GstFlowReturn gst_omx_h264_enc_handle_output_frame (GstOMXVideoEnc * enc, GstOMXPort * port, GstOMXBuffer * buf, GstVideoCodecFrame * frame) { GstOMXH264Enc *self = GST_OMX_H264_ENC (enc); if (buf->omx_buf->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { /* The codec data is SPS/PPS with a startcode => bytestream stream format * For bytestream stream format the SPS/PPS is only in-stream and not * in the caps! */ if (buf->omx_buf->nFilledLen >= 4 && GST_READ_UINT32_BE (buf->omx_buf->pBuffer + buf->omx_buf->nOffset) == 0x00000001) { GstBuffer *hdrs; GstMapInfo map = GST_MAP_INFO_INIT; GST_DEBUG_OBJECT (self, "got codecconfig in byte-stream format"); hdrs = gst_buffer_new_and_alloc (buf->omx_buf->nFilledLen); gst_buffer_map (hdrs, &map, GST_MAP_WRITE); memcpy (map.data, buf->omx_buf->pBuffer + buf->omx_buf->nOffset, buf->omx_buf->nFilledLen); gst_buffer_unmap (hdrs, &map); self->headers = g_list_append (self->headers, hdrs); if (frame) gst_video_codec_frame_unref (frame); return GST_FLOW_OK; } } else if (self->headers) { gst_video_encoder_set_headers (GST_VIDEO_ENCODER (self), self->headers); self->headers = NULL; } return GST_OMX_VIDEO_ENC_CLASS (gst_omx_h264_enc_parent_class)->handle_output_frame (enc, port, buf, frame); }
static void gst_omx_h264_enc_class_init (GstOMXH264EncClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstOMXVideoEncClass *videoenc_class = GST_OMX_VIDEO_ENC_CLASS (klass); videoenc_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_set_format); videoenc_class->get_caps = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_get_caps); videoenc_class->cdata.default_src_template_caps = "video/x-h264, " "width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]"; videoenc_class->handle_output_frame = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_handle_output_frame); gst_element_class_set_static_metadata (element_class, "OpenMAX H.264 Video Encoder", "Codec/Encoder/Video", "Encode H.264 video streams", "Sebastian Dröge <*****@*****.**>"); gst_omx_set_default_role (&videoenc_class->cdata, "video_encoder.avc"); }
static void gst_omx_mpeg4_video_enc_class_init (GstOMXMPEG4VideoEncClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstOMXVideoEncClass *videoenc_class = GST_OMX_VIDEO_ENC_CLASS (klass); videoenc_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_enc_set_format); videoenc_class->get_caps = GST_DEBUG_FUNCPTR (gst_omx_mpeg4_video_enc_get_caps); videoenc_class->cdata.default_src_template_caps = "video/mpeg, " "mpegversion=(int) 4, " "systemstream=(boolean) false, " "width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]"; gst_element_class_set_details_simple (element_class, "OpenMAX MPEG4 Video Encoder", "Codec/Encoder/Video", "Encode MPEG4 video streams", "Sebastian Dröge <*****@*****.**>"); gst_omx_set_default_role (&videoenc_class->cdata, "video_encoder.mpeg4"); }