mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	format: implement more gstreamer -> pinos format
This commit is contained in:
		
							parent
							
								
									0d2f5a1386
								
							
						
					
					
						commit
						837c23a370
					
				
					 8 changed files with 367 additions and 60 deletions
				
			
		| 
						 | 
					@ -17,6 +17,8 @@
 | 
				
			||||||
 * Boston, MA 02110-1301, USA.
 | 
					 * Boston, MA 02110-1301, USA.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <gst/gst.h>
 | 
					#include <gst/gst.h>
 | 
				
			||||||
#include <gst/video/video.h>
 | 
					#include <gst/video/video.h>
 | 
				
			||||||
#include <gst/audio/audio.h>
 | 
					#include <gst/audio/audio.h>
 | 
				
			||||||
| 
						 | 
					@ -27,67 +29,355 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "gstpinosformat.h"
 | 
					#include "gstpinosformat.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static guint
 | 
				
			||||||
 | 
					calc_range_size (const GValue *val)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  guint res = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (G_VALUE_TYPE (val) == GST_TYPE_LIST)
 | 
				
			||||||
 | 
					    res += gst_value_list_get_size (val);
 | 
				
			||||||
 | 
					  else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY)
 | 
				
			||||||
 | 
					    res += gst_value_array_get_size (val);
 | 
				
			||||||
 | 
					  else if (G_VALUE_TYPE (val) == GST_TYPE_INT_RANGE)
 | 
				
			||||||
 | 
					    res += 2;
 | 
				
			||||||
 | 
					  else if (G_VALUE_TYPE (val) == GST_TYPE_INT64_RANGE)
 | 
				
			||||||
 | 
					    res += 2;
 | 
				
			||||||
 | 
					  else if (G_VALUE_TYPE (val) == GST_TYPE_DOUBLE_RANGE)
 | 
				
			||||||
 | 
					    res += 2;
 | 
				
			||||||
 | 
					  else if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION_RANGE)
 | 
				
			||||||
 | 
					    res += 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return res;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					calc_size (GstCapsFeatures *cf, GstStructure *cs, guint *n_infos, guint *n_ranges, guint *n_datas)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  guint c;
 | 
				
			||||||
 | 
					  const GValue *val;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (gst_structure_has_name (cs, "video/x-raw")) {
 | 
				
			||||||
 | 
					    if ((val = gst_structure_get_value (cs, "format"))) {
 | 
				
			||||||
 | 
					      c = calc_range_size (val);
 | 
				
			||||||
 | 
					      n_infos[0] += 1;
 | 
				
			||||||
 | 
					      n_ranges[0] += c;
 | 
				
			||||||
 | 
					      n_datas[0] += (1 + c) * sizeof (SpaVideoFormat);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((val = gst_structure_get_value (cs, "width")) ||
 | 
				
			||||||
 | 
					        (val = gst_structure_get_value (cs, "height"))) {
 | 
				
			||||||
 | 
					      c = calc_range_size (val);
 | 
				
			||||||
 | 
					      n_infos[0]++;
 | 
				
			||||||
 | 
					      n_ranges[0] += c;
 | 
				
			||||||
 | 
					      n_datas[0] += (1 + c) * sizeof (SpaRectangle);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((val = gst_structure_get_value (cs, "framerate"))) {
 | 
				
			||||||
 | 
					      c = calc_range_size (val);
 | 
				
			||||||
 | 
					      n_infos[0]++;
 | 
				
			||||||
 | 
					      n_ranges[0] += c;
 | 
				
			||||||
 | 
					      n_datas[0] += (1 + c) * sizeof (SpaFraction);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } else if (gst_structure_has_name (cs, "audio/x-raw")) {
 | 
				
			||||||
 | 
					    if ((val = gst_structure_get_value (cs, "format"))) {
 | 
				
			||||||
 | 
					      c = calc_range_size (val);
 | 
				
			||||||
 | 
					      n_infos[0]++;
 | 
				
			||||||
 | 
					      n_ranges[0] += c;
 | 
				
			||||||
 | 
					      n_datas[0] += (1 + c) * sizeof (SpaAudioFormat);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((val = gst_structure_get_value (cs, "layout"))) {
 | 
				
			||||||
 | 
					      c = calc_range_size (val);
 | 
				
			||||||
 | 
					      n_infos[0]++;
 | 
				
			||||||
 | 
					      n_ranges[0] += c;
 | 
				
			||||||
 | 
					      n_datas[0] += (1 + c) * sizeof (SpaAudioLayout);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((val = gst_structure_get_value (cs, "rate"))) {
 | 
				
			||||||
 | 
					      c = calc_range_size (val);
 | 
				
			||||||
 | 
					      n_infos[0]++;
 | 
				
			||||||
 | 
					      n_ranges[0] += c;
 | 
				
			||||||
 | 
					      n_datas[0] += (1 + c) * sizeof (uint32_t);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((val = gst_structure_get_value (cs, "channels"))) {
 | 
				
			||||||
 | 
					      c = calc_range_size (val);
 | 
				
			||||||
 | 
					      n_infos[0]++;
 | 
				
			||||||
 | 
					      n_ranges[0] += c;
 | 
				
			||||||
 | 
					      n_datas[0] += (1 + c) * sizeof (uint32_t);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static SpaFormat *
 | 
					static SpaFormat *
 | 
				
			||||||
convert_1 (GstCapsFeatures *cf, GstStructure *cs)
 | 
					convert_1 (GstCapsFeatures *cf, GstStructure *cs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  SpaMemory *mem;
 | 
					  SpaMemory *mem;
 | 
				
			||||||
  SpaFormat *res = NULL;
 | 
					  SpaFormat *f;
 | 
				
			||||||
  const gchar *s;
 | 
					  guint size, n_infos = 0, n_ranges = 0, n_datas = 0;
 | 
				
			||||||
  int i;
 | 
					  SpaPropInfo *bpi;
 | 
				
			||||||
 | 
					  SpaPropRangeInfo *bri;
 | 
				
			||||||
 | 
					  int pi, ri;
 | 
				
			||||||
 | 
					  void *p;
 | 
				
			||||||
 | 
					  const GValue *val, *val2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  calc_size (cf, cs, &n_infos, &n_ranges, &n_datas);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  size = sizeof (SpaFormat);
 | 
				
			||||||
 | 
					  size += n_infos * sizeof (SpaPropInfo);
 | 
				
			||||||
 | 
					  size += n_ranges * sizeof (SpaPropRangeInfo);
 | 
				
			||||||
 | 
					  size += n_datas;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  mem = spa_memory_alloc_size (SPA_MEMORY_POOL_LOCAL, NULL, size);
 | 
				
			||||||
 | 
					  f = spa_memory_ensure_ptr (mem);
 | 
				
			||||||
 | 
					  f->mem.mem = mem->mem;
 | 
				
			||||||
 | 
					  f->mem.offset = 0;
 | 
				
			||||||
 | 
					  f->mem.size = mem->size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bpi = SPA_MEMBER (f, sizeof (SpaFormat), SpaPropInfo);
 | 
				
			||||||
 | 
					  bri = SPA_MEMBER (bpi, n_infos * sizeof (SpaPropInfo), SpaPropRangeInfo);
 | 
				
			||||||
 | 
					  p = SPA_MEMBER (bri, n_ranges * sizeof (SpaPropRangeInfo), void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  pi = ri = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  f->props.n_prop_info = n_infos;
 | 
				
			||||||
 | 
					  f->props.prop_info = bpi;
 | 
				
			||||||
 | 
					  f->props.unset_mask = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (gst_structure_has_name (cs, "video/x-raw")) {
 | 
					  if (gst_structure_has_name (cs, "video/x-raw")) {
 | 
				
			||||||
    SpaVideoRawFormat *f;
 | 
					    f->media_type = SPA_MEDIA_TYPE_VIDEO;
 | 
				
			||||||
 | 
					    f->media_subtype = SPA_MEDIA_SUBTYPE_RAW;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mem = spa_memory_alloc_size (SPA_MEMORY_POOL_LOCAL, NULL, sizeof (SpaVideoRawFormat));
 | 
					    val = gst_structure_get_value (cs, "format");
 | 
				
			||||||
    f = spa_memory_ensure_ptr (mem);
 | 
					    if (val) {
 | 
				
			||||||
    f->format.mem.mem = mem->mem;
 | 
					      SpaVideoFormat *sv = p;
 | 
				
			||||||
    f->format.mem.offset = 0;
 | 
					 | 
				
			||||||
    f->format.mem.size = mem->size;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    spa_video_raw_format_init (f);
 | 
					      spa_video_raw_fill_prop_info (&bpi[pi],
 | 
				
			||||||
 | 
					                                    SPA_PROP_ID_VIDEO_FORMAT,
 | 
				
			||||||
 | 
					                                    SPA_PTRDIFF (p, f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(s = gst_structure_get_string (cs, "format")))
 | 
					      if (G_VALUE_TYPE (val) == G_TYPE_STRING) {
 | 
				
			||||||
      goto done;
 | 
					        *sv = gst_video_format_from_string (g_value_get_string (val));
 | 
				
			||||||
    f->info.format = gst_video_format_from_string (s);
 | 
					        p = ++sv;
 | 
				
			||||||
    if (!gst_structure_get_int (cs, "width", &i))
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
      goto done;
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
    f->info.size.width = i;
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
    if (!gst_structure_get_int (cs, "height", &i))
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
      goto done;
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
    f->info.size.height = i;
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
    f->format.props.unset_mask = 0;
 | 
					      } else {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
    res = &f->format;
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
  } else if (gst_structure_has_name (cs, "audio/x-raw")) {
 | 
					 | 
				
			||||||
    SpaAudioRawFormat *f;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    mem = spa_memory_alloc_size (SPA_MEMORY_POOL_LOCAL, NULL, sizeof (SpaAudioRawFormat));
 | 
					 | 
				
			||||||
    f = spa_memory_ensure_ptr (mem);
 | 
					 | 
				
			||||||
    f->format.mem.mem = mem->mem;
 | 
					 | 
				
			||||||
    f->format.mem.offset = 0;
 | 
					 | 
				
			||||||
    f->format.mem.size = mem->size;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    spa_audio_raw_format_init (f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!(s = gst_structure_get_string (cs, "format")))
 | 
					 | 
				
			||||||
      goto done;
 | 
					 | 
				
			||||||
    f->info.format = gst_audio_format_from_string (s);
 | 
					 | 
				
			||||||
    if (!(s = gst_structure_get_string (cs, "layout")))
 | 
					 | 
				
			||||||
      goto done;
 | 
					 | 
				
			||||||
    f->info.layout = 0;
 | 
					 | 
				
			||||||
    if (!gst_structure_get_int (cs, "rate", &i))
 | 
					 | 
				
			||||||
      goto done;
 | 
					 | 
				
			||||||
    f->info.rate = i;
 | 
					 | 
				
			||||||
    if (!gst_structure_get_int (cs, "channels", &i))
 | 
					 | 
				
			||||||
      goto done;
 | 
					 | 
				
			||||||
    f->info.channels = i;
 | 
					 | 
				
			||||||
    f->format.props.unset_mask = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    res = &f->format;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      pi++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    val = gst_structure_get_value (cs, "width");
 | 
				
			||||||
 | 
					    val2 = gst_structure_get_value (cs, "height");
 | 
				
			||||||
 | 
					    if (val || val2) {
 | 
				
			||||||
 | 
					      SpaRectangle *sv = p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
done:
 | 
					      spa_video_raw_fill_prop_info (&bpi[pi],
 | 
				
			||||||
  return res;
 | 
					                                    SPA_PROP_ID_VIDEO_SIZE,
 | 
				
			||||||
 | 
					                                    SPA_PTRDIFF (p, f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (val && val2 && G_VALUE_TYPE (val) == G_VALUE_TYPE (val2)) {
 | 
				
			||||||
 | 
					        if (G_VALUE_TYPE (val) == G_TYPE_INT) {
 | 
				
			||||||
 | 
					          sv->width = g_value_get_int (val);
 | 
				
			||||||
 | 
					          sv->height = g_value_get_int (val2);
 | 
				
			||||||
 | 
					          p = ++sv;
 | 
				
			||||||
 | 
					          bpi[pi].range_type = SPA_PROP_RANGE_TYPE_NONE;
 | 
				
			||||||
 | 
					          bpi[pi].n_range_values = 0;
 | 
				
			||||||
 | 
					          bpi[pi].range_values = NULL;
 | 
				
			||||||
 | 
					        } else if (G_VALUE_TYPE (val) == GST_TYPE_INT_RANGE) {
 | 
				
			||||||
 | 
					          bpi[pi].range_type = SPA_PROP_RANGE_TYPE_MIN_MAX;
 | 
				
			||||||
 | 
					          bpi[pi].n_range_values = 2;
 | 
				
			||||||
 | 
					          bpi[pi].range_values = &bri[ri];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          bri[ri].name = NULL;
 | 
				
			||||||
 | 
					          bri[ri].description = NULL;
 | 
				
			||||||
 | 
					          bri[ri].size = sizeof (SpaRectangle);
 | 
				
			||||||
 | 
					          bri[ri].value = p;
 | 
				
			||||||
 | 
					          sv->width = gst_value_get_int_range_min (val);
 | 
				
			||||||
 | 
					          sv->height = gst_value_get_int_range_min (val2);
 | 
				
			||||||
 | 
					          p = ++sv;
 | 
				
			||||||
 | 
					          ri++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          bri[ri].name = NULL;
 | 
				
			||||||
 | 
					          bri[ri].description = NULL;
 | 
				
			||||||
 | 
					          bri[ri].size = sizeof (SpaRectangle);
 | 
				
			||||||
 | 
					          bri[ri].value = p;
 | 
				
			||||||
 | 
					          sv->width = gst_value_get_int_range_max (val);
 | 
				
			||||||
 | 
					          sv->height = gst_value_get_int_range_max (val2);
 | 
				
			||||||
 | 
					          p = ++sv;
 | 
				
			||||||
 | 
					          ri++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					        } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
 | 
					          fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					          f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					        } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
 | 
					          fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					          f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					          f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      pi++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    val = gst_structure_get_value (cs, "framerate");
 | 
				
			||||||
 | 
					    if (val) {
 | 
				
			||||||
 | 
					      SpaFraction *sv = p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      spa_video_raw_fill_prop_info (&bpi[pi],
 | 
				
			||||||
 | 
					                                    SPA_PROP_ID_VIDEO_FRAMERATE,
 | 
				
			||||||
 | 
					                                    SPA_PTRDIFF (p, f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION) {
 | 
				
			||||||
 | 
					        sv->num = gst_value_get_fraction_numerator (val);
 | 
				
			||||||
 | 
					        sv->denom = gst_value_get_fraction_denominator (val);
 | 
				
			||||||
 | 
					        p = ++sv;
 | 
				
			||||||
 | 
					        bpi[pi].range_type = SPA_PROP_RANGE_TYPE_NONE;
 | 
				
			||||||
 | 
					        bpi[pi].n_range_values = 0;
 | 
				
			||||||
 | 
					        bpi[pi].range_values = NULL;
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION_RANGE) {
 | 
				
			||||||
 | 
					        const GValue *min, *max;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        min = gst_value_get_fraction_range_min (val);
 | 
				
			||||||
 | 
					        max = gst_value_get_fraction_range_max (val);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bpi[pi].range_type = SPA_PROP_RANGE_TYPE_MIN_MAX;
 | 
				
			||||||
 | 
					        bpi[pi].n_range_values = 2;
 | 
				
			||||||
 | 
					        bpi[pi].range_values = &bri[ri];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bri[ri].name = NULL;
 | 
				
			||||||
 | 
					        bri[ri].description = NULL;
 | 
				
			||||||
 | 
					        bri[ri].size = sizeof (SpaFraction);
 | 
				
			||||||
 | 
					        bri[ri].value = p;
 | 
				
			||||||
 | 
					        sv->num = gst_value_get_fraction_numerator (min);
 | 
				
			||||||
 | 
					        sv->denom = gst_value_get_fraction_denominator (min);
 | 
				
			||||||
 | 
					        p = ++sv;
 | 
				
			||||||
 | 
					        ri++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bri[ri].name = NULL;
 | 
				
			||||||
 | 
					        bri[ri].description = NULL;
 | 
				
			||||||
 | 
					        bri[ri].size = sizeof (SpaFraction);
 | 
				
			||||||
 | 
					        bri[ri].value = p;
 | 
				
			||||||
 | 
					        sv->num = gst_value_get_fraction_numerator (max);
 | 
				
			||||||
 | 
					        sv->denom = gst_value_get_fraction_denominator (max);
 | 
				
			||||||
 | 
					        p = ++sv;
 | 
				
			||||||
 | 
					        ri++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      pi++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } else if (gst_structure_has_name (cs, "audio/x-raw")) {
 | 
				
			||||||
 | 
					    f->media_type = SPA_MEDIA_TYPE_AUDIO;
 | 
				
			||||||
 | 
					    f->media_subtype = SPA_MEDIA_SUBTYPE_RAW;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    val = gst_structure_get_value (cs, "format");
 | 
				
			||||||
 | 
					    if (val) {
 | 
				
			||||||
 | 
					      SpaAudioFormat *sv = p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      spa_audio_raw_fill_prop_info (&bpi[pi],
 | 
				
			||||||
 | 
					                                    SPA_PROP_ID_AUDIO_FORMAT,
 | 
				
			||||||
 | 
					                                    SPA_PTRDIFF (p, f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (G_VALUE_TYPE (val) == G_TYPE_STRING) {
 | 
				
			||||||
 | 
					        *sv = gst_audio_format_from_string (g_value_get_string (val));
 | 
				
			||||||
 | 
					        p = ++sv;
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      pi++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    val = gst_structure_get_value (cs, "layout");
 | 
				
			||||||
 | 
					    if (val) {
 | 
				
			||||||
 | 
					      SpaAudioLayout *sv = p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      spa_audio_raw_fill_prop_info (&bpi[pi],
 | 
				
			||||||
 | 
					                                    SPA_PROP_ID_AUDIO_LAYOUT,
 | 
				
			||||||
 | 
					                                    SPA_PTRDIFF (p, f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (G_VALUE_TYPE (val) == G_TYPE_STRING) {
 | 
				
			||||||
 | 
					        const gchar *s = g_value_get_string (val);
 | 
				
			||||||
 | 
					        if (!strcmp (s, "interleaved"))
 | 
				
			||||||
 | 
					          *sv = SPA_AUDIO_LAYOUT_INTERLEAVED;
 | 
				
			||||||
 | 
					        else if (!strcmp (s, "non-interleaved"))
 | 
				
			||||||
 | 
					          *sv = SPA_AUDIO_LAYOUT_NON_INTERLEAVED;
 | 
				
			||||||
 | 
					        p = ++sv;
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      pi++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    val = gst_structure_get_value (cs, "rate");
 | 
				
			||||||
 | 
					    if (val) {
 | 
				
			||||||
 | 
					      uint32_t *sv = p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      spa_audio_raw_fill_prop_info (&bpi[pi],
 | 
				
			||||||
 | 
					                                    SPA_PROP_ID_AUDIO_RATE,
 | 
				
			||||||
 | 
					                                    SPA_PTRDIFF (p, f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (G_VALUE_TYPE (val) == G_TYPE_INT) {
 | 
				
			||||||
 | 
					        *sv = g_value_get_int (val);
 | 
				
			||||||
 | 
					        p = ++sv;
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      pi++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    val = gst_structure_get_value (cs, "channels");
 | 
				
			||||||
 | 
					    if (val) {
 | 
				
			||||||
 | 
					      uint32_t *sv = p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      spa_audio_raw_fill_prop_info (&bpi[pi],
 | 
				
			||||||
 | 
					                                    SPA_PROP_ID_AUDIO_CHANNELS,
 | 
				
			||||||
 | 
					                                    SPA_PTRDIFF (p, f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (G_VALUE_TYPE (val) == G_TYPE_INT) {
 | 
				
			||||||
 | 
					        *sv = g_value_get_int (val);
 | 
				
			||||||
 | 
					        p = ++sv;
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else if (G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        fprintf (stderr, "implement me\n");
 | 
				
			||||||
 | 
					        f->props.unset_mask |= (1u << pi);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      pi++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return f;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SpaFormat *
 | 
					SpaFormat *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -185,13 +185,11 @@ no_node:
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_port_added (PinosNode *node, PinosPort *port, PinosClient *client)
 | 
					on_port_added (PinosNode *node, PinosPort *port, PinosClient *client)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  pinos_client_add_object (client, G_OBJECT (port));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_port_removed (PinosNode *node, PinosPort *port, PinosClient *client)
 | 
					on_port_removed (PinosNode *node, PinosPort *port, PinosClient *client)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  pinos_client_remove_object (client, G_OBJECT (port));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static gboolean
 | 
					static gboolean
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -514,7 +514,7 @@ pinos_node_class_init (PinosNodeClass * klass)
 | 
				
			||||||
                                             NULL,
 | 
					                                             NULL,
 | 
				
			||||||
                                             g_cclosure_marshal_generic,
 | 
					                                             g_cclosure_marshal_generic,
 | 
				
			||||||
                                             G_TYPE_NONE,
 | 
					                                             G_TYPE_NONE,
 | 
				
			||||||
                                             0,
 | 
					                                             1,
 | 
				
			||||||
                                             PINOS_TYPE_PORT);
 | 
					                                             PINOS_TYPE_PORT);
 | 
				
			||||||
  signals[SIGNAL_PORT_REMOVED] = g_signal_new ("port-removed",
 | 
					  signals[SIGNAL_PORT_REMOVED] = g_signal_new ("port-removed",
 | 
				
			||||||
                                               G_TYPE_FROM_CLASS (klass),
 | 
					                                               G_TYPE_FROM_CLASS (klass),
 | 
				
			||||||
| 
						 | 
					@ -524,7 +524,7 @@ pinos_node_class_init (PinosNodeClass * klass)
 | 
				
			||||||
                                               NULL,
 | 
					                                               NULL,
 | 
				
			||||||
                                               g_cclosure_marshal_generic,
 | 
					                                               g_cclosure_marshal_generic,
 | 
				
			||||||
                                               G_TYPE_NONE,
 | 
					                                               G_TYPE_NONE,
 | 
				
			||||||
                                               0,
 | 
					                                               1,
 | 
				
			||||||
                                               PINOS_TYPE_PORT);
 | 
					                                               PINOS_TYPE_PORT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  node_class->set_state = node_set_state;
 | 
					  node_class->set_state = node_set_state;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,6 +48,9 @@ SpaResult   spa_audio_raw_format_init    (SpaAudioRawFormat *format);
 | 
				
			||||||
SpaResult   spa_audio_raw_format_parse   (const SpaFormat *format,
 | 
					SpaResult   spa_audio_raw_format_parse   (const SpaFormat *format,
 | 
				
			||||||
                                          SpaAudioRawFormat *rawformat);
 | 
					                                          SpaAudioRawFormat *rawformat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SpaResult   spa_audio_raw_fill_prop_info (SpaPropInfo     *info,
 | 
				
			||||||
 | 
					                                          SpaPropIdAudio   id,
 | 
				
			||||||
 | 
					                                          size_t           offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
}  /* extern "C" */
 | 
					}  /* extern "C" */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -126,9 +126,6 @@ typedef struct {
 | 
				
			||||||
 * @range_values: array of possible values
 | 
					 * @range_values: array of possible values
 | 
				
			||||||
 * @tags: extra tags, NULL terminated
 | 
					 * @tags: extra tags, NULL terminated
 | 
				
			||||||
 * @offset: offset in structure with data
 | 
					 * @offset: offset in structure with data
 | 
				
			||||||
 * @mask_offset: offset in structure for the mask
 | 
					 | 
				
			||||||
 * @unset_mask: mask to clear when value is set
 | 
					 | 
				
			||||||
 * @priv: extra private data
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  uint32_t                  id;
 | 
					  uint32_t                  id;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -234,3 +234,23 @@ fallback:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return res;
 | 
					  return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SpaResult
 | 
				
			||||||
 | 
					spa_audio_raw_fill_prop_info (SpaPropInfo    *info,
 | 
				
			||||||
 | 
					                              SpaPropIdAudio  id,
 | 
				
			||||||
 | 
					                              size_t          offset)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  unsigned int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (info == NULL)
 | 
				
			||||||
 | 
					    return SPA_RESULT_INVALID_ARGUMENTS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i = 0; i < SPA_N_ELEMENTS (raw_format_prop_info); i++) {
 | 
				
			||||||
 | 
					    if (raw_format_prop_info[i].id == id) {
 | 
				
			||||||
 | 
					      memcpy (info, &raw_format_prop_info[i], sizeof (SpaPropInfo));
 | 
				
			||||||
 | 
					      info->offset = offset;
 | 
				
			||||||
 | 
					      return SPA_RESULT_OK;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return SPA_RESULT_INVALID_PROPERTY_INDEX;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ spa_props_set_prop (SpaProps           *props,
 | 
				
			||||||
  if (info->offset != 0)
 | 
					  if (info->offset != 0)
 | 
				
			||||||
    memcpy ((uint8_t*)props + info->offset, value->value, value->size);
 | 
					    memcpy ((uint8_t*)props + info->offset, value->value, value->size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  props->unset_mask &= ~(1 << index);
 | 
					  props->unset_mask &= ~(1u << index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					  return SPA_RESULT_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -68,8 +68,7 @@ spa_props_get_prop (const SpaProps *props,
 | 
				
			||||||
  info = &props->prop_info[index];
 | 
					  info = &props->prop_info[index];
 | 
				
			||||||
  if ((info->flags & SPA_PROP_FLAG_READABLE) == 0)
 | 
					  if ((info->flags & SPA_PROP_FLAG_READABLE) == 0)
 | 
				
			||||||
    return SPA_RESULT_INVALID_PROPERTY_ACCESS;
 | 
					    return SPA_RESULT_INVALID_PROPERTY_ACCESS;
 | 
				
			||||||
 | 
					  if (props->unset_mask & (1u << index))
 | 
				
			||||||
  if (props->unset_mask & (1 << index))
 | 
					 | 
				
			||||||
    return SPA_RESULT_PROPERTY_UNSET;
 | 
					    return SPA_RESULT_PROPERTY_UNSET;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  value->type = info->type;
 | 
					  value->type = info->type;
 | 
				
			||||||
| 
						 | 
					@ -106,7 +105,7 @@ spa_props_copy (const SpaProps *src,
 | 
				
			||||||
    if (info->offset)
 | 
					    if (info->offset)
 | 
				
			||||||
      memcpy ((uint8_t*)dest + info->offset, value.value, value.size);
 | 
					      memcpy ((uint8_t*)dest + info->offset, value.value, value.size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dest->unset_mask &= ~(1 << i);
 | 
					    dest->unset_mask &= ~(1u << i);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					  return SPA_RESULT_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue