gstreamer_core/gst/gstregistrybinary.c
author hgs
Fri, 30 Apr 2010 19:11:56 -0500
changeset 19 24ed0baaf8e5
parent 16 8e837d1bf446
child 30 7e817e7e631c
permissions -rw-r--r--
201017
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/* GStreamer
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
 * Copyright (C) 2006 Josep Torra <josep@fluendo.com>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
 *               2006 Mathieu Garcia <matthieu@fluendo.com>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
 *               2006,2007 Stefan Kost <ensonic@users.sf.net>
16
hgs
parents: 0
diff changeset
     5
 *               2008 Sebastian Dröge <slomo@circular-chaos.org>
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
 * gstregistrybinary.c: GstRegistryBinary object, support routines
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
 * This library is free software; you can redistribute it and/or
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
 * modify it under the terms of the GNU Library General Public
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
 * License as published by the Free Software Foundation; either
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
 * version 2 of the License, or (at your option) any later version.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
 * This library is distributed in the hope that it will be useful,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
 * Library General Public License for more details.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
 * You should have received a copy of the GNU Library General Public
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
 * License along with this library; if not, write to the
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
 * Boston, MA 02111-1307, USA.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
/* FIXME:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
 * - keep registry binary blob and reference strings
16
hgs
parents: 0
diff changeset
    27
 *   - don't free/
hgs
parents: 0
diff changeset
    28
#ifdef __SYMBIAN32__
hgs
parents: 0
diff changeset
    29
EXPORT_C
hgs
parents: 0
diff changeset
    30
#endif
hgs
parents: 0
diff changeset
    31
unmmap contents when leaving gst_registry_binary_read_cache()
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
 *     - free at gst_deinit() / _priv_gst_registry_cleanup() ?
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
 *   - GstPlugin:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
 *     - GST_PLUGIN_FLAG_CONST
16
hgs
parents: 0
diff changeset
    35
 *   - GstPluginFeature, GstIndexFactory, GstElementFactory
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
 *     - needs Flags (GST_PLUGIN_FEATURE_FLAG_CONST)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
 *     - can we turn loaded into flag?
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
 * - why do we collect a list of binary chunks and not write immediately
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
 *   - because we need to process subchunks, before we can set e.g. nr_of_items
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
 *     in parent chunk
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#ifdef HAVE_CONFIG_H
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#  include "config.h"
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#ifdef HAVE_UNISTD_H
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#include <unistd.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
#include <errno.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
#include <stdio.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
#if defined (_MSC_VER) && _MSC_VER >= 1400
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
#include <io.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
#include <gst/gst_private.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
#include <gst/gstconfig.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
#include <gst/gstelement.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
#include <gst/gsttypefind.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
#include <gst/gsttypefindfactory.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
#include <gst/gsturi.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
#include <gst/gstinfo.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
#include <gst/gstenumtypes.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
#include <gst/gstpadtemplate.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
#include <gst/gstregistrybinary.h>
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
#include <glib/gstdio.h>        /* for g_stat(), g_mapped_file(), ... */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
#include "glib-compat-private.h"
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
#define GST_CAT_DEFAULT GST_CAT_REGISTRY
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
16
hgs
parents: 0
diff changeset
    77
/* count string length, but return -1 if we hit the eof */
hgs
parents: 0
diff changeset
    78
static gint
hgs
parents: 0
diff changeset
    79
_strnlen (const gchar * str, gint maxlen)
hgs
parents: 0
diff changeset
    80
{
hgs
parents: 0
diff changeset
    81
  gint len = 0;
hgs
parents: 0
diff changeset
    82
hgs
parents: 0
diff changeset
    83
  if (G_UNLIKELY (len == maxlen))
hgs
parents: 0
diff changeset
    84
    return -1;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
16
hgs
parents: 0
diff changeset
    86
  while (*str++ != '\0') {
hgs
parents: 0
diff changeset
    87
    len++;
hgs
parents: 0
diff changeset
    88
    if (G_UNLIKELY (len == maxlen))
hgs
parents: 0
diff changeset
    89
      return -1;
hgs
parents: 0
diff changeset
    90
  }
hgs
parents: 0
diff changeset
    91
  return len;
hgs
parents: 0
diff changeset
    92
}
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
16
hgs
parents: 0
diff changeset
    94
/* reading macros */
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
16
hgs
parents: 0
diff changeset
    96
#define unpack_element(inptr, outptr, element, endptr, error_label) G_STMT_START{ \
hgs
parents: 0
diff changeset
    97
  if (inptr + sizeof(element) >= endptr) \
hgs
parents: 0
diff changeset
    98
    goto error_label; \
hgs
parents: 0
diff changeset
    99
  outptr = (element *) inptr; \
hgs
parents: 0
diff changeset
   100
  inptr += sizeof (element); \
hgs
parents: 0
diff changeset
   101
}G_STMT_END
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
16
hgs
parents: 0
diff changeset
   103
#define unpack_const_string(inptr, outptr, endptr, error_label) G_STMT_START{\
hgs
parents: 0
diff changeset
   104
  gint _len = _strnlen (inptr, (endptr-inptr)); \
hgs
parents: 0
diff changeset
   105
  if (_len == -1) \
hgs
parents: 0
diff changeset
   106
    goto error_label; \
hgs
parents: 0
diff changeset
   107
  outptr = g_intern_string ((const gchar *)inptr); \
hgs
parents: 0
diff changeset
   108
  inptr += _len + 1; \
hgs
parents: 0
diff changeset
   109
}G_STMT_END
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
16
hgs
parents: 0
diff changeset
   111
#define unpack_string(inptr, outptr, endptr, error_label)  G_STMT_START{\
hgs
parents: 0
diff changeset
   112
  gint _len = _strnlen (inptr, (endptr-inptr)); \
hgs
parents: 0
diff changeset
   113
  if (_len == -1) \
hgs
parents: 0
diff changeset
   114
    goto error_label; \
hgs
parents: 0
diff changeset
   115
  outptr = g_memdup ((gconstpointer)inptr, _len + 1); \
hgs
parents: 0
diff changeset
   116
  inptr += _len + 1; \
hgs
parents: 0
diff changeset
   117
}G_STMT_END
hgs
parents: 0
diff changeset
   118
hgs
parents: 0
diff changeset
   119
#define ALIGNMENT            (sizeof (void *))
hgs
parents: 0
diff changeset
   120
#define alignment(_address)  (gsize)_address%ALIGNMENT
hgs
parents: 0
diff changeset
   121
#define align(_ptr)          _ptr += (( alignment(_ptr) == 0) ? 0 : ALIGNMENT-alignment(_ptr))
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
/* Registry saving */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
16
hgs
parents: 0
diff changeset
   125
#ifdef G_OS_WIN32
hgs
parents: 0
diff changeset
   126
/* On win32, we can't use g_mkstmp(), because of cross-DLL file I/O problems.
hgs
parents: 0
diff changeset
   127
 * So, we just create the entire binary registry in memory, then write it out
hgs
parents: 0
diff changeset
   128
 * with g_file_set_contents(), which creates a temporary file internally
hgs
parents: 0
diff changeset
   129
 */
hgs
parents: 0
diff changeset
   130
hgs
parents: 0
diff changeset
   131
typedef struct BinaryRegistryCache
hgs
parents: 0
diff changeset
   132
{
hgs
parents: 0
diff changeset
   133
  const char *location;
hgs
parents: 0
diff changeset
   134
  guint8 *mem;
hgs
parents: 0
diff changeset
   135
  gssize len;
hgs
parents: 0
diff changeset
   136
} BinaryRegistryCache;
hgs
parents: 0
diff changeset
   137
hgs
parents: 0
diff changeset
   138
static BinaryRegistryCache *
hgs
parents: 0
diff changeset
   139
gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
hgs
parents: 0
diff changeset
   140
{
hgs
parents: 0
diff changeset
   141
  BinaryRegistryCache *cache = g_new0 (BinaryRegistryCache, 1);
hgs
parents: 0
diff changeset
   142
  cache->location = location;
hgs
parents: 0
diff changeset
   143
  return cache;
hgs
parents: 0
diff changeset
   144
}
hgs
parents: 0
diff changeset
   145
hgs
parents: 0
diff changeset
   146
static int
hgs
parents: 0
diff changeset
   147
gst_registry_binary_cache_write (GstRegistry * registry,
hgs
parents: 0
diff changeset
   148
    BinaryRegistryCache * cache, unsigned long offset,
hgs
parents: 0
diff changeset
   149
    const void *data, int length)
hgs
parents: 0
diff changeset
   150
{
hgs
parents: 0
diff changeset
   151
  cache->len = MAX (offset + length, cache->len);
hgs
parents: 0
diff changeset
   152
  cache->mem = g_realloc (cache->mem, cache->len);
hgs
parents: 0
diff changeset
   153
hgs
parents: 0
diff changeset
   154
  memcpy (cache->mem + offset, data, length);
hgs
parents: 0
diff changeset
   155
hgs
parents: 0
diff changeset
   156
  return length;
hgs
parents: 0
diff changeset
   157
}
hgs
parents: 0
diff changeset
   158
hgs
parents: 0
diff changeset
   159
