~ubuntu-branches/ubuntu/precise/liboggz/precise

« back to all changes in this revision

Viewing changes to doc/liboggz/html/group__hungry.html

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Wilkinson
  • Date: 2005-04-16 01:19:44 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050416011944-5ipwrrc260ihkpp8
Tags: 0.9.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
<title>liboggz: Writing with OggzHungry callbacks</title>
4
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
5
</head><body>
6
 
<!-- Generated by Doxygen 1.3.5 -->
7
 
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="globals.html">Globals</a></div>
 
6
<!-- Generated by Doxygen 1.4.0 -->
 
7
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="globals.html">Globals</a></div>
8
8
<h1>Writing with OggzHungry callbacks</h1>An OggzHungry callback will:<ul>
9
9
<li>Create an <em>ogg_packet</em> structure</li><li>Add it to the packet queue with <a class="el" href="group__write__api.html#ga2">oggz_write_feed()</a></li></ul>
10
10
<p>
13
13
<div align="center">
14
14
<img src="hungry.png" alt="hungry.png">
15
15
</div>
16
 
<p>
 
16
 <p>
17
17
The following example code generates a stream of ten packets, each containing a single byte ('A', 'B', ... , 'J'):<p>
18
 
<div class="fragment"><pre>
 
18
<div class="fragment"><pre class="fragment">
19
19
<span class="preprocessor">#include &lt;stdlib.h&gt;</span> <span class="comment">/* exit */</span>
20
20
<span class="preprocessor">#include &lt;<a class="code" href="oggz_8h.html">oggz/oggz.h</a>&gt;</span>
21
21
 
24
24
<span class="keyword">static</span> ogg_int64_t packetno = 0;
25
25
 
26
26
<span class="keyword">static</span> <span class="keywordtype">int</span>
27
 
hungry (<a class="code" href="oggz_8h.html#a0">OGGZ</a> * oggz, <span class="keywordtype">int</span> empty, <span class="keywordtype">void</span> * user_data)
 
27
hungry (OGGZ * oggz, <span class="keywordtype">int</span> empty, <span class="keywordtype">void</span> * user_data)
28
28
{
29
29
  ogg_packet op;
30
30
  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> buf[1];
31
31
 
32
 
  buf[0] = <span class="charliteral">'A'</span> + (<span class="keywordtype">int</span>)packetno;
 
32
  buf[0] = <span class="charliteral">'A'</span> + (int)packetno;
33
33
 
34
34
  op.packet = buf;
35
35
  op.bytes = 1;
37
37
  op.packetno = packetno;
38
38
 
39
39
  <span class="keywordflow">if</span> (packetno == 0) op.b_o_s = 1;
40
 
  <span class="keywordflow">else</span> op.b_o_s = 0;
41
 
 
42
 
  <span class="keywordflow">if</span> (packetno == 9) op.e_o_s = 1;
43
 
  <span class="keywordflow">else</span> op.e_o_s = 0;
44
 
 
45
 
  <a class="code" href="group__write__api.html#ga2">oggz_write_feed</a> (oggz, &amp;op, serialno, OGGZ_FLUSH_AFTER, NULL);
 
40
  else op.b_o_s = 0;
 
41
 
 
42
  if (packetno == 9) op.e_o_s = 1;
 
43
  else op.e_o_s = 0;
 
44
 
 
45
  oggz_write_feed (oggz, &amp;op, serialno, OGGZ_FLUSH_AFTER, NULL);
46
46
 
47
47
  granulepos += 100;
48
48
  packetno++;
49
49
 
50
 
  <span class="keywordflow">return</span> 0;
 
50
  return 0;
51
51
}
52
52
 
53
53
<span class="keywordtype">int</span>
60
60
  progname = argv[0];
61
61
  <span class="keywordflow">if</span> (argc &gt; 1) filename = argv[1];
62
62
 
63
 
  <span class="keywordflow">if</span> (filename) {
64
 
    oggz = <a class="code" href="oggz_8h.html#a5">oggz_open</a> (filename, OGGZ_WRITE);
 
63
  if (filename) {
 
64
    oggz = <a class="code" href="oggz_8h.html#a2">oggz_open</a> (filename, OGGZ_WRITE);
65
65
  } <span class="keywordflow">else</span> {
66
 
    oggz = <a class="code" href="oggz_8h.html#a6">oggz_open_stdio</a> (stdout, OGGZ_WRITE);
 
66
    oggz = <a class="code" href="oggz_8h.html#a3">oggz_open_stdio</a> (stdout, OGGZ_WRITE);
67
67
  }
68
68
 
69
69
  <span class="keywordflow">if</span> (oggz == NULL) {
71
71
    exit (1);
72
72
  }
73
73
 
74
 
  serialno = <a class="code" href="oggz_8h.html#a27">oggz_serialno_new</a> (oggz);
 
74
  serialno = <a class="code" href="oggz_8h.html#a8">oggz_serialno_new</a> (oggz);
75
75
 
76
 
  <span class="keywordflow">if</span> (<a class="code" href="group__write__api.html#ga1">oggz_write_set_hungry_callback</a> (oggz, hungry, 1, NULL) == -1) {
 
76
  <span class="keywordflow">if</span> (oggz_write_set_hungry_callback (oggz, hungry, 1, NULL) == -1) {
77
77
    fprintf (stderr, <span class="stringliteral">"%s: Error setting OggzHungry callback\n"</span>, progname);
78
78
    exit (1);
79
79
  }
80
80
 
81
 
  <span class="keywordflow">while</span> ((n = <a class="code" href="group__write__api.html#ga4">oggz_write</a> (oggz, 32)) &gt; 0);
 
81
  <span class="keywordflow">while</span> ((n = oggz_write (oggz, 32)) &gt; 0);
82
82
 
83
 
  <a class="code" href="oggz_8h.html#a8">oggz_close</a> (oggz);
 
83
  <a class="code" href="oggz_8h.html#a5">oggz_close</a> (oggz);
84
84
 
85
85
  exit (0);
86
86
}
87
87
</pre></div> 
88
88
<p>
89
 
<table border=0 cellpadding=0 cellspacing=0>
 
89
<table border="0" cellpadding="0" cellspacing="0">
90
90
<tr><td></td></tr>
91
91
</table>
92
 
<hr size="1"><address style="align: right;"><small>Generated on Thu Mar 11 13:02:14 2004 for liboggz by
 
92
<hr size="1"><address style="align: right;"><small>Generated on Fri Apr 8 23:36:18 2005 for liboggz by&nbsp;
93
93
<a href="http://www.doxygen.org/index.html">
94
 
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
95
 
</a>1.3.5 </small></address>
 
94
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.0 </small></address>
96
95
</body>
97
96
</html>