Beispiel #1
0
static void
on_new_pad (GstElement * dec, GstPad * pad, GstElement * sinkElement)
{
  GstPad *sinkpad;
  if(pad==NULL) return;
  if(sinkElement==NULL) return;

  sinkpad = gst_element_get_static_pad (sinkElement, "sink");
  if(sinkpad==NULL) return;
  if (!gst_pad_is_linked (sinkpad)) {
    GstPadLinkReturn ret = gst_pad_link (pad, sinkpad);
    if(ret == GST_PAD_LINK_NOFORMAT) {
      GstCaps* a, *b;
      a = gst_pad_get_current_caps(pad);
      b = gst_pad_get_current_caps(sinkpad);
      g_warning("Formats of A: %s\nFormats of B:%s\n",
	      a ? gst_caps_to_string(a) : "<NULL>",
	      b ? gst_caps_to_string(b) : "<NULL>");
      gst_pad_unlink (pad, sinkpad);
    } else if(ret != GST_PAD_LINK_OK) {
      GstElement* parentA = gst_pad_get_parent_element(pad);
      GstElement* parentB = gst_pad_get_parent_element(sinkpad);
      g_error ("Failed to link pads! %s - %s : %d",
	       gst_element_get_name(parentA),
	       gst_element_get_name(parentB),
	       ret);
      g_object_unref(parentA);
      g_object_unref(parentB);
      exit(3);
    }
  }
  gst_object_unref (sinkpad);
}
Beispiel #2
0
gint
main (gint argc, gchar ** argv)
{
  GstCaps *caps;
  GstElement *sink, *identity;
  GstElement *pipeline;

  gst_init (&argc, &argv);

  pipeline = gst_pipeline_new ("pipeline");
  g_assert (pipeline);
  identity = gst_element_factory_make ("identity", NULL);
  g_assert (identity);
  sink = gst_element_factory_make ("fakesink", NULL);
  g_assert (sink);
  gst_bin_add_many (GST_BIN (pipeline), identity, sink, NULL);
  gst_element_link_filtered (identity, sink,
      gst_caps_new_simple ("audio/x-raw-int", NULL));
  caps = gst_pad_get_caps (gst_element_get_pad (identity, "sink"));
  g_print ("caps:         %s\n", gst_caps_to_string (caps));
  g_assert (!gst_caps_is_any (caps));

  caps = gst_pad_get_allowed_caps (gst_element_get_pad (identity, "sink"));
  g_print ("allowed caps: %s\n", gst_caps_to_string (caps));
  /* get_allowed_caps doesn't mean anything if you aren't connected */
  g_assert (!caps);

  return 0;
}
Beispiel #3
0
static void
check_caps (const gchar * set, const gchar * subset)
{
  GstCaps *one, *two, *test, *test2;

  g_print ("        A  =  %s\n", set);
  one = gst_caps_from_string (set);
  g_print ("        B  =  %s\n", subset);
  two = gst_caps_from_string (subset);
  /* basics */
  test = gst_caps_subtract (one, one);
  g_assert (gst_caps_is_empty (test));
  gst_caps_unref (test);
  test = gst_caps_subtract (two, two);
  g_assert (gst_caps_is_empty (test));
  gst_caps_unref (test);
  test = gst_caps_subtract (two, one);
  g_assert (gst_caps_is_empty (test));
  gst_caps_unref (test);
  /* now the nice part */
  test = gst_caps_subtract (one, two);
  g_assert (!gst_caps_is_empty (test));
  g_print ("    A - B  =  %s\n", gst_caps_to_string (test));
  test2 = gst_caps_union (test, two);
  g_print ("A - B + B  =  %s\n", gst_caps_to_string (test2));
  gst_caps_unref (test);
  test = gst_caps_subtract (test2, one);
  g_assert (gst_caps_is_empty (test));
  gst_caps_unref (test);
}
static void
debug_codec_cap (CodecCap *codec_cap)
{
  gchar *caps;
  if (codec_cap->caps)
  {
    caps = gst_caps_to_string (codec_cap->caps);
    GST_LOG ("%p:%d:media_caps %s\n", codec_cap->caps,
        GST_CAPS_REFCOUNT_VALUE (codec_cap->caps),
        caps);
    g_free (caps);
  }

  if (codec_cap->rtp_caps)
  {
    caps = gst_caps_to_string (codec_cap->rtp_caps);
    GST_LOG ("%p:%d:rtp_caps %s\n", codec_cap->rtp_caps,
        GST_CAPS_REFCOUNT_VALUE (codec_cap->rtp_caps), caps);
    g_free (caps);
    g_assert (gst_caps_get_size (codec_cap->rtp_caps) == 1);
  }

  GST_LOG ("element_list1 -> ");
  debug_pipeline (codec_cap->element_list1);
  GST_LOG ("element_list2 -> ");
  debug_pipeline (codec_cap->element_list2);
}
Beispiel #5
0
gint
main (gint argc, gchar * argv[])
{
  gchar *str;
  GstCaps *caps;
  GstAudioChannelPosition pos[2] = { GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
    GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT
  };

  /* register multichannel type */
  gst_init (&argc, &argv);
  gst_audio_channel_position_get_type ();

  /* test some caps-string conversions */
  caps = gst_caps_new_simple ("audio/x-raw-int",
      "channels", G_TYPE_INT, 2, NULL);
  str = gst_caps_to_string (caps);
  g_print ("Test caps #1: %s\n", str);
  g_free (str);
  gst_audio_set_channel_positions (gst_caps_get_structure (caps, 0), pos);
  str = gst_caps_to_string (caps);
  g_print ("Test caps #2: %s\n", str);
  g_free (str);
  gst_caps_unref (caps);

  return 0;
}
gboolean
gst_validate_media_info_compare (GstValidateMediaInfo * expected,
    GstValidateMediaInfo * extracted)
{
  gboolean ret = TRUE;
  if (expected->duration != extracted->duration) {
    g_print ("Duration changed: %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT "\n",
        GST_TIME_ARGS (expected->duration),
        GST_TIME_ARGS (extracted->duration));
    ret = FALSE;
  }
  if (expected->file_size != extracted->file_size) {
    g_print ("File size changed: %" G_GUINT64_FORMAT " -> %" G_GUINT64_FORMAT
        "\n", expected->file_size, extracted->file_size);
    ret = FALSE;
  }
  if (expected->seekable && !extracted->seekable) {
    g_print ("File isn't seekable anymore\n");
    ret = FALSE;
  }

  if (extracted->discover_only == FALSE) {
    if (expected->playback_error == NULL && extracted->playback_error) {
      g_print ("Playback is now failing with: %s\n", extracted->playback_error);
      ret = FALSE;
    }
    if (expected->reverse_playback_error == NULL
        && extracted->reverse_playback_error) {
      g_print ("Reverse playback is now failing with: %s\n",
          extracted->reverse_playback_error);
      ret = FALSE;
    }
    if (expected->track_switch_error == NULL && extracted->track_switch_error) {
      g_print ("Track switching is now failing with: %s\n",
          extracted->track_switch_error);
      ret = FALSE;
    }
  }

  if (extracted->stream_info == NULL || expected->stream_info == NULL) {
    g_print ("Stream infos could not be retrieved, an error occured\n");
    ret = FALSE;
  } else if (expected->stream_info
      && !gst_caps_is_equal_fixed (expected->stream_info->caps,
          extracted->stream_info->caps)) {
    gchar *caps1 = gst_caps_to_string (expected->stream_info->caps);
    gchar *caps2 = gst_caps_to_string (extracted->stream_info->caps);

    g_print ("Media caps changed: '%s' -> '%s'\n", caps1, caps2);
    g_free (caps1);
    g_free (caps2);
    ret = FALSE;
  }
  return ret;
}
Beispiel #7
0
static void on_new_decoded_pad(GstElement *introdec, 
                               GstPad *srcpad,
                               gpointer data)
{  
   GstPadLinkReturn result;
   GstPad *sinkpad;
   GstCaps *new_pad_caps;

   CustomData *cdata=(CustomData*)data;
   GstElement *introbin=cdata->introbin;

   new_pad_caps=gst_pad_query_caps(srcpad,NULL);
   g_print("Caps:%s\n",gst_caps_to_string(new_pad_caps));

   /* Setup src pad offset, sync with pipeline. */
   gint64 pos2;
   pos2=gst_element_get_base_time(cdata->pipeline);
   GstClock *clock;
   clock=gst_pipeline_get_clock(GST_PIPELINE(cdata->pipeline));
   GstClockTime clock_time;
   clock_time=gst_clock_get_time(clock);
   gst_object_unref(clock);
//   g_print("Pipeline times: base_time=%lld\n clock_time=%lld\n",
//		            pos2,clock_time);
   gst_pad_set_offset(srcpad,clock_time-pos2);
   cdata->introbin_offset=clock_time-pos2;

   if(strncmp(gst_caps_to_string(new_pad_caps),"video",5)==0) {
       GstElement *vqueue;
       vqueue=gst_bin_get_by_name(GST_BIN(introbin),"introscale");
       sinkpad=gst_element_get_static_pad(vqueue,"sink");
       result=gst_pad_link(srcpad,sinkpad);
       if(result!=GST_PAD_LINK_OK) {
          g_printerr("Couldn't link introbin decodebin video pad...\n");
       }
       gst_object_unref(vqueue);
   }
   if(strncmp(gst_caps_to_string(new_pad_caps),"audio",5)==0) {
       GstElement *arate;
       arate=gst_bin_get_by_name(GST_BIN(introbin),"introaudiorate");
       sinkpad=gst_element_get_static_pad(arate,"sink");
       result=gst_pad_link(srcpad,sinkpad);
       if(result!=GST_PAD_LINK_OK) {
          GstCaps *peer_caps;
	  peer_caps=gst_pad_query_caps(sinkpad,NULL);
	  g_print("SinkCaps:%s\n",gst_caps_to_string(peer_caps));
          g_printerr("Couldn't link introbin decodebin audio pad...\n");
	  gst_caps_unref(peer_caps);
       }
       gst_object_unref(arate);
   }
}
Beispiel #8
0
/* Print information regarding a stream */
void print_stream_info (GstDiscovererStreamInfo *info, gint depth) {
  gchar *desc = NULL;
  GstCaps *caps;
  const GstTagList *tags;
   
  caps = gst_discoverer_stream_info_get_caps (info);
   
  if (caps) {
    if (gst_caps_is_fixed (caps))
      desc = gst_pb_utils_get_codec_description (caps);
    else
      desc = gst_caps_to_string (caps);
    gst_caps_unref (caps);
  }
   
  g_print ("%*s%s: %s\n", 2 * depth, " ", gst_discoverer_stream_info_get_stream_type_nick (info), (desc ? desc : ""));
   
  if (desc) {
    g_free (desc);
    desc = NULL;
  }
   
  tags = gst_discoverer_stream_info_get_tags (info);
  if (tags) {
    g_print ("%*sTags:\n", 2 * (depth + 1), " ");
    gst_tag_list_foreach (tags, print_tag_foreach, GINT_TO_POINTER (depth + 2));
  }
}
Beispiel #9
0
void CvCapture_GStreamer::restartPipeline()
{
    CV_FUNCNAME("icvRestartPipeline");

    __BEGIN__;

    printf("restarting pipeline, going to ready\n");

    if(gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY) ==
            GST_STATE_CHANGE_FAILURE) {
        CV_ERROR(CV_StsError, "GStreamer: unable to start pipeline\n");
        return;
    }

    printf("ready, relinking\n");

    gst_element_unlink(uridecodebin, color);
    printf("filtering with %s\n", gst_caps_to_string(caps));
    gst_element_link_filtered(uridecodebin, color, caps);

    printf("relinked, pausing\n");

    if(gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING) ==
            GST_STATE_CHANGE_FAILURE) {
        CV_ERROR(CV_StsError, "GStreamer: unable to start pipeline\n");
        return;
    }

    printf("state now paused\n");

    __END__;
}
static void
new_decoded_pad_cb(GstElement *demuxer,
                   GstPad *new_pad,
                   gpointer user_data)
{
   GstElement *decoder;
   GstPad *pad;
   GstCaps *caps;
   gchar *str;

   caps = gst_pad_get_caps(new_pad);
   str = gst_caps_to_string(caps);

   if (g_str_has_prefix(str, "video/"))
     {
        decoder = GST_ELEMENT(user_data);

        pad = gst_element_get_pad(decoder, "sink");
        if (GST_PAD_LINK_FAILED(gst_pad_link(new_pad, pad)))
          {
             g_warning("Failed to link %s:%s to %s:%s", GST_DEBUG_PAD_NAME(new_pad),
                       GST_DEBUG_PAD_NAME(pad));
          }
     }
   g_free(str);
   gst_caps_unref(caps);
}
Beispiel #11
0
static void
gst_shmdata_src_get_property (GObject * object, guint prop_id,
                              GValue * value, GParamSpec * pspec)
{
  GstShmdataSrc *self = GST_SHMDATA_SRC (object);
  gchar *caps_str = NULL;
  switch (prop_id) {
    case PROP_SOCKET_PATH:
      GST_OBJECT_LOCK (object);
      g_value_set_string (value, self->socket_path);
      GST_OBJECT_UNLOCK (object);
      break;
    case PROP_CAPS:
      if (NULL != self->caps) {
        caps_str = gst_caps_to_string(self->caps);
        g_value_set_string (value, caps_str);
        g_free(caps_str);
      } else
        g_value_set_string (value, NULL);
      break;
    case PROP_BYTES_SINCE_LAST_REQUEST:
      g_value_set_uint64 (value, self->bytes_since_last_request);
      self->bytes_since_last_request = 0;
      break;
    case PROP_COPY_BUFFERS:
      g_value_set_boolean (value, self->copy_buffers);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
/**
 * gst_pb_utils_get_codec_description:
 * @caps: the (fixed) #GstCaps for which an format description is needed
 *
 * Returns a localised (as far as this is possible) string describing the
 * media format specified in @caps, for use in error dialogs or other messages
 * to be seen by the user. Should never return NULL unless @caps is invalid.
 *
 * Also see the convenience function
 * gst_pb_utils_add_codec_description_to_tag_list().
 *
 * Returns: a newly-allocated description string, or NULL on error. Free
 *          string with g_free() when not needed any longer.
 */
gchar *
gst_pb_utils_get_codec_description (const GstCaps * caps)
{
  const FormatInfo *info;
  gchar *str, *comma;
  GstCaps *tmp;

  g_return_val_if_fail (caps != NULL, NULL);
  g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
  tmp = copy_and_clean_caps (caps);
  g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL);

  info = find_format_info (tmp);

  if (info) {
    str = format_info_get_desc (info, tmp);
  } else {
    str = gst_caps_to_string (tmp);

    /* cut off everything after the media type, if there is anything */
    if ((comma = strchr (str, ','))) {
      *comma = '\0';
      g_strchomp (str);
      /* we could do something more elaborate here, like taking into account
       * audio/, video/, image/ and application/ prefixes etc. */
    }

    GST_WARNING ("No description available for media type: %s", str);
  }
  gst_caps_unref (tmp);

  return str;
}
Beispiel #13
0
/*
 * \brief Build the sink of SU's pipeline, if this is a reidrection, modify the caps to pass it to the SP pipeline
 * \param pipeline the pipepline of the stream
 * \param input the las element of the pipeline, (avenc_mp4 or capsfilter) as we built our own source
 * \param caps the caps built from the SDP to replace if you have MPEG-4 or J2K video
 * \return GstElement* the last element added to the pipeline (RAW: return input, MPEG: mpeg4videoparse, J2k:capsfilter)
 */
static GstElement *handle_redirection_SU_pipeline ( GstElement *pipeline, GstCaps *caps, GstElement *input){

	GstStructure *video_caps = gst_caps_get_structure( caps , 0 );

	g_debug("handle_redirection_SU_pipeline: checks and handles Service User's pipeline for redirection");

	/* in case MPEG4 video type has been detected */
	if  (gst_structure_has_name( video_caps, "video/mpeg")){

		/* Add the MPEG-4 parser in SU pipeline */
		GstElement *parser 	= gst_element_factory_make_log ("mpeg4videoparse", MPEG4PARSER_NAME);
		if ( !parser )
			return NULL;

		g_debug("add %s to pipeline", MPEG4PARSER_NAME);

		gst_bin_add(GST_BIN(pipeline),parser);

		if ( !gst_element_link_log(input, parser))
			return NULL;

		input = parser;

	}
	/* in case J2K video type has been detected */
	else if  ( g_strv_contains ( J2K_STR_NAMES, gst_structure_get_name(video_caps))){

		GstElement *capsfilter = gst_element_factory_make_log("capsfilter", CAPSFITER_J2K_NAME );

		GstCaps *caps_jpeg2000 = get_rtpj2kpay_allowed_caps();

		/* Put the source in the pipeline */
		g_object_set (capsfilter, "caps", caps_jpeg2000 , NULL);

		g_debug("add %s to pipeline", CAPSFITER_J2K_NAME );

		gst_bin_add(GST_BIN(pipeline),capsfilter);

		if ( !gst_element_link_log(input,capsfilter )){
			g_critical("JPEG2000 format can only be %s", gst_caps_to_string( caps_jpeg2000 ) );
			return NULL;
		}

		input = capsfilter;
	}

	/*
	 * Run a new typefind to update caps in order to succeed to run a last typefind in the pipeline of the SP of the
	 * redirection. Update caps in consequence
	 */
	video_caps = type_detection(GST_BIN(pipeline), input, NULL);
	if( !video_caps )
		return NULL;

	gst_caps_append_structure( caps , gst_structure_copy ( video_caps ) );
	gst_caps_remove_structure ( caps, 0 ) ;

	return input;

}
static GstElement *
setup_element (const gchar * factory, GstStaticPadTemplate * sink_template,
               GstCaps * sink_caps, GstStaticPadTemplate * src_template,
               GstCaps * src_caps)
{
    GstElement *element;
    GstBus *bus;
    gchar *caps_str = NULL;

    element = gst_check_setup_element (factory);
    srcpad = gst_check_setup_src_pad (element, src_template);
    if (sink_caps) {
        caps_str = gst_caps_to_string (sink_caps);
        sink_template->static_caps.string = caps_str;
    }
    sinkpad = gst_check_setup_sink_pad (element, sink_template);
    gst_pad_set_active (srcpad, TRUE);
    gst_check_setup_events (srcpad, element, src_caps, GST_FORMAT_BYTES);
    gst_pad_set_active (sinkpad, TRUE);

    bus = gst_bus_new ();
    gst_element_set_bus (element, bus);

    fail_unless (gst_element_set_state (element,
                                        GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE,
                 "could not set to playing");

    ts_counter = offset_counter = buffer_counter = 0;
    buffers = NULL;
    g_free (caps_str);
    return element;
}
static GstBusSyncReply
sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{
  const GstStructure *st;
  const GValue *image;
  GstBuffer *buf = NULL;
  guint8 *data_buf = NULL;
  gchar *caps_string;
  guint size = 0;
  gchar *preview_filename = NULL;
  FILE *f = NULL;
  size_t written;

  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ELEMENT:{
      st = gst_message_get_structure (message);
      if (st) {
        if (gst_structure_has_name (message->structure, "prepare-xwindow-id")) {
          if (!no_xwindow && window) {
            gst_x_overlay_set_window_handle (GST_X_OVERLAY (GST_MESSAGE_SRC
                    (message)), window);
            gst_message_unref (message);
            message = NULL;
            return GST_BUS_DROP;
          }
        } else if (gst_structure_has_name (st, "preview-image")) {
          GST_DEBUG ("preview-image");
          /* extract preview-image from msg */
          image = gst_structure_get_value (st, "buffer");
          if (image) {
            buf = gst_value_get_buffer (image);
            data_buf = GST_BUFFER_DATA (buf);
            size = GST_BUFFER_SIZE (buf);
            preview_filename = g_strdup_printf ("test_vga.rgb");
            caps_string = gst_caps_to_string (GST_BUFFER_CAPS (buf));
            g_print ("writing buffer to %s, elapsed: %.2fs, buffer caps: %s\n",
                preview_filename, g_timer_elapsed (timer, NULL), caps_string);
            g_free (caps_string);
            f = g_fopen (preview_filename, "w");
            if (f) {
              written = fwrite (data_buf, size, 1, f);
              if (!written) {
                g_print ("error writing file\n");
              }
              fclose (f);
            } else {
              g_print ("error opening file for raw image writing\n");
            }
            g_free (preview_filename);
          }
        }
      }
      break;
    }
    default:
      /* unhandled message */
      break;
  }
  return GST_BUS_PASS;
}
static gboolean gst_avdtp_sink_update_caps(GstAvdtpSink *self)
{
	sbc_capabilities_t *sbc;
	mpeg_capabilities_t *mpeg;
	GstStructure *sbc_structure;
	GstStructure *mpeg_structure;
	gchar *tmp;

	GST_LOG_OBJECT(self, "updating device caps");

	sbc = (void *) gst_avdtp_find_caps(self, BT_A2DP_SBC_SINK);
	mpeg = (void *) gst_avdtp_find_caps(self, BT_A2DP_MPEG12_SINK);

	sbc_structure = gst_avdtp_sink_parse_sbc_caps(self, sbc);
	mpeg_structure = gst_avdtp_sink_parse_mpeg_caps(self, mpeg);

	if (self->dev_caps != NULL)
		gst_caps_unref(self->dev_caps);
	self->dev_caps = gst_caps_new_full(sbc_structure, NULL);
	if (mpeg_structure != NULL)
		gst_caps_append_structure(self->dev_caps, mpeg_structure);

	tmp = gst_caps_to_string(self->dev_caps);
	GST_DEBUG_OBJECT(self, "Device capabilities: %s", tmp);
	g_free(tmp);

	return TRUE;
}
static GstCaps *
gst_caps_debug_getcaps (GstPad * pad)
{
  GstCaps *caps;
  GstCapsDebug *capsdebug;
  gchar *s;
  GstPad *otherpad;

  capsdebug = GST_CAPS_DEBUG (gst_pad_get_parent (pad));
  otherpad =
      (pad == capsdebug->srcpad) ? capsdebug->sinkpad : capsdebug->srcpad;

  GST_INFO ("%s called getcaps", THISPAD);

  caps = gst_pad_peer_get_caps (otherpad);

  s = gst_caps_to_string (caps);
  GST_INFO ("%s returned %s", OTHERPAD, s);
  g_free (s);

  if (caps == NULL)
    caps = gst_caps_new_any ();

  gst_object_unref (capsdebug);

  return caps;
}
static void
gst_stream_information_to_string (GstDiscovererStreamInfo * info, GString * s,
    guint depth)
{
  gchar *tmp;
  GstCaps *caps;
  const GstStructure *misc;

  my_g_string_append_printf (s, depth, "Codec:\n");
  caps = gst_discoverer_stream_info_get_caps (info);
  tmp = gst_caps_to_string (caps);
  gst_caps_unref (caps);
  my_g_string_append_printf (s, depth, "  %s\n", tmp);
  g_free (tmp);

  my_g_string_append_printf (s, depth, "Additional info:\n");
  if ((misc = gst_discoverer_stream_info_get_misc (info))) {
    tmp = gst_structure_to_string (misc);
    my_g_string_append_printf (s, depth, "  %s\n", tmp);
    g_free (tmp);
  } else {
    my_g_string_append_printf (s, depth, "  None\n");
  }

  my_g_string_append_printf (s, depth, "Stream ID: %s\n",
      gst_discoverer_stream_info_get_stream_id (info));
}
Beispiel #19
0
void test_from_string()
{
  GstCaps *caps;
  GstCaps *caps2;
  gchar *to_str;
  int i;
  //xmlfile = "test_from_string";
      std_log(LOG_FILENAME_LINE, "Test Started test_from_string");
  for (i = 0; i < G_N_ELEMENTS (caps_list); i++) {
    caps = gst_caps_from_string (caps_list[i]);
    fail_if (caps == NULL,
        "Could not create caps from string %s\n", caps_list[i]);
    to_str = gst_caps_to_string (caps);
    fail_if (to_str == NULL,
        "Could not convert caps back to string %s\n", caps_list[i]);
    caps2 = gst_caps_from_string (caps_list[i]);
    fail_if (caps2 == NULL, "Could not create caps from string %s\n", to_str);

    fail_unless (gst_caps_is_equal (caps, caps));
    fail_unless (gst_caps_is_equal (caps, caps2));

    gst_caps_unref (caps);
    gst_caps_unref (caps2);
    g_free (to_str);
  }
  std_log(LOG_FILENAME_LINE, "Test Successful");
      create_xml(0);
}
Beispiel #20
0
static gboolean
sink_setcaps(GstPad *pad,
	     GstCaps *caps)
{
	GstDspVpp *self;
	GstDspBase *base;
	GstCaps *out_caps;
	gboolean ret;

	self = GST_DSP_VPP(GST_PAD_PARENT(pad));
	base = GST_DSP_BASE(self);

	{
		gchar *str = gst_caps_to_string(caps);
		pr_info(self, "sink caps: %s", str);
		g_free(str);
	}

	base->codec = &td_vpp_codec;

	du_port_alloc_buffers(base->ports[0], 4);
	du_port_alloc_buffers(base->ports[1], 4);

	out_caps = gst_caps_new_empty();
	configure_caps(self, caps, out_caps);
	base->tmp_caps = out_caps;

	ret = gst_pad_set_caps(pad, caps);

	if (!ret)
		return FALSE;

	return TRUE;
}
gchar *
gst_validate_media_info_to_string (GstValidateMediaInfo * mi, gsize * length)
{
  GKeyFile *kf = g_key_file_new ();
  gchar *data = NULL;
  gchar *str;

  /* file info */
  g_key_file_set_string (kf, "file-info", "uri", mi->uri);
  g_key_file_set_uint64 (kf, "file-info", "file-size", mi->file_size);

  /* media info */
  g_key_file_set_uint64 (kf, "media-info", "file-duration", mi->duration);
  g_key_file_set_boolean (kf, "media-info", "seekable", mi->seekable);
  g_key_file_set_boolean (kf, "media-info", "is-image", mi->is_image);

  if (mi->stream_info && mi->stream_info->caps) {
    str = gst_caps_to_string (mi->stream_info->caps);
    g_key_file_set_string (kf, "media-info", "caps", str);
    g_free (str);
  }

  /* playback tests */
  g_key_file_set_string (kf, "playback-tests", "playback-error",
      mi->playback_error ? mi->playback_error : "");
  g_key_file_set_string (kf, "playback-tests", "reverse-playback-error",
      mi->reverse_playback_error ? mi->reverse_playback_error : "");
  g_key_file_set_string (kf, "playback-tests", "track-switch-error",
      mi->track_switch_error ? mi->track_switch_error : "");

  data = g_key_file_to_data (kf, length, NULL);
  g_key_file_free (kf);

  return data;
}
static void
print_profile (GUPnPDLNAProfile *profile, gpointer unused)
{
        GstEncodingProfile *enc_profile;
        const GList *tmp;
        gchar *caps_str;

        enc_profile = gupnp_dlna_profile_get_encoding_profile (profile);
        tmp = gst_encoding_container_profile_get_profiles
                                        (GST_ENCODING_CONTAINER_PROFILE (enc_profile));

        g_print ("%s %-30s%-35s",
                 gupnp_dlna_profile_get_extended (profile) ? "*" : " ",
                 gupnp_dlna_profile_get_name (profile),
                 gupnp_dlna_profile_get_mime (profile));

        if (verbose) {
                caps_str = gst_caps_to_string
                        (gst_encoding_profile_get_format (enc_profile));
                g_print ("\n`- container: %s\n", caps_str);
                g_free (caps_str);

                while (tmp) {
                        print_caps (gst_encoding_profile_get_format
                                        (GST_ENCODING_PROFILE (tmp->data)));
                        tmp = tmp->next;
                }
        }

        g_print ("\n");
        gst_encoding_profile_unref (enc_profile);
}
static void
fixate_vis_caps (RBVisualizerPlugin *plugin)
{
	GstPad *pad;
	GstCaps *caps = NULL;
	const GstCaps *template_caps;

	pad = gst_element_get_static_pad (plugin->vis_plugin, "src");
	template_caps = gst_pad_get_pad_template_caps (pad);
	gst_object_unref (pad);

	if (template_caps == NULL) {
		rb_debug ("vis element has no template caps?");
		return;
	}

	caps = gst_caps_copy (template_caps);

	if (gst_caps_is_fixed (caps) == FALSE) {
		guint i;
		char *dbg;
		const VisualizerQuality *q = &rb_visualizer_quality[g_settings_get_enum (plugin->settings, "quality")];

		rb_debug ("fixating caps towards %dx%d, %d/%d", q->width, q->height, q->fps_n, q->fps_d);
		caps = gst_caps_make_writable (caps);
		for (i = 0; i < gst_caps_get_size (caps); i++) {
			GstStructure *s = gst_caps_get_structure (caps, i);

			gst_structure_fixate_field_nearest_int (s, "width", q->width);
			gst_structure_fixate_field_nearest_int (s, "height", q->height);
			gst_structure_fixate_field_nearest_fraction (s, "framerate", q->fps_n, q->fps_d);
		}

		dbg = gst_caps_to_string (caps);
		rb_debug ("setting fixed caps on capsfilter: %s", dbg);
		g_free (dbg);

		g_object_set (plugin->capsfilter, "caps", caps, NULL);
	} else {
		char *dbg = gst_caps_to_string (caps);
		rb_debug ("vis element caps already fixed: %s", dbg);
		g_free (dbg);
	}

	gst_caps_unref (caps);
}
/* Serialize the top-level profiles
 * Note: They don't have to be containerprofiles */
static gboolean
serialize_encoding_profile (GKeyFile * out, GstEncodingProfile * prof)
{
  gchar *profgroupname;
  const GList *tmp;
  guint i;
  const gchar *profname, *profdesc, *profpreset, *proftype;
  GstCaps *profformat;

  profname = gst_encoding_profile_get_name (prof);
  profdesc = gst_encoding_profile_get_description (prof);
  profformat = gst_encoding_profile_get_format (prof);
  profpreset = gst_encoding_profile_get_preset (prof);
  proftype = gst_encoding_profile_get_type_nick (prof);

  profgroupname = g_strdup_printf ("profile-%s", profname);

  g_key_file_set_string (out, profgroupname, "name", profname);

  g_key_file_set_value (out, profgroupname, "type", proftype);

  if (profdesc) {
    gchar *locale;

    locale = get_locale ();
    if (locale != NULL) {
      g_key_file_set_locale_string (out, profgroupname, "description",
          locale, profdesc);
      g_free (locale);
    } else {
      g_key_file_set_string (out, profgroupname, "description", profdesc);
    }
  }
  if (profformat) {
    gchar *tmpc = gst_caps_to_string (profformat);
    g_key_file_set_string (out, profgroupname, "format", tmpc);
    g_free (tmpc);
  }
  if (profpreset)
    g_key_file_set_string (out, profgroupname, "preset", profpreset);

  /* stream profiles */
  if (GST_IS_ENCODING_CONTAINER_PROFILE (prof)) {
    for (tmp =
        gst_encoding_container_profile_get_profiles
        (GST_ENCODING_CONTAINER_PROFILE (prof)), i = 0; tmp;
        tmp = tmp->next, i++) {
      GstEncodingProfile *sprof = (GstEncodingProfile *) tmp->data;

      if (!serialize_stream_profiles (out, sprof, profname, i))
        return FALSE;
    }
  }
  if (profformat)
    gst_caps_unref (profformat);
  g_free (profgroupname);
  return TRUE;
}
Beispiel #25
0
gint
main (gint argc, gchar * argv[])
{
  gchar *str;
  GstCaps *caps, *res_caps;
  GstStructure *strc;
  GValue value = { 0 };
  TestBool yes, no;

  /* register multichannel type */
  gst_init (&argc, &argv);
  test_bool_get_type ();

  /* test some caps */
  caps = gst_caps_new_simple ("application/x-gst-test", NULL);
  str = gst_caps_to_string (caps);
  g_assert (str);
  g_free (str);

  /* set enums in list */
  strc = gst_caps_get_structure (caps, 0);
  g_value_init (&value, TEST_BOOL_TYPE);
  g_value_set_enum (&value, TEST_YES);
  gst_structure_set_value (strc, "yes", &value);
  g_value_set_enum (&value, TEST_NO);
  gst_structure_set_value (strc, "no", &value);
  g_value_unset (&value);

  /* test to-/from-string conversions for enums */
  str = gst_caps_to_string (caps);
  g_assert (str);
  res_caps = gst_caps_from_string (str);
  g_free (str);

  /* see if all worked */
  strc = gst_caps_get_structure (res_caps, 0);
  yes = g_value_get_enum (gst_structure_get_value (strc, "yes"));
  no = g_value_get_enum (gst_structure_get_value (strc, "no"));
  g_assert (yes == TEST_YES && no == TEST_NO);
  gst_caps_unref (caps);
  gst_caps_unref (res_caps);

  /* yes */
  return 0;
}
Beispiel #26
0
/// Sets caps on capsfilter
void VideoSource::setCapsFilter(const std::string &capsStr)
{
    assert(capsFilter_);
    GstCaps *videoCaps = gst_caps_from_string(capsStr.c_str());
    LOG_DEBUG("Setting caps to " << gst_caps_to_string(videoCaps));
    g_object_set(G_OBJECT(capsFilter_), "caps", videoCaps, NULL);

    gst_caps_unref(videoCaps);
}
Beispiel #27
0
void Uridecodebin::unknown_type_cb(GstElement* bin,
                                   GstPad* pad,
                                   GstCaps* caps,
                                   gpointer user_data) {
  Uridecodebin* context = static_cast<Uridecodebin*>(user_data);
  g_warning(
      "Uridecodebin unknown type: %s (%s)\n", gst_caps_to_string(caps), gst_element_get_name(bin));
  context->pad_to_shmdata_writer(context->gst_pipeline_->get_pipeline(), pad);
}
Beispiel #28
0
static void cb_typefound(GstElement* , guint probability,
        GstCaps* caps, gpointer )
{
    //GMainLoop* loop = data;

    gchar* type = gst_caps_to_string(caps);
    std::cout << "Stream of " << type << " found, propability " << probability << "%" << std::endl;
    g_free(type);
}
static GstEncodingProfile *
create_profile (GstCaps * cf, GstCaps * vf, GstCaps * af)
{
    GstEncodingContainerProfile *cprof = NULL;

    cprof =
        gst_encoding_container_profile_new ((gchar *) "test-application-profile",
                                            NULL, cf, NULL);

    if (vf)
        gst_encoding_container_profile_add_profile (cprof,
                (GstEncodingProfile *) gst_encoding_video_profile_new (vf,
                        NULL, NULL, 0));
    if (af)
        gst_encoding_container_profile_add_profile (cprof, (GstEncodingProfile *)
                gst_encoding_audio_profile_new (af, NULL, NULL, 0));

    /* Let's print out some info */
    if (!silent) {
        gchar *desc = gst_pb_utils_get_codec_description (cf);
        gchar *cd = gst_caps_to_string (cf);
        g_print ("Encoding parameters\n");
        g_print ("  Container format : %s (%s)\n", desc, cd);
        g_free (desc);
        g_free (cd);
        if (vf) {
            desc = gst_pb_utils_get_codec_description (vf);
            cd = gst_caps_to_string (vf);
            g_print ("  Video format : %s (%s)\n", desc, cd);
            g_free (desc);
            g_free (cd);
        }
        if (af) {
            desc = gst_pb_utils_get_codec_description (af);
            cd = gst_caps_to_string (af);
            g_print ("  Audio format : %s (%s)\n", desc, cd);
            g_free (desc);
            g_free (cd);
        }
    }

    return (GstEncodingProfile *) cprof;
}
static GstFlowReturn
gst_caps_debug_bufferalloc (GstPad * pad, guint64 offset, guint size,
    GstCaps * caps, GstBuffer ** buf)
{
  GstCapsDebug *capsdebug;
  gchar *s;
  gchar *t;
  GstFlowReturn ret;
  GstPad *otherpad;
  gboolean newcaps;

  capsdebug = GST_CAPS_DEBUG (gst_pad_get_parent (pad));
  otherpad =
      (pad == capsdebug->srcpad) ? capsdebug->sinkpad : capsdebug->srcpad;

  newcaps = (caps != GST_PAD_CAPS (pad));

  if (newcaps) {
    s = gst_caps_to_string (caps);
    GST_INFO ("%s called bufferalloc with new caps, offset=%" G_GUINT64_FORMAT
        " size=%d caps=%s", THISPAD, offset, size, s);
    g_free (s);
  }

  ret = gst_pad_alloc_buffer_and_set_caps (otherpad, offset, size, caps, buf);

  if (newcaps) {
    GST_INFO ("%s returned %s", OTHERPAD, gst_flow_get_name (ret));
  }
  if (caps != GST_BUFFER_CAPS (*buf)) {
    s = gst_caps_to_string (caps);
    t = gst_caps_to_string (GST_BUFFER_CAPS (*buf));
    GST_INFO
        ("%s returned from bufferalloc with different caps, requested=%s returned=%s",
        OTHERPAD, s, t);
    g_free (s);
    g_free (t);
  }

  gst_object_unref (capsdebug);

  return ret;
}