Ejemplo n.º 1
0
GST_END_TEST
GST_START_TEST (check_properties)
{
  GstElement *filterelement, *filter;
  GstElementFactory *factory;
  gchar *filter_factory;

  filterelement = gst_element_factory_make ("filterelement", NULL);

  /* Default value for filter factory must be NULL */
  g_object_get (G_OBJECT (filterelement), "filter_factory", &filter_factory,
      NULL);
  GST_DEBUG ("Got filter_factory property value : %s", filter_factory);
  fail_unless (filter_factory == NULL);

  /* Default value for filter must be NULL */
  g_object_get (G_OBJECT (filterelement), "filter", &filter, NULL);
  GST_DEBUG ("Got filter property value : %" GST_PTR_FORMAT, filter);
  fail_unless (filter == NULL);

  /* Set factory */
  filter_factory = "videoflip";
  GST_DEBUG ("Setting property uri to : %s", filter_factory);
  g_object_set (G_OBJECT (filterelement), "filter_factory", filter_factory,
      NULL);

  g_object_get (G_OBJECT (filterelement), "filter", &filter, NULL);
  fail_unless (filter != NULL);
  factory = gst_element_get_factory (filter);
  fail_unless (factory != NULL);
  GST_DEBUG ("Got factory: %s", GST_OBJECT_NAME (factory));
  fail_unless (g_strcmp0 (filter_factory, GST_OBJECT_NAME (factory)) == 0);

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (filterelement),
      GST_DEBUG_GRAPH_SHOW_ALL, "filter");

  /* Reset factory */
  filter_factory = "videocrop";
  GST_DEBUG ("Setting property uri to : %s", filter_factory);
  g_object_set (G_OBJECT (filterelement), "filter_factory", filter_factory,
      NULL);

  g_object_get (G_OBJECT (filterelement), "filter", &filter, NULL);
  fail_unless (filter != NULL);
  factory = gst_element_get_factory (filter);
  fail_unless (factory != NULL);
  GST_DEBUG ("Got factory: %s", GST_OBJECT_NAME (factory));
  /* Factory changes are not allowed */
  fail_unless (g_strcmp0 (filter_factory, GST_OBJECT_NAME (factory)));

  gst_object_unref (filterelement);
}
Ejemplo n.º 2
0
static void
conference_element_added (FsElementAddedNotifier *notifier,
    GstBin *bin,
    GstElement *element,
    gpointer user_data)
{
  GstElementFactory *factory;
  const gchar *name;

  factory = gst_element_get_factory (element);
  name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));

  if (!tp_strdiff (name, "x264enc"))
    {
      /* Ensure that the encoder creates the baseline profile */
      g_object_set (element,
          "byte-stream", TRUE,
          "bframes", 0,
          "b-adapt", FALSE,
          "cabac", FALSE,
          "dct8x8", FALSE,
          NULL);
    }
  else if (!tp_strdiff (name, "gstrtpbin"))
    {
      /* Lower the jitterbuffer latency to make it more suitable for video
       * conferencing */
      g_object_set (element, "latency", 100, NULL);
    }
}
Ejemplo n.º 3
0
static struct device_resources find_source (GstElement* self)
{

    struct device_resources res = {};
    res.color.max = 255;

    /* if camera_src is not set we assume that the first default camera src found shall be used */

    GstElement* e = GST_ELEMENT(gst_object_get_parent(GST_OBJECT(self)));

    GList* l =  GST_BIN(e)->children;

    while (1==1)
    {

        const char* name = g_type_name(gst_element_factory_get_element_type(gst_element_get_factory(l->data)));

        if (g_strcmp0(name, "GstTcamSrc") == 0)
        {
            GST_INFO("Found tcam source element");
            res.source_element = l->data;
            break;
        }

        if (g_list_next(l) == NULL)
            break;

        l = g_list_next(l);
    }

    update_device_resources(&res);

    return res;
}
Ejemplo n.º 4
0
static void
element_setup (GstElement * playbin, GstElement * element, GQueue * elts)
{
  GstElementFactory *f = gst_element_get_factory (element);

  g_queue_push_tail (elts, f ? GST_OBJECT_NAME (f) : GST_OBJECT_NAME (element));
}
Ejemplo n.º 5
0
GstElement* tcam_gst_find_camera_src (GstElement* element)
{
    GstPad* orig_pad = gst_element_get_static_pad(element, "sink");

    GstPad* src_pad = gst_pad_get_peer(orig_pad);
    g_object_unref(orig_pad);

    if (!src_pad)
    {
        // this means we have reached a dead end where no valid tcamsrc exists
        return nullptr;
    }

    GstElement* el = gst_pad_get_parent_element(src_pad);

    gst_object_unref(src_pad);
    GstElement* ret;
    const char* name = g_type_name(gst_element_factory_get_element_type(gst_element_get_factory(el)));
    if (g_strcmp0(name, "GstTcamSrc") == 0)
    {
        return el;
    }
    ret =  tcam_gst_find_camera_src(el);

    gst_object_unref(el);

    return ret;
}
Ejemplo n.º 6
0
static GstElement *
kms_av_muxer_create_muxer (KmsAVMuxer * self)
{
  switch (KMS_BASE_MEDIA_MUXER_GET_PROFILE (self)) {
    case KMS_RECORDING_PROFILE_WEBM:
    case KMS_RECORDING_PROFILE_WEBM_VIDEO_ONLY:
    case KMS_RECORDING_PROFILE_WEBM_AUDIO_ONLY:
      return gst_element_factory_make ("webmmux", NULL);
    case KMS_RECORDING_PROFILE_MP4:
    case KMS_RECORDING_PROFILE_MP4_VIDEO_ONLY:
    case KMS_RECORDING_PROFILE_MP4_AUDIO_ONLY:{
      GstElement *mux = gst_element_factory_make ("mp4mux", NULL);
      GstElementFactory *file_sink_factory =
          gst_element_factory_find ("filesink");
      GstElementFactory *sink_factory =
          gst_element_get_factory (self->priv->sink);

      if ((gst_element_factory_get_element_type (sink_factory) !=
              gst_element_factory_get_element_type (file_sink_factory))) {
        g_object_set (mux, "faststart", TRUE, NULL);
      }

      g_object_unref (file_sink_factory);
      return mux;
    }
    case KMS_RECORDING_PROFILE_JPEG_VIDEO_ONLY:
      return gst_element_factory_make ("jifmux", NULL);
    default:
      GST_ERROR_OBJECT (self, "No valid recording profile set");
      return NULL;
  }
}
Ejemplo n.º 7
0
static void
mutate_playbin (RBVisualizerPlugin *plugin, GstElement *playbin)
{
	GstElement *current_vis_plugin;
	GstElement *current_video_sink;
	int playbin_flags;

	if (playbin == plugin->playbin)
		return;

	rb_debug ("mutating playbin");

	/* check no one has already set the playbin properties we're interested in */
	g_object_get (playbin,
		      "vis-plugin", &current_vis_plugin,
		      "video-sink", &current_video_sink,
		      "flags", &playbin_flags,
		      NULL);

	/* ignore fakesinks */
	if (current_video_sink != NULL) {
		const char *factoryname;
		GstElementFactory *factory;

		factory = gst_element_get_factory (current_video_sink);
		factoryname = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
		if (strcmp (factoryname, "fakesink") == 0) {
			g_object_unref (current_video_sink);
			current_video_sink = NULL;
		}
	}

	if ((current_vis_plugin != NULL) || (current_video_sink != NULL)) {
		g_warning ("sink and/or vis plugin already set on playbin");
		if (current_vis_plugin)
			g_object_unref (current_vis_plugin);
		if (current_video_sink)
			g_object_unref (current_video_sink);
		return;
	}

	/* detach from old playbin (this should never really happen) */
	if (plugin->playbin) {
		g_object_unref (plugin->playbin);
	}

	/* attach to new playbin */
	plugin->playbin = g_object_ref (playbin);
	g_object_set (plugin->playbin, "video-sink", plugin->sink, NULL);

	/* start visualizer if it's supposed to be running */
	if (plugin->visualizer != NULL) {
		playbin_flags |= PLAYBIN2_FLAG_VIS;
		g_object_set (plugin->playbin,
			      "flags", playbin_flags,
			      "vis-plugin", plugin->visualizer,
			      NULL);
	}
}
Ejemplo n.º 8
0
static const gchar *
factory_name_from_element (GstElement *element)
{
  GstElementFactory *factory = gst_element_get_factory (element);

  if (factory)
    return gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
  else
    return NULL;
}
static void
test_position (InsanityTest * test, GstBuffer * buf)
{
  GstQuery *query;
  GstClockTimeDiff diff;

  if (GST_BUFFER_PTS_IS_VALID (buf) == FALSE)
    return;

  if (GST_CLOCK_TIME_IS_VALID (glob_first_pos_point) == FALSE) {
    glob_first_pos_point = gst_segment_to_stream_time (&glob_last_segment,
        glob_last_segment.format, GST_BUFFER_PTS (buf));
  }

  glob_expected_pos = gst_segment_to_stream_time (&glob_last_segment,
      glob_last_segment.format, GST_BUFFER_PTS (buf));

  diff = ABS (GST_CLOCK_DIFF (glob_expected_pos, glob_first_pos_point));

  if (diff < glob_playback_duration * GST_SECOND)
    return;

  query = gst_query_new_position (GST_FORMAT_TIME);

  if (gst_element_query (glob_pipeline, query)) {
    gint64 pos;
    GstFormat fmt;
    GstClockTimeDiff diff;

    gst_query_parse_position (query, &fmt, &pos);
    diff = ABS (GST_CLOCK_DIFF (glob_expected_pos, pos));

    if (diff <= POSITION_THRESHOLD) {
      insanity_test_validate_checklist_item (test, "position-detection", TRUE,
          NULL);
    } else {
      gchar *validate_msg = g_strdup_printf ("Found position: %" GST_TIME_FORMAT
          " expected: %" GST_TIME_FORMAT, GST_TIME_ARGS (pos),
          GST_TIME_ARGS (glob_expected_pos));

      insanity_test_validate_checklist_item (test, "position-detection",
          FALSE, validate_msg);

      g_free (validate_msg);
    }
  } else {
    LOG (test,
        "%s Does not handle position queries (position-detection \"SKIP\")",
        gst_element_factory_get_metadata (gst_element_get_factory
            (glob_demuxer), GST_ELEMENT_METADATA_LONGNAME));
  }

  next_test (test);
}
Ejemplo n.º 10
0
static gint
find_composition_func (const GValue * velement)
{
  GstElement *element = g_value_get_object (velement);
  GstElementFactory *fac = gst_element_get_factory (element);
  const gchar *name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (fac));

  if (g_strcmp0 (name, "gnlcomposition") == 0)
    return 0;

  return 1;
}
Ejemplo n.º 11
0
gboolean
rb_gst_encoder_set_encoding_style (GstElement *encoder, const char *style)
{
	GstElementFactory *factory;
	char *group_name;
	char **keys;
	int i;

	factory = gst_element_get_factory (encoder);
	group_name = g_strdup_printf (ENCODER_STYLE_SETTINGS_PREFIX "%s-%s",
				      gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)),
				      style);
	rb_debug ("applying settings from %s", group_name);

	keys = g_key_file_get_keys (get_target_keyfile (), group_name, NULL, NULL);
	if (keys == NULL) {
		rb_debug ("nothing to apply");
		g_free (group_name);
		return FALSE;
	}

	for (i = 0; keys[i] != NULL; i++) {
		GParamSpec *pspec;
		GValue v = {0,};
		char *value;

		pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (encoder), keys[i]);
		if (pspec == NULL) {
			rb_debug ("couldn't find property %s", keys[i]);
			continue;
		}

		value = g_key_file_get_string (get_target_keyfile (), group_name, keys[i], NULL);
		if (value == NULL) {
			rb_debug ("couldn't get value for property %s", keys[i]);
			continue;
		}

		g_value_init (&v, pspec->value_type);
		if (gst_value_deserialize (&v, value)) {
			rb_debug ("applying value \"%s\" to property %s", value, keys[i]);
			g_object_set_property (G_OBJECT (encoder), keys[i], &v);
		} else {
			rb_debug ("couldn't deserialize value \"%s\" for property %s", value, keys[i]);
		}

		g_value_unset (&v);
	}

	g_strfreev (keys);
	g_free (group_name);
	return TRUE;
}
Ejemplo n.º 12
0
GstElement * _owr_payload_create_encoder(OwrPayload *payload)
{
    GstElement *encoder = NULL;
    gchar *element_name = NULL;
    GstElementFactory *factory;
    const gchar *factory_name;

    g_return_val_if_fail(payload, NULL);

    switch (payload->priv->codec_type) {
    case OWR_CODEC_TYPE_H264:
        encoder = try_codecs(h264_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);

        factory = gst_element_get_factory(encoder);
        factory_name = gst_plugin_feature_get_name(factory);

        if (!strcmp(factory_name, "openh264enc")) {
            g_object_set(encoder, "gop-size", 0, NULL);
            gst_util_set_object_arg(G_OBJECT(encoder), "rate-control", "bitrate");
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        } else if (!strcmp(factory_name, "x264enc")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
            g_object_set(encoder, "tune", 0x04 /* zero-latency */, NULL);
        } else if (!strcmp(factory_name, "vtenc_h264")) {
            g_object_bind_property_full(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE,
                binding_transform_to_kbps, NULL, NULL, NULL);
        } else {
            /* Assume bits/s instead of kbit/s */
            g_object_bind_property(payload, "bitrate", encoder, "bitrate", G_BINDING_SYNC_CREATE);
        }
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;

    case OWR_CODEC_TYPE_VP8:
        encoder = try_codecs(vp8_encoders, "encoder");
        g_return_val_if_fail(encoder, NULL);
        g_object_set(encoder, "end-usage", 1, "deadline", G_GINT64_CONSTANT(1), "lag-in-frames", 0,
            "error-resilient", 1, "keyframe-mode", 0, NULL);
        g_object_bind_property(payload, "bitrate", encoder, "target-bitrate", G_BINDING_SYNC_CREATE);
        g_object_set(payload, "bitrate", evaluate_bitrate_from_payload(payload), NULL);
        break;
    default:
        element_name = g_strdup_printf("encoder_%s_%u", OwrCodecTypeEncoderElementName[payload->priv->codec_type], get_unique_id());
        encoder = gst_element_factory_make(OwrCodecTypeEncoderElementName[payload->priv->codec_type], element_name);
        g_free(element_name);
        g_return_val_if_fail(encoder, NULL);
        break;
    }

    return encoder;
}
nsresult GStreamerReader::CheckSupportedFormats()
{
  bool done = false;
  bool unsupported = false;

  GstIterator *it = gst_bin_iterate_recurse(GST_BIN(mPlayBin));
  while (!done) {
    GstElement* element;
    GstIteratorResult res = gst_iterator_next(it, (void **)&element);
    switch(res) {
      case GST_ITERATOR_OK:
      {
        GstElementFactory* factory = gst_element_get_factory(element);
        if (factory) {
          const char* klass = gst_element_factory_get_klass(factory);
          GstPad* pad = gst_element_get_pad(element, "sink");
          if (pad) {
            GstCaps* caps = gst_pad_get_negotiated_caps(pad);

            if (caps) {
              /* check for demuxers but ignore elements like id3demux */
              if (strstr (klass, "Demuxer") && !strstr(klass, "Metadata"))
                unsupported = !GStreamerFormatHelper::Instance()->CanHandleContainerCaps(caps);
              else if (strstr (klass, "Decoder"))
                unsupported = !GStreamerFormatHelper::Instance()->CanHandleCodecCaps(caps);

              gst_caps_unref(caps);
            }
            gst_object_unref(pad);
          }
        }

        gst_object_unref(element);
        done = unsupported;
        break;
      }
      case GST_ITERATOR_RESYNC:
        unsupported = false;
        done = false;
        break;
      case GST_ITERATOR_ERROR:
        done = true;
        break;
      case GST_ITERATOR_DONE:
        done = true;
        break;
    }
  }

  return unsupported ? NS_ERROR_FAILURE : NS_OK;
}
GstElement *
_bp_equalizer_new (BansheePlayer *player)
{
    GstElement *equalizer;
    
    if (player->equalizer_status == BP_EQ_STATUS_DISABLED) {
        return NULL;
    }
    
    if (player->equalizer_status == BP_EQ_STATUS_UNCHECKED || 
        player->equalizer_status == BP_EQ_STATUS_USE_BUILTIN) {
        equalizer = gst_element_factory_make ("banshee-equalizer", "banshee-equalizer");
        if (equalizer != NULL) {
            if (player->equalizer_status == BP_EQ_STATUS_UNCHECKED) {
                player->equalizer_status = BP_EQ_STATUS_USE_BUILTIN;
                bp_debug ("Using built-in equalizer element");
            }
            
            return equalizer;
        }
    }
    
    if (player->equalizer_status == BP_EQ_STATUS_UNCHECKED || 
        player->equalizer_status == BP_EQ_STATUS_USE_SYSTEM) {
        equalizer = gst_element_factory_make ("equalizer-10bands", "equalizer-10bands");
        if (equalizer != NULL) {
            GstElementFactory *efactory = NULL;

            if (player->equalizer_status == BP_EQ_STATUS_USE_SYSTEM) {
                return equalizer;
            }
            
            efactory = gst_element_get_factory (equalizer);
            if (gst_plugin_feature_check_version (GST_PLUGIN_FEATURE (efactory), 0, 10, 9)) {
                bp_debug ("Using system (gst-plugins-good) equalizer element");
                player->equalizer_status = BP_EQ_STATUS_USE_SYSTEM;
                return equalizer;
            }
            
            bp_debug ("Buggy system equalizer found. gst-plugins-good 0.10.9 or better "
                "required, or build Banshee with the built-in equalizer.");
            gst_object_unref (equalizer);
        } else {
            bp_debug ("No system equalizer found");
        }
    }
    
    bp_debug ("No suitable equalizer element could be found, disabling EQ for this session");
    player->equalizer_status = BP_EQ_STATUS_DISABLED;
    return NULL;
}
static void
add_element_used (InsanityGstPipelineTest * ptest, GstElement * element)
{
  GstElementFactory *factory;
  const char *factory_name;
  char label[32], *element_name;
  GValue string_value = { 0 };
  GstElement *parent;

  /* Only add once */
  element_name = gst_element_get_name (element);
  if (g_hash_table_lookup_extended (ptest->priv->elements_used, element_name,
          NULL, NULL)) {
    g_free (element_name);
    return;
  }
  g_hash_table_insert (ptest->priv->elements_used, g_strdup (element_name),
      NULL);

  ptest->priv->element_count++;
  g_value_init (&string_value, G_TYPE_STRING);

  factory = gst_element_get_factory (element);
  factory_name =
      factory ? gst_element_factory_get_metadata (factory,
      GST_ELEMENT_METADATA_LONGNAME) : "(no factory)";

  g_value_take_string (&string_value, element_name);
  snprintf (label, sizeof (label), "elements-used.%u.name",
      ptest->priv->element_count);
  insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value);
  g_value_reset (&string_value);

  g_value_set_string (&string_value, factory_name);
  snprintf (label, sizeof (label), "elements-used.%u.factory",
      ptest->priv->element_count);
  insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value);
  g_value_reset (&string_value);

  parent = GST_ELEMENT (gst_element_get_parent (element));
  if (parent) {
    g_value_take_string (&string_value, gst_element_get_name (parent));
    snprintf (label, sizeof (label), "elements-used.%u.parent",
        ptest->priv->element_count);
    insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value);
    g_value_reset (&string_value);
    gst_object_unref (parent);
  }
}
static void
unvalidate_seeking_tests (InsanityTest * test)
{
  gchar *message = g_strdup_printf ("%s not seekable in %s mode",
      gst_element_factory_get_metadata (gst_element_get_factory
          (glob_demuxer), GST_ELEMENT_METADATA_LONGNAME),
      pipeline_mode_get_name (glob_push_mode));

  insanity_test_validate_checklist_item (test, "fast-forward", TRUE, message);
  insanity_test_validate_checklist_item (test, "fast-backward", TRUE, message);
  insanity_test_validate_checklist_item (test, "backward-playback", TRUE,
      message);

  g_free (message);
}
static gint
find_hlsdemux (GValue * value, gpointer user_data)
{
  GstElement *e = GST_ELEMENT (g_value_get_object (value));
  GstObject *fact = GST_OBJECT (gst_element_get_factory (e));
  gchar *name = gst_object_get_name (fact);

  if (g_strcmp0 (name, "hlsdemux") == 0) {
    g_free (name);
    return 0;
  }

  g_free (name);

  return 1;
}
Ejemplo n.º 18
0
void GStreamerReader::ElementAddedCb(GstBin *aPlayBin,
                                     GstElement *aElement,
                                     gpointer aUserData)
{
  GstElementFactory *factory = gst_element_get_factory(aElement);

  if (!factory)
    return;

  const gchar *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory));

  if (name && !strcmp(name, "uridecodebin")) {
    g_signal_connect(G_OBJECT(aElement), "autoplug-sort",
                     G_CALLBACK(GStreamerReader::ElementFilterCb), aUserData);
  }
}
Ejemplo n.º 19
0
static void
element_added (FsElementAddedNotifier *notif, GstBin *bin, GstElement *element,
    gpointer user_data)
{
  GstElementFactory *fact = gst_element_get_factory (element);

  if (!fact)
    return;

  if (strcmp (gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (fact)),
              "theoradec"))
    return;

  ts_fail_unless (decoder_count == 0);
  decoder_count++;
}
Ejemplo n.º 20
0
struct device_resources find_source (GstElement* self)
{

