~ubuntu-branches/ubuntu/trusty/gstreamer1.0/trusty

« back to all changes in this revision

Viewing changes to gst/gsttaglist.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2012-08-08 18:12:33 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120808181233-riejwxprfsxh1njl
Tags: 0.11.93-1
* New upstream release:
  + debian/libgstreamer.symbols:
    - Update symbols file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
#define GST_TAG_IS_VALID(tag)           (gst_tag_get_info (tag) != NULL)
54
54
 
55
 
/* FIXME 0.11: make taglists refcounted maybe? */
56
 
/* a tag list is basically a structure, but we don't make this fact public */
57
55
typedef struct _GstTagListImpl
58
56
{
59
57
  GstTagList taglist;
60
58
 
61
59
  GstStructure *structure;
 
60
  GstTagScope scope;
62
61
} GstTagListImpl;
63
62
 
64
 
#define GST_TAG_LIST_STRUCTURE(taglist) ((GstTagListImpl*)(taglist))->structure
65
 
 
66
 
 
67
 
/* FIXME 0.11: use GParamSpecs or something similar for tag registrations,
68
 
 * possibly even gst_tag_register(). Especially value ranges might be
69
 
 * useful for some tags. */
 
63
#define GST_TAG_LIST_STRUCTURE(taglist)  ((GstTagListImpl*)(taglist))->structure
 
64
#define GST_TAG_LIST_SCOPE(taglist)  ((GstTagListImpl*)(taglist))->scope
70
65
 
71
66
typedef struct
72
67
{
387
382
      G_TYPE_STRING, _("application name"),
388
383
      _("Application used to create the media"), NULL);
389
384
  gst_tag_register_static (GST_TAG_APPLICATION_DATA, GST_TAG_FLAG_META,
390
 
      GST_TYPE_BUFFER, _("application data"),
 
385
      GST_TYPE_SAMPLE, _("application data"),
391
386
      _("Arbitrary application data to be serialized into the media"), NULL);
392
387
  gst_tag_register_static (GST_TAG_IMAGE_ORIENTATION, GST_TAG_FLAG_META,
393
388
      G_TYPE_STRING, _("image orientation"),
580
575
}
581
576
 
582
577
/**
583
 
 * gst_tag_get_nick
 
578
 * gst_tag_get_nick:
584
579
 * @tag: the tag
585
580
 *
586
581
 * Returns the human-readable name of this tag, You must not change or free
662
657
  return info->merge_func == NULL;
663
658
}
664
659
 
665
 
static void
666
 
gst_tag_list_init (GstTagList * taglist, gsize size)
667
 
{
668
 
  gst_mini_object_init (GST_MINI_OBJECT_CAST (taglist),
669
 
      gst_tag_list_get_type (), size);
670
 
 
671
 
  taglist->mini_object.copy = (GstMiniObjectCopyFunction) __gst_tag_list_copy;
672
 
  taglist->mini_object.dispose = NULL;
673
 
  taglist->mini_object.free = (GstMiniObjectFreeFunction) __gst_tag_list_free;
674
 
}
675
 
 
676
660
/* takes ownership of the structure */
677
661
static GstTagList *
678
662
gst_tag_list_new_internal (GstStructure * s)
683
667
 
684
668
  tag_list = (GstTagList *) g_slice_new (GstTagListImpl);
685
669
 
686
 
  gst_tag_list_init (tag_list, sizeof (GstTagListImpl));
 
670
  gst_mini_object_init (GST_MINI_OBJECT_CAST (tag_list), 0, GST_TYPE_TAG_LIST,
 
671
      (GstMiniObjectCopyFunction) __gst_tag_list_copy, NULL,
 
672
      (GstMiniObjectFreeFunction) __gst_tag_list_free);
687
673
 
688
674
  GST_TAG_LIST_STRUCTURE (tag_list) = s;
 
675
  GST_TAG_LIST_SCOPE (tag_list) = GST_TAG_SCOPE_STREAM;
689
676
 
690
677
#ifdef DEBUG_REFCOUNT
691
678
  GST_CAT_TRACE (GST_CAT_TAGS, "created taglist %p", tag_list);
700
687
  g_return_if_fail (GST_IS_TAG_LIST (list));
701
688
 
702
689
#ifdef DEBUG_REFCOUNT
703
 
  GST_CAT_TRACE (GST_CAT_TAGS, "freeing caps %p", list);
 
690
  GST_CAT_TRACE (GST_CAT_TAGS, "freeing taglist %p", list);
704
691
#endif
705
692
 
706
693
  gst_structure_free (GST_TAG_LIST_STRUCTURE (list));
707
694
 
708
 
  /* why not just pass sizeof (GstTagListImpl) here? */
709
 
  g_slice_free1 (GST_MINI_OBJECT_SIZE (list), list);
 
695
  g_slice_free1 (sizeof (GstTagListImpl), list);
710
696
}
711
697
 
712
698
static GstTagList *
757
743
 *
758
744
 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_unref()
759
745
 *     when no longer needed.
760
 
 *
761
 
 * Since: 0.10.24
762
746
 */
763
747
GstTagList *
764
748
gst_tag_list_new (const gchar * tag, ...)
787
771
 *
788
772
 * Returns: (transfer full): a new #GstTagList. Free with gst_tag_list_unref()
789
773
 *     when no longer needed.
790
 
 *
791
 
 * Since: 0.10.24
792
774
 */
793
775
GstTagList *
794
776
gst_tag_list_new_valist (va_list var_args)
805
787
}
806
788
 
807
789
/**
 
790
 * gst_tag_list_set_scope:
 
791
 * @list: a #GstTagList
 
792
 * @scope: new scope for @list
 
793
 *
 
794
 * Sets the scope of @list to @scope. By default the scope
 
795
 * of a taglist is #GST_TAG_SCOPE_STREAM.
 
796
 *
 
797
 */
 
798
void
 
799
gst_tag_list_set_scope (GstTagList * list, GstTagScope scope)
 
800
{
 
801
  g_return_if_fail (GST_IS_TAG_LIST (list));
 
802
  g_return_if_fail (gst_tag_list_is_writable (list));
 
803
 
 
804
  GST_TAG_LIST_SCOPE (list) = scope;
 
805
}
 
806
 
 
807
/**
 
808
 * gst_tag_list_get_scope:
 
809
 * @list: a #GstTagList
 
810
 *
 
811
 * Gets the scope of @list.
 
812
 *
 
813
 * Returns: The scope of @list
 
814
 */
 
815
GstTagScope
 
816
gst_tag_list_get_scope (const GstTagList * list)
 
817
{
 
818
  g_return_val_if_fail (GST_IS_TAG_LIST (list), GST_TAG_SCOPE_STREAM);
 
819
 
 
820
  return GST_TAG_LIST_SCOPE (list);
 
821
}
 
822
 
 
823
/**
808
824
 * gst_tag_list_to_string:
809
825
 * @list: a #GstTagList
810
826
 *
812
828
 *
813
829
 * Returns: a newly-allocated string, or NULL in case of an error. The
814
830
 *    string must be freed with g_free() when no longer needed.
815
 
 *
816
 
 * Since: 0.10.36
817
831
 */
818
832
gchar *
819
833
gst_tag_list_to_string (const GstTagList * list)
830
844
 * Deserializes a tag list.
831
845
 *
832
846
 * Returns: a new #GstTagList, or NULL in case of an error.
833
 
 *
834
 
 * Since: 0.10.36
835
847
 */
836
848
GstTagList *
837
849
gst_tag_list_new_from_string (const gchar * str)
887
899
 * Checks if the given taglist is empty.
888
900
 *
889
901
 * Returns: TRUE if the taglist is empty, otherwise FALSE.
890
 
 *
891
 
 * Since: 0.10.11
892
902
 */
