gstreamer_core/plugins/indexers/gstfileindex.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    16  * License along with this library; if not, write to the
    16  * License along with this library; if not, write to the
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    18  * Boston, MA 02111-1307, USA.
    18  * Boston, MA 02111-1307, USA.
    19  */
    19  */
    20 
    20 
       
    21 #ifdef __SYMBIAN32__
       
    22 #include <gst_global.h>
       
    23 #endif
    21 #include <gst/gst.h>
    24 #include <gst/gst.h>
    22 
    25 
    23 #include <unistd.h>
    26 #include <unistd.h>
    24 #include <sys/mman.h>
    27 #include <sys/mman.h>
    25 #include <sys/stat.h>
    28 #include <sys/stat.h>
   190   gstindex_class->commit = gst_file_index_commit;
   193   gstindex_class->commit = gst_file_index_commit;
   191   gstindex_class->get_writer_id = gst_file_index_get_writer_id;
   194   gstindex_class->get_writer_id = gst_file_index_get_writer_id;
   192 
   195 
   193   g_object_class_install_property (gobject_class, ARG_LOCATION,
   196   g_object_class_install_property (gobject_class, ARG_LOCATION,
   194       g_param_spec_string ("location", "File Location",
   197       g_param_spec_string ("location", "File Location",
   195           "Location of the index file", NULL,
   198           "Location of the index file", NULL, G_PARAM_READWRITE));
   196           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   197 }
   199 }
   198 
   200 
   199 static void
   201 static void
   200 gst_file_index_init (GstFileIndex * index)
   202 gst_file_index_init (GstFileIndex * index)
   201 {
   203 {
   214   if (index_id->array) {
   216   if (index_id->array) {
   215     if (is_mmapped)
   217     if (is_mmapped)
   216       munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
   218       munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
   217     g_array_free (index_id->array, !is_mmapped);
   219     g_array_free (index_id->array, !is_mmapped);
   218   }
   220   }
   219   g_slice_free (GstFileIndexId, index_id);
   221   g_free (index_id);
   220 }
   222 }
   221 
   223 
   222 static gboolean
   224 static gboolean
   223 _id_index_free_helper (gpointer _key, GstFileIndexId * index_id,
   225 _id_index_free_helper (gpointer _key, GstFileIndexId * index_id,
   224     GstFileIndex * index)
   226     GstFileIndex * index)
   401           GST_ERROR_OBJECT (index,
   403           GST_ERROR_OBJECT (index,
   402               "Can't open '%s': %s", path, g_strerror (errno));
   404               "Can't open '%s': %s", path, g_strerror (errno));
   403           continue;
   405           continue;
   404         }
   406         }
   405 
   407 
   406         id_index = g_slice_new0 (GstFileIndexId);
   408         id_index = g_new0 (GstFileIndexId, 1);
   407         id_index->id_desc = (char *) xmlGetProp (writer, (xmlChar *) "id");
   409         id_index->id_desc = (char *) xmlGetProp (writer, (xmlChar *) "id");
   408 
   410 
   409         for (wpart = writer->children; wpart; wpart = wpart->next) {
   411         for (wpart = writer->children; wpart; wpart = wpart->next) {
   410           if (strcmp ((char *) wpart->name, "formats") == 0) {
   412           if (strcmp ((char *) wpart->name, "formats") == 0) {
   411             xmlChar *count_str = xmlGetProp (wpart, (xmlChar *) "count");
   413             xmlChar *count_str = xmlGetProp (wpart, (xmlChar *) "count");
   666   GstFileIndexId *id_index;
   668   GstFileIndexId *id_index;
   667 
   669 
   668   id_index = g_hash_table_lookup (fileindex->id_index, &entry->id);
   670   id_index = g_hash_table_lookup (fileindex->id_index, &entry->id);
   669 
   671 
   670   if (!id_index) {
   672   if (!id_index) {
   671     id_index = g_slice_new0 (GstFileIndexId);
   673     id_index = g_new0 (GstFileIndexId, 1);
   672 
   674 
   673     id_index->id = entry->id;
   675     id_index->id = entry->id;
   674     id_index->id_desc = g_strdup (entry->data.id.description);
   676     id_index->id_desc = g_strdup (entry->data.id.description);
   675 
   677 
   676     /* It would be useful to know the GType of the writer so
   678     /* It would be useful to know the GType of the writer so
   970       row_data = id_index->array->data + mx * ARRAY_ROW_SIZE (id_index);
   972       row_data = id_index->array->data + mx * ARRAY_ROW_SIZE (id_index);
   971     }
   973     }
   972 
   974 
   973   /* entry memory management needs improvement FIXME */
   975   /* entry memory management needs improvement FIXME */
   974   if (!fileindex->ret_entry)
   976   if (!fileindex->ret_entry)
   975     fileindex->ret_entry = g_slice_new0 (GstIndexEntry);
   977     fileindex->ret_entry = g_new0 (GstIndexEntry, 1);
   976   entry = fileindex->ret_entry;
   978   entry = fileindex->ret_entry;
   977   if (entry->data.assoc.assocs) {
   979   if (entry->data.assoc.assocs) {
   978     g_free (entry->data.assoc.assocs);
   980     g_free (entry->data.assoc.assocs);
   979     entry->data.assoc.assocs = NULL;
   981     entry->data.assoc.assocs = NULL;
   980   }
   982   }