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.c611
1 files changed, 317 insertions, 294 deletions
diff --git a/src/plugins/gstreamer_extractor.c b/src/plugins/gstreamer_extractor.c
index 31568a7..87f0153 100644
--- a/src/plugins/gstreamer_extractor.c
+++ b/src/plugins/gstreamer_extractor.c
@@ -64,8 +64,7 @@ struct KnownTag
64/** 64/**
65 * Struct mapping known tags (that do occur in GST API) to LE tags. 65 * Struct mapping known tags (that do occur in GST API) to LE tags.
66 */ 66 */
67static struct KnownTag __known_tags[] = 67static struct KnownTag __known_tags[] = {
68{
69 /** 68 /**
70 * GST_TAG_TITLE: 69 * GST_TAG_TITLE:
71 * 70 *
@@ -562,7 +561,8 @@ static struct KnownTag __known_tags[] =
562 * Represents the expected error on the horizontal positioning in 561 * Represents the expected error on the horizontal positioning in
563 * meters (double). 562 * meters (double).
564 */ 563 */
565 {GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR}, 564 {GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR,
565 EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR},
566 566
567 /** 567 /**
568 * GST_TAG_GEO_LOCATION_MOVEMENT_SPEED: 568 * GST_TAG_GEO_LOCATION_MOVEMENT_SPEED:
@@ -572,7 +572,8 @@ static struct KnownTag __known_tags[] =
572 * 572 *
573 * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION 573 * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION
574 */ 574 */
575 {GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED}, 575 {GST_TAG_GEO_LOCATION_MOVEMENT_SPEED,
576 EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED},
576 577
577 /** 578 /**
578 * GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION: 579 * GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION:
@@ -583,7 +584,8 @@ static struct KnownTag __known_tags[] =
583 * 584 *
584 * See also #GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION 585 * See also #GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION
585 */ 586 */
586 {GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION}, 587 {GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION,
588 EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION},
587 589
588 /** 590 /**
589 * GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION: 591 * GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION:
@@ -594,7 +596,8 @@ static struct KnownTag __known_tags[] =
594 * 596 *
595 * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION 597 * See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION
596 */ 598 */
597 {GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION}, 599 {GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION,
600 EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION},
598 601
599 /** 602 /**
600 * GST_TAG_SHOW_NAME: 603 * GST_TAG_SHOW_NAME:
@@ -735,23 +738,22 @@ struct NamedTag
735 * Mapping from GST tag names to LE types for tags that are not in 738 * Mapping from GST tag names to LE types for tags that are not in
736 * the public GST API. 739 * the public GST API.
737 */ 740 */
738struct NamedTag named_tags[] = 741struct NamedTag named_tags[] = {
739 { 742 { "FPS", EXTRACTOR_METATYPE_FRAME_RATE },
740 { "FPS", EXTRACTOR_METATYPE_FRAME_RATE }, 743 { "PLAY_COUNTER", EXTRACTOR_METATYPE_PLAY_COUNTER },
741 { "PLAY_COUNTER", EXTRACTOR_METATYPE_PLAY_COUNTER }, 744 { "RATING", EXTRACTOR_METATYPE_RATING },
742 { "RATING", EXTRACTOR_METATYPE_RATING }, 745 { "SUMMARY", EXTRACTOR_METATYPE_SUMMARY },
743 { "SUMMARY", EXTRACTOR_METATYPE_SUMMARY }, 746 { "SUBJECT", EXTRACTOR_METATYPE_SUBJECT },
744 { "SUBJECT", EXTRACTOR_METATYPE_SUBJECT }, 747 { "MOOD", EXTRACTOR_METATYPE_MOOD },
745 { "MOOD", EXTRACTOR_METATYPE_MOOD }, 748 { "LEAD_PERFORMER", EXTRACTOR_METATYPE_PERFORMER },
746 { "LEAD_PERFORMER", EXTRACTOR_METATYPE_PERFORMER }, 749 { "DIRECTOR", EXTRACTOR_METATYPE_MOVIE_DIRECTOR },
747 { "DIRECTOR", EXTRACTOR_METATYPE_MOVIE_DIRECTOR }, 750 { "WRITTEN_BY", EXTRACTOR_METATYPE_WRITER },
748 { "WRITTEN_BY", EXTRACTOR_METATYPE_WRITER }, 751 { "PRODUCER", EXTRACTOR_METATYPE_PRODUCER },
749 { "PRODUCER", EXTRACTOR_METATYPE_PRODUCER }, 752 { "PUBLISHER", EXTRACTOR_METATYPE_PUBLISHER },
750 { "PUBLISHER", EXTRACTOR_METATYPE_PUBLISHER }, 753 { "ORIGINAL/ARTIST", EXTRACTOR_METATYPE_ORIGINAL_ARTIST },
751 { "ORIGINAL/ARTIST", EXTRACTOR_METATYPE_ORIGINAL_ARTIST }, 754 { "ORIGINAL/TITLE", EXTRACTOR_METATYPE_ORIGINAL_TITLE },
752 { "ORIGINAL/TITLE", EXTRACTOR_METATYPE_ORIGINAL_TITLE }, 755 { NULL, EXTRACTOR_METATYPE_UNKNOWN }
753 { NULL, EXTRACTOR_METATYPE_UNKNOWN } 756};
754 };
755 757
756 758
757/** 759/**
@@ -914,9 +916,9 @@ _data_timeout (struct PrivStruct *ps)
914 * @param ps our execution context 916 * @param ps our execution context
915 */ 917 */
916static void 918static void
917feed_data (GstElement * appsrc, 919feed_data (GstElement *appsrc,
918 guint size, 920 guint size,
919 struct PrivStruct * ps) 921 struct PrivStruct *ps)
920{ 922{
921 ssize_t data_len; 923 ssize_t data_len;
922 uint8_t *le_data; 924 uint8_t *le_data;
@@ -929,7 +931,8 @@ feed_data (GstElement * appsrc,
929 931
930 if (ps->timeout_id > 0) 932 if (ps->timeout_id > 0)
931 g_source_remove (ps->timeout_id); 933 g_source_remove (ps->timeout_id);
932 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); 934 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
935 ps);
933 936
934 if ( (ps->length > 0) && (ps->offset >= ps->length) ) 937 if ( (ps->length > 0) && (ps->offset >= ps->length) )
935 { 938 {
@@ -938,11 +941,11 @@ feed_data (GstElement * appsrc,
938 return; 941 return;
939 } 942 }
940 943
941 if (ps->length > 0 && ps->offset + size > ps->length) 944 if ((ps->length > 0) && (ps->offset + size > ps->length))
942 size = ps->length - ps->offset; 945 size = ps->length - ps->offset;
943 946
944 mem = gst_allocator_alloc (NULL, size, NULL); 947 mem = gst_allocator_alloc (NULL, size, NULL);
945 if (!gst_memory_map (mem, &mi, GST_MAP_WRITE)) 948 if (! gst_memory_map (mem, &mi, GST_MAP_WRITE))
946 { 949 {
947 gst_memory_unref (mem); 950 gst_memory_unref (mem);
948 GST_DEBUG ("Failed to map the memory"); 951 GST_DEBUG ("Failed to map the memory");
@@ -955,7 +958,8 @@ feed_data (GstElement * appsrc,
955 pthread_mutex_lock (&pipe_mutex); 958 pthread_mutex_lock (&pipe_mutex);
956 while ( (accumulated < size) && (data_len > 0) ) 959 while ( (accumulated < size) && (data_len > 0) )
957 { 960 {
958 data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size - accumulated); 961 data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size
962 - accumulated);
959 if (data_len > 0) 963 if (data_len > 0)
960 { 964 {
961 memcpy (&mi.data[accumulated], le_data, data_len); 965 memcpy (&mi.data[accumulated], le_data, data_len);
@@ -974,7 +978,7 @@ feed_data (GstElement * appsrc,
974 GST_BUFFER_OFFSET_END (buffer) = ps->offset + size; 978 GST_BUFFER_OFFSET_END (buffer) = ps->offset + size;
975 979
976 GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u", 980 GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u",
977 buffer, ps->offset, size); 981 buffer, ps->offset, size);
978 gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer); 982 gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer);
979 ps->offset += size; 983 ps->offset += size;
980 } 984 }
@@ -987,7 +991,8 @@ feed_data (GstElement * appsrc,
987 991
988 if (ps->timeout_id > 0) 992 if (ps->timeout_id > 0)
989 g_source_remove (ps->timeout_id); 993 g_source_remove (ps->timeout_id);
990 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); 994 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
995 ps);
991} 996}
992 997
993 998
@@ -1001,9 +1006,9 @@ feed_data (GstElement * appsrc,
1001 * @return TRUE if seeking succeeded, FALSE if not 1006 * @return TRUE if seeking succeeded, FALSE if not
1002 */ 1007 */
1003static gboolean 1008static gboolean
1004seek_data (GstElement * appsrc, 1009seek_data (GstElement *appsrc,
1005 guint64 position, 1010 guint64 position,
1006 struct PrivStruct * ps) 1011 struct PrivStruct *ps)
1007{ 1012{
1008 GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position); 1013 GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position);
1009 pthread_mutex_lock (&pipe_mutex); 1014 pthread_mutex_lock (&pipe_mutex);
@@ -1011,7 +1016,8 @@ seek_data (GstElement * appsrc,
1011 pthread_mutex_unlock (&pipe_mutex); 1016 pthread_mutex_unlock (&pipe_mutex);
1012 if (ps->timeout_id > 0) 1017 if (ps->timeout_id > 0)
1013 g_source_remove (ps->timeout_id); 1018 g_source_remove (ps->timeout_id);
1014 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); 1019 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
1020 ps);
1015 return ps->offset == position; 1021 return ps->offset == position;
1016} 1022}
1017 1023
@@ -1026,8 +1032,8 @@ seek_data (GstElement * appsrc,
1026 */ 1032 */
1027static gboolean 1033static gboolean
1028send_structure_foreach (GQuark field_id, 1034send_structure_foreach (GQuark field_id,
1029 const GValue *value, 1035 const GValue *value,
1030 gpointer user_data) 1036 gpointer user_data)
1031{ 1037{
1032 struct PrivStruct *ps = user_data; 1038 struct PrivStruct *ps = user_data;
1033 gchar *str; 1039 gchar *str;
@@ -1095,20 +1101,21 @@ send_structure_foreach (GQuark field_id,
1095 { 1101 {
1096 unsigned int i; 1102 unsigned int i;
1097 1103
1098 for (i=0; NULL != named_tags[i].tag; i++) 1104 for (i = 0; NULL != named_tags[i].tag; i++)
1099 if (0 == strcmp (named_tags[i].tag, field_name)) 1105 if (0 == strcmp (named_tags[i].tag, field_name))
1100 { 1106 {
1101 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1107 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1102 named_tags[i].le_type, 1108 named_tags[i].le_type,
1103 EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1109 EXTRACTOR_METAFORMAT_UTF8,
1104 (const char *) str, strlen (str) + 1); 1110 "text/plain",
1105 if (NULL != str) 1111 (const char *) str, strlen (str) + 1);
1106 { 1112 if (NULL != str)
1107 g_free (str); 1113 {
1108 str = NULL; 1114 g_free (str);
1109 } 1115 str = NULL;
1110 break; 1116 }
1111 } 1117 break;
1118 }
1112 } 1119 }
1113 if (NULL != str) 1120 if (NULL != str)
1114 { 1121 {
@@ -1116,16 +1123,16 @@ send_structure_foreach (GQuark field_id,
1116 field_name, 1123 field_name,
1117 str); 1124 str);
1118 if (NULL != senddata) 1125 if (NULL != senddata)
1119 { 1126 {
1120 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1127 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1121 "gstreamer", 1128 "gstreamer",
1122 EXTRACTOR_METATYPE_UNKNOWN, 1129 EXTRACTOR_METATYPE_UNKNOWN,
1123 EXTRACTOR_METAFORMAT_UTF8, 1130 EXTRACTOR_METAFORMAT_UTF8,
1124 "text/plain", 1131 "text/plain",
1125 (const char *) senddata, 1132 (const char *) senddata,
1126 strlen (senddata) + 1); 1133 strlen (senddata) + 1);
1127 g_free (senddata); 1134 g_free (senddata);
1128 } 1135 }
1129 } 1136 }
1130 if (NULL != str) 1137 if (NULL != str)
1131 g_free (str); 1138 g_free (str);
@@ -1143,7 +1150,7 @@ send_structure_foreach (GQuark field_id,
1143 */ 1150 */
1144static gboolean 1151static gboolean
1145send_audio_info (GstDiscovererAudioInfo *info, 1152send_audio_info (GstDiscovererAudioInfo *info,
1146 struct PrivStruct *ps) 1153 struct PrivStruct *ps)
1147{ 1154{
1148 gchar *tmp; 1155 gchar *tmp;
1149 const gchar *ctmp; 1156 const gchar *ctmp;
@@ -1152,10 +1159,11 @@ send_audio_info (GstDiscovererAudioInfo *info,
1152 ctmp = gst_discoverer_audio_info_get_language (info); 1159 ctmp = gst_discoverer_audio_info_get_language (info);
1153 if (ctmp) 1160 if (ctmp)
1154 if ((ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1161 if ((ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1155 EXTRACTOR_METATYPE_AUDIO_LANGUAGE, 1162 EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
1156 EXTRACTOR_METAFORMAT_UTF8, 1163 EXTRACTOR_METAFORMAT_UTF8,
1157 "text/plain", 1164 "text/plain",
1158 (const char *) ctmp, strlen (ctmp) + 1))) 1165 (const char *) ctmp, strlen (ctmp)
1166 + 1)))
1159 return TRUE; 1167 return TRUE;
1160 1168
1161 u = gst_discoverer_audio_info_get_channels (info); 1169 u = gst_discoverer_audio_info_get_channels (info);
@@ -1163,16 +1171,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
1163 { 1171 {
1164 tmp = g_strdup_printf ("%u", u); 1172 tmp = g_strdup_printf ("%u", u);
1165 if (NULL != tmp) 1173 if (NULL != tmp)
1166 { 1174 {
1167 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1175 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1168 "gstreamer", 1176 "gstreamer",
1169 EXTRACTOR_METATYPE_CHANNELS, 1177 EXTRACTOR_METATYPE_CHANNELS,
1170 EXTRACTOR_METAFORMAT_UTF8, 1178 EXTRACTOR_METAFORMAT_UTF8,
1171 "text/plain", 1179 "text/plain",
1172 (const char *) tmp, 1180 (const char *) tmp,
1173 strlen (tmp) + 1); 1181 strlen (tmp) + 1);
1174 g_free (tmp); 1182 g_free (tmp);
1175 } 1183 }
1176 if (ps->time_to_leave) 1184 if (ps->time_to_leave)
1177 return TRUE; 1185 return TRUE;
1178 } 1186 }
@@ -1182,16 +1190,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
1182 { 1190 {
1183 tmp = g_strdup_printf ("%u", u); 1191 tmp = g_strdup_printf ("%u", u);
1184 if (NULL != tmp) 1192 if (NULL != tmp)
1185 { 1193 {
1186 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1194 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1187 "gstreamer", 1195 "gstreamer",
1188 EXTRACTOR_METATYPE_SAMPLE_RATE, 1196 EXTRACTOR_METATYPE_SAMPLE_RATE,
1189 EXTRACTOR_METAFORMAT_UTF8, 1197 EXTRACTOR_METAFORMAT_UTF8,
1190 "text/plain", 1198 "text/plain",
1191 (const char *) tmp, 1199 (const char *) tmp,
1192 strlen (tmp) + 1); 1200 strlen (tmp) + 1);
1193 g_free (tmp); 1201 g_free (tmp);
1194 } 1202 }
1195 if (ps->time_to_leave) 1203 if (ps->time_to_leave)
1196 return TRUE; 1204 return TRUE;
1197 } 1205 }
@@ -1201,16 +1209,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
1201 { 1209 {
1202 tmp = g_strdup_printf ("%u", u); 1210 tmp = g_strdup_printf ("%u", u);
1203 if (NULL != tmp) 1211 if (NULL != tmp)
1204 { 1212 {
1205 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1213 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1206 "gstreamer", 1214 "gstreamer",
1207 EXTRACTOR_METATYPE_AUDIO_DEPTH, 1215 EXTRACTOR_METATYPE_AUDIO_DEPTH,
1208 EXTRACTOR_METAFORMAT_UTF8, 1216 EXTRACTOR_METAFORMAT_UTF8,
1209 "text/plain", 1217 "text/plain",
1210 (const char *) tmp, 1218 (const char *) tmp,
1211 strlen (tmp) + 1); 1219 strlen (tmp) + 1);
1212 g_free (tmp); 1220 g_free (tmp);
1213 } 1221 }
1214 if (ps->time_to_leave) 1222 if (ps->time_to_leave)
1215 return TRUE; 1223 return TRUE;
1216 } 1224 }
@@ -1220,16 +1228,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
1220 { 1228 {
1221 tmp = g_strdup_printf ("%u", u); 1229 tmp = g_strdup_printf ("%u", u);
1222 if (NULL != tmp) 1230 if (NULL != tmp)
1223 { 1231 {
1224 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1232 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1225 "gstreamer", 1233 "gstreamer",
1226 EXTRACTOR_METATYPE_AUDIO_BITRATE, 1234 EXTRACTOR_METATYPE_AUDIO_BITRATE,
1227 EXTRACTOR_METAFORMAT_UTF8, 1235 EXTRACTOR_METAFORMAT_UTF8,
1228 "text/plain", 1236 "text/plain",
1229 (const char *) tmp, 1237 (const char *) tmp,
1230 strlen (tmp) + 1); 1238 strlen (tmp) + 1);
1231 g_free (tmp); 1239 g_free (tmp);
1232 } 1240 }
1233 if (ps->time_to_leave) 1241 if (ps->time_to_leave)
1234 return TRUE; 1242 return TRUE;
1235 } 1243 }
@@ -1239,16 +1247,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
1239 { 1247 {
1240 tmp = g_strdup_printf ("%u", u); 1248 tmp = g_strdup_printf ("%u", u);
1241 if (NULL != tmp) 1249 if (NULL != tmp)
1242 { 1250 {
1243 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1251 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1244 "gstreamer", 1252 "gstreamer",
1245 EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE, 1253 EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE,
1246 EXTRACTOR_METAFORMAT_UTF8, 1254 EXTRACTOR_METAFORMAT_UTF8,
1247 "text/plain", 1255 "text/plain",
1248 (const char *) tmp, 1256 (const char *) tmp,
1249 strlen (tmp) + 1); 1257 strlen (tmp) + 1);
1250 g_free (tmp); 1258 g_free (tmp);
1251 } 1259 }
1252 if (ps->time_to_leave) 1260 if (ps->time_to_leave)
1253 return TRUE; 1261 return TRUE;
1254 } 1262 }
@@ -1266,7 +1274,7 @@ send_audio_info (GstDiscovererAudioInfo *info,
1266 */ 1274 */
1267static int 1275static int
1268send_video_info (GstDiscovererVideoInfo *info, 1276send_video_info (GstDiscovererVideoInfo *info,
1269 struct PrivStruct *ps) 1277 struct PrivStruct *ps)
1270{ 1278{
1271 gchar *tmp; 1279 gchar *tmp;
1272 guint u; 1280 guint u;
@@ -1278,16 +1286,16 @@ send_video_info (GstDiscovererVideoInfo *info,
1278 { 1286 {
1279 tmp = g_strdup_printf ("%ux%u", u, u2); 1287 tmp = g_strdup_printf ("%ux%u", u, u2);
1280 if (NULL != tmp) 1288 if (NULL != tmp)
1281 { 1289 {
1282 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1290 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1283 "gstreamer", 1291 "gstreamer",
1284 EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, 1292 EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
1285 EXTRACTOR_METAFORMAT_UTF8, 1293 EXTRACTOR_METAFORMAT_UTF8,
1286 "text/plain", 1294 "text/plain",
1287 (const char *) tmp, 1295 (const char *) tmp,
1288 strlen (tmp) + 1); 1296 strlen (tmp) + 1);
1289 g_free (tmp); 1297 g_free (tmp);
1290 } 1298 }
1291 if (ps->time_to_leave) 1299 if (ps->time_to_leave)
1292 return TRUE; 1300 return TRUE;
1293 } 1301 }
@@ -1297,16 +1305,16 @@ send_video_info (GstDiscovererVideoInfo *info,
1297 { 1305 {
1298 tmp = g_strdup_printf ("%u", u); 1306 tmp = g_strdup_printf ("%u", u);
1299 if (NULL != tmp) 1307 if (NULL != tmp)
1300 { 1308 {
1301 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1309 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1302 "gstreamer", 1310 "gstreamer",
1303 EXTRACTOR_METATYPE_VIDEO_DEPTH, 1311 EXTRACTOR_METATYPE_VIDEO_DEPTH,
1304 EXTRACTOR_METAFORMAT_UTF8, 1312 EXTRACTOR_METAFORMAT_UTF8,
1305 "text/plain", 1313 "text/plain",
1306 (const char *) tmp, 1314 (const char *) tmp,
1307 strlen (tmp) + 1); 1315 strlen (tmp) + 1);
1308 g_free (tmp); 1316 g_free (tmp);
1309 } 1317 }
1310 if (ps->time_to_leave) 1318 if (ps->time_to_leave)
1311 return TRUE; 1319 return TRUE;
1312 } 1320 }
@@ -1317,16 +1325,16 @@ send_video_info (GstDiscovererVideoInfo *info,
1317 { 1325 {
1318 tmp = g_strdup_printf ("%u/%u", u, u2); 1326 tmp = g_strdup_printf ("%u/%u", u, u2);
1319 if (NULL != tmp) 1327 if (NULL != tmp)
1320 { 1328 {
1321 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1329 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1322 "gstreamer", 1330 "gstreamer",
1323 EXTRACTOR_METATYPE_FRAME_RATE, 1331 EXTRACTOR_METATYPE_FRAME_RATE,
1324 EXTRACTOR_METAFORMAT_UTF8, 1332 EXTRACTOR_METAFORMAT_UTF8,
1325 "text/plain", 1333 "text/plain",
1326 (const char *) tmp, 1334 (const char *) tmp,
1327 strlen (tmp) + 1); 1335 strlen (tmp) + 1);
1328 g_free (tmp); 1336 g_free (tmp);
1329 } 1337 }
1330 if (ps->time_to_leave) 1338 if (ps->time_to_leave)
1331 return TRUE; 1339 return TRUE;
1332 } 1340 }
@@ -1337,16 +1345,16 @@ send_video_info (GstDiscovererVideoInfo *info,
1337 { 1345 {
1338 tmp = g_strdup_printf ("%u/%u", u, u2); 1346 tmp = g_strdup_printf ("%u/%u", u, u2);
1339 if (NULL != tmp) 1347 if (NULL != tmp)
1340 { 1348 {
1341 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1349 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1342 "gstreamer", 1350 "gstreamer",
1343 EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, 1351 EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
1344 EXTRACTOR_METAFORMAT_UTF8, 1352 EXTRACTOR_METAFORMAT_UTF8,
1345 "text/plain", 1353 "text/plain",
1346 (const char *) tmp, 1354 (const char *) tmp,
1347 strlen (tmp) + 1); 1355 strlen (tmp) + 1);
1348 g_free (tmp); 1356 g_free (tmp);
1349 } 1357 }
1350 if (ps->time_to_leave) 1358 if (ps->time_to_leave)
1351 return TRUE; 1359 return TRUE;
1352 } 1360 }
@@ -1358,16 +1366,16 @@ send_video_info (GstDiscovererVideoInfo *info,
1358 { 1366 {
1359 tmp = g_strdup_printf ("%u", u); 1367 tmp = g_strdup_printf ("%u", u);
1360 if (NULL != tmp) 1368 if (NULL != tmp)
1361 { 1369 {
1362 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1370 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1363 "gstreamer", 1371 "gstreamer",
1364 EXTRACTOR_METATYPE_VIDEO_BITRATE, 1372 EXTRACTOR_METATYPE_VIDEO_BITRATE,
1365 EXTRACTOR_METAFORMAT_UTF8, 1373 EXTRACTOR_METAFORMAT_UTF8,
1366 "text/plain", 1374 "text/plain",
1367 (const char *) tmp, 1375 (const char *) tmp,
1368 strlen (tmp) + 1); 1376 strlen (tmp) + 1);
1369 g_free (tmp); 1377 g_free (tmp);
1370 } 1378 }
1371 if (ps->time_to_leave) 1379 if (ps->time_to_leave)
1372 return TRUE; 1380 return TRUE;
1373 } 1381 }
@@ -1377,16 +1385,16 @@ send_video_info (GstDiscovererVideoInfo *info,
1377 { 1385 {
1378 tmp = g_strdup_printf ("%u", u); 1386 tmp = g_strdup_printf ("%u", u);
1379 if (NULL != tmp) 1387 if (NULL != tmp)
1380 { 1388 {
1381 ps->time_to_leave = ps->ec->proc (ps->ec->cls, 1389 ps->time_to_leave = ps->ec->proc (ps->ec->cls,
1382 "gstreamer", 1390 "gstreamer",
1383 EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE, 1391 EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE,
1384 EXTRACTOR_METAFORMAT_UTF8, 1392 EXTRACTOR_METAFORMAT_UTF8,
1385 "text/plain", 1393 "text/plain",
1386 (const char *) tmp, 1394 (const char *) tmp,
1387 strlen (tmp) + 1); 1395 strlen (tmp) + 1);
1388 g_free (tmp); 1396 g_free (tmp);
1389 } 1397 }
1390 if (ps->time_to_leave) 1398 if (ps->time_to_leave)
1391 return TRUE; 1399 return TRUE;
1392 } 1400 }
@@ -1404,26 +1412,27 @@ send_video_info (GstDiscovererVideoInfo *info,
1404 */ 1412 */
1405static int 1413static int
1406send_subtitle_info (GstDiscovererSubtitleInfo *info, 1414send_subtitle_info (GstDiscovererSubtitleInfo *info,
1407 struct PrivStruct *ps) 1415 struct PrivStruct *ps)
1408{ 1416{
1409 const gchar *ctmp; 1417 const gchar *ctmp;
1410 1418
1411 ctmp = gst_discoverer_subtitle_info_get_language (info); 1419 ctmp = gst_discoverer_subtitle_info_get_language (info);
1412 if ( (NULL != ctmp) && 1420 if ( (NULL != ctmp) &&
1413 (0 != (ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1421 (0 != (ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1414 EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE, 1422 EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE,
1415 EXTRACTOR_METAFORMAT_UTF8, 1423 EXTRACTOR_METAFORMAT_UTF8,
1416 "text/plain", 1424 "text/plain",
1417 (const char *) ctmp, strlen (ctmp) + 1))) ) 1425 (const char *) ctmp, strlen (
1426 ctmp) + 1))) )
1418 return TRUE; 1427 return TRUE;
1419 return FALSE; 1428 return FALSE;
1420} 1429}
1421 1430
1422 1431
1423static void 1432static void
1424send_tag_foreach (const GstTagList * tags, 1433send_tag_foreach (const GstTagList *tags,
1425 const gchar * tag, 1434 const gchar *tag,
1426 gpointer user_data) 1435 gpointer user_data)
1427{ 1436{
1428 static struct KnownTag unknown_tag = {NULL, EXTRACTOR_METATYPE_UNKNOWN}; 1437 static struct KnownTag unknown_tag = {NULL, EXTRACTOR_METATYPE_UNKNOWN};
1429 struct PrivStruct *ps = user_data; 1438 struct PrivStruct *ps = user_data;
@@ -1480,7 +1489,9 @@ send_tag_foreach (const GstTagList * tags,
1480 str = gst_value_serialize (&val); 1489 str = gst_value_serialize (&val);
1481 break; 1490 break;
1482 default: 1491 default:
1483 if (G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE && (sample = gst_value_get_sample (&val))) 1492 if ((G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE) && (sample =
1493 gst_value_get_sample (
1494 &val)))
1484 { 1495 {
1485 GstMapInfo mi; 1496 GstMapInfo mi;
1486 GstCaps *caps; 1497 GstCaps *caps;
@@ -1498,7 +1509,9 @@ send_tag_foreach (const GstTagList * tags,
1498 info = gst_sample_get_info (sample); 1509 info = gst_sample_get_info (sample);
1499 1510
1500 if ( (NULL == info) || 1511 if ( (NULL == info) ||
1501 (!gst_structure_get (info, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &imagetype, NULL)) ) 1512 (! gst_structure_get (info, "image-type",
1513 GST_TYPE_TAG_IMAGE_TYPE, &imagetype,
1514 NULL)) )
1502 le_type = EXTRACTOR_METATYPE_PICTURE; 1515 le_type = EXTRACTOR_METATYPE_PICTURE;
1503 else 1516 else
1504 { 1517 {
@@ -1545,12 +1558,12 @@ send_tag_foreach (const GstTagList * tags,
1545 le_type, 1558 le_type,
1546 EXTRACTOR_METAFORMAT_BINARY, 1559 EXTRACTOR_METAFORMAT_BINARY,
1547 mime_type, 1560 mime_type,
1548 (const char *) mi.data, mi.size); 1561 (const char *) mi.data, mi.size);
1549 gst_buffer_unmap (buf, &mi); 1562 gst_buffer_unmap (buf, &mi);
1550 } 1563 }
1551 } 1564 }
1552 else if ((G_VALUE_TYPE (&val) == G_TYPE_UINT64) && 1565 else if ((G_VALUE_TYPE (&val) == G_TYPE_UINT64) &&
1553 (tag_quark == duration_quark)) 1566 (tag_quark == duration_quark))
1554 { 1567 {
1555 GstClockTime duration = (GstClockTime) g_value_get_uint64 (&val); 1568 GstClockTime duration = (GstClockTime) g_value_get_uint64 (&val);
1556 if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0)) 1569 if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0))
@@ -1566,14 +1579,12 @@ send_tag_foreach (const GstTagList * tags,
1566 * ignore these tags to avoid duplicates. 1579 * ignore these tags to avoid duplicates.
1567 * This MIGHT be fixed in new GStreamer versions, but won't affect 1580 * This MIGHT be fixed in new GStreamer versions, but won't affect
1568 * this code (we simply won't get the tags that we think we should skip). 1581 * this code (we simply won't get the tags that we think we should skip).
1569 */ 1582 */gboolean skip = FALSE;
1570 gboolean skip = FALSE;
1571 /* We have one tag-processing routine and use it for different 1583 /* We have one tag-processing routine and use it for different
1572 * stream types. However, tags themselves don't know the type of the 1584 * stream types. However, tags themselves don't know the type of the
1573 * stream they are attached to. We remember that before listing the 1585 * stream they are attached to. We remember that before listing the
1574 * tags, and adjust LE type accordingly. 1586 * tags, and adjust LE type accordingly.
1575 */ 1587 */enum EXTRACTOR_MetaType le_type = kt->le_type;
1576 enum EXTRACTOR_MetaType le_type = kt->le_type;
1577 switch (kt->le_type) 1588 switch (kt->le_type)
1578 { 1589 {
1579 case EXTRACTOR_METATYPE_LANGUAGE: 1590 case EXTRACTOR_METATYPE_LANGUAGE:
@@ -1662,7 +1673,7 @@ send_tag_foreach (const GstTagList * tags,
1662 { 1673 {
1663 gchar *new_str; 1674 gchar *new_str;
1664 /* GST_TAG_EXTENDED_COMMENT is already in key=value form */ 1675 /* GST_TAG_EXTENDED_COMMENT is already in key=value form */
1665 if ((0 != strcmp (tag, "extended-comment")) || !strchr (str, '=')) 1676 if ((0 != strcmp (tag, "extended-comment")) || ! strchr (str, '='))
1666 { 1677 {
1667 new_str = g_strdup_printf ("%s=%s", tag, str); 1678 new_str = g_strdup_printf ("%s=%s", tag, str);
1668 if (NULL != str) 1679 if (NULL != str)
@@ -1693,12 +1704,12 @@ send_tag_foreach (const GstTagList * tags,
1693 1704
1694static void 1705static void
1695send_streams (GstDiscovererStreamInfo *info, 1706send_streams (GstDiscovererStreamInfo *info,
1696 struct PrivStruct *ps); 1707 struct PrivStruct *ps);
1697 1708
1698 1709
1699static void 1710static void
1700send_stream_info (GstDiscovererStreamInfo * info, 1711send_stream_info (GstDiscovererStreamInfo *info,
1701 struct PrivStruct *ps) 1712 struct PrivStruct *ps)
1702{ 1713{
1703 const GstStructure *misc; 1714 const GstStructure *misc;
1704 GstCaps *caps; 1715 GstCaps *caps;
@@ -1722,9 +1733,11 @@ send_stream_info (GstDiscovererStreamInfo * info,
1722 if (g_str_has_prefix (structname, "image/")) 1733 if (g_str_has_prefix (structname, "image/"))
1723 ps->st = STREAM_TYPE_IMAGE; 1734 ps->st = STREAM_TYPE_IMAGE;
1724 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", 1735 ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
1725 EXTRACTOR_METATYPE_MIMETYPE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", 1736 EXTRACTOR_METATYPE_MIMETYPE,
1726 (const char *) structname, strlen (structname) + 1); 1737 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
1727 if (!ps->time_to_leave) 1738 (const char *) structname, strlen (
1739 structname) + 1);
1740 if (! ps->time_to_leave)
1728 { 1741 {
1729 gst_structure_foreach (structure, send_structure_foreach, ps); 1742 gst_structure_foreach (structure, send_structure_foreach, ps);
1730 } 1743 }
@@ -1770,8 +1783,8 @@ send_stream_info (GstDiscovererStreamInfo * info,
1770 GList *child; 1783 GList *child;
1771 GstDiscovererContainerInfo *c = GST_DISCOVERER_CONTAINER_INFO (info); 1784 GstDiscovererContainerInfo *c = GST_DISCOVERER_CONTAINER_INFO (info);
1772 GList *children = gst_discoverer_container_info_get_streams (c); 1785 GList *children = gst_discoverer_container_info_get_streams (c);
1773 for (child = children; (NULL != child) && (!ps->time_to_leave); 1786 for (child = children; (NULL != child) && (! ps->time_to_leave);
1774 child = child->next) 1787 child = child->next)
1775 { 1788 {
1776 GstDiscovererStreamInfo *sinfo = child->data; 1789 GstDiscovererStreamInfo *sinfo = child->data;
1777 /* send_streams () will unref it */ 1790 /* send_streams () will unref it */
@@ -1786,7 +1799,7 @@ send_stream_info (GstDiscovererStreamInfo * info,
1786 1799
1787static void 1800static void
1788send_streams (GstDiscovererStreamInfo *info, 1801send_streams (GstDiscovererStreamInfo *info,
1789 struct PrivStruct *ps) 1802 struct PrivStruct *ps)
1790{ 1803{
1791 GstDiscovererStreamInfo *next; 1804 GstDiscovererStreamInfo *next;
1792 1805
@@ -1808,9 +1821,9 @@ send_streams (GstDiscovererStreamInfo *info,
1808 * @param user_data the 'struct PrivStruct' with the 'toc' string we are assembling 1821 * @param user_data the 'struct PrivStruct' with the 'toc' string we are assembling
1809 */ 1822 */
1810static void 1823static void
1811send_toc_tags_foreach (const GstTagList * tags, 1824send_toc_tags_foreach (const GstTagList *tags,
1812 const gchar * tag, 1825 const gchar *tag,
1813 gpointer user_data) 1826 gpointer user_data)
1814{ 1827{
1815 struct PrivStruct *ps = user_data; 1828 struct PrivStruct *ps = user_data;
1816 GValue val = { 0 }; 1829 GValue val = { 0 };
@@ -1899,9 +1912,11 @@ send_toc_foreach (gpointer data, gpointer user_data)
1899 return; 1912 return;
1900 gst_toc_entry_get_start_stop_times (entry, &start, &stop); 1913 gst_toc_entry_get_start_stop_times (entry, &start, &stop);
1901 s = g_strdup_printf ("%*.*s<%s start=\"%" GST_TIME_FORMAT "\" stop=\"%" 1914 s = g_strdup_printf ("%*.*s<%s start=\"%" GST_TIME_FORMAT "\" stop=\"%"
1902 GST_TIME_FORMAT"\">\n", ps->toc_depth * 2, ps->toc_depth * 2, " ", 1915 GST_TIME_FORMAT "\">\n", ps->toc_depth * 2,
1903 gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS (start), 1916 ps->toc_depth * 2, " ",
1904 GST_TIME_ARGS (stop)); 1917 gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS (
1918 start),
1919 GST_TIME_ARGS (stop));
1905 if (NULL != s) 1920 if (NULL != s)
1906 { 1921 {
1907 if (ps->toc_print_phase) 1922 if (ps->toc_print_phase)
@@ -1916,21 +1931,25 @@ send_toc_foreach (gpointer data, gpointer user_data)
1916 ps->toc_depth++; 1931 ps->toc_depth++;
1917 tags = gst_toc_entry_get_tags (entry); 1932 tags = gst_toc_entry_get_tags (entry);
1918 if (tags) 1933 if (tags)
1919 { 1934 {
1920 if (ps->toc_print_phase) 1935 if (ps->toc_print_phase)
1921 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, 1936 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length
1922 "%*.*s<tags>\n", ps->toc_depth * 2, ps->toc_depth * 2, " "); 1937 - ps->toc_pos,
1923 else 1938 "%*.*s<tags>\n", ps->toc_depth * 2,
1924 ps->toc_length += strlen ("<tags>\n") + ps->toc_depth * 2; 1939 ps->toc_depth * 2, " ");
1925 ps->toc_depth++; 1940 else
1926 gst_tag_list_foreach (tags, &send_toc_tags_foreach, ps); 1941 ps->toc_length += strlen ("<tags>\n") + ps->toc_depth * 2;
1927 ps->toc_depth--; 1942 ps->toc_depth++;
1928 if (ps->toc_print_phase) 1943 gst_tag_list_foreach (tags, &send_toc_tags_foreach, ps);
1929 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, 1944 ps->toc_depth--;
1930 "%*.*s</tags>\n", ps->toc_depth * 2, ps->toc_depth * 2, " "); 1945 if (ps->toc_print_phase)
1931 else 1946 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length
1932 ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2; 1947 - ps->toc_pos,
1933 } 1948 "%*.*s</tags>\n", ps->toc_depth * 2,
1949 ps->toc_depth * 2, " ");
1950 else
1951 ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2;
1952 }
1934 1953
1935 subentries = gst_toc_entry_get_sub_entries (entry); 1954 subentries = gst_toc_entry_get_sub_entries (entry);
1936 g_list_foreach (subentries, send_toc_foreach, ps); 1955 g_list_foreach (subentries, send_toc_foreach, ps);
@@ -1939,11 +1958,12 @@ send_toc_foreach (gpointer data, gpointer user_data)
1939 s = g_strdup_printf ("%*.*s</%s>\n", 1958 s = g_strdup_printf ("%*.*s</%s>\n",
1940 ps->toc_depth * 2, 1959 ps->toc_depth * 2,
1941 ps->toc_depth * 2, " ", 1960 ps->toc_depth * 2, " ",
1942 gst_toc_entry_type_get_nick (entype)); 1961 gst_toc_entry_type_get_nick (entype));
1943 if (NULL != s) 1962 if (NULL != s)
1944 { 1963 {
1945 if (ps->toc_print_phase) 1964 if (ps->toc_print_phase)
1946 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, "%s", s); 1965 ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length
1966 - ps->toc_pos, "%s", s);
1947 else 1967 else
1948 ps->toc_length += strlen (s); 1968 ps->toc_length += strlen (s);
1949 g_free (s); 1969 g_free (s);
@@ -1958,8 +1978,8 @@ send_toc_foreach (gpointer data, gpointer user_data)
1958 1978
1959 1979
1960static void 1980static void
1961send_info (GstDiscovererInfo * info, 1981send_info (GstDiscovererInfo *info,
1962 struct PrivStruct *ps) 1982 struct PrivStruct *ps)
1963{ 1983{
1964 const GstToc *toc; 1984 const GstToc *toc;
1965 gchar *s; 1985 gchar *s;
@@ -1992,9 +2012,7 @@ send_info (GstDiscovererInfo * info,
1992 { 2012 {
1993 gst_tag_list_foreach (tags, send_tag_foreach, ps); 2013 gst_tag_list_foreach (tags, send_tag_foreach, ps);
1994 } 2014 }
1995 */ 2015 */if (ps->time_to_leave)
1996
1997 if (ps->time_to_leave)
1998 return; 2016 return;
1999 2017
2000 if ((toc = gst_discoverer_info_get_toc (info))) 2018 if ((toc = gst_discoverer_info_get_toc (info)))
@@ -2040,8 +2058,8 @@ send_info (GstDiscovererInfo * info,
2040 2058
2041 2059
2042static void 2060static void
2043send_discovered_info (GstDiscovererInfo * info, 2061send_discovered_info (GstDiscovererInfo *info,
2044 struct PrivStruct * ps) 2062 struct PrivStruct *ps)
2045{ 2063{
2046 GstDiscovererResult result; 2064 GstDiscovererResult result;
2047 2065
@@ -2051,20 +2069,20 @@ send_discovered_info (GstDiscovererInfo * info,
2051 result = gst_discoverer_info_get_result (info); 2069 result = gst_discoverer_info_get_result (info);
2052 2070
2053 switch (result) 2071 switch (result)
2054 { 2072 {
2055 case GST_DISCOVERER_OK: 2073 case GST_DISCOVERER_OK:
2056 break; 2074 break;
2057 case GST_DISCOVERER_URI_INVALID: 2075 case GST_DISCOVERER_URI_INVALID:
2058 break; 2076 break;
2059 case GST_DISCOVERER_ERROR: 2077 case GST_DISCOVERER_ERROR:
2060 break; 2078 break;
2061 case GST_DISCOVERER_TIMEOUT: 2079 case GST_DISCOVERER_TIMEOUT:
2062 break; 2080 break;
2063 case GST_DISCOVERER_BUSY: 2081 case GST_DISCOVERER_BUSY:
2064 break; 2082 break;
2065 case GST_DISCOVERER_MISSING_PLUGINS: 2083 case GST_DISCOVERER_MISSING_PLUGINS:
2066 break; 2084 break;
2067 } 2085 }
2068 pthread_mutex_lock (&pipe_mutex); 2086 pthread_mutex_lock (&pipe_mutex);
2069 send_info (info, ps); 2087 send_info (info, ps);
2070 pthread_mutex_unlock (&pipe_mutex); 2088 pthread_mutex_unlock (&pipe_mutex);
@@ -2072,20 +2090,21 @@ send_discovered_info (GstDiscovererInfo * info,
2072 2090
2073 2091
2074static void 2092static void
2075_new_discovered_uri (GstDiscoverer * dc, 2093_new_discovered_uri (GstDiscoverer *dc,
2076 GstDiscovererInfo * info, 2094 GstDiscovererInfo *info,
2077 GError * err, 2095 GError *err,
2078 struct PrivStruct *ps) 2096 struct PrivStruct *ps)
2079{ 2097{
2080 send_discovered_info (info, ps); 2098 send_discovered_info (info, ps);
2081 if (ps->timeout_id > 0) 2099 if (ps->timeout_id > 0)
2082 g_source_remove (ps->timeout_id); 2100 g_source_remove (ps->timeout_id);
2083 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); 2101 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
2102 ps);
2084} 2103}
2085 2104
2086 2105
2087static void 2106static void
2088_discoverer_finished (GstDiscoverer * dc, struct PrivStruct *ps) 2107_discoverer_finished (GstDiscoverer *dc, struct PrivStruct *ps)
2089{ 2108{
2090 if (ps->timeout_id > 0) 2109 if (ps->timeout_id > 0)
2091 g_source_remove (ps->timeout_id); 2110 g_source_remove (ps->timeout_id);
@@ -2105,9 +2124,9 @@ _discoverer_finished (GstDiscoverer * dc, struct PrivStruct *ps)
2105 * @param ps 2124 * @param ps
2106 */ 2125 */
2107static void 2126static void
2108_source_setup (GstDiscoverer * dc, 2127_source_setup (GstDiscoverer *dc,
2109 GstElement * source, 2128 GstElement *source,
2110 struct PrivStruct *ps) 2129 struct PrivStruct *ps)
2111{ 2130{
2112 if (ps->source) 2131 if (ps->source)
2113 gst_object_unref (GST_OBJECT (ps->source)); 2132 gst_object_unref (GST_OBJECT (ps->source));
@@ -2120,7 +2139,8 @@ _source_setup (GstDiscoverer * dc,
2120 if (ps->length > 0) 2139 if (ps->length > 0)
2121 { 2140 {
2122 g_object_set (ps->source, "size", (gint64) ps->length, NULL); 2141 g_object_set (ps->source, "size", (gint64) ps->length, NULL);
2123 gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "random-access"); 2142 gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type",
2143 "random-access");
2124 } 2144 }
2125 else 2145 else
2126 gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "seekable"); 2146 gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "seekable");
@@ -2129,16 +2149,16 @@ _source_setup (GstDiscoverer * dc,
2129 * data */ 2149 * data */
2130 g_signal_connect (ps->source, "need-data", G_CALLBACK (feed_data), ps); 2150 g_signal_connect (ps->source, "need-data", G_CALLBACK (feed_data), ps);
2131 g_signal_connect (ps->source, "seek-data", G_CALLBACK (seek_data), ps); 2151 g_signal_connect (ps->source, "seek-data", G_CALLBACK (seek_data), ps);
2132 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps); 2152 ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
2153 ps);
2133} 2154}
2134 2155
2135 2156
2136
2137static void 2157static void
2138log_handler (const gchar *log_domain, 2158log_handler (const gchar *log_domain,
2139 GLogLevelFlags log_level, 2159 GLogLevelFlags log_level,
2140 const gchar *message, 2160 const gchar *message,
2141 gpointer unused_data) 2161 gpointer unused_data)
2142{ 2162{
2143 /* do nothing */ 2163 /* do nothing */
2144} 2164}
@@ -2151,11 +2171,12 @@ log_handler (const gchar *log_domain,
2151 * @return FALSE (always) 2171 * @return FALSE (always)
2152 */ 2172 */
2153static gboolean 2173static gboolean
2154_run_async (struct PrivStruct * ps) 2174_run_async (struct PrivStruct *ps)
2155{ 2175{
2156 g_log_set_default_handler (&log_handler, NULL); 2176 g_log_set_default_handler (&log_handler, NULL);
2157 g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, 2177 g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
2158 &log_handler, NULL); 2178 | G_LOG_FLAG_RECURSION,
2179 &log_handler, NULL);
2159 gst_discoverer_discover_uri_async (ps->dc, "appsrc://"); 2180 gst_discoverer_discover_uri_async (ps->dc, "appsrc://");
2160 return FALSE; 2181 return FALSE;
2161} 2182}
@@ -2178,11 +2199,11 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec)
2178 memset (&ps, 0, sizeof (ps)); 2199 memset (&ps, 0, sizeof (ps));
2179 ps.dc = gst_discoverer_new (8 * GST_SECOND, &err); 2200 ps.dc = gst_discoverer_new (8 * GST_SECOND, &err);
2180 if (NULL == ps.dc) 2201 if (NULL == ps.dc)
2181 { 2202 {
2182 if (NULL != err) 2203 if (NULL != err)
2183 g_error_free (err); 2204 g_error_free (err);
2184 return; 2205 return;
2185 } 2206 }
2186 if (NULL != err) 2207 if (NULL != err)
2187 g_error_free (err); 2208 g_error_free (err);
2188 /* connect signals */ 2209 /* connect signals */
@@ -2195,10 +2216,11 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec)
2195 if (ps.length == UINT_MAX) 2216 if (ps.length == UINT_MAX)
2196 ps.length = 0; 2217 ps.length = 0;
2197 g_log_set_default_handler (&log_handler, NULL); 2218 g_log_set_default_handler (&log_handler, NULL);
2198 g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, 2219 g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
2199 &log_handler, NULL); 2220 | G_LOG_FLAG_RECURSION,
2221 &log_handler, NULL);
2200 gst_discoverer_start (ps.dc); 2222 gst_discoverer_start (ps.dc);
2201 g_idle_add ((GSourceFunc) &_run_async, &ps); 2223 g_idle_add ((GSourceFunc) & _run_async, &ps);
2202 g_main_loop_run (ps.loop); 2224 g_main_loop_run (ps.loop);
2203 if (ps.timeout_id > 0) 2225 if (ps.timeout_id > 0)
2204 g_source_remove (ps.timeout_id); 2226 g_source_remove (ps.timeout_id);
@@ -2216,35 +2238,36 @@ gstreamer_init ()
2216{ 2238{
2217 gst_init (NULL, NULL); 2239 gst_init (NULL, NULL);
2218 g_log_set_default_handler (&log_handler, NULL); 2240 g_log_set_default_handler (&log_handler, NULL);
2219 g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, 2241 g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
2220 &log_handler, NULL); 2242 | G_LOG_FLAG_RECURSION,
2243 &log_handler, NULL);
2221 GST_DEBUG_CATEGORY_INIT (gstreamer_extractor, "GstExtractor", 2244 GST_DEBUG_CATEGORY_INIT (gstreamer_extractor, "GstExtractor",
2222 0, "GStreamer-based libextractor plugin"); 2245 0, "GStreamer-based libextractor plugin");
2223 2246
2224 audio_quarks = g_new0 (GQuark, 4); 2247 audio_quarks = g_new0 (GQuark, 4);
2225 if (NULL != audio_quarks) 2248 if (NULL != audio_quarks)
2226 { 2249 {
2227 audio_quarks[0] = g_quark_from_string ("rate"); 2250 audio_quarks[0] = g_quark_from_string ("rate");
2228 audio_quarks[1] = g_quark_from_string ("channels"); 2251 audio_quarks[1] = g_quark_from_string ("channels");
2229 audio_quarks[2] = g_quark_from_string ("depth"); 2252 audio_quarks[2] = g_quark_from_string ("depth");
2230 audio_quarks[3] = g_quark_from_string (NULL); 2253 audio_quarks[3] = g_quark_from_string (NULL);
2231 } 2254 }
2232 video_quarks = g_new0 (GQuark, 6); 2255 video_quarks = g_new0 (GQuark, 6);
2233 if (NULL != video_quarks) 2256 if (NULL != video_quarks)
2234 { 2257 {
2235 video_quarks[0] = g_quark_from_string ("width"); 2258 video_quarks[0] = g_quark_from_string ("width");
2236 video_quarks[1] = g_quark_from_string ("height"); 2259 video_quarks[1] = g_quark_from_string ("height");
2237 video_quarks[2] = g_quark_from_string ("framerate"); 2260 video_quarks[2] = g_quark_from_string ("framerate");
2238 video_quarks[3] = g_quark_from_string ("max-framerate"); 2261 video_quarks[3] = g_quark_from_string ("max-framerate");
2239 video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio"); 2262 video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio");
2240 video_quarks[5] = g_quark_from_string (NULL); 2263 video_quarks[5] = g_quark_from_string (NULL);
2241 } 2264 }
2242 subtitle_quarks = g_new0 (GQuark, 2); 2265 subtitle_quarks = g_new0 (GQuark, 2);
2243 if (NULL != subtitle_quarks) 2266 if (NULL != subtitle_quarks)
2244 { 2267 {
2245 subtitle_quarks[0] = g_quark_from_string ("language-code"); 2268 subtitle_quarks[0] = g_quark_from_string ("language-code");
2246 subtitle_quarks[1] = g_quark_from_string (NULL); 2269 subtitle_quarks[1] = g_quark_from_string (NULL);
2247 } 2270 }
2248 2271
2249 duration_quark = g_quark_from_string ("duration"); 2272 duration_quark = g_quark_from_string ("duration");
2250 2273