    struct device_resources res = {};
    res.color.max = 255;

    /* if camera_src is not set we assume that the first default camera src found shall be used */

    GstElement* e = GST_ELEMENT( gst_object_get_parent(GST_OBJECT(self)));

    GList* l =  GST_BIN(e)->children;

    while (1==1)
    {

        const char* name = g_type_name(gst_element_factory_get_element_type (gst_element_get_factory(l->data)));

        if (g_strcmp0(name, CAMERASRC_USB) == 0)
        {
            GST_LOG_OBJECT(self, "Found v4l2 device");
            res.source_type = V4L2;
            res.source_element = l->data;
            break;
        }
        if (g_strcmp0(name, CAMERASRC_NETWORK) == 0)
        {
            GST_LOG_OBJECT(self, "Found aravis device");
            res.source_type = ARAVIS;
            res.source_element = l->data;
            break;
        }

        if (g_list_next(l) == NULL)
            break;

        l = g_list_next(l);
    }

    if (res.source_type == UNKNOWN)
    {
        GST_LOG_OBJECT(self, "Unknown source type");
    }

    update_device_resources (&res);

    return res;
}
Ejemplo n.º 21
0
static gpointer
rb_audiocd_load_songs (RBAudioCdSource *source)
{
	RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source);
	RhythmDB *db;
	GVolume *volume;

	g_object_get (source, "volume", &volume, NULL);
	priv->device_path = g_volume_get_identifier (volume,
						     G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
	g_object_unref (volume);

	db = get_db_for_source (source);

	rb_debug ("loading Audio CD from %s", priv->device_path);
	/* create a cdda gstreamer element, to get cd info from */
	priv->cdda = gst_element_make_from_uri (GST_URI_SRC, "cdda://", NULL);
	if (!priv->cdda) {
		gdk_threads_enter ();
		rb_error_dialog (NULL, _("Couldn't load Audio CD"),
					_("Rhythmbox could not get access to the CD device."));
		gdk_threads_leave ();
		goto error_out;
	}

	rb_debug ("cdda longname: %s", gst_element_factory_get_longname (gst_element_get_factory (priv->cdda)));
	g_object_set (G_OBJECT (priv->cdda), "device", priv->device_path, NULL);
	priv->pipeline = gst_pipeline_new ("pipeline");
	priv->fakesink = gst_element_factory_make ("fakesink", "fakesink");
	gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdda, priv->fakesink, NULL);
	gst_element_link (priv->cdda, priv->fakesink);

	/* disable paranoia (if using cdparanoia) since we're only reading track information here.
	 * this reduces cdparanoia's cache size, so the process is much faster.
	 */
	if (g_object_class_find_property (G_OBJECT_GET_CLASS (source), "paranoia-mode"))
		g_object_set (source, "paranoia-mode", 0, NULL);

	if (rb_audiocd_scan_songs (source, db))
		rb_audiocd_load_metadata (source, db);