static gboolean
hgs
parents: 0
diff changeset
   160
gst_registry_binary_cache_finish (GstRegistry * registry,
hgs
parents: 0
diff changeset
   161
    BinaryRegistryCache * cache, gboolean success)
hgs
parents: 0
diff changeset
   162
{
hgs
parents: 0
diff changeset
   163
  gboolean ret = TRUE;
hgs
parents: 0
diff changeset
   164
  GError *error = NULL;
hgs
parents: 0
diff changeset
   165
  if (!g_file_set_contents (cache->location, (const gchar *) cache->mem,
hgs
parents: 0
diff changeset
   166
          cache->len, &error)) {
hgs
parents: 0
diff changeset
   167
    /* Probably the directory didn't exist; create it */
hgs
parents: 0
diff changeset
   168
    gchar *dir;
hgs
parents: 0
diff changeset
   169
    dir = g_path_get_dirname (cache->location);
hgs
parents: 0
diff changeset
   170
    g_mkdir_with_parents (dir, 0777);
hgs
parents: 0
diff changeset
   171
    g_free (dir);
hgs
parents: 0
diff changeset
   172
hgs
parents: 0
diff changeset
   173
    g_error_free (error);
hgs
parents: 0
diff changeset
   174
    error = NULL;
hgs
parents: 0
diff changeset
   175
hgs
parents: 0
diff changeset
   176
    if (!g_file_set_contents (cache->location, (const gchar *) cache->mem,
hgs
parents: 0
diff changeset
   177
            cache->len, &error)) {
hgs
parents: 0
diff changeset
   178
      GST_ERROR ("Failed to write to cache file: %s", error->message);
hgs
parents: 0
diff changeset
   179
      g_error_free (error);
hgs
parents: 0
diff changeset
   180
      ret = FALSE;
hgs
parents: 0
diff changeset
   181
    }
hgs
parents: 0
diff changeset
   182
  }
hgs
parents: 0
diff changeset
   183
hgs
parents: 0
diff changeset
   184
  g_free (cache->mem);
hgs
parents: 0
diff changeset
   185
  g_free (cache);
hgs
parents: 0
diff changeset
   186
  return ret;
hgs
parents: 0
diff changeset
   187
}
hgs
parents: 0
diff changeset
   188
hgs
parents: 0
diff changeset
   189
#else
hgs
parents: 0
diff changeset
   190
typedef struct BinaryRegistryCache
hgs
parents: 0
diff changeset
   191
{
hgs
parents: 0
diff changeset
   192
  const char *location;
hgs
parents: 0
diff changeset
   193
  char *tmp_location;
hgs
parents: 0
diff changeset
   194
  unsigned long currentoffset;
hgs
parents: 0
diff changeset
   195
} BinaryRegistryCache;
hgs
parents: 0
diff changeset
   196
hgs
parents: 0
diff changeset
   197
static BinaryRegistryCache *
hgs
parents: 0
diff changeset
   198
gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
hgs
parents: 0
diff changeset
   199
{
hgs
parents: 0
diff changeset
   200
  BinaryRegistryCache *cache = g_new0 (BinaryRegistryCache, 1);
hgs
parents: 0
diff changeset
   201
hgs
parents: 0
diff changeset
   202
  cache->location = location;
hgs
parents: 0
diff changeset
   203
  cache->tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
hgs
parents: 0
diff changeset
   204
  registry->cache_file = g_mkstemp (cache->tmp_location);
hgs
parents: 0
diff changeset
   205
  if (registry->cache_file == -1) {
hgs
parents: 0
diff changeset
   206
    gchar *dir;
hgs
parents: 0
diff changeset
   207
hgs
parents: 0
diff changeset
   208
    /* oops, I bet the directory doesn't exist */
hgs
parents: 0
diff changeset
   209
    dir = g_path_get_dirname (location);
hgs
parents: 0
diff changeset
   210
    g_mkdir_with_parents (dir, 0777);
hgs
parents: 0
diff changeset
   211
    g_free (dir);
hgs
parents: 0
diff changeset
   212
hgs
parents: 0
diff changeset
   213
    /* the previous g_mkstemp call overwrote the XXXXXX placeholder ... */
hgs
parents: 0
diff changeset
   214
    g_free (cache->tmp_location);
hgs
parents: 0
diff changeset
   215
    cache->tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
hgs
parents: 0
diff changeset
   216
    registry->cache_file = g_mkstemp (cache->tmp_location);
hgs
parents: 0
diff changeset
   217
hgs
parents: 0
diff changeset
   218
    if (registry->cache_file == -1) {
hgs
parents: 0
diff changeset
   219
      GST_DEBUG ("g_mkstemp() failed: %s", g_strerror (errno));
hgs
parents: 0
diff changeset
   220
      g_free (cache->tmp_location);
hgs
parents: 0
diff changeset
   221
      g_free (cache);
hgs
parents: 0
diff changeset
   222
      return NULL;
hgs
parents: 0
diff changeset
   223
    }
hgs
parents: 0
diff changeset
   224
  }
hgs
parents: 0
diff changeset
   225
hgs
parents: 0
diff changeset
   226
  return cache;
hgs
parents: 0
diff changeset
   227
}
hgs
parents: 0
diff changeset
   228
hgs
parents: 0
diff changeset
   229
static int
hgs
parents: 0
diff changeset
   230
gst_registry_binary_cache_write (GstRegistry * registry,
hgs
parents: 0
diff changeset
   231
    BinaryRegistryCache * cache, unsigned long offset,
hgs
parents: 0
diff changeset
   232
    const void *data, int length)
hgs
parents: 0
diff changeset
   233
{
hgs
parents: 0
diff changeset
   234
  long written;
hgs
parents: 0
diff changeset
   235
  if (offset != cache->currentoffset) {
hgs
parents: 0
diff changeset
   236
    if (lseek (registry->cache_file, offset, SEEK_SET) != 0) {
hgs
parents: 0
diff changeset
   237
      GST_ERROR ("Seeking to new offset failed");
hgs
parents: 0
diff changeset
   238
      return FALSE;
hgs
parents: 0
diff changeset
   239
    }
hgs
parents: 0
diff changeset
   240
    cache->currentoffset = offset;
hgs
parents: 0
diff changeset
   241
  }
hgs
parents: 0
diff changeset
   242
hgs
parents: 0
diff changeset
   243
  written = write (registry->cache_file, data, length);
hgs
parents: 0
diff changeset
   244
  if (written != length) {
hgs
parents: 0
diff changeset
   245
    GST_ERROR ("Failed to write to cache file");
hgs
parents: 0
diff changeset
   246
  }
hgs
parents: 0
diff changeset
   247
  cache->currentoffset += written;
hgs
parents: 0
diff changeset
   248
hgs
parents: 0
diff changeset
   249
  return written;
hgs
parents: 0
diff changeset
   250
}
hgs
parents: 0
diff changeset
   251
hgs
parents: 0
diff changeset
   252
static gboolean
hgs
parents: 0
diff changeset
   253
gst_registry_binary_cache_finish (GstRegistry * registry,
hgs
parents: 0
diff changeset
   254
    BinaryRegistryCache * cache, gboolean success)
hgs
parents: 0
diff changeset
   255
{
hgs
parents: 0
diff changeset
   256
  /* only fsync if we're actually going to use and rename the file below */
hgs
parents: 0
diff changeset
   257
  if (success && fsync (registry->cache_file) < 0)
hgs
parents: 0
diff changeset
   258
    goto fsync_failed;
hgs
parents: 0
diff changeset
   259
hgs
parents: 0
diff changeset
   260
  if (close (registry->cache_file) < 0)
hgs
parents: 0
diff changeset
   261
    goto close_failed;
hgs
parents: 0
diff changeset
   262
hgs
parents: 0
diff changeset
   263
  if (success) {
hgs
parents: 0
diff changeset
   264
    /* Only do the rename if we wrote the entire file successfully */
hgs
parents: 0
diff changeset
   265
    if (g_rename (cache->tmp_location, cache->location) < 0)
hgs
parents: 0
diff changeset
   266
      goto rename_failed;
hgs
parents: 0
diff changeset
   267
  }
hgs
parents: 0
diff changeset
   268
hgs
parents: 0
diff changeset
   269
  g_free (cache->tmp_location);
hgs
parents: 0
diff changeset
   270
  g_free (cache);
hgs
parents: 0
diff changeset
   271
  GST_INFO ("Wrote binary registry cache");
hgs
parents: 0
diff changeset
   272
  return TRUE;
hgs
parents: 0
diff changeset
   273
hgs
parents: 0
diff changeset
   274
/* ERRORS */
hgs
parents: 0
diff changeset
   275
fail_after_close:
hgs
parents: 0
diff changeset
   276
  {
hgs
parents: 0
diff changeset
   277
    g_unlink (cache->tmp_location);
hgs
parents: 0
diff changeset
   278
    g_free (cache->tmp_location);
hgs
parents: 0
diff changeset
   279
    g_free (cache);
hgs
parents: 0
diff changeset
   280
    return FALSE;
hgs
parents: 0
diff changeset
   281
  }
hgs
parents: 0
diff changeset
   282
fsync_failed:
hgs
parents: 0
diff changeset
   283
  {
hgs
parents: 0
diff changeset
   284
    GST_ERROR ("fsync() failed: %s", g_strerror (errno));
hgs
parents: 0
diff changeset
   285
    goto fail_after_close;
hgs
parents: 0
diff changeset
   286
  }
hgs
parents: 0
diff changeset
   287
close_failed:
hgs
parents: 0
diff changeset
   288
  {
hgs
parents: 0
diff changeset
   289
    GST_ERROR ("close() failed: %s", g_strerror (errno));
hgs
parents: 0
diff changeset
   290
    goto fail_after_close;
hgs
parents: 0
diff changeset
   291
  }
hgs
parents: 0
diff changeset
   292
rename_failed:
hgs
parents: 0
diff changeset
   293
  {
hgs
parents: 0
diff changeset
   294
    GST_ERROR ("g_rename() failed: %s", g_strerror (errno));
hgs
parents: 0
diff changeset
   295
    goto fail_after_close;
hgs
parents: 0
diff changeset
   296
  }
hgs
parents: 0
diff changeset
   297
}
hgs
parents: 0
diff changeset
   298