893
903
gboolean
894
904
gst_tag_list_is_empty (const GstTagList * list)
928
938
 * Checks if the two given taglists are equal.
929
939
 *
930
940
 * Returns: TRUE if the taglists are equal, otherwise FALSE
931
 
 *
932
 
 * Since: 0.10.36
933
941
 */
934
942
gboolean
935
943
gst_tag_list_is_equal (const GstTagList * list1, const GstTagList * list2)
993
1001
    }
994
1002
  }
995
1003
 
 
1004
  if (G_UNLIKELY (!G_VALUE_HOLDS (value, info->type) &&
 
1005
          !GST_VALUE_HOLDS_LIST (value))) {
 
1006
    g_warning ("tag '%s' should hold value of type '%s', but value of "
 
1007
        "type '%s' passed", info->nick, g_type_name (info->type),
 
1008
        g_type_name (G_VALUE_TYPE (value)));
 
1009
    return;
 
1010
  }
 
1011
 
996
1012
  tag_quark = info->name_quark;
997
1013
 
998
1014
  if (info->merge_func
1291
1307
 * @value: GValue for this tag
1292
1308
 *
1293
1309
 * Sets the GValue for a given tag using the specified mode.
1294
 
 *
1295
 
 * Since: 0.10.24
1296
1310
 */
1297
1311
void
1298
1312
gst_tag_list_add_value (GstTagList * list, GstTagMergeMode mode,
1715
1729
 * to retrieve the first string associated with this tag unmodified.
1716
1730
 *
1717
1731
 * The resulting string in @value will be in UTF-8 encoding and should be
1718
 
 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
 
1732
 * freed by the caller using g_free when no longer needed. The
1719
1733
 * returned string is also guaranteed to be non-NULL and non-empty.
1720
1734
 *
1721
1735
 * Free-function: g_free
1734
1748
 * list.
1735
1749
 *
1736
1750
 * The resulting string in @value will be in UTF-8 encoding and should be
1737
 
 * freed by the caller using g_free when no longer needed. Since 0.10.24 the
 
1751
 * freed by the caller using g_free when no longer needed. The
1738
1752
 * returned string is also guaranteed to be non-NULL and non-empty.
1739
1753
 *
1740
1754
 * Free-function: g_free
1862
1876
 *
1863
1877
 * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in
1864
1878
 *              thegiven list or if it was #NULL.
1865
 
 *
1866
 
 * Since: 0.10.31
1867
1879
 */
1868
1880
gboolean
1869
1881
gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag,
1900
1912
 *
1901
1913
 * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the
1902
1914
 *              given list or if it was #NULL.
1903
 
 *
1904
 
 * Since: 0.10.31
1905
1915
 */
1906
1916
gboolean
1907
1917
gst_tag_list_get_date_time_index (const GstTagList * list,
1920
1930
}
1921
1931
 
1922
1932
/**
1923
 
 * gst_tag_list_get_buffer:
 
1933
 * gst_tag_list_get_sample:
1924
1934
 * @list: a #GstTagList to get the tag from
1925
1935
 * @tag: tag to read out
1926
 
 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
 
1936
 * @sample: (out callee-allocates) (transfer full): address of a GstSample
1927
1937
 *     pointer variable to store the result into
1928
1938
 *
1929
 
 * Copies the first buffer for the given tag in the taglist into the variable
1930
 
 * pointed to by @value. Free the buffer with gst_buffer_unref() when it is
1931
 
 * no longer needed.
1932
 
 *
1933
 
 * Free-function: gst_buffer_unref
1934
 
 *
1935
 
 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
1936
 
 *              given list or if it was #NULL.
1937
 
 *
1938
 
 * Since: 0.10.23
 
1939
 * Copies the first sample for the given tag in the taglist into the variable
 
1940
 * pointed to by @sample. Free the sample with gst_sample_unref() when it is
 
1941
 * no longer needed. You can retrieve the buffer from the sample using
 
1942
 * gst_sample_get_buffer() and the associated caps (if any) with
 
1943
 * gst_sample_get_caps().
 
1944
 *
 
1945
 * Free-function: gst_sample_unref
 
1946
 *
 
1947
 * Returns: TRUE, if a sample was returned, FALSE if the tag didn't exist in
 
1948
 *              the given list or if it was #NULL.
1939
1949
 */
1940
1950
gboolean
1941
 
gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag,
1942
 
    GstBuffer ** value)
 
1951
gst_tag_list_get_sample (const GstTagList * list, const gchar * tag,
 
1952
    GstSample ** sample)
1943
1953
{
1944
1954
  GValue v = { 0, };
1945
1955
 
1946
1956
  g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1947
1957
  g_return_val_if_fail (tag != NULL, FALSE);
1948
 
  g_return_val_if_fail (value != NULL, FALSE);
 
1958
  g_return_val_if_fail (sample != NULL, FALSE);
1949
1959
 
1950
1960
  if (!gst_tag_list_copy_value (&v, list, tag))
1951
1961
    return FALSE;
1952
 
  *value = g_value_dup_boxed (&v);
 
1962
  *sample = g_value_dup_boxed (&v);
1953
1963
  g_value_unset (&v);
1954
 
  return (*value != NULL);
 
1964
  return (*sample != NULL);
1955
1965
}
1956
1966
 
1957
1967
/**
1958
 
 * gst_tag_list_get_buffer_index:
 
1968
 * gst_tag_list_get_sample_index:
1959
1969
 * @list: a #GstTagList to get the tag from
1960
1970
 * @tag: tag to read out
1961
1971
 * @index: number of entry to read out
1962
 
 * @value: (out callee-allocates) (transfer full): address of a GstBuffer
 
1972
 * @sample: (out callee-allocates) (transfer full): address of a GstSample
1963
1973
 *     pointer variable to store the result into
1964
1974
 *
1965
 
 * Gets the buffer that is at the given index for the given tag in the given
1966
 
 * list and copies it into the variable pointed to by @value. Free the buffer
1967
 
 * with gst_buffer_unref() when it is no longer needed.
1968
 
 *
1969
 
 * Free-function: gst_buffer_unref
1970
 
 *
1971
 
 * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the
 
1975
 * Gets the sample that is at the given index for the given tag in the given
 
1976
 * list and copies it into the variable pointed to by @smple. Free the sample
 
1977
 * with gst_sample_unref() when it is no longer needed. You can retrieve the
 
1978
 * buffer from the sample using gst_sample_get_buffer() and the associated
 
1979
 * caps (if any) with gst_sample_get_caps().
 
1980
 *
 
1981
 * Free-function: gst_sample_unref
 
1982
 *
 
1983
 * Returns: TRUE, if a sample was copied, FALSE if the tag didn't exist in the
1972
1984
 *              given list or if it was #NULL.
1973
 
 *
1974
 
 * Since: 0.10.23
1975
1985
 */
1976
1986
gboolean
1977
 
gst_tag_list_get_buffer_index (const GstTagList * list,
1978
 
    const gchar * tag, guint index, GstBuffer ** value)
 
1987
gst_tag_list_get_sample_index (const GstTagList * list,
 
1988
    const gchar * tag, guint index, GstSample ** sample)
1979
1989
{
1980
1990
  const GValue *v;
1981
1991
 
1982
1992
  g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE);
1983
1993
  g_return_val_if_fail (tag != NULL, FALSE);
1984
 
  g_return_val_if_fail (value != NULL, FALSE);
 
1994
  g_return_val_if_fail (sample != NULL, FALSE);
1985
1995
 
1986
1996
  if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL)
1987
1997
    return FALSE;
1988
 
  *value = g_value_dup_boxed (v);
1989
 
  return (*value != NULL);
 
1998
  *sample = g_value_dup_boxed (v);
 
1999
  return (*sample != NULL);
1990
2000
}