mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-25 18:14:15 +00:00
mpegts: Add functions to send sections as events
Added function that enables the user to send a GstMpegTsSection as an event to a GstElement. (i.e. mpegtsmux)
This commit is contained in:
parent
930cde73a7
commit
8f429c6c6e
2 changed files with 93 additions and 17 deletions
|
@ -257,20 +257,9 @@ gst_message_parse_mpegts_section (GstMessage * message)
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static GstStructure *
|
||||||
* gst_message_new_mpegts_section:
|
_mpegts_section_get_structure (GstMpegTsSection * section)
|
||||||
* @parent: (transfer none): The creator of the message
|
|
||||||
* @section: (transfer none): The #GstMpegTsSection to put in a message
|
|
||||||
*
|
|
||||||
* Creates a new #GstMessage for a @GstMpegTsSection.
|
|
||||||
*
|
|
||||||
* Returns: (transfer full): The new #GstMessage to be posted, or %NULL if the
|
|
||||||
* section is not valid.
|
|
||||||
*/
|
|
||||||
GstMessage *
|
|
||||||
gst_message_new_mpegts_section (GstObject * parent, GstMpegTsSection * section)
|
|
||||||
{
|
{
|
||||||
GstMessage *msg;
|
|
||||||
GstStructure *st;
|
GstStructure *st;
|
||||||
GQuark quark;
|
GQuark quark;
|
||||||
|
|
||||||
|
@ -303,7 +292,7 @@ gst_message_new_mpegts_section (GstObject * parent, GstMpegTsSection * section)
|
||||||
quark = QUARK_TOT;
|
quark = QUARK_TOT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
GST_DEBUG ("Creating message for unknown GstMpegTsSection");
|
GST_DEBUG ("Creating structure for unknown GstMpegTsSection");
|
||||||
quark = QUARK_SECTION;
|
quark = QUARK_SECTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -311,11 +300,96 @@ gst_message_new_mpegts_section (GstObject * parent, GstMpegTsSection * section)
|
||||||
st = gst_structure_new_id (quark, QUARK_SECTION, MPEG_TYPE_TS_SECTION,
|
st = gst_structure_new_id (quark, QUARK_SECTION, MPEG_TYPE_TS_SECTION,
|
||||||
section, NULL);
|
section, NULL);
|
||||||
|
|
||||||
|
return st;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_message_new_mpegts_section:
|
||||||
|
* @parent: (transfer none): The creator of the message
|
||||||
|
* @section: (transfer none): The #GstMpegTsSection to put in a message
|
||||||
|
*
|
||||||
|
* Creates a new #GstMessage for a @GstMpegTsSection.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): The new #GstMessage to be posted, or %NULL if the
|
||||||
|
* section is not valid.
|
||||||
|
*/
|
||||||
|
GstMessage *
|
||||||
|
gst_message_new_mpegts_section (GstObject * parent, GstMpegTsSection * section)
|
||||||
|
{
|
||||||
|
GstMessage *msg;
|
||||||
|
GstStructure *st;
|
||||||
|
|
||||||
|
st = _mpegts_section_get_structure (section);
|
||||||
|
|
||||||
msg = gst_message_new_element (parent, st);
|
msg = gst_message_new_element (parent, st);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstEvent *
|
||||||
|
_mpegts_section_get_event (GstMpegTsSection * section)
|
||||||
|
{
|
||||||
|
GstStructure *structure;
|
||||||
|
GstEvent *event;
|
||||||
|
|
||||||
|
structure = _mpegts_section_get_structure (section);
|
||||||
|
|
||||||
|
event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, structure);
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_event_parse_mpegts_section:
|
||||||
|
* @event: (transfer none): #GstEvent containing a #GstMpegTsSection
|
||||||
|
*
|
||||||
|
* Extracts the #GstMpegTsSection contained in the @event #GstEvent
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): The extracted #GstMpegTsSection
|
||||||
|
*/
|
||||||
|
GstMpegTsSection *
|
||||||
|
gst_event_parse_mpegts_section (GstEvent * event)
|
||||||
|
{
|
||||||
|
const GstStructure *structure;
|
||||||
|
GstMpegTsSection *section;
|
||||||
|
|
||||||
|
structure = gst_event_get_structure (event);
|
||||||
|
|
||||||
|
if (!gst_structure_id_get (structure, QUARK_SECTION, MPEG_TYPE_TS_SECTION,
|
||||||
|
§ion, NULL))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return section;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_mpegts_section_send_event:
|
||||||
|
* @element: (transfer none): The #GstElement to send to section event to
|
||||||
|
* @section: (transfer none): The #GstMpegTsSection to put in the event
|
||||||
|
*
|
||||||
|
* Creates a custom #GstEvent with a @GstMpegTsSection.
|
||||||
|
* The #GstEvent is sent to the @element #GstElement.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the event is sent
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_mpegts_section_send_event (GstMpegTsSection * section, GstElement * element)
|
||||||
|
{
|
||||||
|
GstEvent *event;
|
||||||
|
|
||||||
|
g_return_val_if_fail (section != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (element != NULL, FALSE);
|
||||||
|
|
||||||
|
event = _mpegts_section_get_event (section);
|
||||||
|
|
||||||
|
if (!gst_element_send_event (element, event)) {
|
||||||
|
gst_event_unref (event);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static GstMpegTsPatProgram *
|
static GstMpegTsPatProgram *
|
||||||
_mpegts_pat_program_copy (GstMpegTsPatProgram * orig)
|
_mpegts_pat_program_copy (GstMpegTsPatProgram * orig)
|
||||||
{
|
{
|
||||||
|
@ -761,9 +835,9 @@ _packetize_common_section (GstMpegTsSection * section, gsize length)
|
||||||
/* reserved - 2 bit
|
/* reserved - 2 bit
|
||||||
version_number - 5 bit uimsbf
|
version_number - 5 bit uimsbf
|
||||||
current_next_indicator - 1 bit */
|
current_next_indicator - 1 bit */
|
||||||
*data++ =
|
*data++ = 0xC0 |
|
||||||
0xC0 | ((section->version_number & 0x1F) << 1) | (section->
|
((section->version_number & 0x1F) << 1) |
|
||||||
current_next_indicator & 0x01);
|
(section->current_next_indicator & 0x01);
|
||||||
|
|
||||||
/* section_number - 8 bit uimsbf */
|
/* section_number - 8 bit uimsbf */
|
||||||
*data++ = section->section_number;
|
*data++ = section->section_number;
|
||||||
|
|
|
@ -360,6 +360,8 @@ GPtrArray *gst_mpegts_section_get_tsdt (GstMpegTsSection *section);
|
||||||
#define gst_mpegts_section_unref(section) (gst_mini_object_unref (GST_MINI_OBJECT_CAST (section)))
|
#define gst_mpegts_section_unref(section) (gst_mini_object_unref (GST_MINI_OBJECT_CAST (section)))
|
||||||
|
|
||||||
GstMessage *gst_message_new_mpegts_section (GstObject *parent, GstMpegTsSection *section);
|
GstMessage *gst_message_new_mpegts_section (GstObject *parent, GstMpegTsSection *section);
|
||||||
|
gboolean gst_mpegts_section_send_event (GstMpegTsSection * section, GstElement * element);
|
||||||
|
GstMpegTsSection *gst_event_parse_mpegts_section (GstEvent * event);
|
||||||
|
|
||||||
GstMpegTsSection *gst_message_parse_mpegts_section (GstMessage *message);
|
GstMpegTsSection *gst_message_parse_mpegts_section (GstMessage *message);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue