gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2008 Axis Communications <dev-gstreamer@axis.com>
|
|
|
|
* @author Bjorn Ostby <bjorn.ostby@axis.com>
|
|
|
|
* @author Peter Kjellerstedt <peter.kjellerstedt@axis.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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-08 14:17:06 +00:00
|
|
|
* SECTION:element-rtpjpegpay
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
*
|
|
|
|
* Payload encode JPEG pictures into RTP packets according to RFC 2435.
|
|
|
|
* For detailed information see: http://www.rfc-editor.org/rfc/rfc2435.txt
|
|
|
|
*
|
|
|
|
* The payloader takes a JPEG picture, scans the header for quantization
|
|
|
|
* tables (if needed) and constructs the RTP packet header followed by
|
|
|
|
* the actual JPEG entropy scan.
|
|
|
|
*
|
|
|
|
* The payloader assumes that correct width and height is found in the caps.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <gst/rtp/gstrtpbuffer.h>
|
|
|
|
|
|
|
|
#include "gstrtpjpegpay.h"
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2013-05-31 13:08:16 +00:00
|
|
|
GST_STATIC_CAPS ("image/jpeg; " "video/x-jpeg")
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("application/x-rtp, "
|
|
|
|
" media = (string) \"video\", "
|
|
|
|
" payload = (int) 26 , "
|
2013-05-20 19:44:13 +00:00
|
|
|
" clock-rate = (int) 90000, "
|
|
|
|
" encoding-name = (string) \"JPEG\", "
|
2013-06-26 18:49:41 +00:00
|
|
|
" width = (int) [ 1, 65536 ], " " height = (int) [ 1, 65536 ]")
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (rtpjpegpay_debug);
|
|
|
|
#define GST_CAT_DEFAULT (rtpjpegpay_debug)
|
|
|
|
|
2009-01-28 10:29:42 +00:00
|
|
|
/*
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
* QUANT_PREFIX_LEN:
|
|
|
|
*
|
|
|
|
* Prefix length in the header before the quantization tables:
|
|
|
|
* Two size bytes and one byte for precision
|
|
|
|
*/
|
|
|
|
#define QUANT_PREFIX_LEN 3
|
|
|
|
|
2009-06-19 15:57:12 +00:00
|
|
|
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
typedef enum _RtpJpegMarker RtpJpegMarker;
|
|
|
|
|
2009-01-28 10:29:42 +00:00
|
|
|
/*
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
* RtpJpegMarker:
|
|
|
|
* @JPEG_MARKER: Prefix for JPEG marker
|
|
|
|
* @JPEG_MARKER_SOI: Start of Image marker
|
|
|
|
* @JPEG_MARKER_JFIF: JFIF marker
|
|
|
|
* @JPEG_MARKER_CMT: Comment marker
|
|
|
|
* @JPEG_MARKER_DQT: Define Quantization Table marker
|
|
|
|
* @JPEG_MARKER_SOF: Start of Frame marker
|
|
|
|
* @JPEG_MARKER_DHT: Define Huffman Table marker
|
|
|
|
* @JPEG_MARKER_SOS: Start of Scan marker
|
|
|
|
* @JPEG_MARKER_EOI: End of Image marker
|
2010-09-10 15:35:53 +00:00
|
|
|
* @JPEG_MARKER_DRI: Define Restart Interval marker
|
2011-08-03 08:09:42 +00:00
|
|
|
* @JPEG_MARKER_H264: H264 marker
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
*
|
|
|
|
* Identifers for markers in JPEG header
|
|
|
|
*/
|
|
|
|
enum _RtpJpegMarker
|
|
|
|
{
|
|
|
|
JPEG_MARKER = 0xFF,
|
|
|
|
JPEG_MARKER_SOI = 0xD8,
|
|
|
|
JPEG_MARKER_JFIF = 0xE0,
|
|
|
|
JPEG_MARKER_CMT = 0xFE,
|
|
|
|
JPEG_MARKER_DQT = 0xDB,
|
|
|
|
JPEG_MARKER_SOF = 0xC0,
|
|
|
|
JPEG_MARKER_DHT = 0xC4,
|
|
|
|
JPEG_MARKER_SOS = 0xDA,
|
|
|
|
JPEG_MARKER_EOI = 0xD9,
|
2011-08-03 08:09:42 +00:00
|
|
|
JPEG_MARKER_DRI = 0xDD,
|
|
|
|
JPEG_MARKER_H264 = 0xE4
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
};
|
|
|
|
|
2009-05-05 14:32:17 +00:00
|
|
|
#define DEFAULT_JPEG_QUANT 255
|
|
|
|
|
|
|
|
#define DEFAULT_JPEG_QUALITY 255
|
|
|
|
#define DEFAULT_JPEG_TYPE 1
|
|
|
|
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_JPEG_QUALITY,
|
2009-06-19 15:57:12 +00:00
|
|
|
PROP_JPEG_TYPE,
|
|
|
|
PROP_LAST
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
Q_TABLE_0 = 0,
|
|
|
|
Q_TABLE_1,
|
|
|
|
Q_TABLE_MAX /* only support for two tables at the moment */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _RtpJpegHeader RtpJpegHeader;
|
|
|
|
|
2009-01-28 10:29:42 +00:00
|
|
|
/*
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
* RtpJpegHeader:
|
|
|
|
* @type_spec: type specific
|
|
|
|
* @offset: fragment offset
|
|
|
|
* @type: type field
|
|
|
|
* @q: quantization table for this frame
|
|
|
|
* @width: width of image in 8-pixel multiples
|
|
|
|
* @height: height of image in 8-pixel multiples
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Type-specific | Fragment Offset |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Type | Q | Width | Height |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
struct _RtpJpegHeader
|
|
|
|
{
|
|
|
|
guint type_spec:8;
|
|
|
|
guint offset:24;
|
|
|
|
guint8 type;
|
|
|
|
guint8 q;
|
|
|
|
guint8 width;
|
|
|
|
guint8 height;
|
|
|
|
};
|
|
|
|
|
2009-01-28 10:29:42 +00:00
|
|
|
/*
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
* RtpQuantHeader
|
|
|
|
* @mbz: must be zero
|
|
|
|
* @precision: specify size of quantization tables
|
|
|
|
* @length: length of quantization data
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | MBZ | Precision | Length |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Quantization Table Data |
|
|
|
|
* | ... |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
2009-05-06 14:09:13 +00:00
|
|
|
typedef struct
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
{
|
|
|
|
guint8 mbz;
|
|
|
|
guint8 precision;
|
|
|
|
guint16 length;
|
2009-05-06 14:09:13 +00:00
|
|
|
} RtpQuantHeader;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
guint8 size;
|
|
|
|
const guint8 *data;
|
|
|
|
} RtpQuantTable;
|
|
|
|
|
2010-09-10 15:35:53 +00:00
|
|
|
/*
|
|
|
|
* RtpRestartMarkerHeader:
|
|
|
|
* @restartInterval: number of MCUs that appear between restart markers
|
|
|
|
* @restartFirstLastCount: a combination of the first packet mark in the chunk
|
2010-09-13 15:31:35 +00:00
|
|
|
* last packet mark in the chunk and the position of the
|
2010-09-10 15:35:53 +00:00
|
|
|
* first restart interval in the current "chunk"
|
|
|
|
*
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Restart Interval |F|L| Restart Count |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*
|
|
|
|
* The restart marker header is implemented according to the following
|
|
|
|
* methodology specified in section 3.1.7 of rfc2435.txt.
|
|
|
|
*
|
|
|
|
* "If the restart intervals in a frame are not guaranteed to be aligned
|
|
|
|
* with packet boundaries, the F (first) and L (last) bits MUST be set
|
|
|
|
* to 1 and the Restart Count MUST be set to 0x3FFF. This indicates
|
|
|
|
* that a receiver MUST reassemble the entire frame before decoding it."
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct
|
2010-09-13 15:31:35 +00:00
|
|
|
{
|
|
|
|
guint16 restart_interval;
|
|
|
|
guint16 restart_count;
|
2010-09-10 15:35:53 +00:00
|
|
|
} RtpRestartMarkerHeader;
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
guint8 id;
|
|
|
|
guint8 samp;
|
|
|
|
guint8 qt;
|
|
|
|
} CompInfo;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
/* FIXME: restart marker header currently unsupported */
|
|
|
|
|
|
|
|
static void gst_rtp_jpeg_pay_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
|
|
|
|
static void gst_rtp_jpeg_pay_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
2011-11-11 11:25:01 +00:00
|
|
|
static gboolean gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload,
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
GstCaps * caps);
|
|
|
|
|
2011-11-11 11:25:01 +00:00
|
|
|
static GstFlowReturn gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * pad,
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
GstBuffer * buffer);
|
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
#define gst_rtp_jpeg_pay_parent_class parent_class
|
2011-11-11 11:25:01 +00:00
|
|
|
G_DEFINE_TYPE (GstRtpJPEGPay, gst_rtp_jpeg_pay, GST_TYPE_RTP_BASE_PAYLOAD);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtp_jpeg_pay_class_init (GstRtpJPEGPayClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2011-07-10 19:50:19 +00:00
|
|
|
GstElementClass *gstelement_class;
|
2011-11-11 11:25:01 +00:00
|
|
|
GstRTPBasePayloadClass *gstrtpbasepayload_class;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
2011-07-10 19:50:19 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2011-11-11 11:25:01 +00:00
|
|
|
gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_rtp_jpeg_pay_set_property;
|
|
|
|
gobject_class->get_property = gst_rtp_jpeg_pay_get_property;
|
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_rtp_jpeg_pay_src_template));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&gst_rtp_jpeg_pay_sink_template));
|
|
|
|
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "RTP JPEG payloader",
|
2011-07-10 19:50:19 +00:00
|
|
|
"Codec/Payloader/Network/RTP",
|
|
|
|
"Payload-encodes JPEG pictures into RTP packets (RFC 2435)",
|
|
|
|
"Axis Communications <dev-gstreamer@axis.com>");
|
|
|
|
|
2011-11-11 11:25:01 +00:00
|
|
|
gstrtpbasepayload_class->set_caps = gst_rtp_jpeg_pay_setcaps;
|
|
|
|
gstrtpbasepayload_class->handle_buffer = gst_rtp_jpeg_pay_handle_buffer;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_JPEG_QUALITY,
|
2009-05-05 14:32:17 +00:00
|
|
|
g_param_spec_int ("quality", "Quality",
|
|
|
|
"Quality factor on JPEG data (unused)", 0, 255, 255,
|
2010-10-13 14:21:23 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_JPEG_TYPE,
|
2009-05-05 14:32:17 +00:00
|
|
|
g_param_spec_int ("type", "Type",
|
|
|
|
"Default JPEG Type, overwritten by SOF when present", 0, 255,
|
2010-10-13 14:21:23 +00:00
|
|
|
DEFAULT_JPEG_TYPE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (rtpjpegpay_debug, "rtpjpegpay", 0,
|
|
|
|
"Motion JPEG RTP Payloader");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-07-10 19:50:19 +00:00
|
|
|
gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay)
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
{
|
2009-05-05 14:32:17 +00:00
|
|
|
pay->quality = DEFAULT_JPEG_QUALITY;
|
|
|
|
pay->quant = DEFAULT_JPEG_QUANT;
|
|
|
|
pay->type = DEFAULT_JPEG_TYPE;
|
2012-09-27 13:42:56 +00:00
|
|
|
pay->width = -1;
|
|
|
|
pay->height = -1;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-11 11:25:01 +00:00
|
|
|
gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
{
|
|
|
|
GstStructure *caps_structure = gst_caps_get_structure (caps, 0);
|
2009-05-05 14:32:17 +00:00
|
|
|
GstRtpJPEGPay *pay;
|
2010-02-04 14:59:25 +00:00
|
|
|
gboolean res;
|
2013-05-31 13:08:16 +00:00
|
|
|
gint width = -1, height = -1;
|
2013-05-31 13:05:51 +00:00
|
|
|
gint num = 0, denom;
|
|
|
|
gchar *rate = NULL;
|
2013-05-31 13:08:16 +00:00
|
|
|
gchar *dim = NULL;
|
|
|
|
gchar *size;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2009-05-05 14:32:17 +00:00
|
|
|
pay = GST_RTP_JPEG_PAY (basepayload);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2013-05-20 19:44:13 +00:00
|
|
|
/* these properties are mandatory, but they might be adjusted by the SOF, if there
|
2009-05-05 14:32:17 +00:00
|
|
|
* is one. */
|
2013-05-20 19:44:13 +00:00
|
|
|
if (!gst_structure_get_int (caps_structure, "height", &height) || height <= 0) {
|
|
|
|
goto invalid_dimension;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
|
2013-05-20 19:44:13 +00:00
|
|
|
if (!gst_structure_get_int (caps_structure, "width", &width) || width <= 0) {
|
|
|
|
goto invalid_dimension;
|
2012-09-27 13:42:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-20 19:34:13 +00:00
|
|
|
if (gst_structure_get_fraction (caps_structure, "framerate", &num, &denom) &&
|
|
|
|
(num < 0 || denom <= 0)) {
|
|
|
|
goto invalid_framerate;
|
|
|
|
}
|
|
|
|
|
2012-09-27 13:42:56 +00:00
|
|
|
if (height > 2040 || width > 2040) {
|
|
|
|
pay->height = 0;
|
|
|
|
pay->width = 0;
|
|
|
|
} else {
|
|
|
|
pay->height = GST_ROUND_UP_8 (height) / 8;
|
|
|
|
pay->width = GST_ROUND_UP_8 (width) / 8;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
|
2011-11-11 11:25:01 +00:00
|
|
|
gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "JPEG", 90000);
|
2012-09-27 13:42:56 +00:00
|
|
|
|
2013-06-26 18:49:41 +00:00
|
|
|
if (num > 0) {
|
2013-05-31 13:05:51 +00:00
|
|
|
gdouble framerate;
|
|
|
|
gst_util_fraction_to_double (num, denom, &framerate);
|
2013-06-26 18:49:41 +00:00
|
|
|
rate = g_strdup_printf ("%f", framerate);
|
2013-05-31 13:05:51 +00:00
|
|
|
}
|
|
|
|
|
2013-06-26 18:49:41 +00:00
|
|
|
size = g_strdup_printf ("%d-%d", width, height);
|
2013-05-31 13:08:16 +00:00
|
|
|
|
|
|
|
if (pay->width == 0) {
|
|
|
|
GST_DEBUG_OBJECT (pay,
|
|
|
|
"width or height are greater than 2040, adding x-dimensions to caps");
|
|
|
|
dim = g_strdup_printf ("%d,%d", width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rate != NULL && dim != NULL) {
|
|
|
|
res = gst_rtp_base_payload_set_outcaps (basepayload, "a-framerate",
|
|
|
|
G_TYPE_STRING, rate, "a-framesize", G_TYPE_STRING, size,
|
|
|
|
"x-dimensions", G_TYPE_STRING, dim, NULL);
|
|
|
|
} else if (rate != NULL && dim == NULL) {
|
|
|
|
res = gst_rtp_base_payload_set_outcaps (basepayload, "a-framerate",
|
|
|
|
G_TYPE_STRING, rate, "a-framesize", G_TYPE_STRING, size, NULL);
|
|
|
|
} else if (rate == NULL && dim != NULL) {
|
|
|
|
res = gst_rtp_base_payload_set_outcaps (basepayload, "x-dimensions",
|
|
|
|
G_TYPE_STRING, dim, "a-framesize", G_TYPE_STRING, size, NULL);
|
|
|
|
} else {
|
|
|
|
res = gst_rtp_base_payload_set_outcaps (basepayload, "a-framesize",
|
|
|
|
G_TYPE_STRING, size, NULL);
|
2012-09-27 13:42:56 +00:00
|
|
|
}
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2013-05-31 13:08:16 +00:00
|
|
|
if (dim != NULL)
|
|
|
|
g_free (dim);
|
2013-05-31 13:05:51 +00:00
|
|
|
if (rate != NULL)
|
|
|
|
g_free (rate);
|
2013-05-31 13:08:16 +00:00
|
|
|
g_free (size);
|
2013-05-31 13:05:51 +00:00
|
|
|
|
2010-02-04 14:59:25 +00:00
|
|
|
return res;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2009-05-05 14:32:17 +00:00
|
|
|
/* ERRORS */
|
|
|
|
invalid_dimension:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (pay, "Invalid width/height from caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-05-20 19:34:13 +00:00
|
|
|
invalid_framerate:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (pay, "Invalid framerate from caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
gst_rtp_jpeg_pay_header_size (const guint8 * data, guint offset)
|
|
|
|
{
|
|
|
|
return data[offset] << 8 | data[offset + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
2010-09-07 14:40:08 +00:00
|
|
|
gst_rtp_jpeg_pay_read_quant_table (const guint8 * data, guint size,
|
|
|
|
guint offset, RtpQuantTable tables[])
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
{
|
2010-09-07 14:40:08 +00:00
|
|
|
guint quant_size, tab_size;
|
2009-05-06 14:09:13 +00:00
|
|
|
guint8 prec;
|
|
|
|
guint8 id;
|
2009-05-05 14:32:17 +00:00
|
|
|
|
2010-09-07 14:40:08 +00:00
|
|
|
if (offset + 2 > size)
|
2010-09-09 16:47:11 +00:00
|
|
|
goto too_small;
|
2010-09-07 14:40:08 +00:00
|
|
|
|
|
|
|
quant_size = gst_rtp_jpeg_pay_header_size (data, offset);
|
|
|
|
if (quant_size < 2)
|
2010-09-09 16:47:11 +00:00
|
|
|
goto small_quant_size;
|
2010-09-07 14:40:08 +00:00
|
|
|
|
|
|
|
/* clamp to available data */
|
|
|
|
if (offset + quant_size > size)
|
|
|
|
quant_size = size - offset;
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
offset += 2;
|
|
|
|
quant_size -= 2;
|
2009-05-05 14:32:17 +00:00
|
|
|
|
2010-09-07 14:40:08 +00:00
|
|
|
while (quant_size > 0) {
|
|
|
|
/* not enough to read the id */
|
|
|
|
if (offset + 1 > size)
|
|
|
|
break;
|
|
|
|
|
2010-09-09 16:47:11 +00:00
|
|
|
id = data[offset] & 0x0f;
|
2010-09-07 14:40:08 +00:00
|
|
|
if (id == 15)
|
|
|
|
/* invalid id received - corrupt data */
|
2010-09-09 16:47:11 +00:00
|
|
|
goto invalid_id;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2010-09-07 14:40:08 +00:00
|
|
|
prec = (data[offset] & 0xf0) >> 4;
|
|
|
|
if (prec)
|
|
|
|
tab_size = 128;
|
|
|
|
else
|
|
|
|
tab_size = 64;
|
|
|
|
|
|
|
|
/* there is not enough for the table */
|
|
|
|
if (quant_size < tab_size + 1)
|
2010-09-09 16:47:11 +00:00
|
|
|
goto no_table;
|
2010-09-07 14:40:08 +00:00
|
|
|
|
|
|
|
GST_LOG ("read quant table %d, tab_size %d, prec %02x", id, tab_size, prec);
|
|
|
|
|
|
|
|
tables[id].size = tab_size;
|
|
|
|
tables[id].data = &data[offset + 1];
|
|
|
|
|
|
|
|
tab_size += 1;
|
|
|
|
quant_size -= tab_size;
|
|
|
|
offset += tab_size;
|
2009-05-06 14:09:13 +00:00
|
|
|
}
|
2010-09-09 16:47:11 +00:00
|
|
|
done:
|
2010-09-07 14:40:08 +00:00
|
|
|
return offset + quant_size;
|
2010-09-09 16:47:11 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
too_small:
|
|
|
|
{
|
|
|
|
GST_WARNING ("not enough data");
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
small_quant_size:
|
|
|
|
{
|
|
|
|
GST_WARNING ("quant_size too small (%u < 2)", quant_size);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
invalid_id:
|
|
|
|
{
|
|
|
|
GST_WARNING ("invalid id");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
no_table:
|
|
|
|
{
|
|
|
|
GST_WARNING ("not enough data for table (%u < %u)", quant_size,
|
|
|
|
tab_size + 1);
|
|
|
|
goto done;
|
|
|
|
}
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 14:32:17 +00:00
|
|
|
static gboolean
|
|
|
|
gst_rtp_jpeg_pay_read_sof (GstRtpJPEGPay * pay, const guint8 * data,
|
2012-05-15 20:58:25 +00:00
|
|
|
guint size, guint * offset, CompInfo info[], RtpQuantTable tables[],
|
|
|
|
gulong tables_elements)
|
2009-05-05 14:32:17 +00:00
|
|
|
{
|
2010-09-07 14:40:08 +00:00
|
|
|
guint sof_size, off;
|
2009-05-05 14:32:17 +00:00
|
|
|
guint width, height, infolen;
|
2009-05-06 14:09:13 +00:00
|
|
|
CompInfo elem;
|
2009-05-05 14:32:17 +00:00
|
|
|
gint i, j;
|
|
|
|
|
2010-09-07 14:40:08 +00:00
|
|
|
off = *offset;
|
|
|
|
|
|
|
|
/* we need at least 17 bytes for the SOF */
|
|
|
|
if (off + 17 > size)
|
2010-09-08 05:13:42 +00:00
|
|
|
goto wrong_size;
|
2010-09-07 14:40:08 +00:00
|
|
|
|
|
|
|
sof_size = gst_rtp_jpeg_pay_header_size (data, off);
|
2009-05-05 14:32:17 +00:00
|
|
|
if (sof_size < 17)
|
|
|
|
goto wrong_length;
|
|
|
|
|
2010-09-07 14:40:08 +00:00
|
|
|
*offset += sof_size;
|
|
|
|
|
2009-05-05 14:32:17 +00:00
|
|
|
/* skip size */
|
2010-09-07 14:40:08 +00:00
|
|
|
off += 2;
|
2009-05-05 14:32:17 +00:00
|
|
|
|
|
|
|
/* precision should be 8 */
|
2010-09-07 14:40:08 +00:00
|
|
|
if (data[off++] != 8)
|
2009-05-05 14:32:17 +00:00
|
|
|
goto bad_precision;
|
|
|
|
|
|
|
|
/* read dimensions */
|
2010-09-07 14:40:08 +00:00
|
|
|
height = data[off] << 8 | data[off + 1];
|
|
|
|
width = data[off + 2] << 8 | data[off + 3];
|
|
|
|
off += 4;
|
2009-05-05 14:32:17 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (pay, "got dimensions %ux%u", height, width);
|
|
|
|
|
2012-09-27 13:42:56 +00:00
|
|
|
if (height == 0) {
|
2009-05-05 14:32:17 +00:00
|
|
|
goto invalid_dimension;
|
2012-09-27 13:42:56 +00:00
|
|
|
}
|
|
|
|
if (height > 2040) {
|
|
|
|
height = 0;
|
|
|
|
}
|
|
|
|
if (width == 0) {
|
2009-05-05 14:32:17 +00:00
|
|
|
goto invalid_dimension;
|
2012-09-27 13:42:56 +00:00
|
|
|
}
|
|
|
|
if (width > 2040) {
|
|
|
|
width = 0;
|
|
|
|
}
|
2009-05-05 14:32:17 +00:00
|
|
|
|
2012-09-27 13:42:56 +00:00
|
|
|
if (height == 0 || width == 0) {
|
|
|
|
pay->height = 0;
|
|
|
|
pay->width = 0;
|
|
|
|
} else {
|
|
|
|
pay->height = GST_ROUND_UP_8 (height) / 8;
|
|
|
|
pay->width = GST_ROUND_UP_8 (width) / 8;
|
|
|
|
}
|
2009-05-05 14:32:17 +00:00
|
|
|
|
|
|
|
/* we only support 3 components */
|
2010-09-07 14:40:08 +00:00
|
|
|
if (data[off++] != 3)
|
2009-05-05 14:32:17 +00:00
|
|
|
goto bad_components;
|
|
|
|
|
|
|
|
infolen = 0;
|
|
|
|
for (i = 0; i < 3; i++) {
|
2010-09-07 14:40:08 +00:00
|
|
|
elem.id = data[off++];
|
|
|
|
elem.samp = data[off++];
|
|
|
|
elem.qt = data[off++];
|
2009-05-05 14:32:17 +00:00
|
|
|
GST_LOG_OBJECT (pay, "got comp %d, samp %02x, qt %d", elem.id, elem.samp,
|
|
|
|
elem.qt);
|
|
|
|
/* insertion sort from the last element to the first */
|
|
|
|
for (j = infolen; j > 1; j--) {
|
|
|
|
if (G_LIKELY (info[j - 1].id < elem.id))
|
|
|
|
break;
|
|
|
|
info[j] = info[j - 1];
|
|
|
|
}
|
|
|
|
info[j] = elem;
|
|
|
|
infolen++;
|
|
|
|
}
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
/* see that the components are supported */
|
|
|
|
if (info[0].samp == 0x21)
|
2009-05-05 14:32:17 +00:00
|
|
|
pay->type = 0;
|
2009-05-06 14:09:13 +00:00
|
|
|
else if (info[0].samp == 0x22)
|
2009-05-05 14:32:17 +00:00
|
|
|
pay->type = 1;
|
|
|
|
else
|
|
|
|
goto invalid_comp;
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
if (!(info[1].samp == 0x11))
|
|
|
|
goto invalid_comp;
|
2009-05-05 14:32:17 +00:00
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
if (!(info[2].samp == 0x11))
|
2009-05-05 14:32:17 +00:00
|
|
|
goto invalid_comp;
|
|
|
|
|
2010-09-09 16:47:11 +00:00
|
|
|
/* the other components are free to use any quant table but they have to
|
|
|
|
* have the same table id */
|
2012-05-15 20:58:25 +00:00
|
|
|
if (info[1].qt != info[2].qt) {
|
|
|
|
/* Some MJPG (like the one from the Logitech C-920 camera) uses different
|
|
|
|
* quant tables for component 1 and 2 but both tables contain the exact
|
|
|
|
* same data, so we could consider them as being the same tables */
|
|
|
|
if (!(info[1].qt < tables_elements &&
|
|
|
|
info[2].qt < tables_elements &&
|
|
|
|
tables[info[1].qt].size > 0 &&
|
|
|
|
tables[info[1].qt].size == tables[info[2].qt].size &&
|
|
|
|
memcmp (tables[info[1].qt].data, tables[info[2].qt].data,
|
|
|
|
tables[info[1].qt].size) == 0))
|
|
|
|
goto invalid_comp;
|
|
|
|
}
|
2009-05-05 14:32:17 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
2010-09-08 05:13:42 +00:00
|
|
|
wrong_size:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT,
|
2010-09-08 05:13:42 +00:00
|
|
|
("Wrong size %u (needed %u).", size, off + 17), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-05-05 14:32:17 +00:00
|
|
|
wrong_length:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT,
|
2009-05-05 14:32:17 +00:00
|
|
|
("Wrong SOF length %u.", sof_size), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
bad_precision:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT,
|
2009-05-05 14:32:17 +00:00
|
|
|
("Wrong precision, expecting 8."), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
invalid_dimension:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT,
|
2009-05-05 14:32:17 +00:00
|
|
|
("Wrong dimension, size %ux%u", width, height), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
bad_components:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT,
|
2009-05-05 14:32:17 +00:00
|
|
|
("Wrong number of components"), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
invalid_comp:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT, ("Invalid component"), (NULL));
|
2009-05-05 14:32:17 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-13 15:31:35 +00:00
|
|
|
static gboolean
|
|
|
|
gst_rtp_jpeg_pay_read_dri (GstRtpJPEGPay * pay, const guint8 * data,
|
|
|
|
guint size, guint * offset, RtpRestartMarkerHeader * dri)
|
|
|
|
{
|
|
|
|
guint dri_size, off;
|
|
|
|
|
|
|
|
off = *offset;
|
|
|
|
|
|
|
|
/* we need at least 4 bytes for the DRI */
|
|
|
|
if (off + 4 > size)
|
|
|
|
goto wrong_size;
|
|
|
|
|
|
|
|
dri_size = gst_rtp_jpeg_pay_header_size (data, off);
|
|
|
|
if (dri_size < 4)
|
|
|
|
goto wrong_length;
|
|
|
|
|
|
|
|
*offset += dri_size;
|
|
|
|
off += 2;
|
|
|
|
|
|
|
|
dri->restart_interval = g_htons ((data[off] << 8) | (data[off + 1]));
|
|
|
|
dri->restart_count = g_htons (0xFFFF);
|
|
|
|
|
|
|
|
return dri->restart_interval > 0;
|
|
|
|
|
|
|
|
wrong_size:
|
|
|
|
{
|
|
|
|
GST_WARNING ("not enough data for DRI");
|
|
|
|
*offset = size;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wrong_length:
|
|
|
|
{
|
|
|
|
GST_WARNING ("DRI size too small (%u)", dri_size);
|
|
|
|
*offset += dri_size;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
static RtpJpegMarker
|
|
|
|
gst_rtp_jpeg_pay_scan_marker (const guint8 * data, guint size, guint * offset)
|
|
|
|
{
|
|
|
|
while ((data[(*offset)++] != JPEG_MARKER) && ((*offset) < size));
|
|
|
|
|
|
|
|
if (G_UNLIKELY ((*offset) >= size)) {
|
2009-05-05 14:32:17 +00:00
|
|
|
GST_LOG ("found EOI marker");
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
return JPEG_MARKER_EOI;
|
|
|
|
} else {
|
2009-05-05 14:32:17 +00:00
|
|
|
guint8 marker;
|
|
|
|
|
2010-09-07 14:40:08 +00:00
|
|
|
marker = data[*offset];
|
2011-08-03 08:09:42 +00:00
|
|
|
GST_LOG ("found 0x%02x marker at offset %u", marker, *offset);
|
2010-09-07 14:40:08 +00:00
|
|
|
(*offset)++;
|
2009-05-05 14:32:17 +00:00
|
|
|
return marker;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2011-11-11 11:25:01 +00:00
|
|
|
gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
GstBuffer * buffer)
|
|
|
|
{
|
2009-05-05 14:32:17 +00:00
|
|
|
GstRtpJPEGPay *pay;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
GstClockTime timestamp;
|
|
|
|
GstFlowReturn ret = GST_FLOW_ERROR;
|
|
|
|
RtpJpegHeader jpeg_header;
|
|
|
|
RtpQuantHeader quant_header;
|
2010-09-10 15:35:53 +00:00
|
|
|
RtpRestartMarkerHeader restart_marker_header;
|
2009-05-06 14:09:13 +00:00
|
|
|
RtpQuantTable tables[15] = { {0, NULL}, };
|
|
|
|
CompInfo info[3] = { {0,}, };
|
|
|
|
guint quant_data_size;
|
2012-01-23 16:25:37 +00:00
|
|
|
GstMapInfo map;
|
|
|
|
guint8 *data;
|
2011-07-10 19:50:19 +00:00
|
|
|
gsize size;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
guint mtu;
|
|
|
|
guint bytes_left;
|
|
|
|
guint jpeg_header_size = 0;
|
2009-05-06 14:09:13 +00:00
|
|
|
guint offset;
|
|
|
|
gboolean frame_done;
|
2010-09-10 15:35:53 +00:00
|
|
|
gboolean sos_found, sof_found, dqt_found, dri_found;
|
2009-05-06 14:09:13 +00:00
|
|
|
gint i;
|
2009-06-19 15:57:12 +00:00
|
|
|
GstBufferList *list = NULL;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2009-05-05 14:32:17 +00:00
|
|
|
pay = GST_RTP_JPEG_PAY (basepayload);
|
2011-11-11 11:25:01 +00:00
|
|
|
mtu = GST_RTP_BASE_PAYLOAD_MTU (pay);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
|
|
|
data = map.data;
|
|
|
|
size = map.size;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
2009-05-06 14:09:13 +00:00
|
|
|
offset = 0;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
GST_LOG_OBJECT (pay, "got buffer size %" G_GSIZE_FORMAT
|
|
|
|
" , timestamp %" GST_TIME_FORMAT, size, GST_TIME_ARGS (timestamp));
|
2009-05-06 10:54:22 +00:00
|
|
|
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
/* parse the jpeg header for 'start of scan' and read quant tables if needed */
|
2009-05-06 14:09:13 +00:00
|
|
|
sos_found = FALSE;
|
2009-05-06 21:56:44 +00:00
|
|
|
dqt_found = FALSE;
|
|
|
|
sof_found = FALSE;
|
2010-09-10 15:35:53 +00:00
|
|
|
dri_found = FALSE;
|
2010-09-07 14:40:08 +00:00
|
|
|
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
while (!sos_found && (offset < size)) {
|
2009-05-06 10:54:22 +00:00
|
|
|
GST_LOG_OBJECT (pay, "checking from offset %u", offset);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
switch (gst_rtp_jpeg_pay_scan_marker (data, size, &offset)) {
|
|
|
|
case JPEG_MARKER_JFIF:
|
|
|
|
case JPEG_MARKER_CMT:
|
2009-05-06 10:54:22 +00:00
|
|
|
case JPEG_MARKER_DHT:
|
2011-08-03 08:09:42 +00:00
|
|
|
case JPEG_MARKER_H264:
|
2010-09-07 14:40:08 +00:00
|
|
|
GST_LOG_OBJECT (pay, "skipping marker");
|
2009-05-05 14:32:17 +00:00
|
|
|
offset += gst_rtp_jpeg_pay_header_size (data, offset);
|
|
|
|
break;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
case JPEG_MARKER_SOF:
|
2012-05-15 20:58:25 +00:00
|
|
|
if (!gst_rtp_jpeg_pay_read_sof (pay, data, size, &offset, info, tables,
|
|
|
|
G_N_ELEMENTS (tables)))
|
2009-05-06 10:54:22 +00:00
|
|
|
goto invalid_format;
|
2009-05-06 21:56:44 +00:00
|
|
|
sof_found = TRUE;
|
2009-05-05 14:32:17 +00:00
|
|
|
break;
|
|
|
|
case JPEG_MARKER_DQT:
|
|
|
|
GST_LOG ("DQT found");
|
2010-09-07 14:40:08 +00:00
|
|
|
offset = gst_rtp_jpeg_pay_read_quant_table (data, size, offset, tables);
|
2009-05-06 21:56:44 +00:00
|
|
|
dqt_found = TRUE;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
break;
|
|
|
|
case JPEG_MARKER_SOS:
|
|
|
|
sos_found = TRUE;
|
2009-05-05 14:32:17 +00:00
|
|
|
GST_LOG_OBJECT (pay, "SOS found");
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
jpeg_header_size = offset + gst_rtp_jpeg_pay_header_size (data, offset);
|
|
|
|
break;
|
|
|
|
case JPEG_MARKER_EOI:
|
2009-05-05 14:32:17 +00:00
|
|
|
GST_WARNING_OBJECT (pay, "EOI reached before SOS!");
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
break;
|
|
|
|
case JPEG_MARKER_SOI:
|
2009-05-05 14:32:17 +00:00
|
|
|
GST_LOG_OBJECT (pay, "SOI found");
|
|
|
|
break;
|
2010-09-10 15:35:53 +00:00
|
|
|
case JPEG_MARKER_DRI:
|
|
|
|
GST_LOG_OBJECT (pay, "DRI found");
|
2010-09-13 15:31:35 +00:00
|
|
|
if (gst_rtp_jpeg_pay_read_dri (pay, data, size, &offset,
|
|
|
|
&restart_marker_header))
|
2010-09-10 15:35:53 +00:00
|
|
|
dri_found = TRUE;
|
2010-09-13 15:31:35 +00:00
|
|
|
break;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-06 21:56:44 +00:00
|
|
|
if (!dqt_found || !sof_found)
|
|
|
|
goto unsupported_jpeg;
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
/* by now we should either have negotiated the width/height or the SOF header
|
|
|
|
* should have filled us in */
|
2012-09-27 13:42:56 +00:00
|
|
|
if (pay->width < 0 || pay->height < 0) {
|
2009-05-05 14:32:17 +00:00
|
|
|
goto no_dimension;
|
2012-09-27 13:42:56 +00:00
|
|
|
}
|
2009-05-05 14:32:17 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (pay, "header size %u", jpeg_header_size);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
size -= jpeg_header_size;
|
|
|
|
data += jpeg_header_size;
|
|
|
|
offset = 0;
|
|
|
|
|
2010-09-10 15:35:53 +00:00
|
|
|
if (dri_found)
|
|
|
|
pay->type += 64;
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
/* prepare stuff for the jpeg header */
|
|
|
|
jpeg_header.type_spec = 0;
|
|
|
|
jpeg_header.type = pay->type;
|
|
|
|
jpeg_header.q = pay->quant;
|
|
|
|
jpeg_header.width = pay->width;
|
|
|
|
jpeg_header.height = pay->height;
|
|
|
|
|
|
|
|
/* collect the quant headers sizes */
|
|
|
|
quant_header.mbz = 0;
|
|
|
|
quant_header.precision = 0;
|
|
|
|
quant_header.length = 0;
|
|
|
|
quant_data_size = 0;
|
|
|
|
|
|
|
|
if (pay->quant > 127) {
|
|
|
|
/* for the Y and U component, look up the quant table and its size. quant
|
|
|
|
* tables for U and V should be the same */
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
guint qsize;
|
|
|
|
guint qt;
|
|
|
|
|
|
|
|
qt = info[i].qt;
|
2011-05-20 07:34:47 +00:00
|
|
|
if (qt >= G_N_ELEMENTS (tables))
|
2009-05-06 14:09:13 +00:00
|
|
|
goto invalid_quant;
|
|
|
|
|
|
|
|
qsize = tables[qt].size;
|
|
|
|
if (qsize == 0)
|
|
|
|
goto invalid_quant;
|
|
|
|
|
|
|
|
quant_header.precision |= (qsize == 64 ? 0 : (1 << i));
|
|
|
|
quant_data_size += qsize;
|
|
|
|
}
|
|
|
|
quant_header.length = g_htons (quant_data_size);
|
|
|
|
quant_data_size += sizeof (quant_header);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (pay, "quant_data size %u", quant_data_size);
|
|
|
|
|
2012-07-23 13:22:24 +00:00
|
|
|
list = gst_buffer_list_new ();
|
2009-06-19 15:57:12 +00:00
|
|
|
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
bytes_left = sizeof (jpeg_header) + quant_data_size + size;
|
|
|
|
|
2010-09-10 15:35:53 +00:00
|
|
|
if (dri_found)
|
|
|
|
bytes_left += sizeof (restart_marker_header);
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
frame_done = FALSE;
|
|
|
|
do {
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
GstBuffer *outbuf;
|
|
|
|
guint8 *payload;
|
2014-03-20 14:28:26 +00:00
|
|
|
guint payload_size;
|
2011-07-10 19:50:19 +00:00
|
|
|
guint header_size;
|
|
|
|
GstBuffer *paybuf;
|
2011-12-05 17:39:59 +00:00
|
|
|
GstRTPBuffer rtp = { NULL };
|
2014-03-20 14:28:26 +00:00
|
|
|
guint rtp_header_size = gst_rtp_buffer_calc_header_len (0);
|
|
|
|
|
|
|
|
/* The available room is the packet MTU, minus the RTP header length. */
|
|
|
|
payload_size =
|
|
|
|
(bytes_left < (mtu - rtp_header_size) ? bytes_left :
|
|
|
|
(mtu - rtp_header_size));
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
header_size = sizeof (jpeg_header) + quant_data_size;
|
|
|
|
if (dri_found)
|
|
|
|
header_size += sizeof (restart_marker_header);
|
2010-09-13 15:31:35 +00:00
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
outbuf = gst_rtp_buffer_new_allocate (header_size, 0, 0);
|
2010-09-13 15:31:35 +00:00
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
if (payload_size == bytes_left) {
|
2009-05-05 14:32:17 +00:00
|
|
|
GST_LOG_OBJECT (pay, "last packet of frame");
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
frame_done = TRUE;
|
2011-07-10 19:50:19 +00:00
|
|
|
gst_rtp_buffer_set_marker (&rtp, 1);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
payload = gst_rtp_buffer_get_payload (&rtp);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
/* update offset */
|
|
|
|
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
|
|
|
jpeg_header.offset = ((offset & 0x0000FF) << 16) |
|
|
|
|
((offset & 0xFF0000) >> 16) | (offset & 0x00FF00);
|
|
|
|
#else
|
|
|
|
jpeg_header.offset = offset;
|
|
|
|
#endif
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
memcpy (payload, &jpeg_header, sizeof (jpeg_header));
|
|
|
|
payload += sizeof (jpeg_header);
|
|
|
|
payload_size -= sizeof (jpeg_header);
|
|
|
|
|
2010-09-13 15:31:35 +00:00
|
|
|
if (dri_found) {
|
2010-09-10 15:35:53 +00:00
|
|
|
memcpy (payload, &restart_marker_header, sizeof (restart_marker_header));
|
|
|
|
payload += sizeof (restart_marker_header);
|
2010-09-13 15:31:35 +00:00
|
|
|
payload_size -= sizeof (restart_marker_header);
|
2010-09-10 15:35:53 +00:00
|
|
|
}
|
|
|
|
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
/* only send quant table with first packet */
|
|
|
|
if (G_UNLIKELY (quant_data_size > 0)) {
|
|
|
|
memcpy (payload, &quant_header, sizeof (quant_header));
|
|
|
|
payload += sizeof (quant_header);
|
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
/* copy the quant tables for luma and chrominance */
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
guint qsize;
|
|
|
|
guint qt;
|
|
|
|
|
|
|
|
qt = info[i].qt;
|
|
|
|
qsize = tables[qt].size;
|
|
|
|
memcpy (payload, tables[qt].data, qsize);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (pay, "component %d using quant %d, size %d", i, qt,
|
|
|
|
qsize);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2009-05-06 14:09:13 +00:00
|
|
|
payload += qsize;
|
|
|
|
}
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
payload_size -= quant_data_size;
|
|
|
|
bytes_left -= quant_data_size;
|
|
|
|
quant_data_size = 0;
|
|
|
|
}
|
2009-05-05 14:32:17 +00:00
|
|
|
GST_LOG_OBJECT (pay, "sending payload size %d", payload_size);
|
2011-07-10 19:50:19 +00:00
|
|
|
gst_rtp_buffer_unmap (&rtp);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
/* create a new buf to hold the payload */
|
|
|
|
paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY,
|
|
|
|
jpeg_header_size + offset, payload_size);
|
2009-06-19 15:57:12 +00:00
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
/* join memory parts */
|
2012-03-28 10:49:19 +00:00
|
|
|
outbuf = gst_buffer_append (outbuf, paybuf);
|
2009-06-19 15:57:12 +00:00
|
|
|
|
2011-07-10 19:50:19 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
|
|
|
|
2012-07-23 13:22:24 +00:00
|
|
|
/* and add to list */
|
|
|
|
gst_buffer_list_insert (list, -1, outbuf);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
|
|
|
bytes_left -= payload_size;
|
|
|
|
offset += payload_size;
|
2009-05-06 14:09:13 +00:00
|
|
|
data += payload_size;
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
2009-05-06 14:09:13 +00:00
|
|
|
while (!frame_done);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
|
2012-07-23 13:22:24 +00:00
|
|
|
/* push the whole buffer list at once */
|
|
|
|
ret = gst_rtp_base_payload_push_list (basepayload, list);
|
2009-06-19 15:57:12 +00:00
|
|
|
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
return ret;
|
2009-05-05 14:32:17 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
2009-05-06 21:56:44 +00:00
|
|
|
unsupported_jpeg:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2009-05-06 21:56:44 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2013-06-26 18:49:41 +00:00
|
|
|
return GST_FLOW_OK;
|
2009-05-06 21:56:44 +00:00
|
|
|
}
|
2009-05-05 14:32:17 +00:00
|
|
|
no_dimension:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT, ("No size given"), (NULL));
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2009-05-06 14:09:13 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2013-06-26 18:49:41 +00:00
|
|
|
return GST_FLOW_OK;
|
2009-05-05 14:32:17 +00:00
|
|
|
}
|
2009-05-06 10:54:22 +00:00
|
|
|
invalid_format:
|
|
|
|
{
|
|
|
|
/* error was posted */
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2009-05-06 14:09:13 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2013-06-26 18:49:41 +00:00
|
|
|
return GST_FLOW_OK;
|
2009-05-06 14:09:13 +00:00
|
|
|
}
|
|
|
|
invalid_quant:
|
|
|
|
{
|
2013-06-26 18:49:41 +00:00
|
|
|
GST_ELEMENT_WARNING (pay, STREAM, FORMAT, ("Invalid quant tables"), (NULL));
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2009-05-06 14:09:13 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2013-06-26 18:49:41 +00:00
|
|
|
return GST_FLOW_OK;
|
2009-05-06 10:54:22 +00:00
|
|
|
}
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtp_jpeg_pay_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstRtpJPEGPay *rtpjpegpay;
|
|
|
|
|
|
|
|
rtpjpegpay = GST_RTP_JPEG_PAY (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_JPEG_QUALITY:
|
|
|
|
rtpjpegpay->quality = g_value_get_int (value);
|
|
|
|
GST_DEBUG_OBJECT (object, "quality = %d", rtpjpegpay->quality);
|
|
|
|
break;
|
|
|
|
case PROP_JPEG_TYPE:
|
|
|
|
rtpjpegpay->type = g_value_get_int (value);
|
|
|
|
GST_DEBUG_OBJECT (object, "type = %d", rtpjpegpay->type);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtp_jpeg_pay_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstRtpJPEGPay *rtpjpegpay;
|
|
|
|
|
|
|
|
rtpjpegpay = GST_RTP_JPEG_PAY (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_JPEG_QUALITY:
|
|
|
|
g_value_set_int (value, rtpjpegpay->quality);
|
|
|
|
break;
|
|
|
|
case PROP_JPEG_TYPE:
|
|
|
|
g_value_set_int (value, rtpjpegpay->type);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_rtp_jpeg_pay_plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
2010-12-21 15:49:28 +00:00
|
|
|
return gst_element_register (plugin, "rtpjpegpay", GST_RANK_SECONDARY,
|
gst/rtp/: Add JPEG payloader. Fixes #560756.
Original commit message from CVS:
Patch by: Bjorn Ostby <bjornos at axis dot com>
* gst/rtp/Makefile.am:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpjpegpay.c: (gst_rtp_jpeg_pay_base_init),
(gst_rtp_jpeg_pay_class_init), (gst_rtp_jpeg_pay_init),
(gst_rtp_jpeg_pay_setcaps), (gst_rtp_jpeg_pay_header_size),
(gst_rtp_jpeg_pay_read_quant_table),
(gst_rtp_jpeg_pay_scan_marker), (gst_rtp_jpeg_pay_handle_buffer),
(gst_rtp_jpeg_pay_set_property), (gst_rtp_jpeg_pay_get_property),
(gst_rtp_jpeg_pay_plugin_init):
* gst/rtp/gstrtpjpegpay.h:
Add JPEG payloader. Fixes #560756.
2008-11-14 11:41:55 +00:00
|
|
|
GST_TYPE_RTP_JPEG_PAY);
|
|
|
|
}
|