linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Linphone-developers] Not able to Record the sound from the MIC


From: rajasekar bonthala
Subject: [Linphone-developers] Not able to Record the sound from the MIC
Date: Thu, 23 Nov 2006 19:11:53 +0530

Hi,

I tried recording sound from MIC (/dev/dsp) so that I can use the same to send using ORTP to the receiver side.
But nuthing is getting played on the receiver side. But instead of sending audio from MIC , if i send some wav file from SENDER to RECEIVER thru ORTP, receiver was able to hear the wav file sound. So I guess some problem in recording from my side. Can anyone please guide me how to write a code to record sound from MIC. I am working on LINUX i386 machine.
I pasted my code below.

Thanks,
RajaSekhar

//#include <ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/soundcard.h>
#include <stdio.h>

main()
{
  int read_fd = -1;
  int write_fd = -1;
  int format = AFMT_S16_LE;
  int stereo = 0;
  int speed  = 8000;
  char buff[102400];
  int bytes = 0;
  read_fd = open("/dev/dsp",O_RDONLY);
  write_fd = open("sound.wav",O_WRONLY);
  if((read_fd < 0) || (write_fd < 0))
  {
    printf("\n Cannot open the file \n");
    return -1;
  }
  ioctl(read_fd, SNDCTL_DSP_RESET, 0);
  ioctl(read_fd, SNDCTL_DSP_SETFMT, &format);
  ioctl(read_fd, SNDCTL_DSP_STEREO, &stereo);
  ioctl(read_fd, SNDCTL_DSP_SPEED, &speed);

  bytes = read(read_fd, buff,102400);
  if(bytes <= 0)
  {
    printf("\n Zero Bytes have been read\n");
  }
  else
  {
    bytes = write(write_fd,buff,102400);
    printf("\n Bytes written is %d\n",bytes);
  }
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]