Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-release > by-pkgid > 1b812d1b0e765bcc0430721ff58676d2 > files > 320

libid3_3.8_3-devel-3.8.3-19.mga1.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>id3lib: src/tag_render.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="id3lib.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>src/tag_render.cpp</h1><a href="tag__render_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// $Id: tag_render.cpp,v 1.44 2002/07/31 13:20:49 t1mpy Exp $</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="comment">// id3lib: a C++ library for creating and manipulating id3v1/v2 tags</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright 1999, 2000  Scott Thomas Haug</span>
<a name="l00005"></a>00005 <span class="comment">// Copyright 2002  Thijmen Klok (thijmen@id3lib.org)</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="comment">// This library is free software; you can redistribute it and/or modify it</span>
<a name="l00008"></a>00008 <span class="comment">// under the terms of the GNU Library General Public License as published by</span>
<a name="l00009"></a>00009 <span class="comment">// the Free Software Foundation; either version 2 of the License, or (at your</span>
<a name="l00010"></a>00010 <span class="comment">// option) any later version.</span>
<a name="l00011"></a>00011 <span class="comment">//</span>
<a name="l00012"></a>00012 <span class="comment">// This library is distributed in the hope that it will be useful, but WITHOUT</span>
<a name="l00013"></a>00013 <span class="comment">// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span>
<a name="l00014"></a>00014 <span class="comment">// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public</span>
<a name="l00015"></a>00015 <span class="comment">// License for more details.</span>
<a name="l00016"></a>00016 <span class="comment">//</span>
<a name="l00017"></a>00017 <span class="comment">// You should have received a copy of the GNU Library General Public License</span>
<a name="l00018"></a>00018 <span class="comment">// along with this library; if not, write to the Free Software Foundation,</span>
<a name="l00019"></a>00019 <span class="comment">// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="comment">// The id3lib authors encourage improvements and optimisations to be sent to</span>
<a name="l00022"></a>00022 <span class="comment">// the id3lib coordinator.  Please see the README file for details on where to</span>
<a name="l00023"></a>00023 <span class="comment">// send such submissions.  See the AUTHORS file for a list of people who have</span>
<a name="l00024"></a>00024 <span class="comment">// contributed to id3lib.  See the ChangeLog file for a list of changes to</span>
<a name="l00025"></a>00025 <span class="comment">// id3lib.  These files are distributed with id3lib at</span>
<a name="l00026"></a>00026 <span class="comment">// http://download.sourceforge.net/id3lib/</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;memory.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="tag__impl_8h.html">tag_impl.h</a>&quot;</span> <span class="comment">//has &lt;stdio.h&gt; &quot;tag.h&quot; &quot;header_tag.h&quot; &quot;frame.h&quot; &quot;field.h&quot; &quot;spec.h&quot; &quot;id3lib_strings.h&quot; &quot;utils.h&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;helpers.h&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;<a class="code" href="writers_8h.html">writers.h</a>&quot;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="io__decorators_8h.html">id3/io_decorators.h</a>&quot;</span> <span class="comment">//has &quot;readers.h&quot; &quot;io_helpers.h&quot; &quot;utils.h&quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;<a class="code" href="io__helpers_8h.html">io_helpers.h</a>&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="io__strings_8h.html">io_strings.h</a>&quot;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#if defined HAVE_SYS_PARAM_H</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#include &lt;sys/param.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="keyword">using namespace </span>dami;
<a name="l00041"></a>00041 
<a name="l00042"></a><a class="code" href="namespacedami_1_1id3_1_1v1.html#aeb5143c535f4bc42e6e13b429e4197e5">00042</a> <span class="keywordtype">void</span> <a class="code" href="namespacedami_1_1id3_1_1v1.html#aeb5143c535f4bc42e6e13b429e4197e5">id3::v1::render</a>(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, <span class="keyword">const</span> <a class="code" href="class_i_d3___tag_impl.html">ID3_TagImpl</a>&amp; tag)
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044   writer.<a class="code" href="class_i_d3___writer.html#a287fd94f06b37fb638029b904e6f1d42" title="Write up to len characters into buf and advance the internal position accordingly...">writeChars</a>(<span class="stringliteral">&quot;TAG&quot;</span>, 3);
<a name="l00045"></a>00045   
<a name="l00046"></a>00046   <a class="code" href="namespacedami_1_1io.html#a48c5360321d009c714964e09953ba134">io::writeTrailingSpaces</a>(writer, id3::v2::getTitle(tag),  <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a9081b85c7be8c29d9586ed3f42e9c5d1">ID3_V1_LEN_TITLE</a>);
<a name="l00047"></a>00047   <a class="code" href="namespacedami_1_1io.html#a48c5360321d009c714964e09953ba134">io::writeTrailingSpaces</a>(writer, id3::v2::getArtist(tag), <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a318eb86fac786d3effe37c3693eb7eb7">ID3_V1_LEN_ARTIST</a>);
<a name="l00048"></a>00048   <a class="code" href="namespacedami_1_1io.html#a48c5360321d009c714964e09953ba134">io::writeTrailingSpaces</a>(writer, id3::v2::getAlbum(tag),  <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a44c89fcc302b16d506d6cc8ad49db82f">ID3_V1_LEN_ALBUM</a>);
<a name="l00049"></a>00049   <a class="code" href="namespacedami_1_1io.html#a48c5360321d009c714964e09953ba134">io::writeTrailingSpaces</a>(writer, id3::v2::getYear(tag),   <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843a2abe844d83449a5bda450d75d803c23c">ID3_V1_LEN_YEAR</a>);
<a name="l00050"></a>00050   
<a name="l00051"></a>00051   <span class="keywordtype">size_t</span> track = id3::v2::getTrackNum(tag);
<a name="l00052"></a>00052   String comment = id3::v2::getV1Comment(tag);
<a name="l00053"></a>00053   <span class="keywordflow">if</span> (track &gt; 0)
<a name="l00054"></a>00054   {
<a name="l00055"></a>00055     <a class="code" href="namespacedami_1_1io.html#a48c5360321d009c714964e09953ba134">io::writeTrailingSpaces</a>(writer, comment, <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843ab769f0f0de48ff0c8abff72106c25e4c">ID3_V1_LEN_COMMENT</a> - 2);
<a name="l00056"></a>00056     writer.<a class="code" href="class_i_d3___writer.html#a2fd7fda2100f38a45038b80de8ed4432" title="Write a single character and advance the internal position.">writeChar</a>(<span class="charliteral">&#39;\0&#39;</span>);
<a name="l00057"></a>00057     writer.<a class="code" href="class_i_d3___writer.html#a2fd7fda2100f38a45038b80de8ed4432" title="Write a single character and advance the internal position.">writeChar</a>((<span class="keywordtype">char</span>) track);
<a name="l00058"></a>00058   }
<a name="l00059"></a>00059   <span class="keywordflow">else</span>
<a name="l00060"></a>00060   {
<a name="l00061"></a>00061     <a class="code" href="namespacedami_1_1io.html#a48c5360321d009c714964e09953ba134">io::writeTrailingSpaces</a>(writer, comment, <a class="code" href="globals_8h.html#af5c00561c08372185f9acec6fffc0843ab769f0f0de48ff0c8abff72106c25e4c">ID3_V1_LEN_COMMENT</a>);
<a name="l00062"></a>00062   }
<a name="l00063"></a>00063   writer.<a class="code" href="class_i_d3___writer.html#a2fd7fda2100f38a45038b80de8ed4432" title="Write a single character and advance the internal position.">writeChar</a>((<span class="keywordtype">char</span>) id3::v2::getGenreNum(tag));
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 <span class="keyword">namespace</span>
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068   <span class="keywordtype">void</span> renderFrames(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, <span class="keyword">const</span> <a class="code" href="class_i_d3___tag_impl.html">ID3_TagImpl</a>&amp; tag)
<a name="l00069"></a>00069   {
<a name="l00070"></a>00070     <span class="keywordflow">for</span> (<a class="code" href="class_i_d3___tag_impl.html#aa682023c07df47c19db046540d260d08">ID3_TagImpl::const_iterator</a> iter = tag.<a class="code" href="class_i_d3___tag_impl.html#a9e0d55c54fb3697b9ebb34d060bfa101">begin</a>(); iter != tag.<a class="code" href="class_i_d3___tag_impl.html#af20fcbf50b599ea55b0ec955bcad1a9d">end</a>(); ++iter)
<a name="l00071"></a>00071     {
<a name="l00072"></a>00072       <span class="keyword">const</span> <a class="code" href="class_i_d3___frame.html" title="The representative class of an id3v2 frame.">ID3_Frame</a>* frame = *iter;
<a name="l00073"></a>00073       <span class="keywordflow">if</span> (frame) frame-&gt;Render(writer);
<a name="l00074"></a>00074     }
<a name="l00075"></a>00075   }
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 
<a name="l00078"></a><a class="code" href="namespacedami_1_1id3_1_1v2.html#a59ee58381f7a615cc27b39990d39585f">00078</a> <span class="keywordtype">void</span> <a class="code" href="namespacedami_1_1id3_1_1v1.html#aeb5143c535f4bc42e6e13b429e4197e5">id3::v2::render</a>(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, <span class="keyword">const</span> <a class="code" href="class_i_d3___tag_impl.html">ID3_TagImpl</a>&amp; tag)
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080   <span class="comment">// There has to be at least one frame for there to be a tag...</span>
<a name="l00081"></a>00081   <span class="keywordflow">if</span> (tag.<a class="code" href="class_i_d3___tag_impl.html#a3b8ddbfa27a87dc083bce598a15a3881">NumFrames</a>() == 0)
<a name="l00082"></a>00082   {
<a name="l00083"></a>00083     ID3D_WARNING( <span class="stringliteral">&quot;id3::v2::render(): no frames to render&quot;</span> );
<a name="l00084"></a>00084     <span class="keywordflow">return</span>;
<a name="l00085"></a>00085   }
<a name="l00086"></a>00086   
<a name="l00087"></a>00087   ID3D_NOTICE( <span class="stringliteral">&quot;id3::v2::render(): rendering&quot;</span> );
<a name="l00088"></a>00088   <a class="code" href="class_i_d3___tag_header.html">ID3_TagHeader</a> hdr;
<a name="l00089"></a>00089   hdr.<a class="code" href="class_i_d3___tag_header.html#a8c662dcf0cdb4a9ec5c06ee05b5210d4">SetSpec</a>(tag.<a class="code" href="class_i_d3___tag_impl.html#aaa19382ddecd2604e88c086c8ccd3982">GetSpec</a>());
<a name="l00090"></a>00090   hdr.<a class="code" href="class_i_d3___tag_header.html#abe86794051e52ed8cb749f53f953a918">SetExtended</a>(tag.<a class="code" href="class_i_d3___tag_impl.html#a1d01fe225c2e1f30ebf9d00d81f2acac">GetExtended</a>());
<a name="l00091"></a>00091   hdr.<a class="code" href="class_i_d3___tag_header.html#a14de3c5870cbd470f6d7d16855553389">SetExperimental</a>(tag.<a class="code" href="class_i_d3___tag_impl.html#ae6c469a8e6d84b395a18d31069ad15c5">GetExperimental</a>());
<a name="l00092"></a>00092   hdr.<a class="code" href="class_i_d3___tag_header.html#a4fb4f83562d9025234fc6ca8d9b758df">SetFooter</a>(tag.<a class="code" href="class_i_d3___tag_impl.html#a139154fd732f350293afe1e1bf382dd2">GetFooter</a>());
<a name="l00093"></a>00093     
<a name="l00094"></a>00094   <span class="comment">// set up the encryption and grouping IDs</span>
<a name="l00095"></a>00095 
<a name="l00096"></a>00096   <span class="comment">// ...</span>
<a name="l00097"></a>00097   String frms;
<a name="l00098"></a>00098   <a class="code" href="classdami_1_1io_1_1_string_writer.html">io::StringWriter</a> frmWriter(frms);
<a name="l00099"></a>00099   <span class="keywordflow">if</span> (!tag.<a class="code" href="class_i_d3___tag_impl.html#ae53a990acbed33819a48dfad94a16df9">GetUnsync</a>())
<a name="l00100"></a>00100   {
<a name="l00101"></a>00101     ID3D_NOTICE( <span class="stringliteral">&quot;id3::v2::render(): rendering frames&quot;</span> );
<a name="l00102"></a>00102     renderFrames(frmWriter, tag);
<a name="l00103"></a>00103     hdr.<a class="code" href="class_i_d3___tag_header.html#ad2fc7cf544516829a72f6fe9385d963c">SetUnsync</a>(<span class="keyword">false</span>);
<a name="l00104"></a>00104   }
<a name="l00105"></a>00105   <span class="keywordflow">else</span>
<a name="l00106"></a>00106   {
<a name="l00107"></a>00107     ID3D_NOTICE( <span class="stringliteral">&quot;id3::v2::render(): rendering unsynced frames&quot;</span> );
<a name="l00108"></a>00108     <a class="code" href="classdami_1_1io_1_1_unsynced_writer.html">io::UnsyncedWriter</a> uw(frmWriter);
<a name="l00109"></a>00109     renderFrames(uw, tag);
<a name="l00110"></a>00110     uw.<a class="code" href="classdami_1_1io_1_1_unsynced_writer.html#aa55a7e411535e4bada76e7c831b4679a" title="Flush the writer.">flush</a>();
<a name="l00111"></a>00111     ID3D_NOTICE( <span class="stringliteral">&quot;id3::v2::render(): numsyncs = &quot;</span> &lt;&lt; uw.<a class="code" href="classdami_1_1io_1_1_unsynced_writer.html#a6dd0f4d7b03af3e5e2a749ed8e82b8c3">getNumSyncs</a>() );
<a name="l00112"></a>00112     hdr.<a class="code" href="class_i_d3___tag_header.html#ad2fc7cf544516829a72f6fe9385d963c">SetUnsync</a>(uw.<a class="code" href="classdami_1_1io_1_1_unsynced_writer.html#a6dd0f4d7b03af3e5e2a749ed8e82b8c3">getNumSyncs</a>() &gt; 0);
<a name="l00113"></a>00113   }
<a name="l00114"></a>00114   <span class="keywordtype">size_t</span> frmSize = frms.size();
<a name="l00115"></a>00115   <span class="keywordflow">if</span> (frmSize == 0)
<a name="l00116"></a>00116   {
<a name="l00117"></a>00117     ID3D_WARNING( <span class="stringliteral">&quot;id3::v2::render(): rendered frame size is 0 bytes&quot;</span> );
<a name="l00118"></a>00118     <span class="keywordflow">return</span>;
<a name="l00119"></a>00119   }
<a name="l00120"></a>00120   
<a name="l00121"></a>00121   <span class="comment">// zero the remainder of the buffer so that our padding bytes are zero</span>
<a name="l00122"></a>00122   <a class="code" href="globals_8h.html#a31c81a77cfd373514f7878719897fca6">luint</a> nPadding = tag.<a class="code" href="class_i_d3___tag_impl.html#a40172ff4497eb53ab73eacdae4fe9e0b">PaddingSize</a>(frmSize);
<a name="l00123"></a>00123   ID3D_NOTICE( <span class="stringliteral">&quot;id3::v2::render(): padding size = &quot;</span> &lt;&lt; nPadding );
<a name="l00124"></a>00124   
<a name="l00125"></a>00125   hdr.<a class="code" href="class_i_d3___header.html#a59ca0d4289297b721cffdc1c33014d5c">SetDataSize</a>(frmSize + tag.<a class="code" href="class_i_d3___tag_impl.html#acc2c9a233d8cda42e6d3fc5ffdd14ca3">GetExtendedBytes</a>() + nPadding);
<a name="l00126"></a>00126   
<a name="l00127"></a>00127   hdr.<a class="code" href="class_i_d3___tag_header.html#ad52a90ddf66bfff6fbf924747453af81">Render</a>(writer);
<a name="l00128"></a>00128 
<a name="l00129"></a>00129   writer.<a class="code" href="class_i_d3___writer.html#a287fd94f06b37fb638029b904e6f1d42" title="Write up to len characters into buf and advance the internal position accordingly...">writeChars</a>(frms.data(), frms.size());
<a name="l00130"></a>00130 
<a name="l00131"></a>00131   <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; nPadding; ++i)
<a name="l00132"></a>00132   {
<a name="l00133"></a>00133     <span class="keywordflow">if</span> (writer.<a class="code" href="class_i_d3___writer.html#a2fd7fda2100f38a45038b80de8ed4432" title="Write a single character and advance the internal position.">writeChar</a>(<span class="charliteral">&#39;\0&#39;</span>) == <a class="code" href="class_i_d3___writer.html#ad86a1c643939307f19d311d8e272a68b">ID3_Writer::END_OF_WRITER</a>)
<a name="l00134"></a>00134     {
<a name="l00135"></a>00135       <span class="keywordflow">break</span>;
<a name="l00136"></a>00136     }
<a name="l00137"></a>00137   }
<a name="l00138"></a>00138 }
<a name="l00139"></a>00139 
<a name="l00140"></a><a class="code" href="class_i_d3___tag_impl.html#ad2c9a88974f03858820ab5e3aa7a2fb2">00140</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___tag_impl.html#ad2c9a88974f03858820ab5e3aa7a2fb2">ID3_TagImpl::Size</a>()<span class="keyword"> const</span>
<a name="l00141"></a>00141 <span class="keyword"></span>{
<a name="l00142"></a>00142   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a3b8ddbfa27a87dc083bce598a15a3881">NumFrames</a>() == 0)
<a name="l00143"></a>00143   {
<a name="l00144"></a>00144     <span class="keywordflow">return</span> 0;
<a name="l00145"></a>00145   }
<a name="l00146"></a>00146   <a class="code" href="class_i_d3___tag_header.html">ID3_TagHeader</a> hdr;
<a name="l00147"></a>00147 
<a name="l00148"></a>00148   hdr.<a class="code" href="class_i_d3___tag_header.html#a8c662dcf0cdb4a9ec5c06ee05b5210d4">SetSpec</a>(this-&gt;<a class="code" href="class_i_d3___tag_impl.html#aaa19382ddecd2604e88c086c8ccd3982">GetSpec</a>());
<a name="l00149"></a>00149   <span class="keywordtype">size_t</span> bytesUsed = hdr.<a class="code" href="class_i_d3___tag_header.html#ac84d93b59696e0a75688486543f71024">Size</a>();
<a name="l00150"></a>00150   
<a name="l00151"></a>00151   <span class="keywordtype">size_t</span> frameBytes = 0;
<a name="l00152"></a>00152   <span class="keywordflow">for</span> (<a class="code" href="class_i_d3___tag_impl.html#aa682023c07df47c19db046540d260d08">const_iterator</a> cur = _frames.begin(); cur != _frames.end(); ++cur)
<a name="l00153"></a>00153   {
<a name="l00154"></a>00154     <span class="keywordflow">if</span> (*cur)
<a name="l00155"></a>00155     {
<a name="l00156"></a>00156       (*cur)-&gt;SetSpec(this-&gt;<a class="code" href="class_i_d3___tag_impl.html#aaa19382ddecd2604e88c086c8ccd3982">GetSpec</a>());
<a name="l00157"></a>00157       frameBytes += (*cur)-&gt;Size();
<a name="l00158"></a>00158     }
<a name="l00159"></a>00159   }
<a name="l00160"></a>00160   
<a name="l00161"></a>00161   <span class="keywordflow">if</span> (!frameBytes)
<a name="l00162"></a>00162   {
<a name="l00163"></a>00163     <span class="keywordflow">return</span> 0;
<a name="l00164"></a>00164   }
<a name="l00165"></a>00165   
<a name="l00166"></a>00166   bytesUsed += frameBytes;
<a name="l00167"></a>00167   <span class="comment">// add 30% for sync</span>
<a name="l00168"></a>00168   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___tag_impl.html#ae53a990acbed33819a48dfad94a16df9">GetUnsync</a>())
<a name="l00169"></a>00169   {
<a name="l00170"></a>00170     bytesUsed += bytesUsed / 3;
<a name="l00171"></a>00171   }
<a name="l00172"></a>00172     
<a name="l00173"></a>00173   bytesUsed += this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a40172ff4497eb53ab73eacdae4fe9e0b">PaddingSize</a>(bytesUsed);
<a name="l00174"></a>00174   <span class="keywordflow">return</span> bytesUsed;
<a name="l00175"></a>00175 }
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 
<a name="l00178"></a><a class="code" href="class_i_d3___tag_impl.html#aab5b8ba999e4f7430729cbd5d9fd0454">00178</a> <span class="keywordtype">void</span> <a class="code" href="class_i_d3___tag_impl.html#aab5b8ba999e4f7430729cbd5d9fd0454">ID3_TagImpl::RenderExtHeader</a>(<a class="code" href="globals_8h.html#a65f85814a8290f9797005d3b28e7e5fc">uchar</a> *buffer)
<a name="l00179"></a>00179 {
<a name="l00180"></a>00180   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___tag_impl.html#aaa19382ddecd2604e88c086c8ccd3982">GetSpec</a>() == <a class="code" href="globals_8h.html#a48b13eb6cb3c520195901516dee1e612af1a537f047f6947efbc735bd0685a9df">ID3V2_3_0</a>)
<a name="l00181"></a>00181   {
<a name="l00182"></a>00182   }
<a name="l00183"></a>00183   
<a name="l00184"></a>00184   return ;
<a name="l00185"></a>00185 }
<a name="l00186"></a>00186 
<a name="l00187"></a>00187 
<a name="l00188"></a><a class="code" href="tag__render_8cpp.html#ab373932fb4a53544ab281f2094d6205d">00188</a> <span class="preprocessor">#define ID3_PADMULTIPLE (2048)</span>
<a name="l00189"></a><a class="code" href="tag__render_8cpp.html#ab2a1fa16a25bc8e3b8aa28b1a2b6b6c5">00189</a> <span class="preprocessor"></span><span class="preprocessor">#define ID3_PADMAX  (4096)</span>
<a name="l00190"></a>00190 <span class="preprocessor"></span>
<a name="l00191"></a>00191 
<a name="l00192"></a><a class="code" href="class_i_d3___tag_impl.html#a40172ff4497eb53ab73eacdae4fe9e0b">00192</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___tag_impl.html#a40172ff4497eb53ab73eacdae4fe9e0b">ID3_TagImpl::PaddingSize</a>(<span class="keywordtype">size_t</span> curSize)<span class="keyword"> const</span>
<a name="l00193"></a>00193 <span class="keyword"></span>{
<a name="l00194"></a>00194   <a class="code" href="globals_8h.html#a31c81a77cfd373514f7878719897fca6">luint</a> newSize = 0;
<a name="l00195"></a>00195   
<a name="l00196"></a>00196   <span class="comment">// if padding is switched off</span>
<a name="l00197"></a>00197   <span class="keywordflow">if</span> (! _is_padded)
<a name="l00198"></a>00198   {
<a name="l00199"></a>00199     <span class="keywordflow">return</span> 0;
<a name="l00200"></a>00200   }
<a name="l00201"></a>00201     
<a name="l00202"></a>00202   <span class="comment">// if the old tag was large enough to hold the new tag, then we will simply</span>
<a name="l00203"></a>00203   <span class="comment">// pad out the difference - that way the new tag can be written without</span>
<a name="l00204"></a>00204   <span class="comment">// shuffling the rest of the song file around</span>
<a name="l00205"></a>00205   <span class="keywordflow">if</span> ((this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>()-<a class="code" href="class_i_d3___tag_header.html#a4182519e23dc329bdf25ab1213bd6096a74cf4937e78303a0b961dfb12c9f2b04">ID3_TagHeader::SIZE</a> &gt; 0) &amp;&amp;
<a name="l00206"></a>00206       (this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>()-<a class="code" href="class_i_d3___tag_header.html#a4182519e23dc329bdf25ab1213bd6096a74cf4937e78303a0b961dfb12c9f2b04">ID3_TagHeader::SIZE</a> &gt;= curSize) &amp;&amp; 
<a name="l00207"></a>00207       (this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>()-<a class="code" href="class_i_d3___tag_header.html#a4182519e23dc329bdf25ab1213bd6096a74cf4937e78303a0b961dfb12c9f2b04">ID3_TagHeader::SIZE</a> - curSize) &lt; <a class="code" href="tag__render_8cpp.html#ab2a1fa16a25bc8e3b8aa28b1a2b6b6c5">ID3_PADMAX</a>)
<a name="l00208"></a>00208   {
<a name="l00209"></a>00209     newSize = this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a9b2279334b6bc5f4a2564b529fe92b03">GetPrependedBytes</a>()-<a class="code" href="class_i_d3___tag_header.html#a4182519e23dc329bdf25ab1213bd6096a74cf4937e78303a0b961dfb12c9f2b04">ID3_TagHeader::SIZE</a>;
<a name="l00210"></a>00210   }
<a name="l00211"></a>00211   <span class="keywordflow">else</span>
<a name="l00212"></a>00212   {
<a name="l00213"></a>00213     <a class="code" href="globals_8h.html#a31c81a77cfd373514f7878719897fca6">luint</a> tempSize = curSize + <a class="code" href="tag__impl_8cpp.html#af1f761cbfe07a83bb9450ab5661bbbae">ID3_GetDataSize</a>(*<span class="keyword">this</span>) +
<a name="l00214"></a>00214                      this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a5bc6c9c5cd3eb1d1b23a7cd46ed0730d">GetAppendedBytes</a>() + <a class="code" href="class_i_d3___tag_header.html#a4182519e23dc329bdf25ab1213bd6096a74cf4937e78303a0b961dfb12c9f2b04">ID3_TagHeader::SIZE</a>;
<a name="l00215"></a>00215     
<a name="l00216"></a>00216     <span class="comment">// this method of automatic padding rounds the COMPLETE FILE up to the</span>
<a name="l00217"></a>00217     <span class="comment">// nearest 2K.  If the file will already be an even multiple of 2K (with</span>
<a name="l00218"></a>00218     <span class="comment">// the tag included) then we just add another 2K of padding</span>
<a name="l00219"></a>00219     tempSize = ((tempSize / <a class="code" href="tag__render_8cpp.html#ab373932fb4a53544ab281f2094d6205d">ID3_PADMULTIPLE</a>) + 1) * <a class="code" href="tag__render_8cpp.html#ab373932fb4a53544ab281f2094d6205d">ID3_PADMULTIPLE</a>;
<a name="l00220"></a>00220     
<a name="l00221"></a>00221     <span class="comment">// the size of the new tag is the new filesize minus the audio data</span>
<a name="l00222"></a>00222     newSize = tempSize - <a class="code" href="tag__impl_8cpp.html#af1f761cbfe07a83bb9450ab5661bbbae">ID3_GetDataSize</a>(*<span class="keyword">this</span>) - this-&gt;<a class="code" href="class_i_d3___tag_impl.html#a5bc6c9c5cd3eb1d1b23a7cd46ed0730d">GetAppendedBytes</a> () -
<a name="l00223"></a>00223               ID3_TagHeader::SIZE;
<a name="l00224"></a>00224   }
<a name="l00225"></a>00225   
<a name="l00226"></a>00226   <span class="keywordflow">return</span> newSize - curSize;
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Jan 12 23:46:36 2011 for id3lib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>