예제 #1
0
// returns bytes written, else -1 if error (0 is OK)
int AmAudio::put(unsigned long long system_ts, unsigned char* buffer, 
		 int input_sample_rate, unsigned int size)
{
  if(!size){
    return 0;
  }

  if(max_rec_time > -1 && rec_time >= max_rec_time)
    return -1;

  memcpy((unsigned char*)samples,buffer,size);
  size = resampleInput((unsigned char*)samples, size, 
		       input_sample_rate, getSampleRate());

  int s = encode(size);
  if(s>0){

    incRecordTime(bytes2samples(size));

    unsigned int wr_ts = scaleSystemTS(system_ts);
    //DBG("write(wr_ts = %10.u; s = %u)\n",wr_ts,s);
    return write(wr_ts,(unsigned int)s);
  }
  else{
    return s;
  }
}
예제 #2
0
int AmRtpAudio::put(unsigned long long system_ts, unsigned char* buffer, 
		    int input_sample_rate, unsigned int size)
{
  last_send_ts_i = true;
  last_send_ts = system_ts;

  if(!size){
    return 0;
  }

  if (mute) return 0;

  memcpy((unsigned char*)samples,buffer,size);
  size = resampleInput((unsigned char*)samples, size, 
		       input_sample_rate, getSampleRate());

  int s = encode(size);
  if(s<=0){
    return s;
  }

  AmAudioRtpFormat* rtp_fmt = (AmAudioRtpFormat*)fmt.get();

  // pre-division by 100 is important
  // so that the first multiplication
  // does not overflow the 64bit int
  unsigned long long user_ts =
    system_ts * ((unsigned long long)rtp_fmt->getTSRate() / 100)
    / (WALLCLOCK_RATE/100);

  return send((unsigned int)user_ts,(unsigned char*)samples,s);
}
예제 #3
0
// returns bytes written, else -1 if error (0 is OK)
int RtmpAudio::put(unsigned long long system_ts, unsigned char* buffer, 
		   int input_sample_rate, unsigned int size)
{
  if(!size){
    return 0;
  }

  //dump_audio((unsigned char*)buffer,size);

  // copy into internal buffer
  memcpy((unsigned char*)samples,buffer,size);
  size = resampleInput((unsigned char*)samples, size, 
		       input_sample_rate, getSampleRate());

  int s = encode(size);
  //DBG("s = %i\n",s);
  
  if(s<=0){
    return s;
  }

  return send(scaleSystemTS(system_ts),(unsigned int)s);
}