#endif
hgs
parents: 0
diff changeset
   299
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
/*
16
hgs
parents: 0
diff changeset
   301
 * gst_registry_binary_write_chunk:
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
 * Write from a memory location to the registry cache file
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
 * Returns: %TRUE for success
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
inline static gboolean
16
hgs
parents: 0
diff changeset
   308
gst_registry_binary_write_chunk (GstRegistry * registry,
hgs
parents: 0
diff changeset
   309
    BinaryRegistryCache * cache, const void *mem,
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    const gssize size, unsigned long *file_position, gboolean align)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
{
16
hgs
parents: 0
diff changeset
   312
  gchar padder[ALIGNMENT] = { 0, };
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
  int padsize = 0;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
  /* Padding to insert the struct that requiere word alignment */
16
hgs
parents: 0
diff changeset
   316
  if ((align) && (alignment (*file_position) != 0)) {
hgs
parents: 0
diff changeset
   317
    padsize = ALIGNMENT - alignment (*file_position);
hgs
parents: 0
diff changeset
   318
    if (gst_registry_binary_cache_write (registry, cache, *file_position,
hgs
parents: 0
diff changeset
   319
            padder, padsize) != padsize) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
      GST_ERROR ("Failed to write binary registry padder");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
      return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    }
16
hgs
parents: 0
diff changeset
   323
    *file_position += padsize;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
16
hgs
parents: 0
diff changeset
   326
  if (gst_registry_binary_cache_write (registry, cache, *file_position,
hgs
parents: 0
diff changeset
   327
          mem, size) != size) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
    GST_ERROR ("Failed to write binary registry element");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
    return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
  }
16
hgs
parents: 0
diff changeset
   331
hgs
parents: 0
diff changeset
   332
  *file_position += size;
hgs
parents: 0
diff changeset
   333
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
 * gst_registry_binary_initialize_magic:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
 * Initialize the GstBinaryRegistryMagic, setting both our magic number and
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
 * gstreamer major/minor version
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
inline static gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
gst_registry_binary_initialize_magic (GstBinaryRegistryMagic * m)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
{
16
hgs
parents: 0
diff changeset
   347
  memset (m, 0, sizeof (GstBinaryRegistryMagic));
hgs
parents: 0
diff changeset
   348
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
  if (!strncpy (m->magic, GST_MAGIC_BINARY_REGISTRY_STR,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
          GST_MAGIC_BINARY_REGISTRY_LEN)
16
hgs
parents: 0
diff changeset
   351
      || !strncpy (m->version, GST_MAGIC_BINARY_VERSION_STR,
hgs
parents: 0
diff changeset
   352
          GST_MAGIC_BINARY_VERSION_LEN)) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
    GST_ERROR ("Failed to write magic to the registry magic structure");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
    return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
  }
16
hgs
parents: 0
diff changeset
   356
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
 * gst_registry_binary_save_const_string:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
 * Store a const string in a binary chunk.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
 * Returns: %TRUE for success
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
inline static gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
gst_registry_binary_save_const_string (GList ** list, const gchar * str)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
  GstBinaryChunk *chunk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
16
hgs
parents: 0
diff changeset
   373
  if (G_UNLIKELY (str == NULL)) {
hgs
parents: 0
diff changeset
   374
    GST_ERROR ("unexpected NULL string in plugin or plugin feature data");
hgs
parents: 0
diff changeset
   375
    str = "";
hgs
parents: 0
diff changeset
   376
  }
