mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
353 lines
14 KiB
C
353 lines
14 KiB
C
/* GStreamer RTP jpeg unit test
|
|
*
|
|
* Copyright (C) 2020 Kristofer Bjorkstrom <at axis dot com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <gst/check/check.h>
|
|
#include <gst/app/app.h>
|
|
#include <gst/rtp/gstrtpbuffer.h>
|
|
|
|
|
|
/* one complete blank jpeg 1x1 */
|
|
static const guint8 rtp_jpeg_frame_data[] =
|
|
{ /* SOI */ 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46,
|
|
0x00, 0x01, 0x01, 0x01, 0x00, 0x60,
|
|
0x00, 0x60, 0x00, 0x00, /* DQT */ 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06,
|
|
0x06, 0x07, 0x06, 0x05, 0x08,
|
|
0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b,
|
|
0x0c, 0x19, 0x12,
|
|
0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 0x24,
|
|
0x2e, 0x27, 0x20,
|
|
0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34,
|
|
0x34, 0x1f, 0x27,
|
|
0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43,
|
|
0x01, 0x09, 0x09,
|
|
0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32,
|
|
0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
|
0x32, /* SOF */ 0xff, 0xc0,
|
|
0x00, 0x11, 0x08, 0x00, 0x01, 0x00, 0x01, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11,
|
|
0x01, 0x03, 0x11,
|
|
0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
|
0x07, 0x08, 0x09,
|
|
0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02,
|
|
0x04, 0x03, 0x05,
|
|
0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11,
|
|
0x05, 0x12, 0x21,
|
|
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91,
|
|
0xa1, 0x08, 0x23,
|
|
0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09,
|
|
0x0a, 0x16, 0x17,
|
|
0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37,
|
|
0x38, 0x39, 0x3a,
|
|
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57,
|
|
0x58, 0x59, 0x5a,
|
|
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77,
|
|
0x78, 0x79, 0x7a,
|
|
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
|
|
0x97, 0x98, 0x99,
|
|
0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
|
|
0xb5, 0xb6, 0xb7,
|
|
0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
|
|
0xd3, 0xd4, 0xd5,
|
|
0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
|
|
0xe9, 0xea, 0xf1,
|
|
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f,
|
|
0x01, 0x00, 0x03,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x01,
|
|
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00,
|
|
0xb5, 0x11, 0x00,
|
|
0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01,
|
|
0x02, 0x77, 0x00,
|
|
0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07,
|
|
0x61, 0x71, 0x13,
|
|
0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
|
|
0x52, 0xf0, 0x15,
|
|
0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19,
|
|
0x1a, 0x26, 0x27,
|
|
0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
|
|
0x47, 0x48, 0x49,
|
|
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
|
|
0x67, 0x68, 0x69,
|
|
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85,
|
|
0x86, 0x87, 0x88,
|
|
0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
|
|
0xa4, 0xa5, 0xa6,
|
|
0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba,
|
|
0xc2, 0xc3, 0xc4,
|
|
0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
|
|
0xd9, 0xda, 0xe2,
|
|
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
|
|
0xf7, 0xf8, 0xf9,
|
|
0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00,
|
|
0x3f, 0x00, 0xf7,
|
|
0xfa, 0x28, 0xa2, 0x80, 0x3f, 0xff, 0xd9
|
|
};
|
|
|
|
/* first slice of one complete blank jpeg 1x1 */
|
|
static const guint8 rtp_jpeg_frame_data_s1[] = {
|
|
/* SOI */ 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00,
|
|
0x01, 0x01, 0x01, 0x00, 0x60,
|
|
0x00, 0x60, 0x00
|
|
};
|
|
|
|
/* second slice of one complete blank jpeg 1x1 */
|
|
static const guint8 rtp_jpeg_frame_data_s2[] = {
|
|
0x00, /* DQT */ 0xff, 0xdb, 0x00, 0x43, 0x00, 0x08, 0x06, 0x06, 0x07, 0x06,
|
|
0x05, 0x08,
|
|
0x07, 0x07, 0x07, 0x09, 0x09, 0x08, 0x0a, 0x0c, 0x14, 0x0d, 0x0c, 0x0b, 0x0b,
|
|
0x0c, 0x19, 0x12,
|
|
0x13, 0x0f, 0x14, 0x1d, 0x1a, 0x1f, 0x1e, 0x1d, 0x1a, 0x1c, 0x1c, 0x20, 0x24,
|
|
0x2e, 0x27, 0x20,
|
|
0x22, 0x2c, 0x23, 0x1c, 0x1c, 0x28, 0x37, 0x29, 0x2c, 0x30, 0x31, 0x34, 0x34,
|
|
0x34, 0x1f, 0x27,
|
|
0x39, 0x3d, 0x38, 0x32, 0x3c, 0x2e, 0x33, 0x34, 0x32, 0xff, 0xdb, 0x00, 0x43,
|
|
0x01, 0x09, 0x09,
|
|
0x09, 0x0c, 0x0b, 0x0c, 0x18, 0x0d, 0x0d, 0x18, 0x32, 0x21, 0x1c, 0x21, 0x32,
|
|
0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32
|
|
};
|
|
|
|
/* third slice of one complete blank jpeg 1x1 */
|
|
static const guint8 rtp_jpeg_frame_data_s3[] = {
|
|
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32,
|
|
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
|
|
0x32, /* SOF */ 0xff, 0xc0,
|
|
0x00, 0x11, 0x08, 0x00, 0x01, 0x00, 0x01, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11,
|
|
0x01, 0x03, 0x11,
|
|
0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
|
0x07, 0x08, 0x09,
|
|
0x0a, 0x0b
|
|
};
|
|
|
|
/* fourth slice of one complete blank jpeg 1x1 */
|
|
static const guint8 rtp_jpeg_frame_data_s4[] = {
|
|
0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03,
|
|
0x05,
|
|
0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11,
|
|
0x05, 0x12, 0x21,
|
|
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91,
|
|
0xa1, 0x08, 0x23,
|
|
0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09,
|
|
0x0a, 0x16, 0x17,
|
|
0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37,
|
|
0x38, 0x39, 0x3a,
|
|
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57,
|
|
0x58, 0x59, 0x5a,
|
|
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77,
|
|
0x78, 0x79, 0x7a,
|
|
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
|
|
0x97, 0x98, 0x99,
|
|
0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
|
|
0xb5, 0xb6, 0xb7,
|
|
0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
|
|
0xd3, 0xd4, 0xd5,
|
|
0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
|
|
0xe9, 0xea, 0xf1,
|
|
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff
|
|
};
|
|
|
|
/* fifth and last slice of one complete blank jpeg 1x1 */
|
|
static const guint8 rtp_jpeg_frame_data_s5[] = {
|
|
0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x01,
|
|
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00,
|
|
0xb5, 0x11, 0x00,
|
|
0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01,
|
|
0x02, 0x77, 0x00,
|
|
0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07,
|
|
0x61, 0x71, 0x13,
|
|
0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
|
|
0x52, 0xf0, 0x15,
|
|
0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19,
|
|
0x1a, 0x26, 0x27,
|
|
0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
|
|
0x47, 0x48, 0x49,
|
|
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
|
|
0x67, 0x68, 0x69,
|
|
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85,
|
|
0x86, 0x87, 0x88,
|
|
0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
|
|
0xa4, 0xa5, 0xa6,
|
|
0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba,
|
|
0xc2, 0xc3, 0xc4,
|
|
0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
|
|
0xd9, 0xda, 0xe2,
|
|
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
|
|
0xf7, 0xf8, 0xf9,
|
|
0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00,
|
|
0x3f, 0x00, 0xf7,
|
|
0xfa, 0x28, 0xa2, 0x80, 0x3f, 0xff, 0xd9
|
|
};
|
|
|
|
|
|
/*
|
|
* rfc2435 3.1. JPEG header
|
|
*
|
|
* Each packet contains a special JPEG header which immediately follows
|
|
* the RTP header. The first 8 bytes of this header, called the "main
|
|
* JPEG header", are as follows:
|
|
*
|
|
* 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 |
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
*
|
|
*/
|
|
|
|
GST_START_TEST (test_rtpjpegpay_1_slice)
|
|
{
|
|
GstFlowReturn ret;
|
|
GstBuffer *buffer;
|
|
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
|
|
GstCaps *caps = gst_caps_from_string ("video/x-jpeg,height=1,width=1");
|
|
gchar *s = g_strdup_printf ("rtpjpegpay");
|
|
GstHarness *h = gst_harness_new_parse (s);
|
|
guint8 *payload;
|
|
|
|
gst_harness_set_src_caps (h, caps);
|
|
g_free (s);
|
|
|
|
buffer = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
|
(guint8 *) rtp_jpeg_frame_data, sizeof (rtp_jpeg_frame_data), 0,
|
|
sizeof (rtp_jpeg_frame_data), NULL, NULL);
|
|
|
|
ret = gst_harness_push (h, buffer);
|
|
fail_unless_equals_int (ret, GST_FLOW_OK);
|
|
|
|
fail_unless_equals_int (gst_harness_buffers_in_queue (h), 1);
|
|
|
|
buffer = gst_harness_pull (h);
|
|
fail_unless (gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp));
|
|
fail_unless (payload = gst_rtp_buffer_get_payload (&rtp));
|
|
|
|
/* verify JPEG header */
|
|
fail_unless (GST_READ_UINT24_BE (&payload[1]) == 0); /* offset */
|
|
fail_unless (payload[4] == 1); /* type */
|
|
fail_unless (payload[6] == 1); /* Width */
|
|
fail_unless (payload[7] == 1); /* Height */
|
|
|
|
fail_unless (gst_rtp_buffer_get_marker (&rtp));
|
|
gst_rtp_buffer_unmap (&rtp);
|
|
gst_buffer_unref (buffer);
|
|
|
|
gst_harness_teardown (h);
|
|
}
|
|
|
|
GST_END_TEST;
|
|
|
|
GST_START_TEST (test_rtpjpegpay_5_slices)
|
|
{
|
|
GstFlowReturn ret;
|
|
GstBuffer *buffer;
|
|
GstBuffer *buffer_s1;
|
|
GstBuffer *buffer_s2;
|
|
GstBuffer *buffer_s3;
|
|
GstBuffer *buffer_s4;
|
|
GstBuffer *buffer_s5;
|
|
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
|
|
GstCaps *caps = gst_caps_from_string ("video/x-jpeg,height=1,width=1");
|
|
gchar *s = g_strdup_printf ("rtpjpegpay");
|
|
GstHarness *h = gst_harness_new_parse (s);
|
|
guint8 *payload;
|
|
|
|
gst_harness_set_src_caps (h, caps);
|
|
g_free (s);
|
|
|
|
buffer_s1 = gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
|
(guint8 *) rtp_jpeg_frame_data_s1, sizeof (rtp_jpeg_frame_data_s1), 0,
|
|
sizeof (rtp_jpeg_frame_data_s1), NULL, NULL);
|
|
buffer_s2 =
|
|
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
|
(guint8 *) rtp_jpeg_frame_data_s2, sizeof (rtp_jpeg_frame_data_s2), 0,
|
|
sizeof (rtp_jpeg_frame_data_s2), NULL, NULL);
|
|
buffer_s3 =
|
|
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
|
(guint8 *) rtp_jpeg_frame_data_s3, sizeof (rtp_jpeg_frame_data_s3), 0,
|
|
sizeof (rtp_jpeg_frame_data_s3), NULL, NULL);
|
|
buffer_s4 =
|
|
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
|
(guint8 *) rtp_jpeg_frame_data_s4, sizeof (rtp_jpeg_frame_data_s4), 0,
|
|
sizeof (rtp_jpeg_frame_data_s4), NULL, NULL);
|
|
buffer_s5 =
|
|
gst_buffer_new_wrapped_full (GST_MEMORY_FLAG_READONLY,
|
|
(guint8 *) rtp_jpeg_frame_data_s5, sizeof (rtp_jpeg_frame_data_s5), 0,
|
|
sizeof (rtp_jpeg_frame_data_s5), NULL, NULL);
|
|
|
|
|
|
buffer = gst_buffer_append (buffer_s1, buffer_s2);
|
|
buffer = gst_buffer_append (buffer, buffer_s3);
|
|
buffer = gst_buffer_append (buffer, buffer_s4);
|
|
buffer = gst_buffer_append (buffer, buffer_s5);
|
|
|
|
ret = gst_harness_push (h, buffer);
|
|
fail_unless_equals_int (ret, GST_FLOW_OK);
|
|
|
|
fail_unless_equals_int (gst_harness_buffers_in_queue (h), 1);
|
|
|
|
buffer = gst_harness_pull (h);
|
|
fail_unless (gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp));
|
|
fail_unless (payload = gst_rtp_buffer_get_payload (&rtp));
|
|
|
|
/* verify JPEG header */
|
|
fail_unless (GST_READ_UINT24_BE (&payload[1]) == 0); /* offset */
|
|
fail_unless (payload[4] == 1); /* type */
|
|
fail_unless (payload[6] == 1); /* Width */
|
|
fail_unless (payload[7] == 1); /* Height */
|
|
|
|
fail_unless (gst_rtp_buffer_get_marker (&rtp));
|
|
gst_rtp_buffer_unmap (&rtp);
|
|
gst_buffer_unref (buffer);
|
|
|
|
gst_harness_teardown (h);
|
|
}
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
static Suite *
|
|
rtpjpeg_suite (void)
|
|
{
|
|
Suite *s = suite_create ("rtpjpeg");
|
|
TCase *tc_chain;
|
|
|
|
tc_chain = tcase_create ("rtpjpegpay_memory_slices");
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_test (tc_chain, test_rtpjpegpay_1_slice);
|
|
tcase_add_test (tc_chain, test_rtpjpegpay_5_slices);
|
|
|
|
return s;
|
|
}
|
|
|
|
GST_CHECK_MAIN (rtpjpeg);
|