track: [API]: ges_track_update_restriction_caps.

+ And specify default restriction caps for audio tracks.
+ Add ges_track_set_restriction_caps to the sections, it
  was missing.

https://bugzilla.gnome.org/show_bug.cgi?id=740726
This commit is contained in:
Mathieu Duponchelle 2014-11-26 20:34:24 +01:00
parent 0d3044b78d
commit f85c463b93
6 changed files with 72 additions and 2 deletions

View file

@ -71,6 +71,8 @@ GESTrack
GESCreateElementForGapFunc GESCreateElementForGapFunc
ges_track_new ges_track_new
ges_track_add_element ges_track_add_element
ges_track_set_restriction_caps
ges_track_update_restriction_caps
ges_track_remove_element ges_track_remove_element
ges_track_set_caps ges_track_set_caps
ges_track_get_caps ges_track_get_caps

View file

@ -20,14 +20,36 @@
/** /**
* SECTION: gesaudiotrack * SECTION: gesaudiotrack
* @short_description: A standard GESTrack for raw audio * @short_description: A standard GESTrack for raw audio
*
* Sane default properties to specify and fixate the output stream are
* set as restriction-caps.
* It is advised, to modify these properties, to use
* #ges_track_update_restriction_caps, setting them directly is
* possible through #ges_track_set_restriction_caps, but not specifying
* one of them can lead to negotiation issues, only use that function
* if you actually know what you're doing :)
*
* The default properties are:
* - format: S32LE
* - channels: 2
* - rate: 44100
* - layout: interleaved
*/ */
#define DEFAULT_CAPS "audio/x-raw"
#include "ges-internal.h" #include "ges-internal.h"
#include "ges-smart-adder.h" #include "ges-smart-adder.h"
#include "ges-audio-track.h" #include "ges-audio-track.h"
#define DEFAULT_CAPS "audio/x-raw"
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define DEFAULT_RESTRICTION_CAPS "audio/x-raw, format=S32LE, channels=2, "\
"rate=44100, layout=interleaved"
#else
#define DEFAULT_RESTRICTION_CAPS "audio/x-raw, format=S32BE, channels=2, "\
"rate=44100, layout=interleaved"
#endif
struct _GESAudioTrackPrivate struct _GESAudioTrackPrivate
{ {
gpointer nothing; gpointer nothing;
@ -106,6 +128,8 @@ ges_audio_track_new (void)
ges_track_set_create_element_for_gap_func (GES_TRACK (ret), ges_track_set_create_element_for_gap_func (GES_TRACK (ret),
create_element_for_raw_audio_gap); create_element_for_raw_audio_gap);
ges_track_set_restriction_caps (GES_TRACK (ret),
gst_caps_from_string (DEFAULT_RESTRICTION_CAPS));
gst_caps_unref (caps); gst_caps_unref (caps);
return ret; return ret;

View file

@ -248,6 +248,13 @@ track_resort_and_fill_gaps (GESTrack * track)
} }
} }
static gboolean
update_field (GQuark field_id, const GValue * value, GstStructure * original)
{
gst_structure_id_set_value (original, field_id, value);
return TRUE;
}
/* callbacks */ /* callbacks */
static void static void
sort_track_elements_cb (GESTrackElement * child, sort_track_elements_cb (GESTrackElement * child,
@ -749,6 +756,40 @@ ges_track_set_restriction_caps (GESTrack * track, const GstCaps * caps)
g_object_notify (G_OBJECT (track), "restriction-caps"); g_object_notify (G_OBJECT (track), "restriction-caps");
} }
/**
* ges_track_update_restriction_caps:
* @track: a #GESTrack
* @caps: the #GstCaps to update with
*
* Updates the restriction caps by modifying all the fields present in @caps
* in the original restriction caps. If for example the current restriction caps
* are video/x-raw, format=I420, width=360 and @caps is video/x-raw, format=RGB,
* the restriction caps will be updated to video/x-raw, format=RGB, width=360.
*
* Modification happens for each structure in the new caps, and
* one can add new fields or structures through that function.
*/
void
ges_track_update_restriction_caps (GESTrack * self, const GstCaps * caps)
{
guint i;
GstCaps *new_restriction_caps = gst_caps_copy (self->priv->restriction_caps);
for (i = 0; i < gst_caps_get_size (caps); i++) {
GstStructure *new = gst_caps_get_structure (caps, i);
if (gst_caps_get_size (new_restriction_caps) > i) {
GstStructure *original = gst_caps_get_structure (new_restriction_caps, i);
gst_structure_foreach (new, (GstStructureForeachFunc) update_field,
original);
} else
gst_caps_append_structure (new_restriction_caps,
gst_structure_copy (new));
}
ges_track_set_restriction_caps (self, new_restriction_caps);
}
/** /**
* ges_track_set_mixing: * ges_track_set_mixing:
* @track: a #GESTrack * @track: a #GESTrack

View file

@ -92,6 +92,7 @@ void ges_track_set_create_element_for_gap_func (GESTrack *track, G
void ges_track_set_mixing (GESTrack *track, gboolean mixing); void ges_track_set_mixing (GESTrack *track, gboolean mixing);
gboolean ges_track_get_mixing (GESTrack *track); gboolean ges_track_get_mixing (GESTrack *track);
void ges_track_set_restriction_caps (GESTrack *track, const GstCaps *caps); void ges_track_set_restriction_caps (GESTrack *track, const GstCaps *caps);
void ges_track_update_restriction_caps (GESTrack *track, const GstCaps *caps);
/* standard methods */ /* standard methods */
GType ges_track_get_type (void); GType ges_track_get_type (void);

View file

@ -42,6 +42,7 @@ check_PROGRAMS = \
ges/mixers\ ges/mixers\
ges/group\ ges/group\
ges/project\ ges/project\
ges/track\
nle/simple \ nle/simple \
nle/complex \ nle/complex \
nle/nleoperation \ nle/nleoperation \

View file

@ -11,3 +11,4 @@ clip
timelineedition timelineedition
titles titles
transition transition
track