~ubuntu-branches/ubuntu/trusty/shotdetect/trusty

« back to all changes in this revision

Viewing changes to .pc/1004-fix_comments_and_names.patch/src/xml.cpp

  • Committer: Package Import Robot
  • Author(s): Giulio Paci, Giulio Paci, Sebastian Ramacher
  • Date: 2013-09-01 15:23:15 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130901152315-pub3i1bw9x90jbx1
Tags: 1.0.86-2
[ Giulio Paci ]
* Add a patch to fix FTBFS with libav 0.9.
  Closes: #694299.
  Fixes FTBFS on Ubuntu 12.04.
* Rename compilation_fixes.patch to 1001-compilation_fixes.patch.
* Add 1003-fix-FTBFS-ffmpeg_1.0.x.patch.
* Add 1004-fix_comments_and_names.patch.
* Add 1005-add_framenumber_to_filename.patch (unused).
* Add 1006-label_xaxis_with_timecode.patch (unused).
* Set Debian Multimedia Maintainers as maintainer.
* Add Giulio Paci as uploader.
* Add Vcs-Git and Vcs-Browser fields in debian/control.
* Drop libstdc++-dev dependency.
* Drop optional libgd2-xpm-dev dependency.
* Require libgd-dev (>= 2.1).
* Fix copyright Format field.
* Fix copyright license information for some files.
* Add hardening flags.
* Set debhelper compatibility level to 9.
* Bump Standards-Version to 3.9.4.
  No changes needed.

[ Sebastian Ramacher]
* Add myself to Uploaders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007 Johan MATHE - johan.mathe@tremplin-utc.net - Centre
 
3
 * Pompidou - IRI This library is free software; you can redistribute it 
 
4
 * and/or modify it under the terms of the GNU Lesser General Public
 
5
 * License as published by the Free Software Foundation; either version
 
6
 * 2.1 of the License, or (at your option) any later version. This
 
7
 * library is distributed in the hope that it will be useful, but WITHOUT
 
8
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
9
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 
10
 * License for more details. You should have received a copy of the GNU
 
11
 * Lesser General Public License along with this library; if not, write to 
 
12
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
13
 * Boston, MA 02110-1301 USA $Id: xml.cpp 139 2007-03-29 14:37:40Z
 
14
 * johmathe $ $Date: 2007-12-12 16:22:16 +0000 (Wed, 12 Dec 2007) $ 
 
15
 */
 
16
 
 
17
#include "xml.h"
 
18
#include "shot.h"
 
19
 
 
20
using namespace std;
 
21
class film;
 
22
class shot;
 
23
 
 
24
xmlChar *
 
25
xml::ConvertInput (const char *in, const char *encoding)
 
26
{
 
27
  xmlChar *out;
 
28
  int ret;
 
29
  int size;
 
30
  int out_size;
 
31
  int temp;
 
32
  xmlCharEncodingHandlerPtr handler;
 
33
 
 
34
  if (in == 0)
 
35
    return 0;
 
36
 
 
37
  handler = xmlFindCharEncodingHandler (encoding);
 
38
 
 
39
  if (!handler)
 
40
    {
 
41
      printf ("ConvertInput: no encoding handler found for '%s'\n", encoding ? encoding : "");
 
42
      return 0;
 
43
    }
 
44
 
 
45
  size = (int) strlen (in) + 1;
 
46
  out_size = size * 2 - 1;
 
47
  out = (unsigned char *) xmlMalloc ((size_t) out_size);
 
48
 
 
49
  if (out != 0)
 
50
    {
 
51
      temp = size - 1;
 
52
      ret = handler->input (out, &out_size, (const xmlChar *) in, &temp);
 
53
      if ((ret < 0) || (temp - size + 1))
 
54
        {
 
55
          if (ret < 0)
 
56
            {
 
57
              printf ("ConvertInput: conversion wasn't successful.\n");
 
58
            }
 
59
          else
 
60
            {
 
61
              printf ("ConvertInput: conversion wasn't successful. converted: %i octets.\n", temp);
 
62
            }
 
63
 
 
64
          xmlFree (out);
 
65
          out = 0;
 
66
        }
 
67
      else
 
68
        {
 
69
          out = (unsigned char *) xmlRealloc (out, out_size + 1);
 
70
          out[out_size] = 0;    /* null terminating out */
 
71
        }
 
72
    }
 
73
  else
 
74
    {
 
75
      printf ("ConvertInput: no mem\n");
 
76
    }
 
77
 
 
78
  return out;
 
79
}
 
80
 
 
81
 
 
82
 
 
83
void
 
84
xml::write_data (string & filename)
 
85
{
 
86
  int rc;
 
87
  xmlTextWriterPtr writer;
 
88
  xmlChar *tmp;
 
89
  xmlDocPtr doc;
 
90
  stringstream strflx;
 
91
 
 
92
  /*  Create a new XmlWriter for DOM, with no compression. */
 
93
  list < shot >::iterator il;
 
94
  writer = xmlNewTextWriterDoc (&doc, 0);
 
95
 
 
96
  rc = xmlTextWriterStartDocument (writer, NULL, MY_ENCODING, NULL);
 
97
  rc = xmlTextWriterStartElement (writer, BAD_CAST "shotdetect");
 
98
  tmp = ConvertInput ("IRI ShotDetect ", MY_ENCODING);
 
99
  rc = xmlTextWriterWriteComment (writer, tmp);
 
100
 
 
101
  if (tmp != NULL)
 
102
    xmlFree (tmp);
 
103
 
 
104
  xmlTextWriterStartElement (writer, BAD_CAST "content");
 
105
 
 
106
  xmlTextWriterStartElement (writer, BAD_CAST "head");
 
107
 
 
108
 
 
109
  xmlTextWriterStartElement (writer, BAD_CAST "media");
 
110
  xmlTextWriterWriteAttribute (writer, BAD_CAST "src", BAD_CAST f->get_ipath().c_str ());
 
111
  strflx.str ("");
 
112
  strflx << f->fps;
 
113
  xmlTextWriterWriteElement (writer, BAD_CAST "fps", BAD_CAST strflx.str ().c_str ());
 
114
  strflx.str ("");
 
115
  strflx << f->height;
 
116
  xmlTextWriterWriteElement (writer, BAD_CAST "height", BAD_CAST strflx.str ().c_str ());
 
117
  strflx.str ("");
 
118
  strflx << f->width;
 
119
  xmlTextWriterWriteElement (writer, BAD_CAST "width", BAD_CAST strflx.str ().c_str ());
 
120
 
 
121
  strflx.str ("");
 
122
  strflx << int (f->duration.mstotal);
 
123
  xmlTextWriterWriteElement (writer, BAD_CAST "duration", BAD_CAST strflx.str ().c_str ());
 
124
 
 
125
  strflx.str ("");
 
126
  strflx << f->nchannel;
 
127
  xmlTextWriterWriteElement (writer, BAD_CAST "nchannel", BAD_CAST strflx.str ().c_str ());
 
128
  xmlTextWriterStartElement (writer, BAD_CAST "codec");
 
129
  xmlTextWriterWriteElement (writer, BAD_CAST "video", BAD_CAST f->codec.video.c_str ());
 
130
  xmlTextWriterWriteElement (writer, BAD_CAST "audio", BAD_CAST f->codec.audio.c_str ());
 
131
  xmlTextWriterEndElement (writer);
 
132
  xmlTextWriterEndElement (writer);
 
133
 
 
134
  xmlTextWriterEndElement (writer);
 
135
 
 
136
  xmlTextWriterStartElement (writer, BAD_CAST "body");
 
137
  xmlTextWriterStartElement (writer, BAD_CAST "shots");
 
138
 
 
139
  /* Mise en place des elements shots */
 
140
  for (il = f->shots.begin (); il != f->shots.end (); il++)
 
141
    {
 
142
      strflx.str ("");
 
143
      strflx << (*il).myid;
 
144
      rc = xmlTextWriterStartElement (writer, BAD_CAST "shot");
 
145
      rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "id", BAD_CAST strflx.str ().c_str ());
 
146
 
 
147
      strflx.str ("");
 
148
      strflx << (*il).fduration;
 
149
      rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "fduration", BAD_CAST strflx.str ().c_str ());
 
150
 
 
151
      strflx.str ("");
 
152
      strflx << int ((*il).msduration);
 
153
      rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "msduration", BAD_CAST strflx.str ().c_str ());
 
154
 
 
155
      strflx.str ("");
 
156
      strflx << (*il).fbegin;
 
157
      rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "fbegin", BAD_CAST strflx.str ().c_str ());
 
158
 
 
159
      strflx.str ("");
 
160
      strflx << int ((*il).msbegin);
 
161
      rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "msbegin", BAD_CAST strflx.str ().c_str ());
 
162
 
 
163
      /*
 
164
       * Element image 
 
165
       */
 
166
 
 
167
      if ((*il).img_begin != NULL)
 
168
        {
 
169
          if (f->get_shot())
 
170
            {
 
171
              rc = xmlTextWriterStartElement (writer, BAD_CAST "img");
 
172
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "size", BAD_CAST "original");
 
173
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "type", BAD_CAST "in");
 
174
 
 
175
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "src", BAD_CAST (*il).img_begin->img.c_str ());
 
176
 
 
177
              strflx.str ("");
 
178
              strflx << (*il).img_begin->width;
 
179
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "width", BAD_CAST strflx.str ().c_str ());
 
180
 
 
181
              strflx.str ("");
 
182
              strflx << (*il).img_begin->height;
 
183
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "height", BAD_CAST strflx.str ().c_str ());
 
184
              rc = xmlTextWriterEndElement (writer);
 
185
            }
 
186
          /*
 
187
           * Element thumb 
 
188
           */
 
189
          if (f->get_thumb())
 
190
            {
 
191
              rc = xmlTextWriterStartElement (writer, BAD_CAST "img");
 
192
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "size", BAD_CAST "thumb");
 
193
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "type", BAD_CAST "in");
 
194
 
 
195
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "src", BAD_CAST (*il).img_begin->thumb.c_str ());
 
196
 
 
197
              strflx.str ("");
 
198
              strflx << (*il).img_begin->width_thumb;
 
199
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "width", BAD_CAST strflx.str ().c_str ());
 
200
 
 
201
              strflx.str ("");
 
202
              strflx << (*il).img_begin->height_thumb;
 
203
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "height", BAD_CAST strflx.str ().c_str ());
 
204
              rc = xmlTextWriterEndElement (writer);
 
205
            }
 
206
        }
 
207
 
 
208
 
 
209
      if ((*il).img_end != NULL)
 
210
        {
 
211
          /*
 
212
           * Element image 
 
213
           */
 
214
          if (f->get_shot())
 
215
            {
 
216
              rc = xmlTextWriterStartElement (writer, BAD_CAST "img");
 
217
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "size", BAD_CAST "original");
 
218
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "type", BAD_CAST "out");
 
219
 
 
220
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "src", BAD_CAST (*il).img_end->img.c_str ());
 
221
 
 
222
              strflx.str ("");
 
223
              strflx << (*il).img_end->width;
 
224
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "width", BAD_CAST strflx.str ().c_str ());
 
225
 
 
226
              strflx.str ("");
 
227
              strflx << (*il).img_end->height;
 
228
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "height", BAD_CAST strflx.str ().c_str ());
 
229
              rc = xmlTextWriterEndElement (writer);
 
230
            }
 
231
          /*
 
232
           * Element thumb 
 
233
           */
 
234
          if (f->get_shot())
 
235
            {
 
236
              rc = xmlTextWriterStartElement (writer, BAD_CAST "img");
 
237
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "size", BAD_CAST "thumb");
 
238
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "type", BAD_CAST "out");
 
239
 
 
240
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "src", BAD_CAST (*il).img_end->thumb.c_str ());
 
241
 
 
242
              strflx.str ("");
 
243
              strflx << (*il).img_end->width_thumb;
 
244
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "width", BAD_CAST strflx.str ().c_str ());
 
245
 
 
246
              strflx.str ("");
 
247
              strflx << (*il).img_end->height_thumb;
 
248
              rc = xmlTextWriterWriteAttribute (writer, BAD_CAST "height", BAD_CAST strflx.str ().c_str ());
 
249
              rc = xmlTextWriterEndElement (writer);
 
250
            }
 
251
 
 
252
        }
 
253
      xmlTextWriterEndElement (writer);
 
254
 
 
255
    }
 
256
 
 
257
  rc = xmlTextWriterEndDocument (writer);
 
258
  if (rc < 0)
 
259
    {
 
260
      printf ("testXmlwriterDoc: Error at xmlTextWriterEndDocument\n");
 
261
      return;
 
262
    }
 
263
 
 
264
  xmlFreeTextWriter (writer);
 
265
  string xml_path;
 
266
  xml_path = f->get_opath();
 
267
  xml_path += "/result.xml";
 
268
  xmlSaveFileEnc (xml_path.c_str (), doc, MY_ENCODING);
 
269
  xmlFreeDoc (doc);
 
270
 
 
271
}
 
272
 
 
273
xml::xml (film * t)
 
274
{
 
275
  this->f = t;
 
276
}
 
277
 
 
278
xml::~xml ()
 
279
{
 
280
}