summaryrefslogtreecommitdiff
path: root/gnl/gnlobject.h
blob: 4ba7dd82ff7364ba79ee2c1a60c7e8d7f3f5fa45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* GStreamer
 * Copyright (C) 2001 Wim Taymans <wim.taymans@gmail.com>
 *               2004-2008 Edward Hervey <bilboed@bilboed.com>
 *
 * gnlobject.h: Header for base GnlObject
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */


#ifndef __GNL_OBJECT_H__
#define __GNL_OBJECT_H__

#include <gst/gst.h>

#include "gnltypes.h"

G_BEGIN_DECLS
#define GNL_TYPE_OBJECT \
  (gnl_object_get_type())
#define GNL_OBJECT(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj),GNL_TYPE_OBJECT,GnlObject))
#define GNL_OBJECT_CAST(obj) ((GnlObject*) (obj))
#define GNL_OBJECT_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST((klass),GNL_TYPE_OBJECT,GnlObjectClass))
#define GNL_OBJECT_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNL_TYPE_OBJECT, GnlObjectClass))
#define GNL_IS_OBJECT(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GNL_TYPE_OBJECT))
#define GNL_IS_OBJECT_CLASS(obj) \
  (G_TYPE_CHECK_CLASS_TYPE((klass),GNL_TYPE_OBJECT))

/**
 * GnlObjectFlags:
 * @GNL_OBJECT_IS_SOURCE:
 * @GNL_OBJECT_IS_OPERATION:
 * @GNL_OBJECT_IS_EXPANDABLE: The #GnlObject start/stop will extend accross the full composition.
 * @GNL_OBJECT_LAST_FLAG:
*/

typedef enum
{
  GNL_OBJECT_SOURCE = (GST_BIN_FLAG_LAST << 0),
  GNL_OBJECT_OPERATION = (GST_BIN_FLAG_LAST << 1),
  GNL_OBJECT_EXPANDABLE = (GST_BIN_FLAG_LAST << 2),
  GNL_OBJECT_COMPOSITION = (GST_BIN_FLAG_LAST << 3),
  /* padding */
  GNL_OBJECT_LAST_FLAG = (GST_BIN_FLAG_LAST << 5)
} GnlObjectFlags;


#define GNL_OBJECT_IS_SOURCE(obj) \
  (GST_OBJECT_FLAG_IS_SET(obj, GNL_OBJECT_SOURCE))
#define GNL_OBJECT_IS_OPERATION(obj) \
  (GST_OBJECT_FLAG_IS_SET(obj, GNL_OBJECT_OPERATION))
#define GNL_OBJECT_IS_EXPANDABLE(obj) \
  (GST_OBJECT_FLAG_IS_SET(obj, GNL_OBJECT_EXPANDABLE))
#define GNL_OBJECT_IS_COMPOSITION(obj) \
  (GST_OBJECT_FLAG_IS_SET(obj, GNL_OBJECT_COMPOSITION))

/* For internal usage only */
#define GNL_OBJECT_START(obj) (GNL_OBJECT_CAST (obj)->start)
#define GNL_OBJECT_STOP(obj) (GNL_OBJECT_CAST (obj)->stop)
#define GNL_OBJECT_DURATION(obj) (GNL_OBJECT_CAST (obj)->duration)
#define GNL_OBJECT_INPOINT(obj) (GNL_OBJECT_CAST (obj)->inpoint)
#define GNL_OBJECT_PRIORITY(obj) (GNL_OBJECT_CAST (obj)->priority)

#define GNL_OBJECT_IS_COMMITING(obj) (GNL_OBJECT_CAST (obj)->commiting)

struct _GnlObject
{
  GstBin parent;

  /* Time positionning */
  GstClockTime start;
  GstClockTime inpoint;
  GstClockTimeDiff duration;

  /* Pending time positionning
   * Should be == GST_CLOCK_TIME_NONE when nothing to do
   */
  GstClockTime pending_start;
  GstClockTime pending_inpoint;
  GstClockTimeDiff pending_duration;
  guint32 pending_priority;
  gboolean pending_active;

  gboolean commit_needed;
  gboolean commiting; /* Set to TRUE during the commiting time only */

  gboolean expandable;

  /* read-only */
  GstClockTime stop;

  /* priority in parent */
  guint32 priority;

  /* active in parent */
  gboolean active;

  /* Filtering caps */
  GstCaps *caps;

  /* current segment seek <RO> */
  gdouble segment_rate;
  GstSeekFlags segment_flags;
  gint64 segment_start;
  gint64 segment_stop;
};

struct _GnlObjectClass
{
  GstBinClass parent_class;

  /* Signal method handler */
  gboolean (*commit_signal_handler) (GnlObject * object, gboolean recurse);

  /* virtual methods for subclasses */
    gboolean (*prepare) (GnlObject * object);
    gboolean (*cleanup) (GnlObject * object);
    gboolean (*commit) (GnlObject * object, gboolean recurse);
};

GType gnl_object_get_type (void);

gboolean
gnl_object_to_media_time (GnlObject * object, GstClockTime otime,
			  GstClockTime * mtime);

gboolean
gnl_media_to_object_time (GnlObject * object, GstClockTime mtime,
			  GstClockTime * otime);

void
gnl_object_set_caps (GnlObject * object, const GstCaps * caps);

void
gnl_object_set_commit_needed (GnlObject *object);

gboolean
gnl_object_commit (GnlObject *object, gboolean recurse);

void
gnl_object_reset (GnlObject *object);
G_END_DECLS
#endif /* __GNL_OBJECT_H__ */