error_out:
	g_object_unref (db);
	g_object_unref (source);

	return NULL;
}
Ejemplo n.º 22
0
bool ofGstUtils::setPipelineWithSink(GstElement * pipeline, GstElement * sink, bool isStream_){
	gstPipeline = pipeline;
	gstSink = sink;
	isStream = isStream_;

	if(gstSink){
		gst_base_sink_set_sync(GST_BASE_SINK(gstSink), true);
	}

	if(gstSink && string(gst_plugin_feature_get_name( GST_PLUGIN_FEATURE(gst_element_get_factory(gstSink))))=="appsink"){
		isAppSink = true;
	}else{
		isAppSink = false;
	}

	return startPipeline();
}
Ejemplo n.º 23
0
static gboolean
mixer_filter_func (GstMixer * mixer, gpointer user_data)
{
  GstElementFactory *factory;
  const gchar *long_name;
  gchar *devname = NULL;
  gchar *name;
  gint *p_count = (gint *) user_data;

  /* fetch name */
  if (g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (mixer)),
                                    "device-name")) {
    g_object_get (mixer, "device-name", &devname, NULL);
    GST_DEBUG ("device name: %s", GST_STR_NULL (devname));
  } else {
    devname = NULL;
    GST_DEBUG ("device name unknown, no 'device-name' property");
  }
    
  factory = gst_element_get_factory (GST_ELEMENT (mixer));
  long_name = gst_element_factory_get_longname (factory);

  if (devname) {
    name = g_strdup_printf ("%s (%s)", devname, long_name);
    g_free (devname);
  } else {
    gchar *title;

    *p_count += 1;

    title = g_strdup_printf (_("Unknown Volume Control %d"),  *p_count);
    name = g_strdup_printf ("%s (%s)", title, long_name);
    g_free (title);
  }

  g_object_set_data_full (G_OBJECT (mixer),
                          "mate-volume-control-name",
                          name,
                          (GDestroyNotify) g_free);

  GST_DEBUG ("Adding '%s' to list of available mixers", name);

  gst_element_set_state (GST_ELEMENT (mixer), GST_STATE_NULL);

  return TRUE; /* add mixer to list */
}
Ejemplo n.º 24
0
static gint find_by_factory_func(gconstpointer p_value_ptr, gconstpointer p_user_data)
{
	GValue const *value = static_cast < GValue const* > (p_value_ptr);
	std::string const *expected_factory_name = static_cast < std::string const * > (p_user_data);

	GstElement *elem = GST_ELEMENT(g_value_get_object(value));

	GST_OBJECT_LOCK(elem);

	GstElementFactory *factory = gst_element_get_factory(elem);
	gchar const *factory_name = gst_plugin_feature_get_name(factory);

	gint result = (factory_name == *expected_factory_name) ? 0 : 1;

	GST_OBJECT_UNLOCK(elem);

	return result;
}
Ejemplo n.º 25
0
static char *
make_bundle_name (GstObject * obj, const gchar * name)
{
  GstElementFactory *factory;
  gchar *basename, *s, *bundle;

  factory = gst_element_get_factory ((GstElement *) obj);
  basename = g_strdup (gst_element_factory_get_metadata (factory,
          GST_ELEMENT_METADATA_LONGNAME));
  s = basename;
  while ((s = strchr (s, ' '))) {
    *s = '_';
  }
  bundle = g_strjoin (NULL, basename, "_", name, ".preset.lv2", NULL);

  g_free (basename);

  return bundle;
}
Ejemplo n.º 26
0
static void
remove_on_unlinked_async (gpointer data, gpointer not_used)
{
  GstElement *elem = GST_ELEMENT_CAST (data);
  GstObject *parent = gst_object_get_parent (GST_OBJECT (elem));

  gst_element_set_locked_state (elem, TRUE);
  if (g_strcmp0 (GST_OBJECT_NAME (gst_element_get_factory (elem)),
          "queue") == 0) {
    g_object_set (G_OBJECT (elem), "flush-on-eos", TRUE, NULL);
    gst_element_send_event (elem, gst_event_new_eos ());
  }
  gst_element_set_state (elem, GST_STATE_NULL);
  if (parent != NULL) {
    gst_bin_remove (GST_BIN (parent), elem);
    g_object_unref (parent);
  }

  g_object_unref (data);
}
void CameraBinAudioEncoder::applySettings(GstElement *encoder)
{
    GObjectClass * const objectClass = G_OBJECT_GET_CLASS(encoder);
    const char * const name = gst_plugin_feature_get_name(
                GST_PLUGIN_FEATURE(gst_element_get_factory(encoder)));

    const bool isVorbis = qstrcmp(name, "vorbisenc") == 0;

    const int bitRate = m_actualAudioSettings.bitRate();
    if (!isVorbis && bitRate == -1) {
        // Bit rate is invalid, don't evaluate the remaining conditions unless the encoder is
        // vorbisenc which is known to accept -1 as an unspecified bitrate.
    } else if (g_object_class_find_property(objectClass, "bitrate")) {
        g_object_set(G_OBJECT(encoder), "bitrate", bitRate, NULL);
    } else if (g_object_class_find_property(objectClass, "target-bitrate")) {
        g_object_set(G_OBJECT(encoder), "target-bitrate", bitRate, NULL);
    }

    if (isVorbis) {
        static const double qualities[] = { 0.1, 0.3, 0.5, 0.7, 1.0 };
        g_object_set(G_OBJECT(encoder), "quality", qualities[m_actualAudioSettings.quality()], NULL);
    }
}
Ejemplo n.º 28
0
void
GstUtils::set_element_property_in_bin(GstElement *bin,
                                      const gchar *factory_name,
                                      const gchar *property_name,
                                      gboolean property_value) {
  if (!GST_IS_BIN(bin))
    return;

  if (g_list_length(GST_BIN_CHILDREN(GST_BIN(bin))) > 0) {
    GList *child = nullptr, *children = GST_BIN_CHILDREN(GST_BIN(bin));
    for (child = children; child != nullptr; child = g_list_next(child)) {
      GstElement *current_element = GST_ELEMENT(child->data);
      GstElementFactory *factory = gst_element_get_factory(current_element);
      // g_print ("The '%s' element is a member of the category %s.\n"
      //  "Description: %s\n",
      //  gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (sub_factory)),
      //  gst_element_factory_get_klass (sub_factory),
      //  gst_element_factory_get_description (sub_factory));
      if (g_strcmp0(factory_name,
                    gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory)))
          == 0) {
        g_debug("GstUtils: setting property for %s", factory_name);
        g_object_set(G_OBJECT(current_element), property_name,
                     property_value, nullptr);
      }

      if (GST_IS_BIN(current_element)) {  // recursive
        GstUtils::set_element_property_in_bin(current_element,
                                              factory_name,
                                              property_name,
                                              property_value);
      }
      
    }
  }
}
Ejemplo n.º 29
0
GstElement *
GstUtils::get_first_element_from_factory_name(GstBin *bin,
                                              const std::string &factory_name) {
  if (!GST_IS_BIN(bin)) {
    g_warning("%s: first argument is not a bin", __FUNCTION__);
    return nullptr;
  }

  if (g_list_length(GST_BIN_CHILDREN(bin)) == 0) {
    g_warning("%s: bin has no child", __FUNCTION__);
    return nullptr;
  }

  GList *child = nullptr, *children = GST_BIN_CHILDREN(GST_BIN(bin));
  for (child = children; child != nullptr; child = g_list_next(child)) {
    GstElement *current_element = GST_ELEMENT(child->data);
    GstElementFactory *factory = gst_element_get_factory(current_element);
    if (factory_name == gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory))) {
      return current_element;
    }
  }
  g_warning("%s: no element found for %s", __FUNCTION__, factory_name.c_str());
  return nullptr;
}
Ejemplo n.º 30
0
static gint create_encoder_pipeline (Encoder *encoder)
{
        GstElement *pipeline, *element;
        Bin *bin;
        Link *link;
        GSList *bins, *links, *elements;
        GstElementFactory *element_factory;
        GType type;
        EncoderStream *stream;
        GstAppSrcCallbacks callbacks = {
                need_data_callback,
                NULL,
                NULL
        };
        GstAppSinkCallbacks encoder_appsink_callbacks = {
                NULL,
                NULL,
                new_sample_callback
        };
        GstCaps *caps;
        GstBus *bus;
 
        pipeline = gst_pipeline_new (NULL);

        /* add element to pipeline first. */
        bins = encoder->bins;
        while (bins != NULL) {
                bin = bins->data;
                elements = bin->elements;
                while (elements != NULL) {
                        element = elements->data;
                        if (!gst_bin_add (GST_BIN (pipeline), element)) {
                                GST_ERROR ("add element %s to bin %s error.", gst_element_get_name (element), bin->name);
                                return 1;
                        }
                        elements = g_slist_next (elements);
                }
                bins = g_slist_next (bins);
        }

        /* then links element. */
        bins = encoder->bins;
        while (bins != NULL) {
                bin = bins->data;
                element = bin->first;
                element_factory = gst_element_get_factory (element);
                type = gst_element_factory_get_element_type (element_factory);
                stream = NULL;
                if (g_strcmp0 ("GstAppSrc", g_type_name (type)) == 0) {
                        GST_INFO ("Encoder appsrc found.");
                        stream = encoder_get_stream (encoder, bin->name);
                        gst_app_src_set_callbacks (GST_APP_SRC (element), &callbacks, stream, NULL);
                }
                element = bin->last;
                element_factory = gst_element_get_factory (element);
                type = gst_element_factory_get_element_type (element_factory);
                if ((g_strcmp0 ("GstAppSink", g_type_name (type)) == 0) ||
                    (g_strcmp0 ("GstHlsSink", g_type_name (type)) == 0) ||
                    (g_strcmp0 ("GstFileSink", g_type_name (type)) == 0)) {
                        GstPad *pad;

                        if (g_strcmp0 ("GstAppSink", g_type_name (type)) == 0) {
                                GST_INFO ("Encoder appsink found.");
                                gst_app_sink_set_callbacks (GST_APP_SINK (element), &encoder_appsink_callbacks, encoder, NULL);
                        }
                        pad = gst_element_get_static_pad (element, "sink");
                        gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, encoder_appsink_event_probe, encoder, NULL);
                }
                links = bin->links;
                while (links != NULL) {
                        link = links->data;
                        GST_INFO ("link element: %s -> %s", link->src_name, link->sink_name);
                        if (link->caps != NULL) {
                                caps = gst_caps_from_string (link->caps);
                                gst_element_link_filtered (link->src, link->sink, caps);
                                gst_caps_unref (caps);

                        } else {
                                gst_element_link (link->src, link->sink);
                        }
                        links = g_slist_next (links);
                }
                bins = g_slist_next (bins);
        }
        bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
        gst_bus_add_watch (bus, bus_callback, encoder);
        g_object_unref (bus);
        encoder->pipeline = pipeline;

        return 0;
}