예제 #1
0
void TagExtractor::printOneTag( const GstTagList * list, const gchar * tag, gpointer user_data ) {
	int i, num;

	num = gst_tag_list_get_tag_size( list, tag );
	for (i = 0; i < num; ++i) {
		const GValue *val;

		/* Note: when looking for specific tags, use the gst_tag_list_get_xyz() API,
		 * we only use the GValue approach here because it is more generic */
		val = gst_tag_list_get_value_index( list, tag, i );
		if( G_VALUE_HOLDS_STRING (val)) {
			g_print( "\t%20s : %s\n", tag, g_value_get_string( val ) );
		} else if( G_VALUE_HOLDS_UINT (val)) {
			g_print( "\t%20s : %u\n", tag, g_value_get_uint( val ) );
		} else if( G_VALUE_HOLDS_DOUBLE (val)) {
			g_print( "\t%20s : %g\n", tag, g_value_get_double( val ) );
		} else if( G_VALUE_HOLDS_BOOLEAN (val)) {
			g_print( "\t%20s : %s\n", tag, (g_value_get_boolean( val )) ? "true" : "false" );
		} else if( GST_VALUE_HOLDS_BUFFER (val)) {
			GstBuffer *buf = gst_value_get_buffer (val);
			guint buffer_size = gst_buffer_get_size( buf );

			g_print( "\t%20s : buffer of size %u\n", tag, buffer_size );
		} else if( GST_VALUE_HOLDS_DATE_TIME (val)) {
			GstDateTime *dt = (GstDateTime*) g_value_get_boxed( val );
			gchar *dt_str = gst_date_time_to_iso8601_string( dt );

			g_print( "\t%20s : %s\n", tag, dt_str );
			g_free( dt_str );
		} else {
			g_print( "\t%20s : tag of type '%s'\n", tag, G_VALUE_TYPE_NAME (val));
		}
	}
}
예제 #2
0
static void
print_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
  gint i, num;

  num = gst_tag_list_get_tag_size (list, tag);
  for (i = 0; i < num; ++i) {
    const GValue *val;

    val = gst_tag_list_get_value_index (list, tag, i);
    if (G_VALUE_HOLDS_STRING (val)) {
      g_print ("    %s : %s \n", tag, g_value_get_string (val));
    } else if (G_VALUE_HOLDS_UINT (val)) {
      g_print ("    %s : %u \n", tag, g_value_get_uint (val));
    } else if (G_VALUE_HOLDS_DOUBLE (val)) {
      g_print ("    %s : %g \n", tag, g_value_get_double (val));
    } else if (G_VALUE_HOLDS_BOOLEAN (val)) {
      g_print ("    %s : %s \n", tag,
          g_value_get_boolean (val) ? "true" : "false");
    } else if (GST_VALUE_HOLDS_DATE_TIME (val)) {
      GstDateTime *dt = g_value_get_boxed (val);
      gchar *dt_str = gst_date_time_to_iso8601_string (dt);

      g_print ("    %s : %s \n", tag, dt_str);
      g_free (dt_str);
    } else {
      g_print ("    %s : tag of type '%s' \n", tag, G_VALUE_TYPE_NAME (val));
    }
  }
}
예제 #3
0
CAMLprim value ocaml_gstreamer_message_parse_tag(value _msg)
{
  CAMLparam1(_msg);
  CAMLlocal4(v,s,t,ans);
  GstMessage *msg = Message_val(_msg);
  GstTagList *tags = NULL;
  const GValue *val;
  const gchar *tag;
  int taglen;
  int i, j, n;

  caml_release_runtime_system();
  gst_message_parse_tag(msg, &tags);
  taglen = gst_tag_list_n_tags(tags);
  caml_acquire_runtime_system();

  ans = caml_alloc_tuple(taglen);
  for(i = 0; i < taglen; i++)
    {
      t = caml_alloc_tuple(2);

      // Tag name
      tag = gst_tag_list_nth_tag_name(tags, i);
      Store_field(t, 0, caml_copy_string(tag));

      // Tag fields
      n = gst_tag_list_get_tag_size(tags, tag);
      v = caml_alloc_tuple(n);
      for (j = 0; j < n; j++)
        {
          val = gst_tag_list_get_value_index(tags, tag, j);
          if (G_VALUE_HOLDS_STRING(val)) {
              s = caml_copy_string(g_value_get_string(val));
            }
          else if (GST_VALUE_HOLDS_DATE_TIME(val)) {
              GstDateTime *dt = g_value_get_boxed(val);
              gchar *dt_str = gst_date_time_to_iso8601_string(dt);
              s = caml_copy_string(dt_str);
              g_free(dt_str);
            }
          else {
              //TODO: better typed handling of non-string values?
              char *vc = g_strdup_value_contents(val);
              s = caml_copy_string(vc);
              free(vc);
            }
          Store_field(v, j, s);
        }
      Store_field(t, 1, v);

      Store_field(ans, i, t);
    }

  gst_tag_list_unref(tags);

  CAMLreturn(ans);
}
예제 #4
0
static void
dump_tot (GstMpegTsSection * section)
{
  const GstMpegTsTOT *tot = gst_mpegts_section_get_tot (section);
  gchar *str = gst_date_time_to_iso8601_string (tot->utc_time);

  g_printf ("     utc_time : %s\n", str);
  dump_descriptors (tot->descriptors, 7);
  g_free (str);
}
예제 #5
0
파일: job.c 프로젝트: rongwj/gstreamill
/*
 * job_reset:
 * @job: job object
 *
 * reset job stat
 *
 */
void job_reset (Job *job)
{
        gchar *stat, **stats, **cpustats;
        GstDateTime *start_time;
        gint i;
        EncoderOutput *encoder;
        guint version, window_size;

        *(job->output->state) = JOB_STATE_VOID_PENDING;
        g_file_get_contents ("/proc/stat", &stat, NULL, NULL);
        stats = g_strsplit (stat, "\n", 10);
        cpustats = g_strsplit (stats[0], " ", 10);
        job->start_ctime = 0;
        for (i = 1; i < 8; i++) {
                job->start_ctime += g_ascii_strtoull (cpustats[i], NULL, 10);
        }
        job->last_ctime = 0;
        job->last_utime = 0;
        job->last_stime = 0;
        g_free (stat);
        g_strfreev (stats);
        g_strfreev (cpustats);
        start_time = gst_date_time_new_now_local_time ();
        if (job->last_start_time != NULL) {
                g_free (job->last_start_time);
        }
        job->last_start_time = gst_date_time_to_iso8601_string (start_time);
        gst_date_time_unref (start_time);

        /* is live job with m3u8streaming? */
        if (!(job->is_live) || !(jobdesc_m3u8streaming (job->description))) {
                return;
        }

        version = jobdesc_m3u8streaming_version (job->description);
        if (version == 0) {
                version = 3;
        }
        window_size = jobdesc_m3u8streaming_window_size (job->description);

        for (i = 0; i < job->output->encoder_count; i++) {
                encoder = &(job->output->encoders[i]);

                /* encoder dvr sequence */
                encoder->sequence = job->output->sequence;

                /* reset m3u8 playlist */
                if (encoder->m3u8_playlist != NULL) {
                        m3u8playlist_free (encoder->m3u8_playlist);
                }
                encoder->m3u8_playlist = m3u8playlist_new (version, window_size, 0);
        }
}
예제 #6
0
static void gstreamill_init (Gstreamill *gstreamill)
{
        GstDateTime *start_time;

        gstreamill->stop = FALSE;
        gstreamill->system_clock = gst_system_clock_obtain ();
        g_object_set (gstreamill->system_clock, "clock-type", GST_CLOCK_TYPE_REALTIME, NULL);
        start_time = gst_date_time_new_now_local_time ();
        gstreamill->start_time = gst_date_time_to_iso8601_string (start_time);
        gst_date_time_unref (start_time);
        g_mutex_init (&(gstreamill->job_list_mutex));
        gstreamill->job_list = NULL;
}
예제 #7
0
static void
dump_tdt (GstMpegTsSection * section)
{
  GstDateTime *date = gst_mpegts_section_get_tdt (section);

  if (date) {
    gchar *str = gst_date_time_to_iso8601_string (date);
    g_printf ("     utc_time : %s\n", str);
    g_free (str);
    gst_date_time_unref (date);
  } else {
    g_printf ("     No utc_time present\n");
  }
}
예제 #8
0
static void
dump_eit (GstMpegTsSection * section)
{
  const GstMpegTsEIT *eit = gst_mpegts_section_get_eit (section);
  guint i, len;

  g_assert (eit);

  g_printf ("     service_id          : 0x%04x\n", section->subtable_extension);
  g_printf ("     transport_stream_id : 0x%04x\n", eit->transport_stream_id);
  g_printf ("     original_network_id : 0x%04x\n", eit->original_network_id);
  g_printf ("     segment_last_section_number:0x%02x, last_table_id:0x%02x\n",
      eit->segment_last_section_number, eit->last_table_id);
  g_printf ("     actual_stream : %s, present_following : %s\n",
      eit->actual_stream ? "TRUE" : "FALSE",
      eit->present_following ? "TRUE" : "FALSE");

  len = eit->events->len;
  g_printf ("     %d Event(s):\n", len);
  for (i = 0; i < len; i++) {
    gchar *tmp = (gchar *) "<NO TIME>";
    GstMpegTsEITEvent *event = g_ptr_array_index (eit->events, i);

    if (event->start_time)
      tmp = gst_date_time_to_iso8601_string (event->start_time);
    g_printf ("       event_id:0x%04x, start_time:%s, duration:%"
        GST_TIME_FORMAT "\n", event->event_id, tmp,
        GST_TIME_ARGS (event->duration * GST_SECOND));
    g_printf ("       running_status:0x%02x (%s), free_CA_mode:%d (%s)\n",
        event->running_status, enum_name (GST_TYPE_MPEG_TS_RUNNING_STATUS,
            event->running_status), event->free_CA_mode,
        event->free_CA_mode ? "MAYBE SCRAMBLED" : "NOT SCRAMBLED");
    if (event->start_time)
      g_free (tmp);
    dump_descriptors (event->descriptors, 9);
  }
}
static void
send_tag (const GstTagList * list, const gchar * tag, gpointer data)
{
  InsanityGstPipelineTest *ptest = INSANITY_GST_PIPELINE_TEST (data);
  gint i, count;
  GValue string_value = { 0 };
  char label[48];

  count = gst_tag_list_get_tag_size (list, tag);
  g_value_init (&string_value, G_TYPE_STRING);

  ptest->priv->tag_count++;

  for (i = 0; i < count; i++) {
    gchar *str;

    if (gst_tag_get_type (tag) == G_TYPE_STRING) {
      if (!gst_tag_list_get_string_index (list, tag, i, &str))
        g_assert_not_reached ();
    } else if (gst_tag_get_type (tag) == GST_TYPE_SAMPLE) {
      GstSample *img;

      img = gst_value_get_sample (gst_tag_list_get_value_index (list, tag, i));
      if (img) {
        GstBuffer *buffer;
        GstCaps *caps;
        gchar *caps_str;

        buffer = gst_sample_get_buffer (img);
        caps = gst_sample_get_caps (img);

        caps_str = caps ? gst_caps_to_string (caps) : g_strdup ("unknown");
        str = g_strdup_printf ("sample of %" G_GSIZE_FORMAT " bytes, type: %s",
            gst_buffer_get_size (buffer), caps_str);
        g_free (caps_str);
      } else {
        str = g_strdup ("NULL sample");
      }
    } else if (gst_tag_get_type (tag) == GST_TYPE_DATE_TIME) {
      GstDateTime *dt = NULL;

      gst_tag_list_get_date_time_index (list, tag, i, &dt);
      str = gst_date_time_to_iso8601_string (dt);
      gst_date_time_unref (dt);
    } else {
      str =
          g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
    }

    if (i == 0) {
      g_value_set_string (&string_value, gst_tag_get_nick (tag));
      snprintf (label, sizeof (label), "tags.%u.id", ptest->priv->tag_count);
      insanity_test_set_extra_info (INSANITY_TEST (ptest), label,
          &string_value);
      g_value_reset (&string_value);
    }
    g_value_set_string (&string_value, str);
    if (count > 1)
      snprintf (label, sizeof (label), "tags.%u.value.%u",
          ptest->priv->tag_count, i);
    else
      snprintf (label, sizeof (label), "tags.%u.value", ptest->priv->tag_count);
    insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value);
    g_value_reset (&string_value);

    g_free (str);
  }
}
예제 #10
0
// ----------------------------------------------------------------------------
// Handle the "tag" message
void
GStreamerImportFileHandle::OnTag(GstAppSink * WXUNUSED(appsink), GstTagList *tags)
{
   // Collect all of the associates tags
   for (guint i = 0, icnt = gst_tag_list_n_tags(tags); i < icnt; i++)
   {
      wxString string;

      // Get tag name...should always succeed...no need to release
      const gchar *name = gst_tag_list_nth_tag_name(tags, i);
      if (!name)
      {
         continue;
      }

      // For each tag, determine its type and retrieve if possible
      for (guint j = 0, jcnt = gst_tag_list_get_tag_size(tags, name); j < jcnt; j++)
      {
         const GValue *val;

         val = gst_tag_list_get_value_index(tags, name, j);

         if (G_VALUE_HOLDS_STRING(val))
         {
            string = wxString::FromUTF8(g_value_get_string(val));
         }
         else if (G_VALUE_HOLDS_UINT(val))
         {
            string.Printf(wxT("%u"), (unsigned int) g_value_get_uint(val));
         }
         else if (G_VALUE_HOLDS_DOUBLE(val))
         {
            string.Printf(wxT("%g"), g_value_get_double(val));
         }
         else if (G_VALUE_HOLDS_BOOLEAN(val))
         {
            string = g_value_get_boolean(val) ? wxT("true") : wxT("false");
         }
         else if (GST_VALUE_HOLDS_DATE_TIME(val))
         {
            GstDateTime *dt = (GstDateTime *) g_value_get_boxed(val);
            gchar *str = gst_date_time_to_iso8601_string(dt);

            string = wxString::FromUTF8(str).c_str();

            g_free(str);
         }
         else if (G_VALUE_HOLDS(val, G_TYPE_DATE))
         {
            gchar *str = gst_value_serialize(val);

            string = wxString::FromUTF8(str).c_str();

            g_free(str);
         }
         else
         {
            wxLogMessage(wxT("Tag %s has unhandled type: %s"),
                         wxString::FromUTF8(name).c_str(),
                         wxString::FromUTF8(G_VALUE_TYPE_NAME(val)).c_str());
            continue;
         }

         // Translate known tag names
         wxString tag;
         if (strcmp(name, GST_TAG_TITLE) == 0)
         {
            tag = TAG_TITLE;
         }
         else if (strcmp(name, GST_TAG_ARTIST) == 0)
         {
            tag = TAG_ARTIST;
         }
         else if (strcmp(name, GST_TAG_ALBUM) == 0)
         {
            tag = TAG_ALBUM;
         }
         else if (strcmp(name, GST_TAG_TRACK_NUMBER) == 0)
         {
            tag = TAG_TRACK;
         }
         else if (strcmp(name, GST_TAG_DATE) == 0)
         {
            tag = TAG_YEAR;
         }
         else if (strcmp(name, GST_TAG_GENRE) == 0)
         {
            tag = TAG_GENRE;
         }
         else if (strcmp(name, GST_TAG_COMMENT) == 0)
         {
            tag = TAG_COMMENTS;
         }
         else
         {
            tag = wxString::FromUTF8(name).c_str();
         }

         if (jcnt > 1)
         {
            tag.Printf(wxT("%s:%d"), tag.c_str(), j);
         }

         // Store the tag
         mTags.SetTag(tag, string);
      }
   }
}
예제 #11
0
파일: job.c 프로젝트: bbshocking/gstreamill
/*
 * job_reset:
 * @job: job object
 *
 * reset job stat
 *
 */
