Debian Codegraph @

gstreamer/src/message.hg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008-2016 The gstreamermm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <gst/gst.h>
21 #include <gstreamermm/miniobject.h>
22 #include <gstreamermm/format.h>
23 #include <gstreamermm/clock.h>
24 #include <gstreamermm/query.h>
25 #include <gstreamermm/context.h>
26 #include <gstreamermm/toc.h>
27
28 _DEFS(gstreamermm,gst)
29
30 namespace Gst
31 {
32
33 template<typename T>
34 Glib::RefPtr<T> wrap_msg_derived(GstMessage* object, bool take_copy)
35 {
36 if(take_copy && object)
37 gst_message_ref(object);
38
39 // See the comment at the top of this file, if you want to know why the cast works.
40 return Glib::RefPtr<T>(reinterpret_cast<T*>(object));
41 }
42
43 _WRAP_ENUM(MessageType, GstMessageType)
44 _WRAP_ENUM(ProgressType, GstProgressType)
45 _WRAP_ENUM(StructureChangeType, GstStructureChangeType)
46 _WRAP_ENUM(StreamStatusType, GstStreamStatusType)
47
48 namespace Enums
49 {
50
51 /** Gets a printable name for the given message type.
52 * @param type The message type.
53 * @return The name of the message type.
54 */
55 Glib::ustring get_name(MessageType type);
56
57 /** Gets the unique quark for the given message type.
58 * @param type The message type.
59 * @return The quark associated with the message type.
60 */
61 Glib::QueryQuark get_quark(MessageType type);
62
63 } //namespace Enums
64
65 class Element;
66 class Pad;
67 class Structure;
68 class TagList;
69
70 /** A class that represents lightweight objects to signal the application of
71 * pipeline events.
72 * Messages are implemented as a subclass of Gst::MiniObject with a generic
73 * Gst::Structure as the content. This allows for writing custom messages
74 * without requiring an API change while allowing a wide range of different
75 * types of messages.
76 *
77 * Messages are posted by objects in the pipeline and are passed to the
78 * application using the Gst::Bus.
79 *
80 * The basic use pattern of posting a message on a Gst::Bus is as follows:
81 * @code
82 * bus->post(Gst::MessageEos::create(my_element));
83 * @endcode
84 *
85 * Last reviewed on 2016-06-06 (1.8.0)
86 */
87 class Message : public Gst::MiniObject
88 {
89 _CLASS_OPAQUE_REFCOUNTED(Message, GstMessage, NONE, gst_message_ref, gst_message_unref)
90 _IGNORE(gst_message_ref, gst_message_unref)
91
92 public:
93 // A copy is taken so that the original is not freed by the wrapper.
94 #m4 _CONVERSION(`const GstStructure*',`Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
95 _WRAP_METHOD(Gst::Structure get_structure() const, gst_message_get_structure)
96
97 /** Checks if a message is writable. If not, a writable copy is made and
98 * returned.
99 * @return A Gst::Message (possibly the same pointer) that is writable.
100 */
101 Glib::RefPtr<Gst::Message> create_writable();
102
103 _WRAP_METHOD(guint32 get_seqnum() const, gst_message_get_seqnum)
104 _WRAP_METHOD(void set_seqnum(guint32 seqnum), gst_message_set_seqnum)
105 _WRAP_METHOD(Glib::RefPtr<Gst::Message> copy() const, gst_message_copy)
106
107 /** Get the GstMessageType of message.
108 */
109 _MEMBER_GET(message_type, type, MessageType, GstMessageType)
110
111 /** Get the timestamp of message. This is the timestamp when the message was
112 * created.
113 */
114 _MEMBER_GET(timestamp, timestamp, Gst::ClockTime, guint64)
115
116 /** Get the object that posted the message.
117 */
118 _MEMBER_GET_GOBJECT(source, src, Gst::Object, GstObject*)
119
120 _WRAP_METHOD(bool has_name(const Glib::ustring& name) const, gst_message_has_name)
121 };
122
123 /** An end of stream message.
124 * See create() for more details.
125 */
126 class MessageEos : public Message
127 {
128 _CLASS_GENERIC(MessageEos, GstMessage)
129 public:
130 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageEos>',`Gst::wrap_msg_derived<MessageEos>($3, false)')
131 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageEos> create(const Glib::RefPtr<Gst::Object>& src), gst_message_new_eos)
132 };
133
134 /** An error message.
135 * See create() for more details.
136 */
137 class MessageError : public Message
138 {
139 _CLASS_GENERIC(MessageError, GstMessage)
140 public:
141 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageError>',`Gst::wrap_msg_derived<MessageError>($3, false)')
142 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageError> create(const Glib::RefPtr<Gst::Object>& src, const Glib::Error& error, const std::string& debug), gst_message_new_error)
143
144 /** Extracts the Glib::Error and debug string from the Gst::MessageError.
145 *
146 * MT safe.
147 *
148 * @param error Location for the Glib::Error.
149 * @param debug Location for the debug message.
150 */
151 void parse(Glib::Error& error, std::string& debug) const;
152 _IGNORE(gst_message_parse_error)
153
154 /** Extracts and returns the Glib::Error from the Gst::MessageError.
155 *
156 * MT safe.
157 *
158 * @return The Glib::Error.
159 */
160 Glib::Error parse_error() const;
161
162 /** Extracts and returns the debug message from the Gst::MessageError.
163 *
164 * MT safe.
165 *
166 * @return The debug message.
167 */
168 std::string parse_debug() const;
169 };
170
171 /** A warning message.
172 * See create() for more details.
173 */
174 class MessageWarning : public Message
175 {
176 _CLASS_GENERIC(MessageWarning, GstMessage)
177 public:
178 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageWarning>',`Gst::wrap_msg_derived<MessageWarning>($3, false)')
179 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageWarning> create(const Glib::RefPtr<Gst::Object>& src, const Glib::Error& error, const std::string& debug), gst_message_new_warning)
180
181 /** Extracts the Glib::Error and debug string from the Gst::MessageWarning.
182 *
183 * MT safe.
184 *
185 * @param error Location for the Glib::Error.
186 * @param debug Location for the debug message.
187 */
188 void parse(Glib::Error& error, std::string& debug) const;
189 _IGNORE(gst_message_parse_warning)
190
191 /** Extracts and returns the Glib::Error from the Gst::MessageWarning.
192 *
193 * MT safe.
194 *
195 * @return The Glib::Error.
196 */
197 Glib::Error parse_error() const;
198
199 /** Extracts and returns the debug message from the Gst::MessageWarning.
200 *
201 * MT safe.
202 *
203 * @return The debug message.
204 */
205 std::string parse_debug() const;
206 };
207
208 /** An informational message.
209 * See create() for more details.
210 */
211 class MessageInfo : public Message
212 {
213 _CLASS_GENERIC(MessageInfo, GstMessage)
214 public:
215 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageInfo>',`Gst::wrap_msg_derived<MessageInfo>($3, false)')
216 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageInfo> create(const Glib::RefPtr<Gst::Object>& src, const Glib::Error& error, const std::string& debug), gst_message_new_info)
217
218 /** Extracts the Glib::Error and debug string from the Gst::MessageInfo.
219 *
220 * MT safe.
221 *
222 * @param error Location for the Glib::Error.
223 * @param debug Location for the debug message.
224 */
225 void parse(Glib::Error& error, std::string& debug) const;
226 _IGNORE(gst_message_parse_info)
227
228 /** Extracts and returns the Glib::Error from the Gst::MessageInfo.
229 *
230 * MT safe.
231 *
232 * @return The Glib::Error.
233 */
234 Glib::Error parse_error() const;
235
236 /** Extracts and returns the debug message from the Gst::MessageInfo.
237 *
238 * MT safe.
239 *
240 * @return The debug message.
241 */
242 std::string parse_debug() const;
243 };
244
245 /** A tag message.
246 * See create() for more details.
247 */
248 class MessageTag : public Message
249 {
250 _CLASS_GENERIC(MessageTag, GstMessage)
251 public:
252 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageTag>',`Gst::wrap_msg_derived<MessageTag>($3, false)')
253 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageTag> create(const Glib::RefPtr<Gst::Object>& src, const Gst::TagList& taglist), gst_message_new_tag)
254
255
256 /** Extracts and returns the Gst::TagList from the Gst::MessageTag.
257 *
258 * MT safe.
259 *
260 * @return A copy of the Gst::TagList.
261 */
262 Gst::TagList parse_tag_list() const;
263 _IGNORE(gst_message_parse_tag)
264
265 };
266
267 /** A buffering message.
268 * See create() for more details.
269 */
270 class MessageBuffering : public Message
271 {
272 _CLASS_GENERIC(MessageBuffering, GstMessage)
273 public:
274 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageBuffering>',`Gst::wrap_msg_derived<MessageBuffering>($3, false)')
275 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageBuffering> create(const Glib::RefPtr<Gst::Object>& src, int percent), gst_message_new_buffering)
276
277 /** Extracts and returns the buffering percent from the
278 * Gst::MessageBuffering.
279 * @return The percent as an integer.
280 */
281 int parse_buffering() const;
282 _IGNORE(gst_message_parse_buffering)
283
284 /** Configures the buffering stats values in message.
285 *
286 * @param mode A buffering mode.
287 * @param avg_in The average input rate.
288 * @param avg_out The average output rate.
289 * @param buffering_left Amount of buffering time left in milliseconds.
290 *
291 * Since 0.10.20.
292 */
293 void set_stats(BufferingMode mode, int avg_in, int avg_out, gint64 buffering_left);
294 _IGNORE(gst_message_set_buffering_stats)
295
296 /** Extracts the buffering stats values from message.
297 *
298 * @param mode Location for the buffering mode.
299 * @param avg_in Location for the average input rate.
300 * @param avg_out Location for the average output rate.
301 * @param buffering_left Location for the amount of buffering time left.
302 *
303 * Since 0.10.20.
304 */
305 void parse_stats(BufferingMode& mode, int& avg_in, int& avg_out, gint64& buffering_left) const;
306 _IGNORE(gst_message_parse_buffering_stats)
307
308 /** Extracts and returns the buffering mode from message.
309 *
310 * @return The buffering mode.
311 */
312 BufferingMode parse_stats_buffering_mode() const;
313
314 /** Extracts and returns the average input rate from message.
315 *
316 * @return The average input rate.
317 */
318 int parse_stats_avg_in() const;
319
320 /** Extracts and returns the average output rate from message.
321 *
322 * @return The average output rate.
323 */
324 int parse_stats_avg_out() const;
325
326 /** Extracts and returns the buffering time in milliseconds remaining from
327 * message.
328 *
329 * @return The buffering time remaining.
330 */
331 gint64 parse_stats_buffering_left() const;
332 };
333
334 /** A state change message.
335 * See create() for more details.
336 */
337 class MessageStateChanged : public Message
338 {
339 _CLASS_GENERIC(MessageStateChanged, GstMessage)
340 public:
341 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageStateChanged>',`Gst::wrap_msg_derived<MessageStateChanged>($3, false)')
342 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageStateChanged> create(const Glib::RefPtr<Gst::Object>& src, State oldstate, State newstate, State pending), gst_message_new_state_changed)
343
344 /** Extracts the old, new and pending states from the
345 * Gst::MessageStateChanged.
346 *
347 * MT safe.
348 *
349 * @param oldstate The previous state.
350 * @param newstate The new (current) state.
351 * @param pending The pending (target) state.
352 */
353 void parse(State& oldstate, State& newstate, State& pending) const;
354 _IGNORE(gst_message_parse_state_changed)
355
356 /** Extracts and returns the new state from the Gst::MessageStateChanged.
357 *
358 * MT safe.
359 *
360 * @return The new (current) state.
361 */
362 State parse_new_state() const;
363
364 /** Extracts and returns the old state from the Gst::MessageStateChanged.
365 *
366 * MT safe.
367 *
368 * @return The old state.
369 */
370 State parse_old_state() const;
371
372 /** Extracts and returns the pending state from the Gst::MessageStateChanged.
373 *
374 * MT safe.
375 *
376 * @return The pending state.
377 */
378 State parse_pending_state() const;
379 };
380
381 /** A state dirty message.
382 * See create() for more details.
383 */
384 class MessageStateDirty : public Message
385 {
386 _CLASS_GENERIC(MessageStateDirty, GstMessage)
387 public:
388 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageStateDirty>',`Gst::wrap_msg_derived<MessageStateDirty>($3, false)')
389 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageStateDirty> create(const Glib::RefPtr<Gst::Object>& src), gst_message_new_state_dirty)
390 };
391
392 /** A step done message.
393 * See create() for more details.
394 */
395 class MessageStepDone : public Message
396 {
397 _CLASS_GENERIC(MessageStepDone, GstMessage)
398 public:
399 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageStepDone>',`Gst::wrap_msg_derived<MessageStepDone>($3, false)')
400 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageStepDone> create(const Glib::RefPtr<Gst::Object>& src, Gst::Format format,
401 guint64 amount, double rate, bool flush, bool intermediate,
402 guint64 duration, bool eos), gst_message_new_step_done)
403
404 /** Extract the values of the step done message.
405 *
406 * MT safe.
407 *
408 * @param format Result location for the format.
409 * @param amount Result location for the amount.
410 * @param rate Result location for the rate.
411 * @param flush Result location for the flush flag.
412 * @param intermediate Result location for the intermediate flag.
413 * @param duration Result location for the duration.
414 * @param eos Result location for the EOS flag.
415 *
416 * Since 0.10.24.
417 */
418 void parse(Gst::Format& format, guint64& amount, double& rate, bool& flush,
419 bool& intermediate, guint64& duration, bool& eos) const;
420 _IGNORE(gst_message_parse_step_done)
421
422 /** Extracts the duration of the step done message.
423 * @return The duration.
424 */
425 guint64 parse_duration() const;
426
427 /** Extracts the format of the step done message.
428 * @return The format.
429 */
430 Gst::Format parse_format() const;
431
432 /** Extracts the amount of the step done message.
433 * @return The amount.
434 */
435 guint64 parse_amount() const;
436
437 /** Extracts the rate of the step done message.
438 * @return The rate.
439 */
440 double parse_rate() const;
441
442 /** Extracts the flush flag of the step done message.
443 * @return The flush flag.
444 */
445 bool parse_flush() const;
446
447 /** Extracts the intermediate flag of the step done message.
448 * @return The intermediate flag.
449 */
450 bool parse_intermediate() const;
451
452 /** Extracts the eos flag of the step done message.
453 * @return The eos flag.
454 */
455 bool parse_eos() const;
456 };
457
458 /** A clock provide message.
459 * See create() for more details.
460 */
461 class MessageClockProvide : public Message
462 {
463 _CLASS_GENERIC(MessageClockProvide, GstMessage)
464 public:
465 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageClockProvide>',`Gst::wrap_msg_derived<MessageClockProvide>($3, false)')
466 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageClockProvide> create(const Glib::RefPtr<Gst::Object>& src, const Glib::RefPtr<Gst::Clock>& clock, bool ready), gst_message_new_clock_provide)
467
468 /** Extracts the clock and ready flag from the Gst::MessageClockProvide. The
469 * clock object returned remains valid until the message is freed.
470 *
471 * MT safe.
472 *
473 * @param clock Location in which to hold a clock object.
474 * @param ready Location in which to hold the ready flag.
475 */
476 void parse(Glib::RefPtr<Gst::Clock>& clock, bool& ready) const;
477 _IGNORE(gst_message_parse_clock_provide)
478
479 /** Extracts and returns the clock from the Gst::MessageClockProvide. The
480 * clock object returned remains valid until the message is freed.
481 *
482 * MT safe.
483 *
484 * @return The clock object of the message.
485 */
486 Glib::RefPtr<Gst::Clock> parse_clock_provide();
487
488 /** Extracts and returns the clock from the Gst::MessageClockProvide. The
489 * clock object returned remains valid until the message is freed.
490 *
491 * MT safe.
492 *
493 * @return The clock object of the message.
494 */
495 Glib::RefPtr<const Gst::Clock> parse_clock_provide() const;
496
497 /** Extracts and returns the ready flag from the Gst::MessageClockProvide.
498 *
499 * MT safe.
500 *
501 * @return The ready flag of the message.
502 */
503 bool parse_ready() const;
504 };
505
506 /** A clock lost message.
507 * See create() for more details.
508 */
509 class MessageClockLost : public Message
510 {
511 _CLASS_GENERIC(MessageClockLost, GstMessage)
512 public:
513 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageClockLost>',`Gst::wrap_msg_derived<MessageClockLost>($3, false)')
514 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageClockLost> create(const Glib::RefPtr<Gst::Object>& src, const Glib::RefPtr<Gst::Clock>& clock), gst_message_new_clock_lost)
515
516 /** Extracts and returns the lost clock from the Gst::MessageClockLost. The
517 * clock object returned remains valid until the message is freed.
518 *
519 * MT safe.
520 * @return The lost clock.
521 */
522 Glib::RefPtr<Gst::Clock> parse_clock_lost();
523 _IGNORE(gst_message_parse_clock_lost)
524
525 /** Extracts and returns the lost clock from the Gst::MessageClockLost. The
526 * clock object returned remains valid until the message is freed.
527 *
528 * MT safe.
529 * @return The lost clock.
530 */
531 Glib::RefPtr<const Gst::Clock> parse_clock_lost() const;
532 };
533
534 /** A new clock message.
535 * See create() for more details.
536 */
537 class MessageNewClock: public Message
538 {
539 _CLASS_GENERIC(MessageNewClock, GstMessage)
540 public:
541 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageNewClock>',`Gst::wrap_msg_derived<MessageNewClock>($3, false)')
542 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageNewClock> create(const Glib::RefPtr<Gst::Object>& src, const Glib::RefPtr<Gst::Clock>& clock), gst_message_new_new_clock)
543
544 /** Extracts and returns the new clock from the Gst::MessageNewClock. The
545 * clock object returned remains valid until the message is freed.
546 *
547 * MT safe.
548 *
549 * @return The selected new clock.
550 */
551 Glib::RefPtr<Gst::Clock> parse_new_clock();
552 _IGNORE(gst_message_parse_new_clock)
553
554 /** Extracts and returns the new clock from the Gst::MessageNewClock. The
555 * clock object returned remains valid until the message is freed.
556 *
557 * MT safe.
558 *
559 * @return The selected new clock.
560 */
561 Glib::RefPtr<const Gst::Clock> parse_new_clock() const;
562 };
563
564 /** An application message.
565 * See create() for more details.
566 */
567 class MessageApplication : public Message
568 {
569 _CLASS_GENERIC(MessageApplication, GstMessage)
570 public:
571 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageApplication>',`Gst::wrap_msg_derived<MessageApplication>($3, false)')
572 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageApplication> create(const Glib::RefPtr<Gst::Object>& src, Gst::Structure&& structure), gst_message_new_application)
573
574 /** Create a new application-typed message. GStreamer will never create these
575 * messages; they are a gift from us to you. Enjoy.
576 *
577 * @param src The object originating the message.
578 * @param structure The structure for the message. The message
579 * will take ownership of the structure.
580 * @return The new application message.
581 *
582 * MT safe.
583 */
584 static Glib::RefPtr<Gst::MessageApplication> create(const Glib::RefPtr<Gst::Object>& src, const Gst::Structure& structure);
585 };
586
587 /** An element specific message.
588 * See create() for more details.
589 */
590 class MessageElement : public Message
591 {
592 _CLASS_GENERIC(MessageElement, GstMessage)
593 public:
594 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageElement>',`Gst::wrap_msg_derived<MessageElement>($3, false)')
595 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageElement> create(const Glib::RefPtr<Gst::Object>& src, Gst::Structure&& structure{?}), gst_message_new_element)
596
597 /** Create a new element-specific message. This is meant as a generic way of
598 * allowing one-way communication from an element to an application, for example
599 * "the firewire cable was unplugged". The format of the message should be
600 * documented in the element's documentation. The structure field can be <tt>0</tt>.
601 *
602 * @param src The object originating the message.
603 * @param structure The structure for the
604 * message. The message will take ownership of the structure.
605 * @return The new element message.
606 *
607 * MT safe.
608 */
609 static Glib::RefPtr<Gst::MessageElement> create(const Glib::RefPtr<Gst::Object>& src, const Gst::Structure& structure);
610 };
611
612 /** A custom message.
613 * See create() for more details.
614 */
615 class MessageCustom : public Message
616 {
617 _CLASS_GENERIC(MessageCustom, GstMessage)
618 public:
619 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageCustom>',`Gst::wrap_msg_derived<MessageCustom>($3, false)')
620 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageCustom> create(MessageType type, const Glib::RefPtr<Gst::Object>& src, Gst::Structure& structure{?}), gst_message_new_custom)
621 };
622
623 /** A segment start message.
624 * See create() for more details.
625 */
626 class MessageSegmentStart : public Message
627 {
628 _CLASS_GENERIC(MessageSegmentStart, GstMessage)
629 public:
630 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageSegmentStart>',`Gst::wrap_msg_derived<MessageSegmentStart>($3, false)')
631 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageSegmentStart> create(const Glib::RefPtr<Gst::Object>& src, Format format, gint64 position), gst_message_new_segment_start)
632
633 /** Extracts the position and format from the segment start message.
634 *
635 * MT safe.
636 *
637 * @param format Result location for the format.
638 * @param position Result location for the position.
639 */
640 void parse(Format& format, gint64& position) const;
641 _IGNORE(gst_message_parse_segment_start)
642
643 /** Extracts and returns the position from the segment start message.
644 *
645 * MT safe.
646 *
647 * @return The position.
648 */
649 gint64 parse_position() const;
650
651 /** Extracts and returns the format from the segment start message.
652 *
653 * MT safe.
654 *
655 * @return The format.
656 */
657 Format parse_format() const;
658 };
659
660 /** A segment done message.
661 * See create() for more details.
662 */
663 class MessageSegmentDone : public Message
664 {
665 _CLASS_GENERIC(MessageSegmentDone, GstMessage)
666 public:
667 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageSegmentDone>',`Gst::wrap_msg_derived<MessageSegmentDone>($3, false)')
668 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageSegmentDone> create(const Glib::RefPtr<Gst::Object>& src, Format format, gint64 position), gst_message_new_segment_done)
669
670 /** Extracts the position and format from the segment done message.
671 *
672 * MT safe.
673 *
674 * @param format Result location for the format.
675 * @param position Result location for the position.
676 */
677 void parse(Format& format, gint64& position) const;
678 _IGNORE(gst_message_parse_segment_done)
679
680 /** Extracts and returns the position from the segment done message.
681 *
682 * MT safe.
683 *
684 * @return The position.
685 */
686 gint64 parse_position() const;
687
688 /** Extracts and returns the format from the segment done message.
689 *
690 * MT safe.
691 *
692 * @return The format.
693 */
694 Format parse_format() const;
695 };
696
697 /** A duration message.
698 * See create() for more details.
699 */
700 class MessageDurationChanged : public Message
701 {
702 _CLASS_GENERIC(MessageDurationChanged, GstMessage)
703 public:
704 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageDurationChanged>',`Gst::wrap_msg_derived<MessageDurationChanged>($3, false)')
705 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageDurationChanged> create(const Glib::RefPtr<Gst::Object>& src), gst_message_new_duration_changed)
706 };
707
708 /** A latency message.
709 * See create() for more details.
710 */
711 class MessageLatency : public Message
712 {
713 _CLASS_GENERIC(MessageLatency, GstMessage)
714 public:
715 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageLatency>',`Gst::wrap_msg_derived<MessageLatency>($3, false)')
716 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageLatency> create(const Glib::RefPtr<Gst::Object>& src), gst_message_new_latency)
717 };
718
719 /** An asynchronous start message.
720 * See create() for more details.
721 */
722 class MessageAsyncStart : public Message
723 {
724 _CLASS_GENERIC(MessageAsyncStart, GstMessage)
725 public:
726 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageAsyncStart>',`Gst::wrap_msg_derived<MessageAsyncStart>($3, false)')
727 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageAsyncStart> create(const Glib::RefPtr<Gst::Object>& src), gst_message_new_async_start)
728 };
729
730 /** An asynchronous done message.
731 * See create() for more details.
732 */
733 class MessageAsyncDone : public Message
734 {
735 _CLASS_GENERIC(MessageAsyncDone, GstMessage)
736 public:
737 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageAsyncDone>',`Gst::wrap_msg_derived<MessageAsyncDone>($3, false)')
738 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageAsyncDone> create(const Glib::RefPtr<Gst::Object>& src, Gst::ClockTime running_time), gst_message_new_async_done)
739
740 /** Extract the running_time from the async_done message.
741 *
742 * MT safe.
743 *
744 * @return The running time from the async_done message.
745 */
746 Gst::ClockTime parse_running_time() const;
747 _IGNORE(gst_message_parse_async_done)
748 };
749
750 /** A step start message.
751 * See create() for more details.
752 */
753 class MessageStepStart : public Message
754 {
755 _CLASS_GENERIC(MessageStepStart, GstMessage)
756 public:
757 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageStepStart>',`Gst::wrap_msg_derived<MessageStepStart>($3, false)')
758 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageStepStart> create(const Glib::RefPtr<Gst::Object>& src, bool active,
759 Gst::Format format, guint64 amount, double rate, bool flush,
760 bool intermediate), gst_message_new_step_start)
761
762 /** Extract the values of the step start message.
763 *
764 * MT safe.
765 *
766 * @param active Result location for the active flag.
767 * @param format Result location for the format.
768 * @param amount Result location for the amount.
769 * @param rate Result location for the rate.
770 * @param flush Result location for the flush flag.
771 * @param intermediate Result location for the intermediate flag.
772 *
773 * Since 0.10.24.
774 */
775 void parse(bool& active, Gst::Format& format, guint64& amount, double& rate,
776 bool& flush, bool& intermediate) const;
777 _IGNORE(gst_message_parse_step_start)
778
779 /** Extracts the amount of the step start message.
780 * @return The amount.
781 */
782 guint64 parse_amount() const;
783
784 /** Extracts the active flag of the step start message.
785 * @return The active flag.
786 */
787 bool parse_active() const;
788
789 /** Extracts the format of the step start message.
790 * @return The format.
791 */
792 Gst::Format parse_format() const;
793
794 /** Extracts the rate of the step start message.
795 * @return The rate.
796 */
797 double parse_rate() const;
798
799 /** Extracts the flush flag of the step start message.
800 * @return The flush flag.
801 */
802 bool parse_flush() const;
803
804 /** Extracts the intermediate flag of the step start message.
805 * @return The intermediate flag.
806 */
807 bool parse_intermediate() const;
808 };
809
810 /** A structure change message.
811 * See create() for more details.
812 */
813 class MessageStructureChange : public Message
814 {
815 _CLASS_GENERIC(MessageStructureChange, GstMessage)
816 public:
817 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageStructureChange>',`Gst::wrap_msg_derived<MessageStructureChange>($3, false)')
818 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageStructureChange> create(const Glib::RefPtr<Gst::Object>& src,
819 Gst::StructureChangeType type, const Glib::RefPtr<Gst::Element>& owner,
820 bool busy), gst_message_new_structure_change)
821
822 /** Extracts the change type and completion status from the Gst::Message.
823 * MT safe.
824 *
825 * @param type A reference to hold the change type.
826 * @param owner The owner element of the message source.
827 * @param busy A reference to hold whether the change is in progress or has
828 * been completed.
829 *
830 * Since 0.10.22.
831 */
832 void parse(Gst::StructureChangeType& type,
833 Glib::RefPtr<Gst::Element>& owner, bool& busy) const;
834 _IGNORE(gst_message_parse_structure_change)
835
836 /** Extracts the change type from the Gs::tMessage.
837 * MT safe.
838 *
839 * @return The change type.
840 *
841 * Since 0.10.22.
842 */
843 Gst::StructureChangeType parse_type() const;
844
845 /** Extracts the owner from the Gst::Message.
846 * MT safe.
847 *
848 * @return The owner element of the message source.
849 *
850 * Since 0.10.22.
851 */
852 Glib::RefPtr<Gst::Element> parse_owner() const;
853
854 /** Extracts the completion status from the Gst::Message.
855 * MT safe.
856 *
857 * @return whether the change is in progress or has been completed.
858 *
859 * Since 0.10.22.
860 */
861 bool parse_busy() const;
862 };
863
864 /** A request state message.
865 * See create() for more details.
866 */
867 class MessageRequestState : public Message
868 {
869 _CLASS_GENERIC(MessageRequestState, GstMessage)
870 public:
871 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageRequestState>',`Gst::wrap_msg_derived<MessageRequestState>($3, false)')
872 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageRequestState> create(const Glib::RefPtr<Gst::Object>& src, Gst::State state), gst_message_new_request_state)
873
874 /** Extract the requested state from the request_state message.
875 * @return The state. MT safe.
876 *
877 * Since 0.10.23.
878 */
879 Gst::State parse_state() const;
880 _IGNORE(gst_message_parse_request_state)
881 };
882
883 /** A stream status message.
884 * See create() for more details.
885 */
886 class MessageStreamStatus : public Message
887 {
888 _CLASS_GENERIC(MessageStreamStatus, GstMessage)
889 public:
890 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageStreamStatus>',`Gst::wrap_msg_derived<MessageStreamStatus>($3, false)')
891 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageStreamStatus> create(const Glib::RefPtr<Gst::Object>& src, Gst::StreamStatusType type,
892 const Glib::RefPtr<Gst::Element>& owner), gst_message_new_stream_status)
893
894 /** Configures the object handling the streaming thread. This is usually a
895 * Gst::Task object but other objects might be added in the future.
896 * @param object The object controlling the streaming.
897 *
898 * Since 0.10.24.
899 */
900 void set_object(const Glib::RefPtr<Gst::Object>& object);
901 _IGNORE(gst_message_set_stream_status_object)
902
903 /** Extracts the object managing the streaming thread from message.
904 * @return The object that manages the streaming thread. The actual object
905 * is usually a Gst::Task but other types can be added in the future. The
906 * object remains valid as long as the message is valid.
907 */
908 Glib::RefPtr<Gst::Object> get_object() const;
909 _IGNORE(gst_message_get_stream_status_object)
910
911 /** Extracts the stream status type and owner of the Gst::Message. The
912 * returned owner remains valid for as long as the reference to the message
913 * is valid.
914 *
915 * MT safe.
916 *
917 * @param type A reference to hold the status type.
918 * @param owner A reference to hold the owner Gst::Element.
919 *
920 * Since 0.10.24.
921 */
922 void parse(Gst::StreamStatusType& type, Glib::RefPtr<Gst::Element>& owner) const;
923 _IGNORE(gst_message_parse_stream_status)
924
925 /** Extracts the stream status type.
926 *
927 * MT safe.
928 *
929 * @return The stream status type.
930 *
931 * Since 0.10.24.
932 */
933 Gst::StreamStatusType parse_type() const;
934
935 /** Extracts the owner of the Gst::Message. The returned owner remains valid
936 * for as long as the reference to the message is valid.
937 *
938 * MT safe.
939 *
940 * @return The owner Gst::Element.
941 *
942 * Since 0.10.24.
943 */
944 Glib::RefPtr<Gst::Element> parse_owner() const;
945 };
946
947 /** A qos message.
948 * See create() for more details.
949 */
950 class MessageQos : public Message
951 {
952 _CLASS_GENERIC(MessageQos, GstMessage)
953 public:
954 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageQos>',`Gst::wrap_msg_derived<MessageQos>($3, false)')
955 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageQos> create(const Glib::RefPtr<Gst::Object>& src, bool live, guint64 running_time,
956 guint64 stream_time, guint64 timestamp, guint64 duration), gst_message_new_qos)
957
958 /** Set the QoS values that have been calculated/analysed from the QoS data.
959 *
960 * MT safe.
961 *
962 * @param jitter The difference of the running-time against the deadline.
963 * @param proportion Long term prediction of the ideal rate relative to normal rate
964 * to get optimal quality.
965 * @param quality An element dependent integer value that specifies the current
966 * quality level of the element. The default maximum quality is 1000000.
967 */
968 void set_values(gint64 jitter, double proportion, gint quality);
969 _IGNORE(gst_message_set_qos_values)
970
971 /** Set the QoS stats representing the history of the current continuous pipeline
972 * playback period.
973 *
974 * When @a format is Gst::FORMAT_UNDEFINED both @a dropped and @a processed are
975 * invalid. Values of -1 for either @a processed or @a dropped mean unknown values.
976 *
977 * MT safe.
978 *
979 * @param format Units of the @a processed and @a dropped fields. Video sinks and video
980 * filters will use Gst::FORMAT_BUFFERS (frames). Audio sinks and audio filters
981 * will likely use Gst::FORMAT_DEFAULT (samples).
982 * @param processed Total number of units correctly processed since the last state
983 * change to READY or a flushing operation.
984 * @param dropped Total number of units dropped since the last state change to READY
985 * or a flushing operation.
986 */
987 void set_stats(Gst::Format format, guint64 processed, guint64 dropped);
988 _IGNORE(gst_message_set_qos_stats)
989
990 /** Extract the timestamps and live status from the QoS message.
991 *
992 * The returned values give the running_time, stream_time, timestamp and
993 * duration of the dropped buffer. Values of Gst::CLOCK_TIME_NONE mean unknown
994 * values.
995 *
996 * MT safe.
997 *
998 * @param live If the message was generated by a live element.
999 * @param running_time The running time of the buffer that
1000 * generated the message.
1001 * @param stream_time The stream time of the buffer that
1002 * generated the message.
1003 * @param timestamp The timestamps of the buffer that
1004 * generated the message.
1005 * @param duration The duration of the buffer that
1006 * generated the message.
1007 */
1008 void parse(bool& live, guint64& running_time, guint64& stream_time,
1009 guint64& timestamp, guint64& duration) const;
1010 _IGNORE(gst_message_parse_qos)
1011
1012 /** Extract the QoS values that have been calculated/analysed from the QoS data.
1013 * @param jitter The difference of the running-time against
1014 * the deadline.
1015 * @param proportion Long term prediction of the ideal rate
1016 * relative to normal rate to get optimal quality.
1017 * @param quality An element dependent integer value that
1018 * specifies the current quality level of the element. The default
1019 * maximum quality is 1000000.
1020 *
1021 * MT safe.
1022 */
1023 void parse_values(gint64& jitter, double& proportion, gint& quality) const;
1024 _IGNORE(gst_message_parse_qos_values)
1025
1026 /** Extract the QoS stats representing the history of the current continuous
1027 * pipeline playback period.
1028 *
1029 * @param format Units of the 'processed' and 'dropped' fields.
1030 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1031 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1032 * (samples).
1033 * @param processed Total number of units correctly processed
1034 * since the last state change to READY or a flushing operation.
1035 * @param dropped Total number of units dropped since the last
1036 * state change to READY or a flushing operation.
1037 *
1038 * MT_safe.
1039 *
1040 * When @a format is Gst::FORMAT_UNDEFINED both @a dropped and @a processed are
1041 * invalid. Values of -1 for either @a processed or @a dropped mean unknown values.
1042 */
1043 void parse_stats(Gst::Format& format, guint64& processed, guint64& dropped) const;
1044 _IGNORE(gst_message_parse_qos_stats)
1045 };
1046
1047 /** A stream-start message.
1048 * See create() for more details.
1049 */
1050 class MessageStreamStart : public Message
1051 {
1052 _CLASS_GENERIC(MessageStreamStart, GstMessage)
1053 public:
1054 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageStreamStart>',`Gst::wrap_msg_derived<MessageStreamStart>($3, false)')
1055 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageStreamStart> create(const Glib::RefPtr<Gst::Object>& src), gst_message_new_stream_start)
1056
1057 /** Sets the group id on the stream-start message.
1058 *
1059 * All streams that have the same group id are supposed to be played
1060 * together, i.e. all streams inside a container file should have the
1061 * same group id but different stream ids. The group id should change
1062 * each time the stream is started, resulting in different group ids
1063 * each time a file is played for example.
1064 *
1065 * MT safe.
1066 *
1067 * @param group_id The group id.
1068 */
1069 void set_group_id(guint group_id);
1070 _IGNORE(gst_message_set_group_id)
1071
1072 /** Extract the group from the STREAM_START message.
1073 *
1074 * MT safe
1075 *
1076 * @param group_id Result location for the group id.
1077 *
1078 * @return true if the message had a group id set, false otherwse.
1079 */
1080 bool parse_group_id(guint& group_id) const;
1081 _IGNORE(gst_message_parse_group_id)
1082 };
1083
1084 /** A have-context message.
1085 * See create() for more details.
1086 */
1087 class MessageHaveContext : public Message
1088 {
1089 _CLASS_GENERIC(MessageHaveContext, GstMessage)
1090 public:
1091 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageHaveContext>',`Gst::wrap_msg_derived<MessageHaveContext>($3, false)')
1092 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageHaveContext> create(const Glib::RefPtr<Gst::Object>& src, const Glib::RefPtr<Gst::Context>& context), gst_message_new_have_context)
1093
1094 /** Extract the context from the HAVE_CONTEXT message.
1095 *
1096 * MT safe.
1097 *
1098 * @return context Result location for the context.
1099 */
1100 Glib::RefPtr<Gst::Context> parse_have_context();
1101 _IGNORE(gst_message_parse_have_context)
1102
1103 /** Extract the context from the HAVE_CONTEXT message.
1104 *
1105 * MT safe.
1106 *
1107 * @return context Result location for the context.
1108 */
1109 Glib::RefPtr<const Gst::Context> parse_have_context() const;
1110 };
1111
1112 /** A need-context message.
1113 * See create() for more details.
1114 */
1115 class MessageNeedContext : public Message
1116 {
1117 _CLASS_GENERIC(MessageNeedContext, GstMessage)
1118 public:
1119 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageNeedContext>',`Gst::wrap_msg_derived<MessageNeedContext>($3, false)')
1120 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageNeedContext> create(const Glib::RefPtr<Gst::Object>& src, const Glib::ustring& context_type), gst_message_new_need_context)
1121
1122 /** Parse a context type from an existing Gst::MESSAGE_NEED_CONTEXT message.
1123 *
1124 * @param context_type The context type.
1125 *
1126 * @return a bool indicating if the parsing succeeded.
1127 */
1128 bool parse(Glib::ustring& context_type) const;
1129 _IGNORE(gst_message_parse_context_type)
1130 };
1131
1132 /** A reset-time message.
1133 * See create() for more details.
1134 */
1135 class MessageResetTime : public Message
1136 {
1137 _CLASS_GENERIC(MessageResetTime, GstMessage)
1138 public:
1139 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageResetTime>',`Gst::wrap_msg_derived<MessageResetTime>($3, false)')
1140 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageResetTime> create(const Glib::RefPtr<Gst::Object>& src, Gst::ClockTime running_time), gst_message_new_reset_time)
1141
1142 /** Extract the running-time from the RESET_TIME message.
1143 *
1144 * MT safe.
1145 *
1146 * @return Result location for the running_time.
1147 */
1148 Gst::ClockTime parse_running_time() const;
1149 _IGNORE(gst_message_parse_reset_time)
1150 };
1151
1152 /** A toc message.
1153 * See create() for more details.
1154 */
1155 class MessageToc : public Message
1156 {
1157 _CLASS_GENERIC(MessageToc, GstMessage)
1158 public:
1159 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageToc>',`Gst::wrap_msg_derived<MessageToc>($3, false)')
1160 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageToc> create(const Glib::RefPtr<Gst::Object>& src, const Glib::RefPtr<Gst::Toc>& toc, bool updated), gst_message_new_toc)
1161
1162 /** Extract the TOC from the Gst::Message.
1163 *
1164 * MT safe.
1165 *
1166 * @param toc Return location for the TOC.
1167 * @param updated Return location for the updated flag.
1168 */
1169 void parse(Glib::RefPtr<Gst::Toc>& toc, bool& updated) const;
1170 _IGNORE(gst_message_parse_toc)
1171 };
1172
1173 /** A progress message.
1174 * See create() for more details.
1175 */
1176 class MessageProgress : public Message
1177 {
1178 _CLASS_GENERIC(MessageProgress, GstMessage)
1179 public:
1180 #m4 _CONVERSION(`GstMessage*',`Glib::RefPtr<Gst::MessageProgress>',`Gst::wrap_msg_derived<MessageProgress>($3, false)')
1181 _WRAP_METHOD(static Glib::RefPtr<Gst::MessageProgress> create(const Glib::RefPtr<Gst::Object>& src,
1182 Gst::ProgressType type, const Glib::ustring& code, const Glib::ustring& text), gst_message_new_progress)
1183
1184 /** Parses the progress @a type, @a code and @a text.
1185 *
1186 * @param type A Gst::ProgressType.
1187 * @param code A code.
1188 * @param text A text.
1189 */
1190 void parse(Gst::ProgressType& type, Glib::ustring& code, Glib::ustring& text) const;
1191 _IGNORE(gst_message_parse_progress)
1192
1193 /** Extracts and returns the ProgressType from the Gst::MessageProgress.
1194 *
1195 * @return The ProgressType.
1196 */
1197 Gst::ProgressType parse_type() const;
1198
1199 /** Extracts and returns the code from the Gst::MessageProgress.
1200 *
1201 * @return The code.
1202 */
1203 Glib::ustring parse_code() const;
1204
1205 /** Extracts and returns the text from the Gst::MessageProgress.
1206 *
1207 * @return The text.
1208 */
1209 Glib::ustring parse_text() const;
1210 };
1211
1212 } //namespace Gst