1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
/*****************************************************************
* gmerlin - a general purpose multimedia framework and applications
*
* Copyright (c) 2001 - 2024 Members of the Gmerlin project
* http://github.com/bplaum
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *****************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <gmerlin/parameter.h>
#include <gmerlin/streaminfo.h>
#include <gmerlin/bgmsg.h>
#include <gavl/gavl.h>
#include <gavl/utils.h>
int num_msgs = 3;
static void gen_msg(gavl_msg_t * msg, int num)
{
gavl_msg_set_id(msg, num);
switch(num)
{
case 0:
break; // ID only
case 1:
{
float col[4] = { 0.1, 0.2, 0.3, 0.4 };
gavl_msg_set_arg_int(msg, 0, 123);
gavl_msg_set_arg_long(msg, 1, 123);
gavl_msg_set_arg_string(msg, 2, NULL);
gavl_msg_set_arg_string(msg, 3, "String");
gavl_msg_set_arg_float(msg, 4, M_PI);
gavl_msg_set_arg_color_rgb(msg, 5, col);
gavl_msg_set_arg_color_rgba(msg, 6, col);
break;
}
case 2:
{
gavl_audio_format_t afmt;
gavl_video_format_t vfmt;
gavl_dictionary_t m;
double pos[2] = { 0.1, -0.2 };
memset(&afmt, 0, sizeof(afmt));
memset(&vfmt, 0, sizeof(vfmt));
gavl_dictionary_init(&m);
gavl_msg_set_arg_position(msg, 0, pos);
afmt.samplerate = 48000;
afmt.num_channels = 6;
afmt.sample_format = GAVL_SAMPLE_FLOAT;
afmt.channel_locations[0] = GAVL_CHID_LFE;
afmt.channel_locations[1] = GAVL_CHID_FRONT_LEFT;
afmt.channel_locations[2] = GAVL_CHID_FRONT_RIGHT;
afmt.channel_locations[3] = GAVL_CHID_FRONT_CENTER;
afmt.channel_locations[4] = GAVL_CHID_REAR_LEFT;
afmt.channel_locations[5] = GAVL_CHID_REAR_RIGHT;
gavl_msg_set_arg_audio_format(msg, 1, &afmt);
vfmt.image_width = 1920;
vfmt.image_height = 1080;
vfmt.frame_width = 1920;
vfmt.frame_height = 1080;
vfmt.pixel_width = 1;
vfmt.pixel_height = 1;
vfmt.pixelformat = GAVL_YUV_420_P;
vfmt.timescale = 30000;
vfmt.frame_duration = 1001;
gavl_msg_set_arg_video_format(msg, 2, &vfmt);
gavl_msg_set_arg_dictionary(msg, 3, &m);
gavl_dictionary_set_string(&m, "tag1", "val1");
gavl_dictionary_set_string(&m, "tag2", "val2");
gavl_msg_set_arg_dictionary(msg, 4, &m);
gavl_dictionary_free(&m);
}
break;
case 3:
break;
}
}
int main(int argc, char ** argv)
{
int i;
gavl_msg_t * msg1;
gavl_msg_t * msg2;
uint8_t * buf;
int len;
msg1 = gavl_msg_create();
msg2 = gavl_msg_create();
for(i = 0; i < num_msgs; i++)
{
gen_msg(msg1, i);
fprintf(stderr, "Message %d (orig)\n", i + 1);
gavl_msg_dump(msg1, 2);
len = 0;
buf = gavl_msg_to_buffer(&len, msg1);
fprintf(stderr, "Message %d (hex)\n", i + 1);
gavl_hexdump(buf, len, 16);
gavl_msg_from_buffer(buf, len, msg2);
fprintf(stderr, "Message %d (copy)\n", i + 1);
gavl_msg_dump(msg2, 2);
if(buf)
free(buf);
gavl_msg_free(msg1);
gavl_msg_free(msg2);
}
gavl_msg_destroy(msg1);
gavl_msg_destroy(msg2);
return EXIT_SUCCESS;
}
|