hgs
parents: 0
diff changeset
   377
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
  chunk = g_malloc (sizeof (GstBinaryChunk));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
  chunk->data = (gpointer) str;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
  chunk->size = strlen ((gchar *) chunk->data) + 1;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
  chunk->flags = GST_BINARY_REGISTRY_FLAG_CONST;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
  chunk->align = FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
  *list = g_list_prepend (*list, chunk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
 * gst_registry_binary_save_string:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
 * Store a string in a binary chunk.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
 * Returns: %TRUE for success
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
inline static gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
gst_registry_binary_save_string (GList ** list, gchar * str)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
  GstBinaryChunk *chunk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
  chunk = g_malloc (sizeof (GstBinaryChunk));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
  chunk->data = str;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
  chunk->size = strlen ((gchar *) chunk->data) + 1;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
  chunk->flags = GST_BINARY_REGISTRY_FLAG_NONE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
  chunk->align = FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
  *list = g_list_prepend (*list, chunk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
 * gst_registry_binary_save_data:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
 * Store some data in a binary chunk.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
 * Returns: the initialized chunk
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
inline static GstBinaryChunk *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
gst_registry_binary_make_data (gpointer data, gulong size)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
  GstBinaryChunk *chunk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
  chunk = g_malloc (sizeof (GstBinaryChunk));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
  chunk->data = data;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
  chunk->size = size;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
  chunk->flags = GST_BINARY_REGISTRY_FLAG_NONE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
  chunk->align = TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
  return chunk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
 * gst_registry_binary_save_pad_template:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
 * Store pad_templates in binary chunks.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
 * Returns: %TRUE for success
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
static gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
gst_registry_binary_save_pad_template (GList ** list,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
    GstStaticPadTemplate * template)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
  GstBinaryPadTemplate *pt;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
  GstBinaryChunk *chk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
16
hgs
parents: 0
diff changeset
   444
  pt = g_malloc0 (sizeof (GstBinaryPadTemplate));
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
  chk = gst_registry_binary_make_data (pt, sizeof (GstBinaryPadTemplate));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
  pt->presence = template->presence;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
  pt->direction = template->direction;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
  /* pack pad template strings */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
  gst_registry_binary_save_const_string (list,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
      (gchar *) (template->static_caps.string));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
  gst_registry_binary_save_const_string (list, template->name_template);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
  *list = g_list_prepend (*list, chk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
 * gst_registry_binary_save_feature:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
 * Store features in binary chunks.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
 * Returns: %TRUE for success
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
static gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
gst_registry_binary_save_feature (GList ** list, GstPluginFeature * feature)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
  const gchar *type_name = g_type_name (G_OBJECT_TYPE (feature));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
  GstBinaryPluginFeature *pf = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
  GstBinaryChunk *chk = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
  GList *walk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
  if (!type_name) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
    GST_ERROR ("NULL feature type_name, aborting.");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
    return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
  if (GST_IS_ELEMENT_FACTORY (feature)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
    GstBinaryElementFactory *ef;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
    GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
16
hgs
parents: 0
diff changeset
   485
    ef = g_malloc0 (sizeof (GstBinaryElementFactory));
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
    chk = gst_registry_binary_make_data (ef, sizeof (GstBinaryElementFactory));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    ef->npadtemplates = ef->ninterfaces = ef->nuriprotocols = 0;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
    pf = (GstBinaryPluginFeature *) ef;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
    /* save interfaces */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
    for (walk = factory->interfaces; walk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
        walk = g_list_next (walk), ef->ninterfaces++) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
      gst_registry_binary_save_const_string (list, (gchar *) walk->data);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
    GST_DEBUG ("Saved %d Interfaces", ef->ninterfaces);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    /* save uritypes */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    if (GST_URI_TYPE_IS_VALID (factory->uri_type)) {
16
hgs
parents: 0
diff changeset
   498
      if (factory->uri_protocols && *factory->uri_protocols) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
        GstBinaryChunk *subchk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
        gchar **protocol;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
        subchk =
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
            gst_registry_binary_make_data (&factory->uri_type,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
            sizeof (factory->uri_type));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
        subchk->flags = GST_BINARY_REGISTRY_FLAG_CONST;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
        protocol = factory->uri_protocols;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
        while (*protocol) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
          gst_registry_binary_save_const_string (list, *protocol++);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
          ef->nuriprotocols++;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
        }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
        *list = g_list_prepend (*list, subchk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
        GST_DEBUG ("Saved %d UriTypes", ef->nuriprotocols);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
      } else {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
        g_warning ("GStreamer feature '%s' is URI handler but does not provide"
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
            " any protocols it can handle", feature->name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
      }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
    /* save pad-templates */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    for (walk = factory->staticpadtemplates; walk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
        walk = g_list_next (walk), ef->npadtemplates++) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
      GstStaticPadTemplate *template = walk->data;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
      if (!gst_registry_binary_save_pad_template (list, template)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
        GST_ERROR ("Can't fill pad template, aborting.");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
        goto fail;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
      }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
    /* pack element factory strings */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
    gst_registry_binary_save_const_string (list, factory->details.author);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
    gst_registry_binary_save_const_string (list, factory->details.description);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
    gst_registry_binary_save_const_string (list, factory->details.klass);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
    gst_registry_binary_save_const_string (list, factory->details.longname);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
  } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
    GstBinaryTypeFindFactory *tff;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
    GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
16
hgs
parents: 0
diff changeset
   540
    tff = g_malloc0 (sizeof (GstBinaryTypeFindFactory));
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
    chk =
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
        gst_registry_binary_make_data (tff, sizeof (GstBinaryTypeFindFactory));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
    tff->nextensions = 0;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
    pf = (GstBinaryPluginFeature *) tff;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
    /* save extensions */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
    if (factory->extensions) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
      while (factory->extensions[tff->nextensions]) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
        gst_registry_binary_save_const_string (list,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
            factory->extensions[tff->nextensions++]);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
      }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
    /* save caps */
16
hgs
parents: 0
diff changeset
   554
    if (factory->caps) {
hgs
parents: 0
diff changeset
   555
      GstCaps *copy = gst_caps_copy (factory->caps);
hgs
parents: 0
diff changeset
   556
      gchar *str;
hgs
parents: 0
diff changeset
   557
hgs
parents: 0
diff changeset
   558
      /* we copy the caps here so we can simplify them
hgs
parents: 0
diff changeset
   559
       * before saving. This is a lot faster when loading
hgs
parents: 0
diff changeset
   560
       * them later on */
hgs
parents: 0
diff changeset
   561
      gst_caps_do_simplify (copy);
hgs
parents: 0
diff changeset
   562
      str = gst_caps_to_string (copy);
hgs
parents: 0
diff changeset
   563
      gst_caps_unref (copy);
hgs
parents: 0
diff changeset
   564
      gst_registry_binary_save_string (list, str);
hgs
parents: 0
diff changeset
   565
    } else {
hgs
parents: 0
diff changeset
   566
      gst_registry_binary_save_const_string (list, "");
hgs
parents: 0
diff changeset
   567
    }
hgs
parents: 0
diff changeset
   568
hgs
parents: 0
diff changeset
   569
  } else if (GST_IS_INDEX_FACTORY (feature)) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
    GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
16
hgs
parents: 0
diff changeset
   572
    pf = g_malloc0 (sizeof (GstBinaryPluginFeature));
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
    chk = gst_registry_binary_make_data (pf, sizeof (GstBinaryPluginFeature));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
    pf->rank = feature->rank;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
    /* pack element factory strings */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
    gst_registry_binary_save_const_string (list, factory->longdesc);
16
hgs
parents: 0
diff changeset
   578
  } else {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    GST_WARNING ("unhandled feature type '%s'", type_name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
  if (pf) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
    pf->rank = feature->rank;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
    *list = g_list_prepend (*list, chk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
    /* pack plugin feature strings */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
    gst_registry_binary_save_const_string (list, feature->name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
    gst_registry_binary_save_const_string (list, (gchar *) type_name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
    return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
  /* Errors */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
fail:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
  g_free (chk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
  g_free (pf);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
  return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
16
hgs
parents: 0
diff changeset
   600
static gboolean
hgs
parents: 0
diff changeset
   601
gst_registry_binary_save_plugin_dep (GList ** list, GstPluginDep * dep)
hgs
parents: 0
diff changeset
   602
{
hgs
parents: 0
diff changeset
   603
  GstBinaryDep *ed;
hgs
parents: 0
diff changeset
   604
  GstBinaryChunk *chk;
hgs
parents: 0
diff changeset
   605
  gchar **s;
hgs
parents: 0
diff changeset
   606
hgs
parents: 0
diff changeset
   607
  ed = g_new0 (GstBinaryDep, 1);
hgs
parents: 0
diff changeset
   608
  chk = gst_registry_binary_make_data (ed, sizeof (GstBinaryDep));
hgs
parents: 0
diff changeset
   609
hgs
parents: 0
diff changeset
   610
  ed->flags = dep->flags;
hgs
parents: 0
diff changeset
   611
  ed->n_env_vars = 0;
hgs
parents: 0
diff changeset
   612
  ed->n_paths = 0;
hgs
parents: 0
diff changeset
   613
  ed->n_names = 0;
hgs
parents: 0
diff changeset
   614
hgs
parents: 0
diff changeset
   615
  ed->env_hash = dep->env_hash;
hgs
parents: 0
diff changeset
   616
  ed->stat_hash = dep->stat_hash;
hgs
parents: 0
diff changeset
   617
hgs
parents: 0
diff changeset
   618
  for (s = dep->env_vars; s != NULL && *s != NULL; ++s, ++ed->n_env_vars)
hgs
parents: 0
diff changeset
   619
    gst_registry_binary_save_string (list, g_strdup (*s));
hgs
parents: 0
diff changeset
   620
hgs
parents: 0
diff changeset
   621
  for (s = dep->paths; s != NULL && *s != NULL; ++s, ++ed->n_paths)
hgs
parents: 0
diff changeset
   622
    gst_registry_binary_save_string (list, g_strdup (*s));
hgs
parents: 0
diff changeset
   623
hgs
parents: 0
diff changeset
   624
  for (s = dep->names; s != NULL && *s != NULL; ++s, ++ed->n_names)
hgs
parents: 0
diff changeset
   625
    gst_registry_binary_save_string (list, g_strdup (*s));
hgs
parents: 0
diff changeset
   626
hgs
parents: 0
diff changeset
   627
  *list = g_list_prepend (*list, chk);
hgs
parents: 0
diff changeset
   628
hgs
parents: 0
diff changeset
   629
  GST_LOG ("Saved external plugin dependency");
hgs
parents: 0
diff changeset
   630
  return TRUE;
hgs
parents: 0
diff changeset
   631
}
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
 * gst_registry_binary_save_plugin:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
 * Adapt a GstPlugin to our GstBinaryPluginElement structure, and write it to
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
 * the registry file.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
static gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
gst_registry_binary_save_plugin (GList ** list, GstRegistry * registry,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
    GstPlugin * plugin)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
  GstBinaryPluginElement *pe;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
  GstBinaryChunk *chk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
  GList *plugin_features = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
  GList *walk;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
16
hgs
parents: 0
diff changeset
   648
  pe = g_malloc0 (sizeof (GstBinaryPluginElement));
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
  chk = gst_registry_binary_make_data (pe, sizeof (GstBinaryPluginElement));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
  pe->file_size = plugin->file_size;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
  pe->file_mtime = plugin->file_mtime;
16
hgs
parents: 0
diff changeset
   653
  pe->n_deps = 0;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
  pe->nfeatures = 0;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
16
hgs
parents: 0
diff changeset
   656
  /* pack external deps */
hgs
parents: 0
diff changeset
   657
  for (walk = plugin->priv->deps; walk != NULL; walk = walk->next) {
hgs
parents: 0
diff changeset
   658
    if (!gst_registry_binary_save_plugin_dep (list, walk->data)) {
hgs
parents: 0
diff changeset
   659
      GST_ERROR ("Could not save external plugin dependency, aborting.");
hgs
parents: 0
diff changeset
   660
      goto fail;
hgs
parents: 0
diff changeset
   661
    }
hgs
parents: 0
diff changeset
   662
    ++pe->n_deps;
hgs
parents: 0
diff changeset
   663
  }
hgs
parents: 0
diff changeset
   664
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
  /* pack plugin features */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
  plugin_features =
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
      gst_registry_get_feature_list_by_plugin (registry, plugin->desc.name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
  for (walk = plugin_features; walk; walk = g_list_next (walk), pe->nfeatures++) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
    GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
    if (!gst_registry_binary_save_feature (list, feature)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
      GST_ERROR ("Can't fill plugin feature, aborting.");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
      goto fail;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
  }
16
hgs
parents: 0
diff changeset
   676
  GST_DEBUG ("Save plugin '%s' with %d feature(s)", plugin->desc.name,
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
      pe->nfeatures);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
  gst_plugin_feature_list_free (plugin_features);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
16
hgs
parents: 0
diff changeset
   681
  /* pack cache data */
hgs
parents: 0
diff changeset
   682
  if (plugin->priv->cache_data) {
hgs
parents: 0
diff changeset
   683
    gchar *cache_str = gst_structure_to_string (plugin->priv->cache_data);
hgs
parents: 0
diff changeset
   684
    gst_registry_binary_save_string (list, cache_str);
hgs
parents: 0
diff changeset
   685
  } else {
hgs
parents: 0
diff changeset
   686
    gst_registry_binary_save_const_string (list, "");
hgs
parents: 0
diff changeset
   687
  }
hgs
parents: 0
diff changeset
   688
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
  /* pack plugin element strings */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
  gst_registry_binary_save_const_string (list, plugin->desc.origin);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
  gst_registry_binary_save_const_string (list, plugin->desc.package);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
  gst_registry_binary_save_const_string (list, plugin->desc.source);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
  gst_registry_binary_save_const_string (list, plugin->desc.license);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
  gst_registry_binary_save_const_string (list, plugin->desc.version);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
  gst_registry_binary_save_const_string (list, plugin->filename);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
  gst_registry_binary_save_const_string (list, plugin->desc.description);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
  gst_registry_binary_save_const_string (list, plugin->desc.name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
  *list = g_list_prepend (*list, chk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
  GST_DEBUG ("Found %d features in plugin \"%s\"", pe->nfeatures,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
      plugin->desc.name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
  /* Errors */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
fail:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
  gst_plugin_feature_list_free (plugin_features);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
  g_free (chk);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
  g_free (pe);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
  return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
/**
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
 * gst_registry_binary_write_cache:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
 * @registry: a #GstRegistry
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
 * @location: a filename
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
 * Write the @registry to a cache to file at given @location.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
 * 
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
 * Returns: %TRUE on success.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
#ifdef __SYMBIAN32__
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
EXPORT_C
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
gst_registry_binary_write_cache (GstRegistry * registry, const char *location)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
  GList *walk;
16
hgs
parents: 0
diff changeset
   730
  GstBinaryRegistryMagic magic;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
  GList *to_write = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
  unsigned long file_position = 0;
16
hgs
parents: 0
diff changeset
   733
  BinaryRegistryCache *cache;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
  GST_INFO ("Building binary registry cache image");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
  g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
16
hgs
parents: 0
diff changeset
   739
  if (!gst_registry_binary_initialize_magic (&magic))
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
    goto fail;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
  /* iterate trough the list of plugins and fit them into binary structures */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
  for (walk = registry->plugins; walk; walk = g_list_next (walk)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
    GstPlugin *plugin = GST_PLUGIN (walk->data);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
    if (!plugin->filename)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
      continue;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
    if (plugin->flags & GST_PLUGIN_FLAG_CACHED) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
      struct stat statbuf;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
16
hgs
parents: 0
diff changeset
   752
      if (g_stat (plugin->filename, &statbuf) < 0 ||
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
          plugin->file_mtime != statbuf.st_mtime ||
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
          plugin->file_size != statbuf.st_size)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
        continue;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
    if (!gst_registry_binary_save_plugin (&to_write, registry, plugin)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
      GST_ERROR ("Can't write binary plugin information for \"%s\"",
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
          plugin->filename);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
  GST_INFO ("Writing binary registry cache");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
16
hgs
parents: 0
diff changeset
   766
  cache = gst_registry_binary_cache_init (registry, location);
hgs
parents: 0
diff changeset
   767
  if (!cache)
hgs
parents: 0
diff changeset
   768
    goto fail_free_list;
hgs
parents: 0
diff changeset
   769
hgs
parents: 0
diff changeset
   770
  /* write magic */
hgs
parents: 0
diff changeset
   771
  if (gst_registry_binary_cache_write (registry, cache, file_position,
hgs
parents: 0
diff changeset
   772
          &magic, sizeof (GstBinaryRegistryMagic)) !=
hgs
parents: 0
diff changeset
   773
      sizeof (GstBinaryRegistryMagic)) {
hgs
parents: 0
diff changeset
   774
    GST_ERROR ("Failed to write binary registry magic");
hgs
parents: 0
diff changeset
   775
    goto fail_free_list;
hgs
parents: 0
diff changeset
   776
  }
hgs
parents: 0
diff changeset
   777
  file_position += sizeof (GstBinaryRegistryMagic);
hgs
parents: 0
diff changeset
   778
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
  /* write out data chunks */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
  for (walk = to_write; walk; walk = g_list_next (walk)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    GstBinaryChunk *cur = walk->data;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
16
hgs
parents: 0
diff changeset
   783
    if (!gst_registry_binary_write_chunk (registry, cache, cur->data, cur->size,
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
            &file_position, cur->align)) {
16
hgs
parents: 0
diff changeset
   785
      goto fail_free_list;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
    if (!(cur->flags & GST_BINARY_REGISTRY_FLAG_CONST))
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
      g_free (cur->data);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
    g_free (cur);
16
hgs
parents: 0
diff changeset
   790
    walk->data = NULL;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
  g_list_free (to_write);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
16
hgs
parents: 0
diff changeset
   794
  if (!gst_registry_binary_cache_finish (registry, cache, TRUE))
hgs
parents: 0
diff changeset
   795
    return FALSE;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
  /* Errors */
16
hgs
parents: 0
diff changeset
   800
fail_free_list:
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
  {
16
hgs
parents: 0
diff changeset
   802
    for (walk = to_write; walk; walk = g_list_next (walk)) {
hgs
parents: 0
diff changeset
   803
      GstBinaryChunk *cur = walk->data;
hgs
parents: 0
diff changeset
   804
hgs
parents: 0
diff changeset
   805
      if (!(cur->flags & GST_BINARY_REGISTRY_FLAG_CONST))
hgs
parents: 0
diff changeset
   806
        g_free (cur->data);
hgs
parents: 0
diff changeset
   807
      g_free (cur);
hgs
parents: 0
diff changeset
   808
    }
hgs
parents: 0
diff changeset
   809
    g_list_free (to_write);
hgs
parents: 0
diff changeset
   810
hgs
parents: 0
diff changeset
   811
    if (cache)
hgs
parents: 0
diff changeset
   812
      (void) gst_registry_binary_cache_finish (registry, cache, FALSE);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
    /* fall through */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
  }
16
hgs
parents: 0
diff changeset
   815
fail:
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
  {
16
hgs
parents: 0
diff changeset
   817
    return FALSE;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
/* Registry loading */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
 * gst_registry_binary_check_magic:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
 * Check GstBinaryRegistryMagic validity.
16
hgs
parents: 0
diff changeset
   828
 * Return < 0 if something is wrong, -2 means
hgs
parents: 0
diff changeset
   829
 * that just the version of the registry is out of
hgs
parents: 0
diff changeset
   830
 * date, -1 is a general failure.
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
 */
16
hgs
parents: 0
diff changeset
   832
static gint
hgs
parents: 0
diff changeset
   833
gst_registry_binary_check_magic (gchar ** in, gsize size)
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   834
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
  GstBinaryRegistryMagic *m;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
16
hgs
parents: 0
diff changeset
   837
  align (*in);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
  GST_DEBUG ("Reading/casting for GstBinaryRegistryMagic at address %p", *in);
16
hgs
parents: 0
diff changeset
   839
  unpack_element (*in, m, GstBinaryRegistryMagic, (*in + size), fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
  if (strncmp (m->magic, GST_MAGIC_BINARY_REGISTRY_STR,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
          GST_MAGIC_BINARY_REGISTRY_LEN) != 0) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    GST_WARNING
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
        ("Binary registry magic is different : %02x%02x%02x%02x != %02x%02x%02x%02x",
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
        GST_MAGIC_BINARY_REGISTRY_STR[0] & 0xff,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
        GST_MAGIC_BINARY_REGISTRY_STR[1] & 0xff,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
        GST_MAGIC_BINARY_REGISTRY_STR[2] & 0xff,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
        GST_MAGIC_BINARY_REGISTRY_STR[3] & 0xff, m->magic[0] & 0xff,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
        m->magic[1] & 0xff, m->magic[2] & 0xff, m->magic[3] & 0xff);
16
hgs
parents: 0
diff changeset
   850
    return -1;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
  }
16
hgs
parents: 0
diff changeset
   852
  if (strncmp (m->version, GST_MAGIC_BINARY_VERSION_STR,
hgs
parents: 0
diff changeset
   853
          GST_MAGIC_BINARY_VERSION_LEN)) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
    GST_WARNING ("Binary registry magic version is different : %s != %s",
16
hgs
parents: 0
diff changeset
   855
        GST_MAGIC_BINARY_VERSION_STR, m->version);
hgs
parents: 0
diff changeset
   856
    return -2;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
  }
16
hgs
parents: 0
diff changeset
   858
hgs
parents: 0
diff changeset
   859
  return 0;
hgs
parents: 0
diff changeset
   860
hgs
parents: 0
diff changeset
   861
fail:
hgs
parents: 0
diff changeset
   862
  GST_WARNING ("Not enough data for binary registry magic structure");
hgs
parents: 0
diff changeset
   863
  return -1;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
 * gst_registry_binary_load_pad_template:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
 * Make a new GstStaticPadTemplate from current GstBinaryPadTemplate structure
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
 * Returns: new GstStaticPadTemplate
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   874
static gboolean
16
hgs
parents: 0
diff changeset
   875
gst_registry_binary_load_pad_template (GstElementFactory * factory, gchar ** in,
hgs
parents: 0
diff changeset
   876
    gchar * end)
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
  GstBinaryPadTemplate *pt;
16
hgs
parents: 0
diff changeset
   879
  GstStaticPadTemplate *template = NULL;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
16
hgs
parents: 0
diff changeset
   881
  align (*in);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
  GST_DEBUG ("Reading/casting for GstBinaryPadTemplate at address %p", *in);
16
hgs
parents: 0
diff changeset
   883
  unpack_element (*in, pt, GstBinaryPadTemplate, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
  template = g_new0 (GstStaticPadTemplate, 1);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
  template->presence = pt->presence;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
  template->direction = pt->direction;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
  /* unpack pad template strings */
16
hgs
parents: 0
diff changeset
   890
  unpack_const_string (*in, template->name_template, end, fail);
hgs
parents: 0
diff changeset
   891
  unpack_string (*in, template->static_caps.string, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
  __gst_element_factory_add_static_pad_template (factory, template);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
  GST_DEBUG ("Added pad_template %s", template->name_template);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
  return TRUE;
16
hgs
parents: 0
diff changeset
   897
hgs
parents: 0
diff changeset
   898
fail:
hgs
parents: 0
diff changeset
   899
  GST_INFO ("Reading pad template failed");
hgs
parents: 0
diff changeset
   900
  g_free (template);
hgs
parents: 0
diff changeset
   901
  return FALSE;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
 * gst_registry_binary_load_feature:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
 * Make a new GstPluginFeature from current binary plugin feature structure
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
 * Returns: new GstPluginFeature
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
static gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in,
16
hgs
parents: 0
diff changeset
   914
    gchar * end, const gchar * plugin_name)
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
  GstBinaryPluginFeature *pf = NULL;
16
hgs
parents: 0
diff changeset
   917
  GstPluginFeature *feature = NULL;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
  gchar *type_name = NULL, *str;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
  GType type;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
  guint i;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
  /* unpack plugin feature strings */
16
hgs
parents: 0
diff changeset
   923
  unpack_string (*in, type_name, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
16
hgs
parents: 0
diff changeset
   925
  if (G_UNLIKELY (!type_name)) {
hgs
parents: 0
diff changeset
   926
    GST_ERROR ("No feature type name");
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
    return FALSE;
16
hgs
parents: 0
diff changeset
   928
  }
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
  GST_DEBUG ("Plugin '%s' feature typename : '%s'", plugin_name, type_name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
16
hgs
parents: 0
diff changeset
   932
  if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
    GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
        plugin_name);
16
hgs
parents: 0
diff changeset
   935
    g_free (type_name);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   936
    return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
  }
16
hgs
parents: 0
diff changeset
   938
  if (G_UNLIKELY ((feature = g_object_new (type, NULL)) == NULL)) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   939
    GST_ERROR ("Can't create feature from type");
16
hgs
parents: 0
diff changeset
   940
    g_free (type_name);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   941
    return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   942
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
16
hgs
parents: 0
diff changeset
   944
  if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) {
hgs
parents: 0
diff changeset
   945
    GST_ERROR ("typename : '%s' is not a plugin feature", type_name);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   946
    goto fail;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   948
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   949
  /* unpack more plugin feature strings */
16
hgs
parents: 0
diff changeset
   950
  unpack_string (*in, feature->name, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
  if (GST_IS_ELEMENT_FACTORY (feature)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
    GstBinaryElementFactory *ef;
16
hgs
parents: 0
diff changeset
   954
    guint n;
hgs
parents: 0
diff changeset
   955
    GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
16
hgs
parents: 0
diff changeset
   957
    align (*in);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
    GST_LOG ("Reading/casting for GstBinaryElementFactory at address %p", *in);
16
hgs
parents: 0
diff changeset
   959
    unpack_element (*in, ef, GstBinaryElementFactory, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
    pf = (GstBinaryPluginFeature *) ef;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
    /* unpack element factory strings */
16
hgs
parents: 0
diff changeset
   963
    unpack_string (*in, factory->details.longname, end, fail);
hgs
parents: 0
diff changeset
   964
    unpack_string (*in, factory->details.klass, end, fail);
hgs
parents: 0
diff changeset
   965
    unpack_string (*in, factory->details.description, end, fail);
hgs
parents: 0
diff changeset
   966
    unpack_string (*in, factory->details.author, end, fail);
hgs
parents: 0
diff changeset
   967
    n = ef->npadtemplates;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
    GST_DEBUG ("Element factory : '%s' with npadtemplates=%d",
16
hgs
parents: 0
diff changeset
   969
        factory->details.longname, n);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   970
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   971
    /* load pad templates */
16
hgs
parents: 0
diff changeset
   972
    for (i = 0; i < n; i++) {
hgs
parents: 0
diff changeset
   973
      if (G_UNLIKELY (!gst_registry_binary_load_pad_template (factory, in,
hgs
parents: 0
diff changeset
   974
                  end))) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   975
        GST_ERROR ("Error while loading binary pad template");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   976
        goto fail;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   977
      }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   978
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   979
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
    /* load uritypes */
16
hgs
parents: 0
diff changeset
   981
    if (G_UNLIKELY ((n = ef->nuriprotocols))) {
hgs
parents: 0
diff changeset
   982
      GST_DEBUG ("Reading %d UriTypes at address %p", n, *in);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   983
16
hgs
parents: 0
diff changeset
   984
      align (*in);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   985
      factory->uri_type = *((guint *) * in);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
      *in += sizeof (factory->uri_type);
16
hgs
parents: 0
diff changeset
   987
      /*unpack_element(*in, &factory->uri_type, factory->uri_type, end, fail); */
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
16
hgs
parents: 0
diff changeset
   989
      factory->uri_protocols = g_new0 (gchar *, n + 1);
hgs
parents: 0
diff changeset
   990
      for (i = 0; i < n; i++) {
hgs
parents: 0
diff changeset
   991
        unpack_string (*in, str, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   992
        factory->uri_protocols[i] = str;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   993
      }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   994
    }
16
hgs
parents: 0
diff changeset
   995
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   996
    /* load interfaces */
16
hgs
parents: 0
diff changeset
   997
    if (G_UNLIKELY ((n = ef->ninterfaces))) {
hgs
parents: 0
diff changeset
   998
      GST_DEBUG ("Reading %d Interfaces at address %p", n, *in);
hgs
parents: 0
diff changeset
   999
      for (i = 0; i < n; i++) {
hgs
parents: 0
diff changeset
  1000
        unpack_string (*in, str, end, fail);
hgs
parents: 0
diff changeset
  1001
        __gst_element_factory_add_interface (factory, str);
hgs
parents: 0
diff changeset
  1002
        g_free (str);
hgs
parents: 0
diff changeset
  1003
      }
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1004
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1005
  } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1006
    GstBinaryTypeFindFactory *tff;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1007
    GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1008
16
hgs
parents: 0
diff changeset
  1009
    align (*in);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1010
    GST_DEBUG ("Reading/casting for GstBinaryPluginFeature at address %p", *in);
16
hgs
parents: 0
diff changeset
  1011
    unpack_element (*in, tff, GstBinaryTypeFindFactory, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1012
    pf = (GstBinaryPluginFeature *) tff;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1013
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1014
    /* load caps */
16
hgs
parents: 0
diff changeset
  1015
    unpack_string (*in, str, end, fail);
hgs
parents: 0
diff changeset
  1016
    factory->caps = (str && *str) ? gst_caps_from_string (str) : NULL;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1017
    g_free (str);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1018
    /* load extensions */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1019
    if (tff->nextensions) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1020
      GST_DEBUG ("Reading %d Typefind extensions at address %p",
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1021
          tff->nextensions, *in);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1022
      factory->extensions = g_new0 (gchar *, tff->nextensions + 1);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1023
      for (i = 0; i < tff->nextensions; i++) {
16
hgs
parents: 0
diff changeset
  1024
        unpack_string (*in, str, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
        factory->extensions[i] = str;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
      }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
    }
16
hgs
parents: 0
diff changeset
  1028
  } else if (GST_IS_INDEX_FACTORY (feature)) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
    GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1030
16
hgs
parents: 0
diff changeset
  1031
    align (*in);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
    GST_DEBUG ("Reading/casting for GstBinaryPluginFeature at address %p", *in);
16
hgs
parents: 0
diff changeset
  1033
    unpack_element (*in, pf, GstBinaryPluginFeature, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1034
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1035
    /* unpack index factory strings */
16
hgs
parents: 0
diff changeset
  1036
    unpack_string (*in, factory->longdesc, end, fail);
hgs
parents: 0
diff changeset
  1037
  } else {
hgs
parents: 0
diff changeset
  1038
    GST_WARNING ("unhandled factory type : %s", G_OBJECT_TYPE_NAME (feature));
hgs
parents: 0
diff changeset
  1039
    goto fail;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1040
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1041
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1042
  feature->rank = pf->rank;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1043
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1044
  /* should already be the interned string, but better make sure */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1045
  feature->plugin_name = g_intern_string (plugin_name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1046
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1047
  gst_registry_add_feature (registry, feature);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1048
  GST_DEBUG ("Added feature %s", feature->name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1049
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1050
  g_free (type_name);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1051
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1052
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1053
  /* Errors */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1054
fail:
16
hgs
parents: 0
diff changeset
  1055
  GST_INFO ("Reading plugin feature failed");
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1056
  g_free (type_name);
16
hgs
parents: 0
diff changeset
  1057
  if (feature) {
hgs
parents: 0
diff changeset
  1058
    if (GST_IS_OBJECT (feature))
hgs
parents: 0
diff changeset
  1059
      gst_object_unref (feature);
hgs
parents: 0
diff changeset
  1060
    else
hgs
parents: 0
diff changeset
  1061
      g_object_unref (feature);
hgs
parents: 0
diff changeset
  1062
  }
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1063
  return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1064
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1065
16
hgs
parents: 0
diff changeset
  1066
static gchar **
hgs
parents: 0
diff changeset
  1067
gst_registry_binary_load_plugin_dep_strv (gchar ** in, gchar * end, guint n)
hgs
parents: 0
diff changeset
  1068
{
hgs
parents: 0
diff changeset
  1069
  gchar **arr;
hgs
parents: 0
diff changeset
  1070
hgs
parents: 0
diff changeset
  1071
  if (n == 0)
hgs
parents: 0
diff changeset
  1072
    return NULL;
hgs
parents: 0
diff changeset
  1073
hgs
parents: 0
diff changeset
  1074
  arr = g_new0 (gchar *, n + 1);
hgs
parents: 0
diff changeset
  1075
  while (n > 0) {
hgs
parents: 0
diff changeset
  1076
    unpack_string (*in, arr[n - 1], end, fail);
hgs
parents: 0
diff changeset
  1077
    --n;
hgs
parents: 0
diff changeset
  1078
  }
hgs
parents: 0
diff changeset
  1079
  return arr;
hgs
parents: 0
diff changeset
  1080
fail:
hgs
parents: 0
diff changeset
  1081
  GST_INFO ("Reading plugin dependency strings failed");
hgs
parents: 0
diff changeset
  1082
  return NULL;
hgs
parents: 0
diff changeset
  1083
}
hgs
parents: 0
diff changeset
  1084
hgs
parents: 0
diff changeset
  1085
static gboolean
hgs
parents: 0
diff changeset
  1086
gst_registry_binary_load_plugin_dep (GstPlugin * plugin, gchar ** in,
hgs
parents: 0
diff changeset
  1087
    gchar * end)
hgs
parents: 0
diff changeset
  1088
{
hgs
parents: 0
diff changeset
  1089
  GstPluginDep *dep;
hgs
parents: 0
diff changeset
  1090
  GstBinaryDep *d;
hgs
parents: 0
diff changeset
  1091
  gchar **s;
hgs
parents: 0
diff changeset
  1092
hgs
parents: 0
diff changeset
  1093
  align (*in);
hgs
parents: 0
diff changeset
  1094
  GST_LOG_OBJECT (plugin, "Unpacking GstBinaryDep from %p", *in);
hgs
parents: 0
diff changeset
  1095
  unpack_element (*in, d, GstBinaryDep, end, fail);
hgs
parents: 0
diff changeset
  1096
hgs
parents: 0
diff changeset
  1097
  dep = g_new0 (GstPluginDep, 1);
hgs
parents: 0
diff changeset
  1098
hgs
parents: 0
diff changeset
  1099
  dep->env_hash = d->env_hash;
hgs
parents: 0
diff changeset
  1100
  dep->stat_hash = d->stat_hash;
hgs
parents: 0
diff changeset
  1101
hgs
parents: 0
diff changeset
  1102
  dep->flags = d->flags;
hgs
parents: 0
diff changeset
  1103
hgs
parents: 0
diff changeset
  1104
  dep->names = gst_registry_binary_load_plugin_dep_strv (in, end, d->n_names);
hgs
parents: 0
diff changeset
  1105
  dep->paths = gst_registry_binary_load_plugin_dep_strv (in, end, d->n_paths);
hgs
parents: 0
diff changeset
  1106
  dep->env_vars =
hgs
parents: 0
diff changeset
  1107
      gst_registry_binary_load_plugin_dep_strv (in, end, d->n_env_vars);
hgs
parents: 0
diff changeset
  1108
hgs
parents: 0
diff changeset
  1109
  plugin->priv->deps = g_list_append (plugin->priv->deps, dep);
hgs
parents: 0
diff changeset
  1110
hgs
parents: 0
diff changeset
  1111
  GST_DEBUG_OBJECT (plugin, "Loaded external plugin dependency from registry: "
hgs
parents: 0
diff changeset
  1112
      "env_hash: %08x, stat_hash: %08x", dep->env_hash, dep->stat_hash);
hgs
parents: 0
diff changeset
  1113
  for (s = dep->env_vars; s != NULL && *s != NULL; ++s)
hgs
parents: 0
diff changeset
  1114
    GST_LOG_OBJECT (plugin, " evar: %s", *s);
hgs
parents: 0
diff changeset
  1115
  for (s = dep->paths; s != NULL && *s != NULL; ++s)
hgs
parents: 0
diff changeset
  1116
    GST_LOG_OBJECT (plugin, " path: %s", *s);
hgs
parents: 0
diff changeset
  1117
  for (s = dep->names; s != NULL && *s != NULL; ++s)
hgs
parents: 0
diff changeset
  1118
    GST_LOG_OBJECT (plugin, " name: %s", *s);
hgs
parents: 0
diff changeset
  1119
hgs
parents: 0
diff changeset
  1120
  return TRUE;
hgs
parents: 0
diff changeset
  1121
fail:
hgs
parents: 0
diff changeset
  1122
  GST_INFO ("Reading plugin dependency failed");
hgs
parents: 0
diff changeset
  1123
  return FALSE;
hgs
parents: 0
diff changeset
  1124
}
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1126
/*
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
 * gst_registry_binary_load_plugin:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
 * Make a new GstPlugin from current GstBinaryPluginElement structure
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1130
 * and save it to the GstRegistry. Return an offset to the next
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1131
 * GstBinaryPluginElement structure.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1132
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1133
static gboolean
16
hgs
parents: 0
diff changeset
  1134
gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in,
hgs
parents: 0
diff changeset
  1135
    gchar * end)
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1136
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1137
  GstBinaryPluginElement *pe;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1138
  GstPlugin *plugin = NULL;
16
hgs
parents: 0
diff changeset
  1139
  gchar *cache_str = NULL;
hgs
parents: 0
diff changeset
  1140
  guint i, n;
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1141
16
hgs
parents: 0
diff changeset
  1142
  align (*in);
hgs
parents: 0
diff changeset
  1143
  GST_LOG ("Reading/casting for GstBinaryPluginElement at address %p", *in);
hgs
parents: 0
diff changeset
  1144
  unpack_element (*in, pe, GstBinaryPluginElement, end, fail);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1145
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1146
  plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
  /* TODO: also set GST_PLUGIN_FLAG_CONST */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
  plugin->flags |= GST_PLUGIN_FLAG_CACHED;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
  plugin->file_mtime = pe->file_mtime;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
  plugin->file_size = pe->file_size;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
  /* unpack plugin element strings */
16
hgs
parents: 0
diff changeset
  1154
  unpack_const_string (*in, plugin->desc.name, end, fail);
hgs
parents: 0
diff changeset
  1155
  unpack_string (*in, plugin->desc.description, end, fail);
hgs
parents: 0
diff changeset
  1156
  unpack_string (*in, plugin->filename, end, fail);
hgs
parents: 0
diff changeset
  1157
  unpack_const_string (*in, plugin->desc.version, end, fail);
hgs
parents: 0
diff changeset
  1158
  unpack_const_string (*in, plugin->desc.license, end, fail);
hgs
parents: 0
diff changeset
  1159
  unpack_const_string (*in, plugin->desc.source, end, fail);
hgs
parents: 0
diff changeset
  1160
  unpack_const_string (*in, plugin->desc.package, end, fail);
hgs
parents: 0
diff changeset
  1161
  unpack_const_string (*in, plugin->desc.origin, end, fail);
hgs
parents: 0
diff changeset
  1162
  GST_LOG ("read strings for name='%s'", plugin->desc.name);
hgs
parents: 0
diff changeset
  1163
  GST_LOG ("  desc.description='%s'", plugin->desc.description);
hgs
parents: 0
diff changeset
  1164
  GST_LOG ("  filename='%s'", plugin->filename);
hgs
parents: 0
diff changeset
  1165
  GST_LOG ("  desc.version='%s'", plugin->desc.version);
hgs
parents: 0
diff changeset
  1166
  GST_LOG ("  desc.license='%s'", plugin->desc.license);
hgs
parents: 0
diff changeset
  1167
  GST_LOG ("  desc.source='%s'", plugin->desc.source);
hgs
parents: 0
diff changeset
  1168
  GST_LOG ("  desc.package='%s'", plugin->desc.package);
hgs
parents: 0
diff changeset
  1169
  GST_LOG ("  desc.origin='%s'", plugin->desc.origin);
hgs
parents: 0
diff changeset
  1170
hgs
parents: 0
diff changeset
  1171
  /* unpack cache data */
hgs
parents: 0
diff changeset
  1172
  unpack_string (*in, cache_str, end, fail);
hgs
parents: 0
diff changeset
  1173
  if (*cache_str) {
hgs
parents: 0
diff changeset
  1174
    plugin->priv->cache_data = gst_structure_from_string (cache_str, NULL);
hgs
parents: 0
diff changeset
  1175
  }
hgs
parents: 0
diff changeset
  1176
  g_free (cache_str);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1177
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
  plugin->basename = g_path_get_basename (plugin->filename);
16
hgs
parents: 0
diff changeset
  1179
hgs
parents: 0
diff changeset
  1180
  /* Takes ownership of plugin */
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1181
  gst_registry_add_plugin (registry, plugin);
16
hgs
parents: 0
diff changeset
  1182
  n = pe->nfeatures;
hgs
parents: 0
diff changeset
  1183
  GST_DEBUG ("Added plugin '%s' plugin with %d features from binary registry",
hgs
parents: 0
diff changeset
  1184
      plugin->desc.name, n);
hgs
parents: 0
diff changeset
  1185
hgs
parents: 0
diff changeset
  1186
  /* Load plugin features */
hgs
parents: 0
diff changeset
  1187
  for (i = 0; i < n; i++) {
hgs
parents: 0
diff changeset
  1188
    if (G_UNLIKELY (!gst_registry_binary_load_feature (registry, in, end,
hgs
parents: 0
diff changeset
  1189
                plugin->desc.name))) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1190
      GST_ERROR ("Error while loading binary feature");
16
hgs
parents: 0
diff changeset
  1191
      gst_registry_remove_plugin (registry, plugin);
hgs
parents: 0
diff changeset
  1192
      goto fail;
hgs
parents: 0
diff changeset
  1193
    }
hgs
parents: 0
diff changeset
  1194
  }
hgs
parents: 0
diff changeset
  1195
hgs
parents: 0
diff changeset
  1196
  /* Load external plugin dependencies */
hgs
parents: 0
diff changeset
  1197
  for (i = 0; i < pe->n_deps; ++i) {
hgs
parents: 0
diff changeset
  1198
    if (G_UNLIKELY (!gst_registry_binary_load_plugin_dep (plugin, in, end))) {
hgs
parents: 0
diff changeset
  1199
      GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency");
hgs
parents: 0
diff changeset
  1200
      gst_registry_remove_plugin (registry, plugin);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1201
      goto fail;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1202
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1203
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1204
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1205
  return TRUE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1206
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1207
  /* Errors */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1208
fail:
16
hgs
parents: 0
diff changeset
  1209
  GST_INFO ("Reading plugin failed");
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1210
  return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1211
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1212
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1213
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1214
/**
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1215
 * gst_registry_binary_read_cache:
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1216
 * @registry: a #GstRegistry
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1217
 * @location: a filename
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1218
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1219
 * Read the contents of the binary cache file at @location into @registry.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1220
 *
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1221
 * Returns: %TRUE on success.
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1222
 */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1223
#ifdef __SYMBIAN32__
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1224
EXPORT_C
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1225
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1226
gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1227
gst_registry_binary_read_cache (GstRegistry * registry, const char *location)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1229
  GMappedFile *mapped = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1230
  gchar *contents = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1231
  gchar *in = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1232
  gsize size;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1233
  GError *err = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1234
  gboolean res = FALSE;
16
hgs
parents: 0
diff changeset
  1235
  gint check_magic_result;
hgs
parents: 0
diff changeset
  1236
#ifndef GST_DISABLE_GST_DEBUG
hgs
parents: 0
diff changeset
  1237
  GTimer *timer = NULL;
hgs
parents: 0
diff changeset
  1238
  gdouble seconds;
hgs
parents: 0
diff changeset
  1239
#endif
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1240
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1241
  /* make sure these types exist */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1242
  GST_TYPE_ELEMENT_FACTORY;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1243
  GST_TYPE_TYPE_FIND_FACTORY;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1244
  GST_TYPE_INDEX_FACTORY;
16
hgs
parents: 0
diff changeset
  1245
hgs
parents: 0
diff changeset
  1246
#ifndef GST_DISABLE_GST_DEBUG
hgs
parents: 0
diff changeset
  1247
  timer = g_timer_new ();
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1248
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1249
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1250
  mapped = g_mapped_file_new (location, FALSE, &err);
16
hgs
parents: 0
diff changeset
  1251
  if (G_UNLIKELY (err != NULL)) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1252
    GST_INFO ("Unable to mmap file %s : %s", location, err->message);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1253
    g_error_free (err);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1254
    err = NULL;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1255
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1256
    g_file_get_contents (location, &contents, &size, &err);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1257
    if (err != NULL) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1258
      GST_INFO ("Unable to read file %s : %s", location, err->message);
16
hgs
parents: 0
diff changeset
  1259
#ifndef GST_DISABLE_GST_DEBUG
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1260
      g_timer_destroy (timer);
16
hgs
parents: 0
diff changeset
  1261
#endif
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1262
      g_error_free (err);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1263
      return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1264
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1265
  } else {
16
hgs
parents: 0
diff changeset
  1266
    if (G_UNLIKELY ((contents = g_mapped_file_get_contents (mapped)) == NULL)) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1267
      GST_ERROR ("Can't load file %s : %s", location, g_strerror (errno));
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1268
      goto Error;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1269
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1270
    /* check length for header */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1271
    size = g_mapped_file_get_length (mapped);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
  }
16
hgs
parents: 0
diff changeset
  1273
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
  /* in is a cursor pointer, we initialize it with the begin of registry and is updated on each read */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1275
  in = contents;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1276
  GST_DEBUG ("File data at address %p", in);
16
hgs
parents: 0
diff changeset
  1277
  if (G_UNLIKELY (size < sizeof (GstBinaryRegistryMagic))) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1278
    GST_ERROR ("No or broken registry header");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1279
    goto Error;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1280
  }
16
hgs
parents: 0
diff changeset
  1281
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1282
  /* check if header is valid */
16
hgs
parents: 0
diff changeset
  1283
  if (G_UNLIKELY ((check_magic_result =
hgs
parents: 0
diff changeset
  1284
              gst_registry_binary_check_magic (&in, size)) < 0)) {
hgs
parents: 0
diff changeset
  1285
hgs
parents: 0
diff changeset
  1286
    if (check_magic_result == -1)
hgs
parents: 0
diff changeset
  1287
      GST_ERROR
hgs
parents: 0
diff changeset
  1288
          ("Binary registry type not recognized (invalid magic) for file at %s",
hgs
parents: 0
diff changeset
  1289
          location);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1290
    goto Error;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1291
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1292
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1293
  /* check if there are plugins in the file */
16
hgs
parents: 0
diff changeset
  1294
  if (G_UNLIKELY (!(((gsize) in + sizeof (GstBinaryPluginElement)) <
hgs
parents: 0
diff changeset
  1295
              (gsize) contents + size))) {
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1296
    GST_INFO ("No binary plugins structure to read");
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1297
    /* empty file, this is not an error */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1298
  } else {
16
hgs
parents: 0
diff changeset
  1299
    gchar *end = contents + size;
hgs
parents: 0
diff changeset
  1300
    /* read as long as we still have space for a GstBinaryPluginElement */
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1301
    for (;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1302
        ((gsize) in + sizeof (GstBinaryPluginElement)) <
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1303
        (gsize) contents + size;) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1304
      GST_DEBUG ("reading binary registry %" G_GSIZE_FORMAT "(%x)/%"
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1305
          G_GSIZE_FORMAT, (gsize) in - (gsize) contents,
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1306
          (guint) ((gsize) in - (gsize) contents), size);
16
hgs
parents: 0
diff changeset
  1307
      if (!gst_registry_binary_load_plugin (registry, &in, end)) {
hgs
parents: 0
diff changeset
  1308
        GST_ERROR ("Problem while reading binary registry %s", location);
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1309
        goto Error;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1310
      }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1311
    }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1312
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1313
16
hgs
parents: 0
diff changeset
  1314
#ifndef GST_DISABLE_GST_DEBUG
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1315
  g_timer_stop (timer);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1316
  seconds = g_timer_elapsed (timer, NULL);
16
hgs
parents: 0
diff changeset
  1317
#endif
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1318
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1319
  GST_INFO ("loaded %s in %lf seconds", location, seconds);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1320
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1321
  res = TRUE;
16
hgs
parents: 0
diff changeset
  1322
  /* TODO: once we re-use the pointers to registry contents, return here */
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1323
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1324
Error:
16
hgs
parents: 0
diff changeset
  1325
#ifndef GST_DISABLE_GST_DEBUG
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1326
  g_timer_destroy (timer);
16
hgs
parents: 0
diff changeset
  1327
#endif
0
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1328
  if (mapped) {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1329
    g_mapped_file_free (mapped);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1330
  } else {
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1331
    g_free (contents);
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1332
  }
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1333
  return res;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1334
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1335
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1336
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1337
/* FIXME 0.11: these are here for backwards compatibility */
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1338
#ifdef __SYMBIAN32__
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1339
EXPORT_C
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1340
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1341
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1342
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1343
gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1344
gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1345
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1346
  return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1347
}
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1348
#ifdef __SYMBIAN32__
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1349
EXPORT_C
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1350
#endif
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1351
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1352
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1353
gboolean
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1354
gst_registry_xml_write_cache (GstRegistry * registry, const char *location)
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1355
{
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1356
  return FALSE;
0e761a78d257 Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1357
}