aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/gstreamer_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/gstreamer_extractor.c')
-rw-r--r--src/plugins/gstreamer_extractor.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/plugins/gstreamer_extractor.c b/src/plugins/gstreamer_extractor.c
index 7334d56..db9d804 100644
--- a/src/plugins/gstreamer_extractor.c
+++ b/src/plugins/gstreamer_extractor.c
@@ -38,7 +38,7 @@ GST_DEBUG_CATEGORY_STATIC (gstreamer_extractor);
38 * How often should we check for data timeout. 38 * How often should we check for data timeout.
39 * In milliseconds. 39 * In milliseconds.
40 */ 40 */
41#define DATA_TIMEOUT_FREQUENCY 45 /* 45ms, hang up for 90ms at most */ 41#define DATA_TIMEOUT_FREQUENCY 750 /* 750ms, hang up for 1.5s at most */
42 42
43/** 43/**
44 * Once discoverer has gone for that long without asking for data or 44 * Once discoverer has gone for that long without asking for data or
@@ -917,8 +917,8 @@ static GQuark duration_quark;
917 * @param ps our execution context 917 * @param ps our execution context
918 */ 918 */
919static void 919static void
920feed_data (GstElement * appsrc, 920feed_data (GstElement * appsrc,
921 guint size, 921 guint size,
922 struct PrivStruct * ps) 922 struct PrivStruct * ps)
923{ 923{
924 ssize_t data_len; 924 ssize_t data_len;
@@ -975,7 +975,7 @@ feed_data (GstElement * appsrc,
975 GST_BUFFER_OFFSET (buffer) = ps->offset; 975 GST_BUFFER_OFFSET (buffer) = ps->offset;
976 GST_BUFFER_OFFSET_END (buffer) = ps->offset + size; 976 GST_BUFFER_OFFSET_END (buffer) = ps->offset + size;
977 977
978 GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", 978 GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u",
979 buffer, ps->offset, size); 979 buffer, ps->offset, size);
980 gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer); 980 gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer);
981 ps->offset += size; 981 ps->offset += size;
@@ -1002,8 +1002,8 @@ feed_data (GstElement * appsrc,
1002 * @return TRUE if seeking succeeded, FALSE if not 1002 * @return TRUE if seeking succeeded, FALSE if not
1003 */ 1003 */
1004static gboolean 1004static gboolean
1005seek_data (GstElement * appsrc, 1005seek_data (GstElement * appsrc,
1006 guint64 position, 1006 guint64 position,
1007 struct PrivStruct * ps) 1007 struct PrivStruct * ps)
1008{ 1008{
1009 GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position); 1009 GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position);
@@ -1017,14 +1017,14 @@ seek_data (GstElement * appsrc,
1017 1017
1018/** 1018/**
1019 * FIXME 1019 * FIXME
1020 * 1020 *
1021 * @param field_id FIXME 1021 * @param field_id FIXME
1022 * @param value FIXME 1022 * @param value FIXME
1023 * @param user_data our 'struct PrivStruct' 1023 * @param user_data our 'struct PrivStruct'
1024 * @return TRUE to continue processing, FALSE to abort 1024 * @return TRUE to continue processing, FALSE to abort
1025 */ 1025 */
1026static gboolean 1026static gboolean
1027send_structure_foreach (GQuark field_id, 1027send_structure_foreach (GQuark field_id,
1028 const GValue *value, 1028 const GValue *value,
1029 gpointer user_data) 1029 gpointer user_data)
1030{ 1030{
@@ -1081,7 +1081,7 @@ send_structure_foreach (GQuark field_id,
1081 str = NULL; 1081 str = NULL;
1082 break; 1082 break;
1083 } 1083 }
1084 if (NULL != str) 1084 if (NULL != str)
1085 { 1085 {
1086 unsigned int i; 1086 unsigned int i;
1087 1087
@@ -1089,7 +1089,7 @@ send_structure_foreach (GQuark field_id,
1089 if (0 == strcmp (named_tags[i].tag, field_name)) 1089 if (0 == strcmp (named_tags[i].tag, field_name))
1090 { 1090 {
1091 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1091 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1092 named_tags[i].le_type, 1092 named_tags[i].le_type,
1093 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1093 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
1094 (const char *) str, strlen (str) + 1); 1094 (const char *) str, strlen (str) + 1);
1095 g_free (str); 1095 g_free (str);
@@ -1102,7 +1102,7 @@ send_structure_foreach (GQuark field_id,
1102 gchar *senddata = g_strdup_printf ("%s=%s", field_name, str); 1102 gchar *senddata = g_strdup_printf ("%s=%s", field_name, str);
1103 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1103 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1104 EXTRACTOR_METATYPE_UNKNOWN, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1104 EXTRACTOR_METATYPE_UNKNOWN, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
1105 (const char *) senddata, 1105 (const char *) senddata,
1106 strlen (senddata) + 1); 1106 strlen (senddata) + 1);
1107 g_free (senddata); 1107 g_free (senddata);
1108 } 1108 }
@@ -1114,13 +1114,13 @@ send_structure_foreach (GQuark field_id,
1114 1114
1115/** 1115/**
1116 * FIXME 1116 * FIXME
1117 * 1117 *
1118 * @param info FIXME 1118 * @param info FIXME
1119 * @param ps processing context 1119 * @param ps processing context
1120 * @return FALSE to continue processing, TRUE to abort 1120 * @return FALSE to continue processing, TRUE to abort
1121 */ 1121 */
1122static gboolean 1122static gboolean
1123send_audio_info (GstDiscovererAudioInfo *info, 1123send_audio_info (GstDiscovererAudioInfo *info,
1124 struct PrivStruct *ps) 1124 struct PrivStruct *ps)
1125{ 1125{
1126 gchar *tmp; 1126 gchar *tmp;
@@ -1131,7 +1131,7 @@ send_audio_info (GstDiscovererAudioInfo *info,
1131 if (ctmp) 1131 if (ctmp)
1132 if ((ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1132 if ((ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1133 EXTRACTOR_METATYPE_AUDIO_LANGUAGE, 1133 EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
1134 EXTRACTOR_METAFORMAT_UTF8, 1134 EXTRACTOR_METAFORMAT_UTF8,
1135 "text/plain", 1135 "text/plain",
1136 (const char *) ctmp, strlen (ctmp) + 1))) 1136 (const char *) ctmp, strlen (ctmp) + 1)))
1137 return TRUE; 1137 return TRUE;
@@ -1202,13 +1202,13 @@ send_audio_info (GstDiscovererAudioInfo *info,
1202 1202
1203/** 1203/**
1204 * FIXME 1204 * FIXME
1205 * 1205 *
1206 * @param info FIXME 1206 * @param info FIXME
1207 * @param ps processing context 1207 * @param ps processing context
1208 * @return FALSE to continue processing, TRUE to abort 1208 * @return FALSE to continue processing, TRUE to abort
1209 */ 1209 */
1210static int 1210static int
1211send_video_info (GstDiscovererVideoInfo *info, 1211send_video_info (GstDiscovererVideoInfo *info,
1212 struct PrivStruct *ps) 1212 struct PrivStruct *ps)
1213{ 1213{
1214 gchar *tmp; 1214 gchar *tmp;
@@ -1298,13 +1298,13 @@ send_video_info (GstDiscovererVideoInfo *info,
1298 1298
1299/** 1299/**
1300 * FIXME 1300 * FIXME
1301 * 1301 *
1302 * @param info FIXME 1302 * @param info FIXME
1303 * @param ps processing context 1303 * @param ps processing context
1304 * @return FALSE to continue processing, TRUE to abort 1304 * @return FALSE to continue processing, TRUE to abort
1305 */ 1305 */
1306static int 1306static int
1307send_subtitle_info (GstDiscovererSubtitleInfo *info, 1307send_subtitle_info (GstDiscovererSubtitleInfo *info,
1308 struct PrivStruct *ps) 1308 struct PrivStruct *ps)
1309{ 1309{
1310 const gchar *ctmp; 1310 const gchar *ctmp;
@@ -1397,7 +1397,7 @@ send_tag_foreach (const GstTagList * tags,
1397 1397
1398 mime_type = gst_structure_get_name (gst_caps_get_structure (caps, 0)); 1398 mime_type = gst_structure_get_name (gst_caps_get_structure (caps, 0));
1399 info = gst_sample_get_info (sample); 1399 info = gst_sample_get_info (sample);
1400 1400
1401 if ( (NULL == info) || 1401 if ( (NULL == info) ||
1402 (!gst_structure_get (info, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &imagetype, NULL)) ) 1402 (!gst_structure_get (info, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &imagetype, NULL)) )
1403 le_type = EXTRACTOR_METATYPE_PICTURE; 1403 le_type = EXTRACTOR_METATYPE_PICTURE;
@@ -1583,13 +1583,13 @@ send_tag_foreach (const GstTagList * tags,
1583} 1583}
1584 1584
1585 1585
1586static void 1586static void
1587send_streams (GstDiscovererStreamInfo *info, 1587send_streams (GstDiscovererStreamInfo *info,
1588 struct PrivStruct *ps); 1588 struct PrivStruct *ps);
1589 1589
1590 1590
1591static void 1591static void
1592send_stream_info (GstDiscovererStreamInfo * info, 1592send_stream_info (GstDiscovererStreamInfo * info,
1593 struct PrivStruct *ps) 1593 struct PrivStruct *ps)
1594{ 1594{
1595 const GstStructure *misc; 1595 const GstStructure *misc;
@@ -1677,7 +1677,7 @@ send_stream_info (GstDiscovererStreamInfo * info,
1677 1677
1678 1678
1679static void 1679static void
1680send_streams (GstDiscovererStreamInfo *info, 1680send_streams (GstDiscovererStreamInfo *info,
1681 struct PrivStruct *ps) 1681 struct PrivStruct *ps)
1682{ 1682{
1683 GstDiscovererStreamInfo *next; 1683 GstDiscovererStreamInfo *next;
@@ -1696,7 +1696,7 @@ send_streams (GstDiscovererStreamInfo *info,
1696 * Callback used to construct the XML 'toc'. 1696 * Callback used to construct the XML 'toc'.
1697 * 1697 *
1698 * @param tags FIXME 1698 * @param tags FIXME
1699 * @param tag FIXME 1699 * @param tag FIXME
1700 * @param user_data the 'struct PrivStruct' with the 'toc' string we are assembling 1700 * @param user_data the 'struct PrivStruct' with the 'toc' string we are assembling
1701 */ 1701 */
1702static void 1702static void
@@ -1802,11 +1802,11 @@ send_toc_foreach (gpointer data, gpointer user_data)
1802 else 1802 else
1803 ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2; 1803 ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2;
1804 } 1804 }
1805 1805
1806 subentries = gst_toc_entry_get_sub_entries (entry); 1806 subentries = gst_toc_entry_get_sub_entries (entry);
1807 g_list_foreach (subentries, send_toc_foreach, ps); 1807 g_list_foreach (subentries, send_toc_foreach, ps);
1808 ps->toc_depth--; 1808 ps->toc_depth--;
1809 1809
1810 s = g_strdup_printf ("%*.*s</%s>\n", ps->toc_depth * 2, ps->toc_depth * 2, " ", 1810 s = g_strdup_printf ("%*.*s</%s>\n", ps->toc_depth * 2, ps->toc_depth * 2, " ",
1811 gst_toc_entry_type_get_nick (entype)); 1811 gst_toc_entry_type_get_nick (entype));
1812 if (ps->toc_print_phase) 1812 if (ps->toc_print_phase)
@@ -1824,7 +1824,7 @@ send_toc_foreach (gpointer data, gpointer user_data)
1824 1824
1825 1825
1826static void 1826static void
1827send_info (GstDiscovererInfo * info, 1827send_info (GstDiscovererInfo * info,
1828 struct PrivStruct *ps) 1828 struct PrivStruct *ps)
1829{ 1829{
1830 const GstToc *toc; 1830 const GstToc *toc;
@@ -1870,15 +1870,15 @@ send_info (GstDiscovererInfo * info,
1870 ps->toc_length += 1 + strlen (TOC_XML_HEADER); 1870 ps->toc_length += 1 + strlen (TOC_XML_HEADER);
1871 ps->toc = g_malloc (ps->toc_length); 1871 ps->toc = g_malloc (ps->toc_length);
1872 ps->toc_pos = 0; 1872 ps->toc_pos = 0;
1873 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], 1873 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
1874 ps->toc_length - ps->toc_pos, 1874 ps->toc_length - ps->toc_pos,
1875 "%s", 1875 "%s",
1876 TOC_XML_HEADER); 1876 TOC_XML_HEADER);
1877 g_list_foreach (entries, &send_toc_foreach, ps); 1877 g_list_foreach (entries, &send_toc_foreach, ps);
1878 ps->toc[ps->toc_length - 1] = '\0'; 1878 ps->toc[ps->toc_length - 1] = '\0';
1879 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1879 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1880 EXTRACTOR_METATYPE_TOC, 1880 EXTRACTOR_METATYPE_TOC,
1881 EXTRACTOR_METAFORMAT_C_STRING, 1881 EXTRACTOR_METAFORMAT_C_STRING,
1882 "application/xml", 1882 "application/xml",
1883 (const char *) ps->toc, 1883 (const char *) ps->toc,
1884 ps->toc_length); 1884 ps->toc_length);
@@ -1896,7 +1896,7 @@ send_info (GstDiscovererInfo * info,
1896 1896
1897 1897
1898static void 1898static void
1899send_discovered_info (GstDiscovererInfo * info, 1899send_discovered_info (GstDiscovererInfo * info,
1900 struct PrivStruct * ps) 1900 struct PrivStruct * ps)
1901{ 1901{
1902 GstDiscovererResult result; 1902 GstDiscovererResult result;
@@ -1928,9 +1928,9 @@ send_discovered_info (GstDiscovererInfo * info,
1928 1928
1929 1929
1930static void 1930static void
1931_new_discovered_uri (GstDiscoverer * dc, 1931_new_discovered_uri (GstDiscoverer * dc,
1932 GstDiscovererInfo * info, 1932 GstDiscovererInfo * info,
1933 GError * err, 1933 GError * err,
1934 struct PrivStruct *ps) 1934 struct PrivStruct *ps)
1935{ 1935{
1936 send_discovered_info (info, ps); 1936 send_discovered_info (info, ps);
@@ -1968,14 +1968,14 @@ _data_timeout (struct PrivStruct *ps)
1968 * This callback is called when discoverer has constructed a source object to 1968 * This callback is called when discoverer has constructed a source object to
1969 * read from. Since we provided the appsrc:// uri to discoverer, this will be 1969 * read from. Since we provided the appsrc:// uri to discoverer, this will be
1970 * the appsrc that we must handle. We set up some signals - one to push data 1970 * the appsrc that we must handle. We set up some signals - one to push data
1971 * into appsrc and one to perform a seek. 1971 * into appsrc and one to perform a seek.
1972 * 1972 *
1973 * @param dc 1973 * @param dc
1974 * @param source 1974 * @param source
1975 * @param ps 1975 * @param ps
1976 */ 1976 */
1977static void 1977static void
1978_source_setup (GstDiscoverer * dc, 1978_source_setup (GstDiscoverer * dc,
1979 GstElement * source, 1979 GstElement * source,
1980 struct PrivStruct *ps) 1980 struct PrivStruct *ps)
1981{ 1981{
@@ -2048,7 +2048,7 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec)
2048 2048
2049 memset (&ps, 0, sizeof (ps)); 2049 memset (&ps, 0, sizeof (ps));
2050 ps.dc = gst_discoverer_new (8 * GST_SECOND, &err); 2050 ps.dc = gst_discoverer_new (8 * GST_SECOND, &err);
2051 if (NULL == ps.dc) 2051 if (NULL == ps.dc)
2052 { 2052 {
2053 if (NULL != err) 2053 if (NULL != err)
2054 g_error_free (err); 2054 g_error_free (err);
@@ -2082,7 +2082,7 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec)
2082/** 2082/**
2083 * Initialize glib and globals. 2083 * Initialize glib and globals.
2084 */ 2084 */
2085void __attribute__ ((constructor)) 2085void __attribute__ ((constructor))
2086gstreamer_init () 2086gstreamer_init ()
2087{ 2087{
2088 gst_init (NULL, NULL); 2088 gst_init (NULL, NULL);