void job_reset (Job *job)
{
        gchar *stat, **stats, **cpustats;
        GstDateTime *start_time;
        gint i;
        EncoderOutput *encoder;
        guint version, window_size;
        struct sigevent sev;
        struct mq_attr attr;
        gchar *name;

        g_file_get_contents ("/proc/stat", &stat, NULL, NULL);
        stats = g_strsplit (stat, "\n", 10);
        cpustats = g_strsplit (stats[0], " ", 10);
        job->start_ctime = 0;
        for (i = 1; i < 8; i++) {
                job->start_ctime += g_ascii_strtoull (cpustats[i], NULL, 10);
        }
        job->last_ctime = 0;
        job->last_utime = 0;
        job->last_stime = 0;
        g_free (stat);
        g_strfreev (stats);
        g_strfreev (cpustats);
        start_time = gst_date_time_new_now_local_time ();
        if (job->last_start_time != NULL) {
                g_free (job->last_start_time);
        }
        job->last_start_time = gst_date_time_to_iso8601_string (start_time);
        gst_date_time_unref (start_time);

        /* is live job with m3u8streaming? */
        if (!(job->is_live) || !(jobdesc_m3u8streaming (job->description))) {
                return;
        }

        version = jobdesc_m3u8streaming_version (job->description);
        if (version == 0) {
                version = 3;
        }
        window_size = jobdesc_m3u8streaming_window_size (job->description);

        for (i = 0; i < job->output->encoder_count; i++) {
                encoder = &(job->output->encoders[i]);
                name = g_strdup_printf ("/%s.%d", job->name, i);

                /* encoder dvr sequence */
                encoder->sequence = job->output->sequence;

                /* reset m3u8 playlist */
                if (encoder->m3u8_playlist != NULL) {
                        m3u8playlist_free (encoder->m3u8_playlist);
                }
                encoder->m3u8_playlist = m3u8playlist_new (version, window_size, 0);

                /* reset message queue */
                if (encoder->mqdes != -1) {
                        if (mq_close (encoder->mqdes) == -1) {
                                GST_ERROR ("mq_close %s error: %s", name, g_strerror (errno));
                        }
                        if (mq_unlink (name) == -1) {
                                GST_ERROR ("mq_unlink %s error: %s", name, g_strerror (errno));
                        }
                }
                attr.mq_flags = 0;
                attr.mq_maxmsg = 10;
                attr.mq_msgsize = 128;
                attr.mq_curmsgs = 0;
                encoder->mqdes = mq_open (name, O_RDONLY | O_CREAT | O_NONBLOCK, 0666, &attr);
                if (encoder->mqdes == -1) {
                        GST_ERROR ("mq_open error : %s", g_strerror (errno));
                }
                sev.sigev_notify = SIGEV_THREAD;
                sev.sigev_notify_function = notify_function;
                sev.sigev_notify_attributes = NULL;
                sev.sigev_value.sival_ptr = encoder;
                if (mq_notify (encoder->mqdes, &sev) == -1) {
                        GST_ERROR ("mq_notify error : %s", g_strerror (errno));
                }

                g_free (name);
        }
}