GESTrack: Add TrackType enum and constructor property.

This allows us to speed up detection of track content type.
This commit is contained in:
Edward Hervey 2009-09-08 18:49:22 +02:00
parent d83dfd6402
commit ae6ac876b1
2 changed files with 65 additions and 6 deletions

View file

@ -34,7 +34,8 @@ G_DEFINE_TYPE (GESTrack, ges_track, GST_TYPE_BIN);
enum
{
ARG_0,
ARG_CAPS
ARG_CAPS,
ARG_TYPE
};
static void pad_added_cb (GstElement * element, GstPad * pad, GESTrack * track);
@ -42,6 +43,31 @@ static void pad_added_cb (GstElement * element, GstPad * pad, GESTrack * track);
static void
pad_removed_cb (GstElement * element, GstPad * pad, GESTrack * track);
#define C_ENUM(v) ((gint) v)
static void
register_ges_track_type_select_result (GType * id)
{
static const GEnumValue values[] = {
{C_ENUM (GES_TRACK_TYPE_AUDIO), "GES_TRACK_TYPE_AUDIO", "audio"},
{C_ENUM (GES_TRACK_TYPE_VIDEO), "GES_TRACK_TYPE_VIDEO", "video"},
{C_ENUM (GES_TRACK_TYPE_TEXT), "GES_TRACK_TYPE_TEXT", "text"},
{C_ENUM (GES_TRACK_TYPE_CUSTOM), "GES_TRACK_TYPE_CUSTOM", "custom"},
{0, NULL, NULL}
};
*id = g_enum_register_static ("GESTrackType", values);
}
GType
ges_track_type_get_type (void)
{
static GType id;
static GOnce once = G_ONCE_INIT;
g_once (&once, (GThreadFunc) register_ges_track_type_select_result, &id);
return id;
}
static void
ges_track_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
@ -52,6 +78,9 @@ ges_track_get_property (GObject * object, guint property_id,
case ARG_CAPS:
gst_value_set_caps (value, track->caps);
break;
case ARG_TYPE:
g_value_set_enum (value, track->type);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@ -67,6 +96,9 @@ ges_track_set_property (GObject * object, guint property_id,
case ARG_CAPS:
ges_track_set_caps (track, gst_value_get_caps (value));
break;
case ARG_TYPE:
track->type = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@ -107,6 +139,11 @@ ges_track_class_init (GESTrackClass * klass)
g_param_spec_boxed ("caps", "Caps",
"Caps used to filter/choose the output stream",
GST_TYPE_CAPS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, ARG_TYPE,
g_param_spec_enum ("track-type", "TrackType",
"Type of stream the track outputs",
GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_CUSTOM,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
static void
@ -124,9 +161,9 @@ ges_track_init (GESTrack * self)
}
GESTrack *
ges_track_new (GstCaps * caps)
ges_track_new (GESTrackType type, GstCaps * caps)
{
return g_object_new (GES_TYPE_TRACK, "caps", caps, NULL);
return g_object_new (GES_TYPE_TRACK, "caps", caps, "track-type", type, NULL);
}
GESTrack *
@ -135,7 +172,7 @@ ges_track_video_raw_new ()
GESTrack *track;
GstCaps *caps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb");
track = ges_track_new (caps);
track = ges_track_new (GES_TRACK_TYPE_VIDEO, caps);
gst_caps_unref (caps);
return track;
@ -147,7 +184,7 @@ ges_track_audio_raw_new ()
GESTrack *track;
GstCaps *caps = gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float");
track = ges_track_new (caps);
track = ges_track_new (GES_TRACK_TYPE_AUDIO, caps);
gst_caps_unref (caps);
return track;

View file

@ -43,10 +43,32 @@ G_BEGIN_DECLS
#define GES_TRACK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_TRACK, GESTrackClass))
#define GES_TYPE_TRACK_TYPE (ges_track_type_get_type ())
GType ges_track_type_get_type (void);
/**
* GESTrackType:
* @GES_TRACK_TYPE_AUDIO: An audio track
* @GES_TRACK_TYPE_VIDEO: A video track
* @GES_TRACK_TYPE_TEXT: A text (subtitle) track
* @GES_TRACK_TYPE_CUSTOM: A custom-content track
*
* Types of content handled by a track.
*/
typedef enum {
GES_TRACK_TYPE_AUDIO = 0,
GES_TRACK_TYPE_VIDEO = 1,
GES_TRACK_TYPE_TEXT = 2,
GES_TRACK_TYPE_CUSTOM = 3
} GESTrackType;
struct _GESTrack {
GstBin parent;
GESTimeline * timeline;
GESTrackType type;
GstCaps * caps;
@ -60,7 +82,7 @@ struct _GESTrackClass {
GType ges_track_get_type (void);
GESTrack* ges_track_new (GstCaps * caps);
GESTrack* ges_track_new (GESTrackType type, GstCaps * caps);
void ges_track_set_timeline (GESTrack * track, GESTimeline *timeline);
void ges_track_set_caps (GESTrack * track, const GstCaps * caps);