Reply by Tim Wescott January 31, 20132013-01-31
On Thu, 31 Jan 2013 01:16:58 +0000, glen herrmannsfeldt wrote:

> Tim Wescott <tim@seemywebsite.com> wrote: > > (snip) >> I'm not familiar enough with Java. Is 'byte' a built-in data type? > > byte, short, int, and long are built-in 8, 16, 32, and 64 bit signed > (twos complement) types. char is an unsigned 16 bit type. > >> And I'm not familiar with your particular audio format. How is the >> audio data encoded in the buffer? Eight bits seems small for an audio >> sample. Does this mean that two (or more) bytes need to be assembled >> into a word? > > It might be twos complement, too. And big or little endian.
Yup. Hence my feeling that the OP isn't giving us enough information. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Reply by glen herrmannsfeldt January 30, 20132013-01-30
Tim Wescott <tim@seemywebsite.com> wrote:

(snip)
> I'm not familiar enough with Java. Is 'byte' a built-in data type?
byte, short, int, and long are built-in 8, 16, 32, and 64 bit signed (twos complement) types. char is an unsigned 16 bit type.
> And I'm not familiar with your particular audio format. How is the audio > data encoded in the buffer? Eight bits seems small for an audio sample. > Does this mean that two (or more) bytes need to be assembled into a word?
It might be twos complement, too. And big or little endian. -- glen
Reply by Tim Wescott January 30, 20132013-01-30
On Wed, 30 Jan 2013 01:27:19 -0800, Tr&#7847;n D&#432;&#417;ng Tu&#7845;n wrote:

> Hi admin, > > The code below to process the audio signal on red5.Audio signal on red5 > is the type of data bytes.I want to change the data type to a sample > (float). > > public void start(IBroadcastStream broadcastStream, IScope scope) throws > StreamException { if (log.isDebugEnabled()) > log.debug("startTranscodingStream({},{})", > broadcastStream.getPublishedName(), scope.getName()); > recordStream(broadcastStream); > mInputListener = new IStreamListener() { public void > packetReceived(IBroadcastStream broadcastStream, IStreamPacket packet) { > IoBuffer buf = packet.getData(); > int readBytes=0; > if (buf != null) > buf.rewind(); > > if (buf == null || buf.remaining() == 0){ > System.out.println("skipping empty packet with no data"); > return; > } > > > if (packet instanceof AudioData) { > byte[] data = SerializeUtils.ByteBufferToByteArray(buf); > > // I would like convert **data** an audio bytes into audio > sample. > > > transcoder.handlePacket(data, 1, data.length-1); > } > } > }; > broadcastStream.addStreamListener(mInputListener); > rtpSender = new RtpStreamSender(srcSocket, connInfo); > rtpSender.connect(); > transcoder.start(); > } > > Please help me do this.
I'm not familiar enough with Java. Is 'byte' a built-in data type? And I'm not familiar with your particular audio format. How is the audio data encoded in the buffer? Eight bits seems small for an audio sample. Does this mean that two (or more) bytes need to be assembled into a word? -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Reply by Trần Dương Tuấn January 30, 20132013-01-30
Hi admin,

The code below to process the audio signal on red5.Audio signal on red5 is the type of data bytes.I want to change the data type to a sample (float).

public void start(IBroadcastStream broadcastStream, IScope scope) throws StreamException {
if (log.isDebugEnabled())
log.debug("startTranscodingStream({},{})", broadcastStream.getPublishedName(), scope.getName());
recordStream(broadcastStream);
mInputListener = new IStreamListener() {
public void packetReceived(IBroadcastStream broadcastStream, IStreamPacket packet) {
      IoBuffer buf = packet.getData();
      int readBytes=0;
      if (buf != null)
          buf.rewind();

      if (buf == null || buf.remaining() == 0){
          System.out.println("skipping empty packet with no data");
          return;
      }


      if (packet instanceof AudioData) {
          byte[] data = SerializeUtils.ByteBufferToByteArray(buf);

          // I would like convert **data**  an audio bytes into audio sample.


          transcoder.handlePacket(data, 1, data.length-1);   
      } 
}
};
  broadcastStream.addStreamListener(mInputListener);    
 rtpSender = new RtpStreamSender(srcSocket, connInfo);
rtpSender.connect();
transcoder.start();
}

Please help me do this.