encode wave to ogg vorbis

Hello,
i would encode a wavebuffer to the oggvorbis.

My actually code is like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
HWAVEIN hWaveIn;
WAVEHDR WaveHdrIn[AUDIOBUFS];
BYTE BufferIn[AUDIOBUFS][BUFSIZE];

DWORD WINAPI WaveInThread (void *Arg)
{
  MSG Msg;
  int rv;

  rv = SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL);
  winexit_if(0 == rv, hWindow, "SetThreadPriority failed");

  while (GetMessage (&Msg, NULL, 0, 0) == TRUE) {
    if (MM_WIM_DATA == Msg.message) {
      int rv = 0;
      WAVEHDR *Hdr = (WAVEHDR *) Msg.lParam;

      EnterCriticalSection(&remotefd_sem);
      if (remotefd != INVALID_SOCKET) {
        rv = sendto(remotefd, Hdr->lpData, sizeof(BufferIn[0]), 0, 
                             (struct sockaddr *) &remote, sizeof(remote));
        if (rv < 0) {
          closesocket(remotefd);
          remotefd = INVALID_SOCKET;
        }
      }
      LeaveCriticalSection(&remotefd_sem);
      waveInAddBuffer(hWaveIn, Hdr, sizeof(*Hdr));
      if (rv < 0) MessageBox(hWindow, "sendto failed", "WARNING", MB_OK);
    }
  }
  return 0; 
}

BOOL CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{
  switch (msg) {
    case WM_INITDIALOG: {      
      WSADATA wsaData;
      int rv;
      int i;
      WAVEFORMATEX waveform;
      HANDLE WaveInThreadHandle;
      DWORD WaveInThreadId;
      
      hWindow = hWnd;

      // Init Netzwerk
      rv = WSAStartup(MAKEWORD(2, 2), &wsaData);
      winexit_if(rv != 0, hWnd, "WSAStartup failed");

      // Init Audio
      waveform.nChannels = AUDIOCHANNELS;
      waveform.wBitsPerSample = 8;
      waveform.nAvgBytesPerSec = AUDIOSPEED * waveform.nChannels * waveform.wBitsPerSample / 8;
      waveform.wFormatTag = AUDIOFORMAT;
      waveform.nSamplesPerSec = AUDIOSPEED;
      waveform.nBlockAlign = 1;
      waveform.cbSize = 0;

      WaveInThreadHandle = CreateThread(NULL, 0, WaveInThread, NULL, 0, &WaveInThreadId);
      winexit_if(NULL == WaveInThreadHandle, hWnd, "CreateThread failed");

      rv = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveform, (DWORD)WaveInThreadId,0,CALLBACK_THREAD);
      winexit_if(rv != MMSYSERR_NOERROR, hWnd, "waveInOpen failed f");

      for (i = 0; i < AUDIOBUFS; ++i) {
        WaveHdrIn[i].lpData = BufferIn[i];
        WaveHdrIn[i].dwBufferLength = sizeof(BufferIn[0]);
        WaveHdrIn[i].dwBytesRecorded = 0;
        WaveHdrIn[i].dwUser = 0;
        WaveHdrIn[i].dwFlags = 0;
        WaveHdrIn[i].dwLoops = 0;
        WaveHdrIn[i].lpNext = NULL;
        WaveHdrIn[i].reserved = 0;
        waveInPrepareHeader(hWaveIn, WaveHdrIn + i, sizeof(WaveHdrIn[0]));
        waveInAddBuffer(hWaveIn, WaveHdrIn + i, sizeof(WaveHdrIn[0]));
      }

      waveInStart(hWaveIn);   // starte Aufnahme
      break;
    }


How can i encode the firstly wave?
I would handle with the microphon stream as wave. Only one step befor i send it with a socket i would encode it to ogg.
I finde the Page of the Ogg Vorbis Project, but i cant understand the message behind the libary and the project has not a board for questions.
http://www.xiph.org/ogg/doc/libogg/encoding.html


PS. Sorry for my bad english.
Windows Programming Forum?
hmm, i cant see a coherence between the winapi and ogg but i am ignoramus and set a link to this Topic.
Topic archived. No new replies allowed.